Repository navigation
Description
This issue was originally created at: 2006-09-12 22:34:45.
This issue was reported by: olpa.
olpa said at 2006-09-12 22:34:45
Here is a sample SConstruct file with suffix rules to build HTML from XML:
# SConstruct
import os, glob
xml_files = glob.glob("*.xml")
basenames = [os.path.splitext(x)[0] for x in xml_files]
html_files = [x + ".html" for x in basenames]
print(basenames)
print(xml_files)
print(html_files)
env = Environment()
bld = Builder(action="cat $SOURCE >$TARGET", suffix=".html", src_suffix=".xml")
env["BUILDERS"]["xmltohtml"] = bld
for name in basenames:
env.xmltohtml(name)When the directory contains only the one file ("name2.xml"), the output is
as expected:
$ scons -n -Q
['name2']
['name2.xml']
['name2.html']
cat name2.xml > name2.html
If there are two files ("name2.xml" and "name.name.xml"), the output is:
$ scons -n -Q
['name2', 'name.name']
['name2.xml', 'name.name.xml']
['name2.html', 'name.name.html']
scons: *** Source `name.name' not found, needed by target `name.html'.
Stop.
Finally, if there are two files ("name.xml" and "name.name.xml"), the
output is:
$ scons -n -Q
['name.name', 'name']
['name.name.xml', 'name.xml']
['name.name.html', 'name.html']
scons: *** Multiple ways to build the same target were specified for:
name.html (from ['name.name'] and from ['name.xml']) File "SConscript.py", line 15, in ?
olpa said at 2006-09-12 22:37:35
Both in 0.96.92 and CVS branches/core of 10 September 2006.
stevenknight said at 2007-08-28 19:49:11
SCons does assume that any suffix is potentially valid. SCons can't change the existing behavior without potentially breaking existing SConstruct files out there, but an enhancement has been checked in that adds an "ensure_suffix" keyword argument to the builder that will do what you want: make sure that the target name ends with the specified string regardless of whether or not there are dots in the base portion of the file name.
*** This issue has been marked as a duplicate of 1719 ***
stevenknight said this issue is a duplicate of #1719 at 2007-08-28 19:49:11.
Activity