default_version = '0.98.0'
+copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008'
+
SConsVersion = '0.98.0'
if SConsVersion == '__' + 'VERSION' + '__':
SConsVersion = default_version
arguments = options + " " + arguments
kw['arguments'] = arguments
kw['stdout'] = self.wrap_stdout(read_str = read_str, build_str = s)
- kw['match'] = self.match_exact
+ kw['stdout'] = string.replace(kw['stdout'],'\n','\\n')
+ kw['stdout'] = string.replace(kw['stdout'],'.','\\.')
+ kw['match'] = self.match_re_dotall
apply(self.run, [], kw)
def not_up_to_date(self, options = None, arguments = None, **kw):
time.sleep(1.0)
waited = waited + 1.0
+ def get_alt_cpp_suffix(self):
+ """
+ Many CXX tests have this same logic.
+ They all needed to determine if the current os supports
+ files with .C and .c as different files or not
+ in which case they are instructed to use .cpp instead of .C
+ """
+ if not case_sensitive_suffixes('.c','.C'):
+ alt_cpp_suffix = '.cpp'
+ else:
+ alt_cpp_suffix = '.C'
+ return alt_cpp_suffix
+
+
# In some environments, $AR will generate a warning message to stderr
# if the library doesn't previously exist and is being created. One
# way to fix this is to tell AR to be quiet (sometimes the 'c' flag),
# See the README file for an overview of how SCons is built and tested.
#
-# When this gets changed, you also need to change test/option-v.py
-# so it looks for the right string.
+# When this gets changed, you must also change the copyright_years string
+# in QMTest/TestSCons.py so the test scripts look for the right string.
copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008'
# This gets inserted into the man pages to reflect the month of release.
checkpoint = time.strftime('d%Y%m%d', time.localtime(time.time()))
elif checkpoint == 'r':
checkpoint = 'r' + revision
- version = version + checkpoint
+ version = version + '.' + checkpoint
svn_status = None
svn_status_lines = []
}
for VERSION in $VERSIONS; do
+ DIR=`expr "$VERSION" : '\(...\)'`
PYTHON=Python-${VERSION}
TAR_GZ=${PYTHON}.tgz
if test ! -d ${DOWNLOADS}; then
Command mkdir ${DOWNLOADS}
fi
- Command "( cd ${DOWNLOADS} && wget ${DOWNLOADS_URL}/${VERSION}/${TAR_GZ} )"
+ Command "( cd ${DOWNLOADS} && wget ${DOWNLOADS_URL}/${DIR}/${TAR_GZ} )"
fi
Command tar zxf ${DOWNLOADS}/${TAR_GZ}
${PRINT} cd ..
)
- Command rm -rf ${Python}
+ Command rm -rf ${PYTHON}
done
"""
bootstrap_dir = 'bootstrap'
-script_dir = os.path.split(__file__)[0]
+try:
+ script_dir = os.path.split(__file__)[0]
+except NameError:
+ # Pre-2.3 versions of Python don't have __file__.
+ script_dir = os.path.split(sys.argv[0])[0]
+ if not script_dir:
+ script_dir = os.getcwd()
+ elif not os.path.is_abs(script_dir):
+ script_dir = os.path.join(os.getcwd(), script_dir)
if script_dir:
bootstrap_dir = os.path.join(script_dir, bootstrap_dir)
pass_through_args = []
epydoc_commands = [
Delete('$OUTDIR'),
- '$EPYDOC $EPYDOCFLAGS --output $OUTDIR --docformat=restructuredText --name SCons --url http://www.scons.org/ $SOURCES',
+ '$EPYDOC $EPYDOCFLAGS --debug --output $OUTDIR --docformat=restructuredText --name SCons --url http://www.scons.org/ $SOURCES',
Touch('$TARGET'),
]
.TP 6
.B cache_debug
.TP 6
-which corresponds to --cache_debug;
+which corresponds to --cache-debug;
.TP 6
.B cache_disable
-which corresponds to --cache_disable;
+which corresponds to --cache-disable;
.TP 6
.B cache_force
-which corresponds to --cache_force;
+which corresponds to --cache-force;
.TP 6
.B cache_show
-which corresponds to --cache_show;
+which corresponds to --cache-show;
.TP 6
.B clean
which corresponds to -c, --clean and --remove;
env = conf.Finish()
.EE
-.SS Construction Variable Options
+.SS Command-Line Construction Variables
-Often when building software, various options need to be specified at build
-time that are not known when the SConstruct/SConscript files are
-written. For example, libraries needed for the build may be in non-standard
+Often when building software,
+some variables must be specified at build time.
+For example, libraries needed for the build may be in non-standard
locations, or site-specific compiler options may need to be passed to the
compiler.
.B scons
-provides an Options object for overridding construction variables
+provides a
+.B Variables
+object to support overriding construction variables
on the command line:
.ES
$ scons VARIABLE=foo
.EE
The variable values can also be specified in a text-based SConscript file.
-To create an Options object, call the Options() function:
+To create a Variables object, call the Variables() function:
.TP
-.RI Options([ files "], [" args ])
-This creates an Options object that will read construction variables from
+.RI Variables([ files "], [" args ])
+This creates a Variables object that will read construction variables from
the file or list of filenames specified in
.IR files .
If no files are specified,
Example:
.ES
-opts = Options('custom.py')
-opts = Options('overrides.py', ARGUMENTS)
-opts = Options(None, {FOO:'expansion', BAR:7})
+vars = Variables('custom.py')
+vars = Variables('overrides.py', ARGUMENTS)
+vars = Variables(None, {FOO:'expansion', BAR:7})
.EE
-Options objects have the following methods:
+Variables objects have the following methods:
.TP
.RI Add( key ", [" help ", " default ", " validator ", " converter ])
-This adds a customizable construction variable to the Options object.
+This adds a customizable construction variable to the Variables object.
.I key
is the name of the variable.
.I help
Examples:
.ES
-opts.Add('CC', 'The C compiler')
+vars.Add('CC', 'The C compiler')
def validate_color(key, val, env):
if not val in ['red', 'blue', 'yellow']:
raise "Invalid color value '%s'" % val
-opts.Add('COLOR', validator=valid_color)
+vars.Add('COLOR', validator=valid_color)
.EE
.TP
-.RI AddOptions( list )
+.RI AddVariables( list )
A wrapper script that adds
multiple customizable construction variables
-to an Options object.
+to a Variables object.
.I list
is a list of tuple or list objects
that contain the arguments
method.
.ES
-opt.AddOptions(
+opt.AddVariables(
('debug', '', 0),
('CC', 'The C compiler'),
('VALIDATE', 'An option for testing validation',
with the customized construction variables.
Any specified variables that are
.I not
-configured for the Options object
+configured for the Variables object
will be saved and may be
retrieved with the
-.BR UnknownOptions ()
+.BR UnknownVariables ()
method, below.
Normally this method is not called directly,
-but is called indirectly by passing the Options object to
+but is called indirectly by passing the Variables object to
the Environment() function:
.ES
-env = Environment(options=opts)
+env = Environment(variables=vars)
.EE
.IP
The text file(s) that were specified
-when the Options object was created
+when the Variables object was created
are executed as Python scripts,
and the values of (global) Python variables set in the file
are added to the construction environment.
.EE
.TP
-.RI UnknownOptions( )
+.RI UnknownVariables( )
Returns a dictionary containing any
variables that were specified
either in the files or the dictionary
-with which the Options object was intialized,
-but for which the Options object was
+with which the Variables object was initialized,
+but for which the Variables object was
not configured.
.ES
-env = Environment(options=opts)
-for key, value in opts.UnknownOptions():
+env = Environment(variables=vars)
+for key, value in vars.UnknownVariables():
print "unknown variable: %s=%s" % (key, value)
.EE
.TP
.RI Save( filename ", " env )
-This saves the currently set options into a script file named
+This saves the currently set variables into a script file named
.I filename
that can be used on the next invocation to automatically load the current
-settings. This method combined with the Options method can be used to
-support caching of options between runs.
+settings. This method combined with the Variables method can be used to
+support caching of variables between runs.
.ES
env = Environment()
-opts = Options(['options.cache', 'custom.py'])
-opts.Add(...)
-opts.Update(env)
-opts.Save('options.cache', env)
+vars = Variables(['variables.cache', 'custom.py'])
+vars.Add(...)
+vars.Update(env)
+vars.Save('variables.cache', env)
.EE
.TP
function).
.ES
-Help(opts.GenerateHelpText(env))
-Help(opts.GenerateHelpText(env, sort=cmp))
+Help(vars.GenerateHelpText(env))
+Help(vars.GenerateHelpText(env, sort=cmp))
.EE
.TP
-.RI FormatOptionHelpText( env ", " opt ", " help ", " default ", " actual )
+.RI FormatVariableHelpText( env ", " opt ", " help ", " default ", " actual )
This method returns a formatted string
containing the printable help text
for one option.
def my_format(env, opt, help, default, actual):
fmt = "\n%s: default=%s actual=%s (%s)\n"
return fmt % (opt, default. actual, help)
-opts.FormatOptionHelpText = my_format
+vars.FormatVariableHelpText = my_format
.EE
-To make it more convenient to work with customizable Options,
+To make it more convenient to work with customizable Variables,
.B scons
provides a number of functions
that make it easy to set up
-various types of Options:
+various types of Variables:
.TP
-.RI BoolOption( key ", " help ", " default )
+.RI BoolVariable( key ", " help ", " default )
Return a tuple of arguments
to set up a Boolean option.
The option will use
as false.
.TP
-.RI EnumOption( key ", " help ", " default ", " allowed_values ", [" map ", " ignorecase ])
+.RI EnumVariable( key ", " help ", " default ", " allowed_values ", [" map ", " ignorecase ])
Return a tuple of arguments
to set up an option
whose value may be one
converted to lower case.
.TP
-.RI ListOption( key ", " help ", " default ", " names ", [", map ])
+.RI ListVariable( key ", " help ", " default ", " names ", [", map ])
Return a tuple of arguments
to set up an option
whose value may be one or more
list.
.TP
-.RI PackageOption( key ", " help ", " default )
+.RI PackageVariable( key ", " help ", " default )
Return a tuple of arguments
to set up an option
whose value is a path name
to disable use of the specified option.
.TP
-.RI PathOption( key ", " help ", " default ", [" validator ])
+.RI PathVariable( key ", " help ", " default ", [" validator ])
Return a tuple of arguments
to set up an option
whose value is expected to be a path name.
is acceptable.
SCons supplies the
following ready-made validators:
-.BR PathOption.PathExists
+.BR PathVariable.PathExists
(the default),
which verifies that the specified path exists;
-.BR PathOption.PathIsFile ,
+.BR PathVariable.PathIsFile ,
which verifies that the specified path is an existing file;
-.BR PathOption.PathIsDir ,
+.BR PathVariable.PathIsDir ,
which verifies that the specified path is an existing directory;
-.BR PathOption.PathIsDirCreate ,
+.BR PathVariable.PathIsDirCreate ,
which verifies that the specified path is a directory
and will create the specified directory if the path does not exist;
and
-.BR PathOption.PathAccept ,
+.BR PathVariable.PathAccept ,
which simply accepts the specific path name argument without validation,
and which is suitable if you want your users
to be able to specify a directory path that will be
function,
which must take three arguments
.RI ( key ,
-the name of the options variable to be set;
+the name of the variable to be set;
.IR val ,
the specified value being checked;
and
.RE
These functions make it
convenient to create a number
-of options with consistent behavior
+of variables with consistent behavior
in a single call to the
-.B AddOptions
+.B AddVariables
method:
.ES
-opts.AddOptions(
- BoolOption('warnings', 'compilation with -Wall and similiar', 1),
- EnumOption('debug', 'debug output and symbols', 'no'
+vars.AddVariables(
+ BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
+ EnumVariable('debug', 'debug output and symbols', 'no'
allowed_values=('yes', 'no', 'full'),
map={}, ignorecase=0), # case sensitive
- ListOption('shared',
+ ListVariable('shared',
'libraries to build as shared libraries',
'all',
names = list_of_libs),
- PackageOption('x11',
+ PackageVariable('x11',
'use X11 installed here (yes = search some places)',
'yes'),
- PathOption('qtdir', 'where the root of Qt is installed', qtdir),
- PathOption('foopath', 'where the foo library is installed', foopath,
- PathOption.PathIsDir),
+ PathVariable('qtdir', 'where the root of Qt is installed', qtdir),
+ PathVariable('foopath', 'where the foo library is installed', foopath,
+ PathVariable.PathIsDir),
)
.EE
line or in the file custom.py.
.ES
-opts = Options('custom.py')
-opts.Add('CC', 'The C compiler.')
-env = Environment(options=opts)
-Help(opts.GenerateHelpText(env))
+vars = Variables('custom.py')
+vars.Add('CC', 'The C compiler.')
+env = Environment(variables=vars)
+Help(vars.GenerateHelpText(env))
.EE
The user could specify the C compiler on the command line:
<!ENTITY AddPostAction "<function>AddPostAction</function>">
<!ENTITY AddPreAction "<function>AddPreAction</function>">
<!ENTITY AddOptions "<function>AddOptions</function>">
+<!ENTITY AddVariables "<function>AddVariables</function>">
<!ENTITY Alias "<function>Alias</function>">
<!ENTITY Aliases "<function>Aliases</function>">
<!ENTITY AlwaysBuild "<function>AlwaysBuild</function>">
<!ENTITY AppendENVPath "<function>AppendENVPath</function>">
<!ENTITY AppendUnique "<function>AppendUnique</function>">
<!ENTITY BoolOption "<function>BoolOption</function>">
+<!ENTITY BoolVariable "<function>BoolVariable</function>">
<!ENTITY Build "<function>Build</function>">
<!ENTITY CacheDir "<function>CacheDir</function>">
<!ENTITY Chmod "<function>Chmod</function>">
<!ENTITY Dump "<function>Dump</function>">
<!ENTITY Entry "<function>Entry</function>">
<!ENTITY EnumOption "<function>EnumOption</function>">
+<!ENTITY EnumVariable "<function>EnumVariable</function>">
<!ENTITY Environment "<function>Environment</function>">
<!ENTITY Execute "<function>Execute</function>">
<!ENTITY Export "<function>Export</function>">
<!ENTITY InstallAs "<function>InstallAs</function>">
<!ENTITY Link "<function>Link</function>">
<!ENTITY ListOption "<function>ListOption</function>">
+<!ENTITY ListVariable "<function>ListVariable</function>">
<!ENTITY Local "<function>Local</function>">
<!ENTITY Mkdir "<function>Mkdir</function>">
<!ENTITY Module "<function>Module</function>">
<!ENTITY NoCache "<function>NoCache</function>">
<!ENTITY Objects "<function>Objects</function>">
<!ENTITY Options "<function>Options</function>">
+<!ENTITY Variables "<function>Variables</function>">
<!ENTITY PackageOption "<function>PackageOption</function>">
+<!ENTITY PackageVariable "<function>PackageVariable</function>">
<!ENTITY ParseConfig "<function>ParseConfig</function>">
<!ENTITY PathOption "<function>PathOption</function>">
<!ENTITY PathOption_PathAccept "<function>PathOption.PathAccept</function>">
<!ENTITY PathOption_PathIsDir "<function>PathOption.PathIsDir</function>">
<!ENTITY PathOption_PathIsDirCreate "<function>PathOption.PathIsDirCreate</function>">
<!ENTITY PathOption_PathIsFile "<function>PathOption.PathIsFile</function>">
+<!ENTITY PathVariable "<function>PathVariable</function>">
+<!ENTITY PathVariable_PathAccept "<function>PathVariable.PathAccept</function>">
+<!ENTITY PathVariable_PathExists "<function>PathVariable.PathExists</function>">
+<!ENTITY PathVariable_PathIsDir "<function>PathVariable.PathIsDir</function>">
+<!ENTITY PathVariable_PathIsDirCreate "<function>PathVariable.PathIsDirCreate</function>">
+<!ENTITY PathVariable_PathIsFile "<function>PathVariable.PathIsFile</function>">
<!ENTITY Precious "<function>Precious</function>">
<!ENTITY Prepend "<function>Prepend</function>">
<!ENTITY PrependENVPath "<function>PrependENVPath</function>">
actions.xml
+add-method.xml
alias.xml
ant.xml
builders.xml
--- /dev/null
+# __COPYRIGHT__
+
+When adding a new file, add it to main.xml and MANIFEST.
+
+To build the .xml files from the .in files:
+ scons -D . BUILDDOC=1
+
+Writing examples: here's a simple template.
+
+ <scons_example name="Foo">
+ <file name="SConstruct">
+ env = Environment()
+ print env.Dump("CC")
+ </file>
+ </scons_example>
+
+ <scons_output example="Foo">
+ <scons_output_command>scons -Q</scons_output_command>
+ </scons_output>
--- /dev/null
+<!--
+
+ __COPYRIGHT__
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+-->
+
+ <para>
+
+ The env.AddMethod(function, [name]) function is used to add a method
+ to an environment. It's typically used to add a "pseudo-builder" or
+ wrap up a call to multiple builders. In the first example, we want
+ to install the program into the standard bin dir, but also copy it
+ into a local install/bin dir that might be used to build a package
+ from.
+
+ </para>
+
+ <scons_example name="ex1">
+ <file name="SConstruct" printme="1">
+ def install_in_bin_dirs(env, source):
+ """Install source in both bin dirs"""
+ i1 = env.Install("$BIN", source)
+ i2 = env.Install("$LOCALBIN", source)
+ return [i1[0], i2][0] # Return a list, like a normal builder
+ env = Environment(BIN='/usr/bin', LOCALBIN='#install/bin')
+ env.AddMethod(install_in_bin_dirs, "InstallInBinDirs")
+ env.InstallInBinDirs(Program('hello.c')) # installs hello in both bin dirs
+ </file>
+ <file name="hello.c">
+ int main() { printf("Hello, world!\n"); }
+ </file>
+ </scons_example>
+
+ <para>
+ This produces the following:
+ </para>
+
+ <scons_output example="ex1">
+ <scons_output_command>scons -Q</scons_output_command>
+ </scons_output>
+
+ <para>
+
+ It also gives more flexibility in parsing arguments than you can get
+ with a builder. The next example shows a pseudo-builder with a
+ named argument that modifies the filename, and a separate argument
+ for the resource file (rather than having the builder figure it out
+ by file extension). Also this example demonstrates using the global
+ AddMethod function to add a method to the global Environment class,
+ so it will be used in all subsequently created environments.
+
+ </para>
+
+ <scons_example name="ex2">
+ <file name="SConstruct" printme="1">
+ import sys;
+ def BuildTestProg(env, testfile, resourcefile, testdir="tests"):
+ """Build the test program;
+ prepends "test_" to src and target, and puts target into testdir."""
+ srcfile="test_%s.c"%testfile
+ if sys.platform=='win32':
+ target="%s/test_%s$EXESUFFIX"%(testdir,[testfile, resourcefile])
+ else:
+ target="%s/test_%s$EXESUFFIX"%(testdir,testfile)
+ p = env.Program(target, srcfile)
+ return p
+ AddMethod(Environment, BuildTestProg)
+
+ # Now use it
+ env=Environment()
+ env.BuildTestProg('stuff', resourcefile='res.rc')
+ </file>
+ <file name="test_stuff.c">
+ int main() { printf("Hello, world!\n"); }
+ </file>
+ </scons_example>
+
+ <para>
+ This produces the following (on Linux, anyway; Windows would include the
+ resource file):
+ </para>
+
+ <scons_output example="ex2">
+ <scons_output_command>scons -Q</scons_output_command>
+ </scons_output>
+
--- /dev/null
+<!--
+
+ __COPYRIGHT__
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+-->
+
+ <para>
+
+ The env.AddMethod(function, [name]) function is used to add a method
+ to an environment. It's typically used to add a "pseudo-builder" or
+ wrap up a call to multiple builders. In the first example, we want
+ to install the program into the standard bin dir, but also copy it
+ into a local install/bin dir that might be used to build a package
+ from.
+
+ </para>
+
+ <programlisting>
+ def install_in_bin_dirs(env, source):
+ """Install source in both bin dirs"""
+ i1 = env.Install("$BIN", source)
+ i2 = env.Install("$LOCALBIN", source)
+ return [i1[0], i2][0] # Return a list, like a normal builder
+ env = Environment(BIN='/usr/bin', LOCALBIN='#install/bin')
+ env.AddMethod(install_in_bin_dirs, "InstallInBinDirs")
+ env.InstallInBinDirs(Program('hello.c')) # installs hello in both bin dirs
+ </programlisting>
+
+ <para>
+ This produces the following:
+ </para>
+
+ <screen>
+ % <userinput>scons -Q</userinput>
+ cc -o hello.o -c hello.c
+ cc -o hello hello.o
+ Install file: "hello" as "install/bin/hello"
+ </screen>
+
+ <para>
+
+ It also gives more flexibility in parsing arguments than you can get
+ with a builder. The next example shows a pseudo-builder with a
+ named argument that modifies the filename, and a separate argument
+ for the resource file (rather than having the builder figure it out
+ by file extension). Also this example demonstrates using the global
+ AddMethod function to add a method to the global Environment class,
+ so it will be used in all subsequently created environments.
+
+ </para>
+
+ <programlisting>
+ import sys
+ def BuildTestProg(env, testfile, resourcefile, testdir="tests"):
+ """Build the test program;
+ prepends "test_" to src and target, and puts target into testdir."""
+ srcfile="test_%s.c"%testfile
+ if sys.platform=='win32':
+ target="%s/test_%s$EXESUFFIX"%(testdir,[testfile, resourcefile])
+ else:
+ target="%s/test_%s$EXESUFFIX"%(testdir,testfile)
+ p = env.Program(target, srcfile)
+ return p
+ AddMethod(Environment, BuildTestProg)
+
+ # Now use it
+ env=Environment()
+ env.BuildTestProg('stuff', resourcefile='res.rc')
+ </programlisting>
+
+ <para>
+ This produces the following (on Linux, anyway; Windows would include the
+ resource file):
+ </para>
+
+ <screen>
+ % <userinput>scons -Q</userinput>
+ cc -o test_stuff.o -c test_stuff.c
+ cc -o tests/test_stuff test_stuff.o
+ </screen>
+
<!ENTITY builders-built-in SYSTEM "builders-built-in.xml">
<!ENTITY builders-commands SYSTEM "builders-commands.xml">
<!ENTITY builders-writing SYSTEM "builders-writing.xml">
+ <!ENTITY add-method SYSTEM "add-method.xml">
<!ENTITY caching SYSTEM "caching.xml">
<!ENTITY command-line SYSTEM "command-line.xml">
<!ENTITY copyright SYSTEM "copyright.xml">
XXX Progress()
- XXX AddMethod()
-
XXX - - diskcheck=
XXX site_scons
&builders-commands;
</chapter>
+ <chapter id="chap-add-method">
+ <title>Pseudo-Builders: the AddMethod function</title>
+ &add-method;
+ </chapter>
+
<!--
XXX Action()
<!ENTITY builders-built-in SYSTEM "builders-built-in.xml">
<!ENTITY builders-commands SYSTEM "builders-commands.xml">
<!ENTITY builders-writing SYSTEM "builders-writing.xml">
+ <!ENTITY add-method SYSTEM "add-method.xml">
<!ENTITY caching SYSTEM "caching.xml">
<!ENTITY command-line SYSTEM "command-line.xml">
<!ENTITY copyright SYSTEM "copyright.xml">
XXX Progress()
- XXX AddMethod()
-
XXX - - diskcheck=
XXX site_scons
&builders-commands;
</chapter>
+ <chapter id="chap-add-method">
+ <title>Pseudo-Builders: the AddMethod function</title>
+ &add-method;
+ </chapter>
+
<!--
XXX Action()
+RELEASE X.XX - XXX
+
+ From Benoit Belley:
+
+ - Speed up the SCons.Util.to_string*() functions.
+
+ - Optimize various Node intialization and calculations.
+
+ - Optimize Executor scanning code.
+
+ - Optimize Taskmaster execution, including dependency-cycle checking.
+
+ - Fix the --debug=stree option so it prints its tree once, not twice.
+
+ From Johan BoulÃ:
+
+ - Fix the ability to use LoadableModule() under MinGW.
+
+ From Steven Knight:
+
+ - Make the -d, -e, -w and --no-print-directory options "Ignored for
+ compatibility." (We're not going to implement them.)
+
+ - Fix a serious inefficiency in how SCons checks for whether any source
+ files are missing when a Builder call creates many targets from many
+ input source files.
+
+ - In Java projects, make the target .class files depend only on the
+ specific source .java files where the individual classes are defined.
+
+ - Don't store duplicate source file entries in the .sconsign file so
+ we don't endlessly rebuild the target(s) for no reason.
+
+ - Add a Variables object as the first step towards deprecating the
+ Options object name. Similarly, add BoolVariable(), EnumVariable(),
+ ListVariable(), PackageVariable() and PathVariable() functions
+ as first steps towards replacing BoolOption(), EnumOption(),
+ ListOption(), PackageOption() and PathOption().
+
+ - Change the options= keyword argument to the Environment() function
+ to variables=, to avoid confusion with SCons command-line options.
+ Continue supporting the options= keyword for backwards compatibility.
+
+ - When $SWIGFLAGS contains the -python flag, expect the generated .py
+ file to be in the same (sub)directory as the target.
+
+ - When compiling C++ files, allow $CCFLAGS settings to show up on the
+ command line even when $CXXFLAGS has been redefined.
+
+ - Fix --interactive with -u/-U/-D when a VariantDir() is used.
+
+ From Anatoly Techtonik:
+
+ - Have the scons.bat file add the script execution directory to its
+ local %PATH% on Windows, so the Python executable can be found.
+
+ From Mike Wake:
+
+ - Fix passing variable names as a list to the Return() function.
+
+ From Matthew Wesley:
+
+ - Add support for the GDC 'D' language compiler.
+
+
+
RELEASE 0.98 - Sun, 30 Mar 2008 23:33:05 -0700
From Benoit Belley:
-RELEASE 0.98 - Sun, 30 Mar 2008 23:33:05 -0700
-
- This is the ninth beta release of SCons. Please consult the
- CHANGES.txt file for a list of specific changes since last release.
+RELEASE 0.98.1 - XXX
+
+ This is an update to the ninth beta release of SCons. Please consult
+ the CHANGES.txt file for a list of specific changes since last release.
+
+ Please note the following important changes since release 0.98:
+
+ -- SCONS NO LONGER SETS THE GNU TOOLCHAIN -fPIC FLAG IN $SHCXXFLAGS
+
+ The GNU toolchain support in previous versions of SCons would
+ add the -fPIC flag to the $SHCXXFLAGS construction variable.
+ The -fPIC flag has been now been removed from the default
+ $SHCXXFLAGS setting. Instead, the $SHCXXCOM construction variable
+ (the default SCons command line for compiling shared objects
+ from C++ source files) has been changed to add the $SHCCFLAGS
+ variable, which contains the -fPIC flag.
+
+ This change was made in order to make the behavior of the default
+ C++ compilation line including $SHCCFLAGS consistent with the
+ default C compilation line including $CCFLAGS.
+
+ This change should have no impact on configurations that use
+ the default $SHCXXCOM command line. It may have an impact on
+ configurations that were using the default $SHCXXFLAGS value
+ *without* the $SHCCFLAGS variable to get the -fPIC flag into a
+ custom command line. You can fix these by adding the $SHCCFLAGS
+ to the custom command line.
+
+ Adding $SHCCFLAGS is backwards compatible with older SCons
+ releases, although it might cause the -fPIC flag to be repeated
+ on the command line if you execute it on an older version of
+ SCons that sets -fPIC in both the $SHCCLAFGS and $SHCXXFLAGS
+ variables. Duplicating the -fPIC flag on the g++ command line
+ will not cause any compilation problems, but the change to the
+ command line may cause SCons to rebuild object files.
Please note the following important changes since release 0.97.0d20071212:
might cause a compatibility issue if a script or other utility
looks for an exact match of the previous text.
- Please note the following important changes since release 0.96.93:
-
- -- THE --debug=memoizer OPTION NOW REQUIRES PYTHON 2.2 OR LATER
-
- The --debug=memoizer option now prints a warning message and
- does nothing if SCons is run on a version of Python that does
- not support metaclasses (earlier than Python 2.2).
-
- -- THE --debug=nomemoizer OPTION DOES NOTHING AND IS NOW DEPRECATED
-
- The --debug=nomemoizer no longer does anything and instead
- now generates a warning message about being deprecated. The
- --debug=nomemoizer will be removed completely in a future release.
-
- Please note the following important changes since release 0.96.91:
-
- -- /opt/bin AND /sw/bin ADDED TO DEFAULT EXECUTION PATH VARIABLES
-
- On all POSIX systems, the default execution PATH variable has had
- the /opt/bin directory added after the /usr/local/bin directory
- and before /bin and /usr/bin directories. This may cause SCons
- to find and/or use different compilers, linkers, etc., if you
- have any same-named utilities installed in /opt/bin that SCons
- previously found in /bin or /usr/bin.
-
- On Mac OS X (Darwin) systems, the /sw/bin directory has been added
- to the end of the default execution PATH. This may cause SCons
- to find compilers, linkers and other utilities it previously did
- not, although it should not otherwise change existing behavior.
-
- -- Configure.Checklib() ARGUMENTS HAVE CHANGED TO MATCH DOCUMENTATION
-
- The order of the arguments to the Configure.CheckLib() function
- has changed to put the "autoadd" keyword argument last, matching
- the documentation in the man page. This could cause problems
- for any calls to Configure.Checklib() that were relying on the
- order of the arguments. Specifying all arguments as keyword
- arguments will work on both older and newer versions of SCons.
-
- -- env.subst() NO LONGER EXPANDS $TARGET, $SOURCES, etc. BY DEFAULT
-
- Calls to the env.subst() method to interpolate construction
- variables in strings no longer automatically expand the special
- variables $TARGET, $TARGETS, $SOURCE and $SOURCES. The keyword
- variables "target" and "source" must now be set to the lists
- of target and source files to be used in expansion of those
- variables, when desired.
-
- This is most likely necessary for any env.subst() calls within
- a Python function being used as an SCons action for a Builder:
-
- def build_it(env, target, source):
- env.subst('$STRING', target=targets, source=sources)
- MyBuilder = Builder(action=build_it)
-
- The "target" and "source" keyword arguments are backwards
- compatible and can be added to SConscript files without breaking
- builds on systems using older SCons releases.
-
- -- INTERNAL FUNCTIONS AND CLASSES HAVE MOVED FROM SCons.Util
-
- All internal functions and classes related to string substitution
- have been moved out of the SCons.Util module into their own
- SCons.Subst module. The following classes have been moved:
-
- Literal
- SpecialAttrWrapper
- NLWrapper
- Targets_or_Sources
- Target_or_Source
-
- And the following functions have moved:
-
- quote_spaces()
- escape_list()
- subst_dict()
- scons_subst()
- scons_subst_list()
- scons_subst_once()
-
- If your SConscript files have been using any of these function
- directly from the SCons.Util module (which they ultimately should
- not be!), you will need to modify them.
-
- Please note the following important changes since release 0.96.90:
-
- -- SIGNATURES ARE NOW STORED IN AN SConsignFile() BY DEFAULT,
- CAUSING LIKELY REBUILDS; SPECIAL NOTE CONCERNING INTERACTION
- WITH REPOSITORIES
-
- The default behavior has been changed to store signature
- information in a single .sconsign.dblite file in the top-level
- SConstruct file. This will cause rebuilds on upgrade to 0.97,
- unless you were already calling the SConsignFile() function in
- your SConscript files.
-
- The previous default behavior was to store signature information
- in a .sconsign file in each directory that contained target
- files that SCons knew about. The old behavior may be preserved
- by specifying:
-
- SConsignFile(None)
-
- in any SConscript file.
-
- If you are using the Repository feature, and are not already
- using the SConsignFile() function in your build, you *must*
- add "SConsignFile(None)" to your build configuration to keep
- interoperating with an existing Repository that uses the old
- behavior of a .sconsign file in each directory. Alternatively,
- you can rebuild the Repository with the new default behavior.
-
- -- OTHER SIGNATURE CHANGES WILL CAUSE LIKELY REBUILDS AFTER UPGRADE
-
- This release adds several changes to the signature mechanism that
- will cause SCons to rebuild most configurations after upgrading
- (and when switching back to an earlier release from 0.97).
- These changes are:
-
- -- NORMALIZED PATHS IN SConsignFile() DATABASES ON WINDOWS
-
- When using an SConsignFile() database, instead of
- individual .sconsign files in each directory, the path
- names are stored in normalized form with / (forward slash)
- separating the elements. This may cause rebuilds when
- upgrading to SCons 0.97 on Windows systems with hierarchical
- build configurations.
-
- -- STORED DEPENDENCY PATHS ARE NOW RELATIVE TO THE TARGET
-
- SCons used to store the paths of all source files and
- dependencies relative to the top-level SConstruct directory.
- It now stores them relative to the directory of the
- associated target file. This makes it possible to use
- content signatures to subdivide a dependency tree without
- causing unnecessary rebuilds due to an intermediate file in
- one build being treated as a source file in a nother build.
-
- This is a step towards making it possible to write a
- hierarchy of SConstruct files that allow developers
- to build just one portion of a tree wherever there's an
- SConstruct file. (Note that this would still require some
- specific code at the top of each SConstruct file, but we
- hope to make this an easier/more naturally supported thing
- in the future.)
-
- -- PYTHON FUNCTION ACTION SIGNATURES HAVE CHANGED TO AVOID
- FUTURE REBUILDS AND REBUILDS BETWEEN PYTHON VERSIONS
-
- SCons Actions for Python functions use the function's
- byte code to generate their signature. The byte code
- in older versions of Python includes indications of the
- line numbers at which the function's code appeared in
- its original source file, which means that changes in the
- location of an otherwise unmodified Python function would
- trigger rebuilds. The line number byte codes are now
- removed from the signature, which will cause any targets
- built by Python function Actions (including various
- pre-supplied SCons Actions) to be rebuilt.
-
- -- REMOVED CONVERSION FROM PRE-0.96 .sconsign FORMATS
-
- Because this release involves so many other signature
- changes that cause rebuilds, the support for automatically
- converting signature information from .sconsign files
- written by SCons versions prior to 0.96 has been removed.
-
- -- ORDER OF -o FLAGS ON CERTAIN LINK COMMAND LINES HAS CHANGED
-
- The -o flag that specifies an output file has been moved
- on certain linker command lines to place it consistently
- right after the link command itself. This will cause
- recompilation of target files created by these changed
- lines.
-
- -- F95 AND F90 COMPILERS ARE NOW PREFERRED OVER F77
-
- SCons now searches for Fortran 95 and Fortran 90 compilers first
- in preference to Fortran 77. This may result in a different
- Fortran compiler being used by default, although as Fortran 95 and
- Fortran 90 are backwards compatible with Fortran 77, this should
- not cause problems for standards-compliant Fortran programs.
- On systems that have multiple versions of Fortran installed,
- the Fortran 77 compiler may be explicitly selected by specifying
- it when creating the construction environment:
-
- env = Environment(tools = ['default', 'f77'])
-
- -- SOLARIS DEFAULT SHARED OBJECT PREFIXES AND SUFFIXES HAVE CHANGED
-
- On Solaris, SCons now builds shared objects from C and C++ source
- files with a default prefix of "so_" and a default suffix of ".o".
- The previous default suffix of ".os" caused problems when trying
- to use SCons with Sun WorkShop.
-
- -- CACHED Configure() RESULTS ARE STORED IN A DIFFERENT FILE
-
- The Configure() subsystem now stores its cached results in a
- different file. This may cause configuration tests to be re-run
- the first time after you install 0.97.
-
- -- setup.py INSTALLS VERSION-NUMBERED SCRIPTS AND DIRS BY DEFAULT
-
- The setup.py script has been changed to always install SCons in
- a version-numbered directory (e.g. /usr/local/lib/scons-0.97
- or D:\Python23\scons-0.97) and with a version-numbered script
- name (scons-0.97) in addition to the usual installation of an
- "scons" script name. A number of new setup.py options allow
- control over what does or does not get installed, and where.
- See the README.txt or README files for additional information.
-
- -- setup.py NOW INSTALLS MAN PAGES ON UNIX AND Linux SYSTEMS
-
- The SCons setup.py script now installs the "scons.1" and
- "sconsign.1" man pages on UNIX and Linux systems. A
- new --no-install-man
-
- -- BUILDERS RETURN A LIST-LIKE OBJECT, NOT A REGULAR LIST
-
- Builder calls now return an object that behaves like a list
- (and which provides some other functionality), not an underlying
- Python list. In general, this should not cause any problems,
- although it introduces a subtle change in the following behavior:
-
- obj += env.Object('foo.c')
-
- If "obj" is a regular Python list, Python will no longer update
- the "obj" in place, because the return value from env.Object()
- is no longer the same type. Python will instead allocate a
- new object and assign the local variable "obj" to it. If "obj"
- is defined in an SConscript file that calls another SConscript
- file containing the above code, "obj" in the first SConscript
- file will not contain the object file nodes created by the
- env.Object() call.
-
- You can guarantee that a list will be updated in place regardless
- of which SConscript file defines it and which adds to it by
- using the list extend() method as follows:
-
- obj.extend(env.Object('foo.c'))
-
- Please note the following important changes since release 0.96.1:
-
- -- DIRECTORY TREES ARE NO LONGER AUTOMATICALLY SCANNED FOR CHANGES
-
- Custom builders and Command() calls that accept directories as
- source arguments no longer scan entire on-disk directory trees by
- default. This means that their targets will not be automatically
- rebuilt if a file changes on disk *unless* SCons already knows
- about the file from a specific Builder or File() call. Note that
- the targets will still be rebuilt correctly if a file changes
- that SCons already knows about due to a Builder or other call.
-
- The existing behavior of scanning on-disk directory trees for
- any changed file can be maintained by passing the new DirScanner
- global directory scanner as the source_scanner keyword argument
- to the Builder call:
-
- bld = Builder("build < $SOURCE > $TARGET",
- source_scanner = DirScanner)
-
- The same keyword argument can also be supplied to any Command()
- calls that need to scan directory trees on-disk for changed files:
-
- env.Command("archive.out", "directory",
- "archiver -o $TARGET $SOURCE",
- source_scanner = DirScanner)
-
- This change was made because scanning directories by default
- could cause huge slowdowns if a configurable directory like /usr
- or /usr/local was passed as the source to a Builder or Command()
- call, in which case SCons would scan the entire directory tree.
-
- -- ParseConfig() METHOD ADDS LIBRARY FILE NAMES TO THE $LIBS VARIABLE
-
- The ParseConfig() method now adds library file names returned
- by the specified *-config command to the $LIBS construction
- variable, instead of returning them (the same way it handles
- the -l option).
-
- -- ParseConfig() METHOD DOESN'T ADD DUPLICATES TO CONSTRUCTION VARIABLES
-
- By default, the ParseConfig() method now avoids adding duplicate
- entries to construction variables. The old behavior may be
- specified using a new "unique=0" keyword argument.
-
- -- WINDOWS %TEMP% and %TMP% VARIABLES ARE PROPAGATED AUTOMATICALLY
-
- The %TEMP% and %TMP% external environment variables are now
- propagated automatically to the command execution environment on
- Windows systems.
-
- -- OUTPUT OF Configure() SUBSYSTEM CHANGED SLIGHTLY
-
- The Configure() subsystem now reports tests results as "yes" and
- "no" instead of "ok" and "failed." This might interfere with any
- scripts that automatically parse the Configure() output from SCons.
-
- -- VISUAL STUDIO ATL AND MFC DIRECTORIES NOT ADDED BY DEFAULT
-
- When compiling with Microsoft Visual Studio, SCons no longer
- adds the ATL and MFC directories to the INCLUDE and LIB
- environment variables by default. If you want these directories
- included in your environment variables, you should now set the
- $MSVS_USE_MFC_DIRS *construction* variable when initializing
- your environment:
-
- env = Environment(MSVS_USE_MFC_DIRS = 1)
-
- -- DEPRECATED GLOBAL FUNCTIONS HAVE BEEN REMOVED
-
- The following deprecated global functions have been removed:
- ParseConfig(), SetBuildSignatureType(), SetContentSignatureType(),
- SetJobs() and GetJobs().
-
- -- DEPRECATED "validater" KEYWORD HAS BEEN REMOVED
-
- The deprecated "validater" keyword to the Options.Add() method
- has been removed.
-
- Please note the following important changes since release 0.95:
-
- -- BUILDERS NOW ALWAYS RETURN A LIST OF TARGETS
-
- All Builder calls (both built-in like Program(), Library(),
- etc. and customer Builders) now always return a list of target
- Nodes. If the Builder only builds one target, the Builder
- call will now return a list containing that target Node, not
- the target Node itself as it used to do.
-
- This change should be invisibile to most normal uses of the
- return values from Builder calls. It will cause an error if the
- SConscript file was performing some direct manipulation of the
- returned Node value. For example, an attempt to print the name
- of a target returned by the Object() Builder:
-
- target = Object('foo.c')
- # OLD WAY
- print target
-
- Will now need to access the first element in the list returned by
- the Object() call:
-
- target = Object('foo.c')
- # NEW WAY
- print target[0]
-
- This change was introduced to make the data type returned by Builder
- calls consistent (always a list), regardless of platform or number
- of returned targets.
-
- -- DEFAULT SConsignFile() DATABASE SCHEME HAS CHANGED
-
- The SConsignFile() function now uses an internally-supplied
- SCons.dblite module as the default DB scheme for the .sconsign file.
- If you are using the SConsignFile() function without an explicitly
- specified dbm_module argument, this will cause all of your targets
- to be recompiled the first time you use SCons 0.96. To preserve the
- previous behavior, specify the "anydbm" module explicitly:
-
- import anydbm
- SConsignFile('.sconsign_file_name', anydbm)
-
- -- INTERNAL .sconsign FILE FORMAT HAS CHANGED
-
- The internal format of .sconsign files has been changed. This might
- cause warnings about "ignoring corrupt .sconsign files" and rebuilds
- when you use SCons 0.96 for the first time in a tree that was
- previously built with SCons 0.95 or earlier.
-
- -- INTERFACE CHANGE OF scan_check FUNCTION TO CUSTOM SCANNERS
-
- The scan_check function that can be supplied to a custom Scanner now
- must take two arguments, the Node to be checked and a construction
- environment. It previously only used the Node as an argument.
-
- -- DEFAULT SCANNERS NO LONGER HEED INTERNAL Scanner.add_skey() METHOD
-
- The internal Scanner.add_skey() method no longer works for the
- default scanners, which now use construction variables to hold their
- lists of suffixes. If you had a custom Tool specification that was
- reaching into the internals in this way to add a suffix to one of
- the following scanner, you must now add the suffix to a construction
- environment through which you plan to call the scanner, as follows:
-
- CScan.add_skey('.x') => env.Append(CPPSUFFIXES = ['.x'])
- DScan.add_skey('.x') => env.Append(DSUFFIXES = ['.x'])
- FortranScan.add_skey('.x') => env.Append(FORTRANSUFFIXES = ['.x'])
-
- -- KEYWORD ARGUMENTS TO Builder() HAVE BEEN REMOVED
-
- The "node_factory" and "scanner" keyword arguments to the Builder()
- function have been removed. In their place, the separate and more
- flexible "target_factory," "source_factory," "target_scanner" and
- "source scanner" keywords should be used instead.
-
- -- ALL-DIGIT FILE "EXTENSIONS" ARE NOW PART OF THE FILE BASENAME
-
- SCons now treats file "extensions" that contain all digits (for
- example, "file.123") as part of the file basename, for easier
- handling of version numbers in the names of shared libraries
- and other files. Builders will now add their file extensions to
- file names specified with all-digit extensions. If you need to
- generate a file with an all-digit extension using a Builder that
- adds a file extension, you can preserve the previous behavior by
- wrapping the file name in a File() call.
-
- -- Append()/Prepend() METHODS CHANGED WHEN USING UserList OBJECTS
+ Please note the following planned, future changes:
- The behavior of the env.Append() and env.Prepend() methods has
- changed when appending a string value to a UserList, or vice versa.
- They now behave like normal Python addition of a string to
- a UserList. Given an initialization and an env.Append() call like:
+ -- THE Options OBJECT AND RELATED FUNCTIONS WILL BE DEPRECATED
+
+ The Options object is being replaced by a new Variables
+ object, which uses a new Variables.AddVariable() method
+ where the previous interface used Options.AddOptions().
+
+ Similarly, the following utility functions are being replaced
+ by the following similarly-named functions:
+
+ BoolOption() BoolVariable()
+ EnumOption() EnumVariable()
+ ListOption() ListVariable()
+ PackageOption() PackageVariable()
+ PathOption() PathVariable()
+
+ And also related, the options= keyword argument when creating
+ construction environments with the Environment() functions is
+ being replaced with a variables= keyword argument.
+
+ In some future release a deprecation warning will be added to
+ existing uses of the Options object, its methods, the above
+ utility functions, and the options= keyword argument of the
+ Environment() function. At some point after the deprecation
+ warning is added, the Options object, related functions and
+ options= keyword argument will be removed entirely.
+
+ You can prepare for this by changing all your uses of the Options
+ object and related functions to the Variables object and the new
+ function names, and changing any uses of the options= keyword
+ argument to variables=.
+
+ NOTE: CONVERTING TO USING THE NEW Variables OBJECT OR THE
+ RELATED *Variable() FUNCTIONS, OR USING THE NEW variable=
+ KEYWORD ARGUMENT, IS NOT BACKWARDS COMPATIBLE TO VERSIONS OF
+ SCons BEFORE 0.98. YOUR SConscript FILES WILL NOT WORK ON
+ EARLIER VERSIONS OF SCons AFTER MAKING THIS CHANGE.
+
+ If you change SConscript files in software that you make available
+ for download or otherwise distribute, other users may try to
+ build your software with an earlier version of SCons that does
+ not have the Variables object or related *Variable() functions.
+ We recommend preparing for this in one of two ways:
- env = Environment(VAR1=UserList(['foo']), VAR2='foo')
- env.Append(VAR1='bar', VAR2=UserList(['bar'])
+ -- Make your SConscript files backwards-compatible by
+ modifying your calls with Python try:-except: blocks
+ as follows:
- The resulting values of $VAR1 and $VAR2 will now be ['foo', 'b',
- 'a', 'r'] and ['f', 'o', 'o', 'bar'], respectively. This is because
- Python UserList objects treat strings as sequences of letters when
- adding them to the value of the UserList.
+ try:
+ vars = Variables('custom.py', ARGUMENTS)
+ vars.AddVariables(
+ BoolVariable('WARNINGS', 'cmopile with -Wall', 1),
+ EnumVariable('DEBUG', 'debug version', 'no'
+ allowed_values=('yes', 'no', 'full'),
+ map={}, ignorecase=0),
+ ListVariable('SHAREDLIBS',
+ 'libraries to build shared',
+ 'all',
+ names = list_of_libs),
+ PackageVariable('X11',
+ 'use X11 from here',
+ '/usr/bin/X11'),
+ PathVariable('QTDIR', 'root of Qt', qtdir),
+ )
+ except NameError:
+ vars = Options('custom.py', ARGUMENTS)
+ vars.AddOptions(
+ BoolOption('WARNINGS', 'cmopile with -Wall', 1),
+ EnumOption('DEBUG', 'debug version', 'no'
+ allowed_values=('yes', 'no', 'full'),
+ map={}, ignorecase=0),
+ ListOption('SHAREDLIBS',
+ 'libraries to build shared',
+ 'all',
+ names = list_of_libs),
+ PackageOption('X11',
+ 'use X11 from here',
+ '/usr/bin/X11'),
+ PathOption('QTDIR', 'root of Qt', qtdir),
+ )
+
+ Additionally, you can check for availability of the new
+ variables= keyword argument as follows:
- The old behavior of yielding $VAR1 and $VAR2 values of ['foo',
- 'bar'] when either variable is a UserList object now requires that
- the string variables be enclosed in a list:
+ try:
+ env = Environment(variables=vars)
+ except TypeError:
+ env = Environment(options=vars)
- env = Environment(VAR1=UserList(['foo']), VAR2=['foo'])
- env.Append(VAR1='bar', VAR2=UserList(['bar']))
+ (Note that we plan to maintain the existing Options object
+ name for some time, to ensure backwards compatibility,
+ so in practice it may be easier to just continue to use
+ the old name until you're reasonably sure you won't have
+ people trying to build your software with versions of
+ SCons earlier than 0.98.1.)
- Note that the SCons behavior when appending to normal lists has
- *not* changed, and the behavior of all of the default values that
- SCons uses to initialize all construction variables has *not*
- changed. This change *only* affects any cases where you explicitly
- use UserList objects to initialize or append to a variable.
+ -- Use the EnsureSConsVersion() function to provide a
+ descriptive error message if your SConscript files
+ are executed by an earlier version of SCons:
- Please note the following planned, future changes:
+ EnsureSConsVersion(0, 98, 1)
-- THE BuildDir() METHOD AND FUNCTION WILL BE DEPRECATED
SCons/Builder.py
SCons/compat/__init__.py
SCons/compat/_scons_hashlib.py
+SCons/compat/_scons_itertools.py
SCons/compat/_scons_optparse.py
SCons/compat/_scons_sets.py
SCons/compat/_scons_sets15.py
SCons/Node/Alias.py
SCons/Node/FS.py
SCons/Node/Python.py
-SCons/Options/__init__.py
-SCons/Options/BoolOption.py
-SCons/Options/EnumOption.py
-SCons/Options/ListOption.py
-SCons/Options/PackageOption.py
-SCons/Options/PathOption.py
+SCons/Options.py
SCons/PathList.py
SCons/Platform/__init__.py
SCons/Platform/aix.py
SCons/Tool/yacc.py
SCons/Tool/zip.py
SCons/Util.py
+SCons/Variables/__init__.py
+SCons/Variables/BoolVariable.py
+SCons/Variables/EnumVariable.py
+SCons/Variables/ListVariable.py
+SCons/Variables/PackageVariable.py
+SCons/Variables/PathVariable.py
SCons/Warnings.py
except AttributeError:
contents = self.funccontents
- return contents + env.subst(string.join(map(lambda v: '${'+v+'}',
- self.varlist)))
+ result = [contents]
+ for v in self.varlist:
+ result.append(env.subst('${'+v+'}'))
+
+ return string.join(result, '')
def get_implicit_deps(self, target, source, env):
return []
expect_nonexecutable = 1
elif sys.platform == 'cygwin':
expect_nonexistent = 127
- expect_nonexecutable = 127
+ # Newer cygwin seems to return 126 for following
+ expect_nonexecutable_file = 126
+ expect_nonexecutable_dir = 127
else:
expect_nonexistent = 127
- expect_nonexecutable = 126
+ expect_nonexecutable_file = 126
+ expect_nonexecutable_dir = 126
# Test that a nonexistent command returns 127
act = SCons.Action.CommandAction(python + "_no_such_command_")
dir, tail = os.path.split(python)
act = SCons.Action.CommandAction(dir)
r = act([], [], env.Clone(out = outfile))
- assert r.status == expect_nonexecutable, r.status
+ assert r.status == expect_nonexecutable_file, r.status
# Test that trying to execute a non-executable file returns 126
act = SCons.Action.CommandAction(outfile)
r = act([], [], env.Clone(out = outfile))
- assert r.status == expect_nonexecutable, r.status
+ assert r.status == expect_nonexecutable_dir, r.status
act = SCons.Action.CommandAction('%s %s 1' % (_python_, exit_py))
r = act([], [], env)
res = resource.getrusage(resource.RUSAGE_SELF)
return res[4]
-
-
-caller_dicts = {}
-
-def caller(*backlist):
+# returns caller's stack
+def caller_stack(*backlist):
import traceback
if not backlist:
backlist = [0]
result = []
for back in backlist:
tb = traceback.extract_stack(limit=3+back)
- key = tb[1][:3]
- try:
- entry = caller_dicts[key]
- except KeyError:
- entry = caller_dicts[key] = {}
key = tb[0][:3]
- entry[key] = entry.get(key, 0) + 1
result.append('%s:%d(%s)' % func_shorten(key))
return result
+caller_bases = {}
+caller_dicts = {}
+
+# trace a caller's stack
+def caller_trace(back=0):
+ import traceback
+ tb = traceback.extract_stack(limit=3+back)
+ tb.reverse()
+ callee = tb[1][:3]
+ caller_bases[callee] = caller_bases.get(callee, 0) + 1
+ for caller in tb[2:]:
+ caller = callee + caller[:3]
+ try:
+ entry = caller_dicts[callee]
+ except KeyError:
+ caller_dicts[callee] = entry = {}
+ entry[caller] = entry.get(caller, 0) + 1
+ callee = caller
+
+# print a single caller and its callers, if any
+def _dump_one_caller(key, file, level=0):
+ l = []
+ for c,v in caller_dicts[key].items():
+ l.append((-v,c))
+ l.sort()
+ leader = ' '*level
+ for v,c in l:
+ file.write("%s %6d %s:%d(%s)\n" % ((leader,-v) + func_shorten(c[-3:])))
+ if caller_dicts.has_key(c):
+ _dump_one_caller(c, file, level+1)
+
+# print each call tree
def dump_caller_counts(file=sys.stdout):
- keys = caller_dicts.keys()
+ keys = caller_bases.keys()
keys.sort()
for k in keys:
- file.write("Callers of %s:%d(%s):\n" % func_shorten(k))
- counts = caller_dicts[k]
- callers = counts.keys()
- callers.sort()
- for c in callers:
- #file.write(" counts[%s] = %s\n" % (c, counts[c]))
- t = ((counts[c],) + func_shorten(c))
- file.write(" %6d %s:%d(%s)\n" % t)
+ file.write("Callers of %s:%d(%s), %d calls:\n"
+ % (func_shorten(k) + (caller_bases[k],)))
+ _dump_one_caller(k, file)
shorten_list = [
( '/scons/SCons/', 1),
if i >= 0:
if t[1]:
i = i + len(t[0])
- f = f[i:]
- break
- return (f,)+func_tuple[1:]
-
+ return (f[i:],)+func_tuple[1:]
+ return func_tuple
TraceFP = {}
platform=None,
tools=None,
toolpath=None,
- options=None,
+ variables=None,
parse_flags = None,
**kw):
"""
self._dict['PLATFORM'] = str(platform)
platform(self)
- # Apply the passed-in variables and customizable options to the
+ # Apply the passed-in and customizable variables to the
# environment before calling the tools, because they may use
# some of them during initialization.
+ if kw.has_key('options'):
+ # Backwards compatibility: they may stll be using the
+ # old "options" keyword.
+ variables = kw['options']
+ del kw['options']
apply(self.Replace, (), kw)
keys = kw.keys()
- if options:
- keys = keys + options.keys()
- options.Update(self)
+ if variables:
+ keys = keys + variables.keys()
+ variables.Update(self)
save = {}
for k in keys:
tools = ['default']
apply_tools(self, tools, toolpath)
- # Now restore the passed-in variables and customized options
+ # Now restore the passed-in and customized variables
# to the environment, since the values the user set explicitly
# should override any values set by the tools.
for key, val in save.items():
assert not env1.has_key('__env__')
assert not env2.has_key('__env__')
- def test_options(self):
- """Test that options only get applied once."""
+ def test_variables(self):
+ """Test that variables only get applied once."""
class FakeOptions:
def __init__(self, key, val):
self.calls = 0
self.calls = self.calls + 1
o = FakeOptions('AAA', 'fake_opt')
- env = Environment(options=o, AAA='keyword_arg')
+ env = Environment(variables=o, AAA='keyword_arg')
assert o.calls == 1, o.calls
assert env['AAA'] == 'fake_opt', env['AAA']
self.sources_need_sorting = False
return self.sources
+ def prepare(self):
+ """
+ Preparatory checks for whether this Executor can go ahead
+ and (try to) build its targets.
+ """
+ for s in self.get_sources():
+ if s.missing():
+ msg = "Source `%s' not found, needed by target `%s'."
+ raise SCons.Errors.StopError, msg % (s, self.targets[0])
+
def add_pre_action(self, action):
self.pre_actions.append(action)
This essentially short-circuits an N*M scan of the sources for
each individual target, which is a hell of a lot more efficient.
"""
- map(lambda N: N.disambiguate(), node_list)
-
env = self.get_build_env()
- select_specific_scanner = lambda t: (t[0], t[1].select(t[0]))
- remove_null_scanners = lambda t: not t[1] is None
- add_scanner_path = lambda t, s=self: \
- (t[0], t[1], s.get_build_scanner_path(t[1]))
+
+ deps = []
if scanner:
- scanner_list = map(lambda n, s=scanner: (n, s), node_list)
+ for node in node_list:
+ node.disambiguate()
+ scanner = scanner.select(node)
+ if not scanner:
+ continue
+ path = self.get_build_scanner_path(scanner)
+ deps.extend(node.get_implicit_deps(env, scanner, path))
else:
kw = self.get_kw()
- get_initial_scanners = lambda n, e=env, kw=kw: \
- (n, n.get_env_scanner(e, kw))
- scanner_list = map(get_initial_scanners, node_list)
- scanner_list = filter(remove_null_scanners, scanner_list)
-
- scanner_list = map(select_specific_scanner, scanner_list)
- scanner_list = filter(remove_null_scanners, scanner_list)
- scanner_path_list = map(add_scanner_path, scanner_list)
-
- deps = []
- for node, scanner, path in scanner_path_list:
- deps.extend(node.get_implicit_deps(env, scanner, path))
+ for node in node_list:
+ node.disambiguate()
+ scanner = node.get_env_scanner(env, kw)
+ if not scanner:
+ continue
+ scanner = scanner.select(node)
+ if not scanner:
+ continue
+ path = self.get_build_scanner_path(scanner)
+ deps.extend(node.get_implicit_deps(env, scanner, path))
deps.extend(self.get_implicit_deps())
for tgt in self.targets:
tgt.add_to_implicit(deps)
- def get_missing_sources(self):
- """
- """
- return filter(lambda s: s.missing(), self.get_sources())
-
def _get_unignored_sources_key(self, ignore=()):
return tuple(ignore)
return None
def cleanup(self):
pass
+ def prepare(self):
+ pass
x.get_sources()
assert x.sources == ['s1', 's2', 's3', 's4'], x.sources
+ def test_prepare(self):
+ """Test the Executor's prepare() method"""
+ env = MyEnvironment()
+ t1 = MyNode('t1')
+ s1 = MyNode('s1')
+ s2 = MyNode('s2')
+ s3 = MyNode('s3')
+ x = SCons.Executor.Executor('b', env, [{}], [t1], [s1, s2, s3])
+
+ s2.missing_val = True
+
+ try:
+ r = x.prepare()
+ except SCons.Errors.StopError, e:
+ assert str(e) == "Source `s2' not found, needed by target `t1'.", e
+ else:
+ raise AssertionError, "did not catch expected StopError: %s" % r
+
def test_add_pre_action(self):
"""Test adding pre-actions to an Executor"""
x = SCons.Executor.Executor('b', 'e', 'o', 't', ['s1', 's2'])
assert t1.implicit == ['scanner-s1', 'scanner-s2'], t1.implicit
assert t2.implicit == ['scanner-s1', 'scanner-s2'], t2.implicit
- def test_get_missing_sources(self):
- """Test the ability to check if any sources are missing"""
- env = MyEnvironment()
- targets = [MyNode('t')]
- sources = [MyNode('s1'), MyNode('s2')]
- x = SCons.Executor.Executor('b', env, [{}], targets, sources)
- sources[0].missing_val = 1
- missing = x.get_missing_sources()
- assert missing == [sources[0]], missing
-
def test_get_unignored_sources(self):
"""Test fetching the unignored source list"""
env = MyEnvironment()
import SCons.compat
+import os
+import signal
+
# The default stack size (in kilobytes) of the threads used to execute
# jobs in parallel.
default_stack_size = 256
+interrupt_msg = 'Build interrupted.'
class Jobs:
"""An instance of this class initializes N jobs, and provides
self.job = Serial(taskmaster)
self.num_jobs = 1
- def run(self):
- """run the job"""
+ self.job.interrupted = False
+
+ def run(self, postfunc=lambda: None):
+ """Run the jobs.
+
+ postfunc() will be invoked after the jobs has run. It will be
+ invoked even if the jobs are interrupted by a keyboard
+ interrupt (well, in fact by a signal such as either SIGINT,
+ SIGTERM or SIGHUP). The execution of postfunc() is protected
+ against keyboard interrupts and is guaranteed to run to
+ completion."""
+ self._setup_sig_handler()
try:
self.job.start()
- except KeyboardInterrupt:
- # mask any further keyboard interrupts so that scons
- # can shutdown cleanly:
- # (this only masks the keyboard interrupt for Python,
- # child processes can still get the keyboard interrupt)
- import signal
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- raise
-
- def cleanup(self):
- self.job.cleanup()
+ finally:
+ postfunc()
+ self._reset_sig_handler()
+
+ def were_interrupted(self):
+ """Returns whether the jobs were interrupted by a signal."""
+ return self.job.interrupted
+
+ def _setup_sig_handler(self):
+ """Setup an interrupt handler so that SCons can shutdown cleanly in
+ various conditions:
+
+ a) SIGINT: Keyboard interrupt
+ b) SIGTERM: kill or system shutdown
+ c) SIGHUP: Controlling shell exiting
+
+ We handle all of these cases by stopping the taskmaster. It
+ turns out that it very difficult to stop the build process
+ by throwing asynchronously an exception such as
+ KeyboardInterrupt. For example, the python Condition
+ variables (threading.Condition) and Queue's do not seem to
+ asynchronous-exception-safe. It would require adding a whole
+ bunch of try/finally block and except KeyboardInterrupt all
+ over the place.
+
+ Note also that we have to be careful to handle the case when
+ SCons forks before executing another process. In that case, we
+ want the child to exit immediately.
+ """
+ def handler(signum, stack, parentpid=os.getpid()):
+ if os.getpid() == parentpid:
+ self.job.taskmaster.stop()
+ self.job.interrupted = True
+ else:
+ os._exit(2)
+
+ self.old_sigint = signal.signal(signal.SIGINT, handler)
+ self.old_sigterm = signal.signal(signal.SIGTERM, handler)
+ try:
+ self.old_sighup = signal.signal(signal.SIGHUP, handler)
+ except AttributeError:
+ pass
+
+ def _reset_sig_handler(self):
+ """Restore the signal handlers to their previous state (before the
+ call to _setup_sig_handler()."""
+
+ signal.signal(signal.SIGINT, self.old_sigint)
+ signal.signal(signal.SIGTERM, self.old_sigterm)
+ try:
+ signal.signal(signal.SIGHUP, self.old_sighup)
+ except AttributeError:
+ pass
class Serial:
"""This class is used to execute tasks in series, and is more efficient
try:
task.prepare()
- task.execute()
- except KeyboardInterrupt:
- raise
+ if task.needs_execute():
+ task.execute()
except:
- task.exception_set()
+ if self.interrupted:
+ try:
+ raise SCons.Errors.BuildError(
+ task.targets[0], errstr=interrupt_msg)
+ except:
+ task.exception_set()
+ else:
+ task.exception_set()
+
# Let the failed() callback function arrange for the
# build to stop if that's appropriate.
task.failed()
task.executed()
task.postprocess()
+ self.taskmaster.cleanup()
- def cleanup(self):
- pass
# Trap import failure so that everything in the Job module but the
# Parallel class (and its dependent classes) will work if the interpreter
try:
task.execute()
- except KeyboardInterrupt:
- # be explicit here for test/interrupts.py
- ok = False
except:
task.exception_set()
ok = False
if 'prev_size' in locals().keys():
threading.stack_size(prev_size)
- def put(self, obj):
+ def put(self, task):
"""Put task into request queue."""
- self.requestQueue.put(obj)
+ self.requestQueue.put(task)
- def get(self, block = True):
+ def get(self):
"""Remove and return a result tuple from the results queue."""
- return self.resultsQueue.get(block)
+ return self.resultsQueue.get()
- def preparation_failed(self, obj):
- self.resultsQueue.put((obj, False))
+ def preparation_failed(self, task):
+ self.resultsQueue.put((task, False))
def cleanup(self):
"""
if task is None:
break
- # prepare task for execution
try:
+ # prepare task for execution
task.prepare()
- except KeyboardInterrupt:
- raise
except:
- # Let the failed() callback function arrange
- # for the build to stop if that's appropriate.
task.exception_set()
- self.tp.preparation_failed(task)
- jobs = jobs + 1
- continue
-
- # dispatch task
- self.tp.put(task)
- jobs = jobs + 1
+ task.failed()
+ task.postprocess()
+ else:
+ if task.needs_execute():
+ # dispatch task
+ self.tp.put(task)
+ jobs = jobs + 1
+ else:
+ task.executed()
+ task.postprocess()
if not task and not jobs: break
# back and put the next batch of tasks on the queue.
while 1:
task, ok = self.tp.get()
-
jobs = jobs - 1
+
if ok:
task.executed()
else:
+ if self.interrupted:
+ try:
+ raise SCons.Errors.BuildError(
+ task.targets[0], errstr=interrupt_msg)
+ except:
+ task.exception_set()
+
+ # Let the failed() callback function arrange
+ # for the build to stop if that's appropriate.
task.failed()
task.postprocess()
if self.tp.resultsQueue.empty():
break
- def cleanup(self):
self.tp.cleanup()
+ self.taskmaster.cleanup()
def _do_something(self):
pass
+ def needs_execute(self):
+ return True
+
def execute(self):
self.taskmaster.test_case.failUnless(self.was_prepared,
"the task wasn't prepared")
def prepare(self):
self.was_prepared = 1
+ def needs_execute(self):
+ return True
+
def execute(self):
raise Exception
def exception_set(self):
pass
+ def cleanup(self):
+ pass
+
SaveThreadPool = None
ThreadPoolCallList = []
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import fnmatch
+from itertools import izip
import os
import os.path
import re
rep_nodes = map(dir.Entry, disk_names)
#rep_nodes = [ n.disambiguate() for n in rep_nodes ]
rep_nodes = map(lambda n: n.disambiguate(), rep_nodes)
- for node, name in zip(rep_nodes, disk_names):
+ for node, name in izip(rep_nodes, disk_names):
n = self.Entry(name)
if n.__class__ != node.__class__:
n.__class__ = node.__class__
pass
else:
nodes = []
- for s, ni in zip(strings, nodeinfos):
+ for s, ni in izip(strings, nodeinfos):
if not isinstance(s, SCons.Node.Node):
s = ni.str_to_node(s)
nodes.append(s)
result = []
bkids = self.bsources + self.bdepends + self.bimplicit
bkidsigs = self.bsourcesigs + self.bdependsigs + self.bimplicitsigs
- for bkid, bkidsig in zip(bkids, bkidsigs):
+ for bkid, bkidsig in izip(bkids, bkidsigs):
result.append(str(bkid) + ': ' +
string.join(bkidsig.format(names=names), ' '))
result.append('%s [%s]' % (self.bactsig, self.bact))
n1 = SCons.Node.Node()
n1.builder_set(Builder())
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n1])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n1])
node.prepare() # should not throw an exception
n2 = SCons.Node.Node()
n2.linked = 1
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n2])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n2])
node.prepare() # should not throw an exception
n3 = SCons.Node.Node()
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n3])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n3])
node.prepare() # should not throw an exception
return None
n4 = MyNode()
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n4])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n4])
exc_caught = 0
try:
node.prepare()
pass
else:
raise "did not catch expected exception"
- assert node.sources == [zero, one, two, three, four]
+ assert node.sources == [zero, one, two, three, four], node.sources
def test_add_ignore(self):
"""Test adding files whose dependencies should be ignored.
node.add_source([n1, n2, n3])
node.add_dependency([n4, n5, n6])
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n7, n8, n9])
- node._add_child(node.implicit, node.implicit_dict, [n10, n11, n12])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n7, n8, n9])
+ node._add_child(node.implicit, node.implicit_set, [n10, n11, n12])
node.add_ignore([n2, n5, n8, n11])
kids = node.children()
node.add_source([n1, n2, n3])
node.add_dependency([n4, n5, n6])
node.implicit = []
- node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n7, n8, n9])
- node._add_child(node.implicit, node.implicit_dict, [n10, n11, n12])
+ node.implicit_set = set()
+ node._add_child(node.implicit, node.implicit_set, [n7, n8, n9])
+ node._add_child(node.implicit, node.implicit_set, [n10, n11, n12])
node.add_ignore([n2, n5, n8, n11])
kids = node.all_children()
n.clear()
assert n.includes is None, n.includes
- assert n.found_includes == {}, n.found_includes
assert x.cleaned_up
def test_get_subst_proxy(self):
def test_postprocess(self):
"""Test calling the base Node postprocess() method"""
n = SCons.Node.Node()
- n.waiting_parents = {'foo':1, 'bar':1}
+ n.waiting_parents = set( ['foo','bar'] )
n.postprocess()
- assert n.waiting_parents == {}, n.waiting_parents
+ assert n.waiting_parents == set(), n.waiting_parents
def test_add_to_waiting_parents(self):
"""Test the add_to_waiting_parents() method"""
n1 = SCons.Node.Node()
n2 = SCons.Node.Node()
- assert n1.waiting_parents == {}, n1.waiting_parents
+ assert n1.waiting_parents == set(), n1.waiting_parents
r = n1.add_to_waiting_parents(n2)
assert r == 1, r
- assert n1.waiting_parents == {n2:1}, n1.waiting_parents
+ assert n1.waiting_parents == set((n2,)), n1.waiting_parents
r = n1.add_to_waiting_parents(n2)
assert r == 0, r
- def test_call_for_all_waiting_parents(self):
- """Test the call_for_all_waiting_parents() method"""
- n1 = SCons.Node.Node()
- n2 = SCons.Node.Node()
- n1.add_to_waiting_parents(n2)
- result = []
- def func(node, result=result):
- result.append(node)
- n1.call_for_all_waiting_parents(func)
- assert result == [n1, n2], result
class NodeListTestCase(unittest.TestCase):
def test___str__(self):
import SCons.compat
import copy
+from itertools import chain, izip
import string
import UserList
failed = 5
StateString = {
- 0 : "0",
+ 0 : "no_state",
1 : "pending",
2 : "executing",
3 : "up_to_date",
# a class. (Of course, we could always still do that in the
# future if we had a good reason to...).
self.sources = [] # source files used to build node
- self.sources_dict = {}
+ self.sources_set = set()
+ self._specific_sources = False
self.depends = [] # explicit dependencies (from Depends)
- self.depends_dict = {}
+ self.depends_set = set()
self.ignore = [] # dependencies to ignore
- self.ignore_dict = {}
+ self.ignore_set = set()
self.prerequisites = SCons.Util.UniqueList()
self.implicit = None # implicit (scanned) dependencies (None means not scanned yet)
- self.waiting_parents = {}
- self.waiting_s_e = {}
+ self.waiting_parents = set()
+ self.waiting_s_e = set()
self.ref_count = 0
self.wkids = None # Kids yet to walk, when it's an array
self.noclean = 0
self.nocache = 0
self.always_build = None
- self.found_includes = {}
self.includes = None
self.attributes = self.Attrs() # Generic place to stick information about the Node.
self.side_effect = 0 # true iff this node is a side effect
is out-of-date and must be rebuilt, but before actually calling
the method to build the Node.
- This default implemenation checks that all children either exist
- or are derived, and initializes the BuildInfo structure that
- will hold the information about how this node is, uh, built.
+ This default implementation checks that explicit or implicit
+ dependencies either exist or are derived, and initializes the
+ BuildInfo structure that will hold the information about how
+ this node is, uh, built.
+
+ (The existence of source files is checked separately by the
+ Executor, which aggregates checks for all of the targets built
+ by a specific action.)
Overriding this method allows for for a Node subclass to remove
the underlying file from the file system. Note that subclass
methods should call this base class method to get the child
check and the BuildInfo structure.
"""
- l = self.depends
+ for d in self.depends:
+ if d.missing():
+ msg = "Explicit dependency `%s' not found, needed by target `%s'."
+ raise SCons.Errors.StopError, msg % (d, self)
if not self.implicit is None:
- l = l + self.implicit
- missing_sources = self.get_executor().get_missing_sources() \
- + filter(lambda c: c.missing(), l)
- if missing_sources:
- desc = "Source `%s' not found, needed by target `%s'." % (missing_sources[0], self)
- raise SCons.Errors.StopError, desc
-
+ for i in self.implicit:
+ if i.missing():
+ msg = "Implicit dependency `%s' not found, needed by target `%s'."
+ raise SCons.Errors.StopError, msg % (i, self)
self.binfo = self.get_binfo()
def build(self, **kw):
# Clear the implicit dependency caches of any Nodes
# waiting for this Node to be built.
- for parent in self.waiting_parents.keys():
+ for parent in self.waiting_parents:
parent.implicit = None
self.clear()
#
def add_to_waiting_s_e(self, node):
- self.waiting_s_e[node] = 1
+ self.waiting_s_e.add(node)
def add_to_waiting_parents(self, node):
"""
True and False instead...)
"""
wp = self.waiting_parents
- if wp.has_key(node):
- result = 0
- else:
- result = 1
- wp[node] = 1
- return result
-
- def call_for_all_waiting_parents(self, func):
- func(self)
- for parent in self.waiting_parents.keys():
- parent.call_for_all_waiting_parents(func)
+ if node in wp:
+ return 0
+ wp.add(node)
+ return 1
def postprocess(self):
"""Clean up anything we don't need to hang onto after we've
been built."""
self.executor_cleanup()
- self.waiting_parents = {}
+ self.waiting_parents = set()
def clear(self):
"""Completely clear a Node of all its cached state (so that it
except AttributeError:
pass
self.includes = None
- self.found_includes = {}
def clear_memoized_values(self):
self._memo = {}
def add_to_implicit(self, deps):
if not hasattr(self, 'implicit') or self.implicit is None:
self.implicit = []
- self.implicit_dict = {}
+ self.implicit_set = set()
self._children_reset()
- self._add_child(self.implicit, self.implicit_dict, deps)
+ self._add_child(self.implicit, self.implicit_set, deps)
def scan(self):
"""Scan this node's dependents for implicit dependencies."""
if not self.implicit is None:
return
self.implicit = []
- self.implicit_dict = {}
+ self.implicit_set = set()
self._children_reset()
if not self.has_builder():
return
# one of this node's sources has changed,
# so we must recalculate the implicit deps:
self.implicit = []
- self.implicit_dict = {}
+ self.implicit_set = set()
# Have the executor scan the sources.
executor.scan_sources(self.builder.source_scanner)
self.binfo = binfo
executor = self.get_executor()
-
- sources = executor.get_unignored_sources(self.ignore)
-
- depends = self.depends
- implicit = self.implicit or []
-
- if self.ignore:
- depends = filter(self.do_not_ignore, depends)
- implicit = filter(self.do_not_ignore, implicit)
-
- def get_ninfo(node):
- return node.get_ninfo()
-
- sourcesigs = map(get_ninfo, sources)
- dependsigs = map(get_ninfo, depends)
- implicitsigs = map(get_ninfo, implicit)
+ ignore_set = self.ignore_set
if self.has_builder():
binfo.bact = str(executor)
binfo.bactsig = SCons.Util.MD5signature(executor.get_contents())
- binfo.bsources = sources
- binfo.bdepends = depends
- binfo.bimplicit = implicit
+ if self._specific_sources:
+ sources = []
+ for s in self.sources:
+ if s not in ignore_set:
+ sources.append(s)
+ else:
+ sources = executor.get_unignored_sources(self.ignore)
+ seen = set()
+ bsources = []
+ bsourcesigs = []
+ for s in sources:
+ if not s in seen:
+ seen.add(s)
+ bsources.append(s)
+ bsourcesigs.append(s.get_ninfo())
+ binfo.bsources = bsources
+ binfo.bsourcesigs = bsourcesigs
- binfo.bsourcesigs = sourcesigs
+ depends = self.depends
+ dependsigs = []
+ for d in depends:
+ if d not in ignore_set:
+ dependsigs.append(d.get_ninfo())
+ binfo.bdepends = depends
binfo.bdependsigs = dependsigs
+
+ implicit = self.implicit or []
+ implicitsigs = []
+ for i in implicit:
+ if i not in ignore_set:
+ implicitsigs.append(i.get_ninfo())
+ binfo.bimplicit = implicit
binfo.bimplicitsigs = implicitsigs
return binfo
def add_dependency(self, depend):
"""Adds dependencies."""
try:
- self._add_child(self.depends, self.depends_dict, depend)
+ self._add_child(self.depends, self.depends_set, depend)
except TypeError, e:
e = e.args[0]
if SCons.Util.is_List(e):
def add_ignore(self, depend):
"""Adds dependencies to ignore."""
try:
- self._add_child(self.ignore, self.ignore_dict, depend)
+ self._add_child(self.ignore, self.ignore_set, depend)
except TypeError, e:
e = e.args[0]
if SCons.Util.is_List(e):
def add_source(self, source):
"""Adds sources."""
+ if self._specific_sources:
+ return
try:
- self._add_child(self.sources, self.sources_dict, source)
+ self._add_child(self.sources, self.sources_set, source)
except TypeError, e:
e = e.args[0]
if SCons.Util.is_List(e):
s = str(e)
raise SCons.Errors.UserError("attempted to add a non-Node as source of %s:\n\t%s is a %s, not a Node" % (str(self), s, type(e)))
- def _add_child(self, collection, dict, child):
- """Adds 'child' to 'collection', first checking 'dict' to see
- if it's already present."""
+ def _add_child(self, collection, set, child):
+ """Adds 'child' to 'collection', first checking 'set' to see if it's
+ already present."""
#if type(child) is not type([]):
# child = [child]
#for c in child:
# raise TypeError, c
added = None
for c in child:
- if not dict.has_key(c):
+ if c not in set:
+ set.add(c)
collection.append(c)
- dict[c] = 1
added = 1
if added:
self._children_reset()
+ def set_specific_source(self, source):
+ self.add_source(source)
+ self._specific_sources = True
+
def add_wkid(self, wkid):
"""Add a node to the list of kids waiting to be evaluated"""
if self.wkids != None:
# build info that it's cached so we can re-calculate it.
self.executor_cleanup()
- def do_not_ignore(self, node):
- return node not in self.ignore
+ memoizer_counters.append(SCons.Memoize.CountValue('_children_get'))
+
+ def _children_get(self):
+ try:
+ return self._memo['children_get']
+ except KeyError:
+ pass
- def _all_children_get(self):
# The return list may contain duplicate Nodes, especially in
# source trees where there are a lot of repeated #includes
# of a tangle of .h files. Profiling shows, however, that
# using dictionary keys, lose the order, and the only ordered
# dictionary patterns I found all ended up using "not in"
# internally anyway...)
- if self.implicit is None:
- return self.sources + self.depends
- else:
- return self.sources + self.depends + self.implicit
+ if self.ignore_set:
+ if self.implicit is None:
+ iter = chain(self.sources,self.depends)
+ else:
+ iter = chain(self.sources, self.depends, self.implicit)
- memoizer_counters.append(SCons.Memoize.CountValue('_children_get'))
+ children = []
+ for i in iter:
+ if i not in self.ignore_set:
+ children.append(i)
+ else:
+ if self.implicit is None:
+ children = self.sources + self.depends
+ else:
+ children = self.sources + self.depends + self.implicit
- def _children_get(self):
- try:
- return self._memo['children_get']
- except KeyError:
- pass
- children = self._all_children_get()
- if self.ignore:
- children = filter(self.do_not_ignore, children)
self._memo['children_get'] = children
return children
"""Return a list of all the node's direct children."""
if scan:
self.scan()
- return self._all_children_get()
+
+ # The return list may contain duplicate Nodes, especially in
+ # source trees where there are a lot of repeated #includes
+ # of a tangle of .h files. Profiling shows, however, that
+ # eliminating the duplicates with a brute-force approach that
+ # preserves the order (that is, something like:
+ #
+ # u = []
+ # for n in list:
+ # if n not in u:
+ # u.append(n)"
+ #
+ # takes more cycles than just letting the underlying methods
+ # hand back cached values if a Node's information is requested
+ # multiple times. (Other methods of removing duplicates, like
+ # using dictionary keys, lose the order, and the only ordered
+ # dictionary patterns I found all ended up using "not in"
+ # internally anyway...)
+ if self.implicit is None:
+ return self.sources + self.depends
+ else:
+ return self.sources + self.depends + self.implicit
def children(self, scan=1):
"""Return a list of the node's direct children, minus those
if t: Trace(': old %s new %s' % (len(then), len(children)))
result = True
- for child, prev_ni in zip(children, then):
+ for child, prev_ni in izip(children, then):
if child.changed_since_last_build(self, prev_ni):
if t: Trace(': %s changed' % child)
result = True
new_bkids = new.bsources + new.bdepends + new.bimplicit
new_bkidsigs = new.bsourcesigs + new.bdependsigs + new.bimplicitsigs
- osig = dict(zip(old_bkids, old_bkidsigs))
- nsig = dict(zip(new_bkids, new_bkidsigs))
+ osig = dict(izip(old_bkids, old_bkidsigs))
+ nsig = dict(izip(new_bkids, new_bkidsigs))
# The sources and dependencies we'll want to report are all stored
# as relative paths to this target's directory, but we want to
--- /dev/null
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__doc__ = """Place-holder for the old SCons.Options module hierarchy
+
+This is for backwards compatibility. The new equivalent is the Variables/
+class hierarchy. These will have deprecation warnings added (some day),
+and will then be removed entirely (some day).
+"""
+
+import SCons.Variables
+
+class Options(SCons.Variables.Variables):
+
+ def AddOptions(self, *args, **kw):
+ return apply(SCons.Variables.Variables.AddVariables,
+ (self,) + args,
+ kw)
+
+ def UnknownOptions(self, *args, **kw):
+ return apply(SCons.Variables.Variables.UnknownVariables,
+ (self,) + args,
+ kw)
+
+ def FormatOptionHelpText(self, *args, **kw):
+ return apply(SCons.Variables.Variables.FormatVariableHelpText,
+ (self,) + args,
+ kw)
+
+BoolOption = SCons.Variables.BoolVariable
+EnumOption = SCons.Variables.EnumVariable
+ListOption = SCons.Variables.ListVariable
+PackageOption = SCons.Variables.PackageVariable
+PathOption = SCons.Variables.PathVariable
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import errno
import os
import os.path
import popen2
def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
stdout_eof = stderr_eof = 0
while not (stdout_eof and stderr_eof):
- (i,o,e) = select.select([cmd_stdout, cmd_stderr], [], [])
- if cmd_stdout in i:
- str = cmd_stdout.read()
- if len(str) == 0:
- stdout_eof = 1
- elif stdout != None:
- stdout.write(str)
- if cmd_stderr in i:
- str = cmd_stderr.read()
- if len(str) == 0:
- #sys.__stderr__.write( "stderr_eof=1\n" )
- stderr_eof = 1
- else:
- #sys.__stderr__.write( "str(stderr) = %s\n" % str )
- stderr.write(str)
+ try:
+ (i,o,e) = select.select([cmd_stdout, cmd_stderr], [], [])
+ if cmd_stdout in i:
+ str = cmd_stdout.read()
+ if len(str) == 0:
+ stdout_eof = 1
+ elif stdout != None:
+ stdout.write(str)
+ if cmd_stderr in i:
+ str = cmd_stderr.read()
+ if len(str) == 0:
+ #sys.__stderr__.write( "stderr_eof=1\n" )
+ stderr_eof = 1
+ else:
+ #sys.__stderr__.write( "str(stderr) = %s\n" % str )
+ stderr.write(str)
+ except select.error, (_errno, _strerror):
+ if _errno != errno.EINTR:
+ raise
def exec_popen3(l, env, stdout, stderr):
proc = popen2.Popen3(string.join(l), 1)
def __init__(self, name):
self.name = name
self.state = None
- self.waiting_parents = {}
+ self.waiting_parents = set()
self.side_effects = []
self.builder = None
+ self.prerequisites = []
def disambiguate(self):
return self
def has_builder(self):
if not nodes:
return
+ # Call each of the Node's alter_targets() methods, which may
+ # provide additional targets that ended up as part of the build
+ # (the canonical example being a VariantDir() when we're building
+ # from a source directory) and which we therefore need their
+ # state cleared, too.
+ x = []
+ for n in nodes:
+ x.extend(n.alter_targets()[0])
+ nodes.extend(x)
+
# Clean up so that we can perform the next build correctly.
#
# We do this by walking over all the children of the targets,
self.progress(self.targets[0])
return SCons.Taskmaster.Task.prepare(self)
- def execute(self):
- for target in self.targets:
- if target.get_state() == SCons.Node.up_to_date:
- continue
- if target.has_builder() and not hasattr(target.builder, 'status'):
- if print_time:
- start_time = time.time()
- global first_command_start
- if first_command_start is None:
- first_command_start = start_time
- SCons.Taskmaster.Task.execute(self)
- if print_time:
- global cumulative_command_time
- global last_command_end
- finish_time = time.time()
- last_command_end = finish_time
- cumulative_command_time = cumulative_command_time+finish_time-start_time
- sys.stdout.write("Command execution time: %f seconds\n"%(finish_time-start_time))
- break
+ def needs_execute(self):
+ target = self.targets[0]
+ if target.get_state() == SCons.Node.executing:
+ return True
else:
if self.top and target.has_builder():
display("scons: `%s' is up to date." % str(self.node))
+ return False
+
+ def execute(self):
+ if print_time:
+ start_time = time.time()
+ global first_command_start
+ if first_command_start is None:
+ first_command_start = start_time
+ SCons.Taskmaster.Task.execute(self)
+ if print_time:
+ global cumulative_command_time
+ global last_command_end
+ finish_time = time.time()
+ last_command_end = finish_time
+ cumulative_command_time = cumulative_command_time+finish_time-start_time
+ sys.stdout.write("Command execution time: %f seconds\n"%(finish_time-start_time))
def do_failed(self, status=2):
_BuildFailures.append(self.exception[1])
t = self.targets[0]
if self.top and not t.has_builder() and not t.side_effect:
if not t.exists():
- sys.stderr.write("scons: *** Do not know how to make target `%s'." % t)
+ errstr="Do not know how to make target `%s'." % t
+ sys.stderr.write("scons: *** " + errstr)
if not self.options.keep_going:
sys.stderr.write(" Stop.")
sys.stderr.write("\n")
+ try:
+ raise SCons.Errors.BuildError(t, errstr)
+ except:
+ self.exception_set()
self.do_failed()
else:
print "scons: Nothing to be done for `%s'." % t
if options.diskcheck:
SCons.Node.FS.set_diskcheck(options.diskcheck)
- _set_debug_values(options)
- SCons.Node.implicit_cache = options.implicit_cache
- SCons.Node.implicit_deps_changed = options.implicit_deps_changed
- SCons.Node.implicit_deps_unchanged = options.implicit_deps_unchanged
-
SCons.CacheDir.cache_enabled = not options.cache_disable
SCons.CacheDir.cache_debug = options.cache_debug
SCons.CacheDir.cache_force = options.cache_force
memory_stats.append('before building targets:')
count_stats.append(('pre-', 'build'))
- try:
- progress_display("scons: " + opening_message)
- try:
- jobs.run()
- except KeyboardInterrupt:
- # If we are in interactive mode, a KeyboardInterrupt
- # interrupts only this current run. Return 'nodes' normally
- # so that the outer loop can clean up the nodes and continue.
- if options.interactive:
- print "Build interrupted."
- # Continue and return normally
- finally:
- jobs.cleanup()
+ def jobs_postfunc(
+ jobs=jobs,
+ options=options,
+ closing_message=closing_message,
+ failure_message=failure_message
+ ):
+ if jobs.were_interrupted():
+ progress_display("scons: Build interrupted.")
+ global exit_status
+ exit_status = 2
+
if exit_status:
progress_display("scons: " + failure_message)
else:
progress_display("scons: " + closing_message)
if not options.no_exec:
+ if jobs.were_interrupted():
+ progress_display("scons: writing .sconsign file.")
SCons.SConsign.write()
+ progress_display("scons: " + opening_message)
+ jobs.run(postfunc = jobs_postfunc)
+
memory_stats.append('after building targets:')
count_stats.append(('post-', 'build'))
parts = ["SCons by Steven Knight et al.:\n"]
try:
+ import __main__
parts.append(version_string("script", __main__))
- except KeyboardInterrupt:
- raise
- except:
+ except (ImportError, AttributeError):
# On Windows there is no scons.py, so there is no
# __main__.__version__, hence there is no script version.
pass
if s:
exit_status = s
except KeyboardInterrupt:
- print "Build interrupted."
+ print("scons: Build interrupted.")
sys.exit(2)
except SyntaxError, e:
_scons_syntax_error(e)
import SCons.compat
import optparse
+import re
import string
import sys
import textwrap
+try:
+ no_hyphen_re = re.compile(r'(\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')
+except re.error:
+ # Pre-2.0 Python versions don't have the (?<= negative
+ # look-behind assertion.
+ no_hyphen_re = re.compile(r'(\s+|-*\w{2,}-(?=\w{2,}))')
+
try:
from gettext import gettext
except ImportError:
def format_option(self, option):
"""
A copy of the normal optparse.IndentedHelpFormatter.format_option()
- method, snarfed so we can set the subsequent_indent on the
- textwrap.wrap() call below...
+ method. This has been snarfed so we can modify text wrapping to
+ out liking:
+
+ -- add our own regular expression that doesn't break on hyphens
+ (so things like --no-print-directory don't get broken);
+
+ -- wrap the list of options themselves when it's too long
+ (the wrapper.fill(opts) call below);
+
+ -- set the subsequent_indent when wrapping the help_text.
"""
# The help for each option consists of two parts:
# * the opt strings and metavars
opt_width = self.help_position - self.current_indent - 2
if len(opts) > opt_width:
- opts = "%*s%s\n" % (self.current_indent, "", opts)
+ wrapper = textwrap.TextWrapper(width=self.width,
+ initial_indent = ' ',
+ subsequent_indent = ' ')
+ wrapper.wordsep_re = no_hyphen_re
+ opts = wrapper.fill(opts) + '\n'
indent_first = self.help_position
else: # start help on same line as opts
opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts)
help_text = expand_default(option)
# SCons: indent every line of the help text but the first.
- help_lines = textwrap.wrap(help_text, self.help_width,
- subsequent_indent = ' ')
+ wrapper = textwrap.TextWrapper(width=self.help_width,
+ subsequent_indent = ' ')
+ wrapper.wordsep_re = no_hyphen_re
+ help_lines = wrapper.wrap(help_text)
result.append("%*s%s\n" % (indent_first, "", help_lines[0]))
for line in help_lines[1:]:
result.append("%*s%s\n" % (self.help_position, "", line))
# options ignored for compatibility
def opt_ignore(option, opt, value, parser):
sys.stderr.write("Warning: ignoring %s option\n" % opt)
- op.add_option("-b", "-m", "-S", "-t",
- "--no-keep-going", "--stop", "--touch",
+ op.add_option("-b", "-d", "-e", "-m", "-S", "-t", "-w",
+ "--environment-overrides",
+ "--no-keep-going",
+ "--no-print-directory",
+ "--print-directory",
+ "--stop",
+ "--touch",
action="callback", callback=opt_ignore,
help="Ignored for compatibility.")
help = opt_config_help,
metavar="MODE")
- def opt_not_yet(option, opt, value, parser):
- sys.stderr.write("Warning: the %s option is not yet implemented\n" % opt)
- sys.exit(0)
- op.add_option('-d',
- action="callback", callback=opt_not_yet,
- help = "Print file dependency information.")
-
op.add_option('-D',
dest="climb_up", default=None,
action="store_const", const=2,
# we don't want to change. These all get a "the -X option is not
# yet implemented" message and don't show up in the help output.
- op.add_option('-e', '--environment-overrides',
- dest="environment_overrides",
- action="callback", callback=opt_not_yet,
- # help="Environment variables override makefiles."
- help=SUPPRESS_HELP)
+ def opt_not_yet(option, opt, value, parser):
+ msg = "Warning: the %s option is not yet implemented\n" % opt
+ sys.stderr.write(msg)
+ sys.exit(0)
+
+
op.add_option('-l', '--load-average', '--max-load',
nargs=1, type="int",
dest="load_average", default=0,
dest="no_builtin_rules",
# help="Clear default environments and variables."
help=SUPPRESS_HELP)
- op.add_option('-w', '--print-directory',
- action="callback", callback=opt_not_yet,
- dest="print_directory",
- # help="Print the current directory."
- help=SUPPRESS_HELP)
- op.add_option('--no-print-directory',
- action="callback", callback=opt_not_yet,
- dest="no_print_directory",
- # help="Turn off -w, even if it was turned on implicitly."
- help=SUPPRESS_HELP)
op.add_option('--write-filenames',
nargs=1, type="string",
dest="write_filenames",
import SCons.Node
import SCons.Node.Alias
import SCons.Node.FS
-import SCons.Options
import SCons.Platform
import SCons.SConf
import SCons.Script.Main
def Return(*vars, **kw):
retval = []
try:
- for var in vars:
+ fvars = SCons.Util.flatten(vars)
+ for var in fvars:
for v in string.split(var):
retval.append(call_stack[-1].globals[v])
except KeyError, x:
import SCons.Subst
import SCons.Tool
import SCons.Util
+import SCons.Variables
import SCons.Defaults
import Main
Action = SCons.Action.Action
AddMethod = SCons.Util.AddMethod
AllowSubstExceptions = SCons.Subst.SetAllowableExceptions
-BoolOption = SCons.Options.BoolOption
Builder = SCons.Builder.Builder
Configure = _SConscript.Configure
-EnumOption = SCons.Options.EnumOption
Environment = SCons.Environment.Environment
#OptParser = SCons.SConsOptions.OptParser
FindPathDirs = SCons.Scanner.FindPathDirs
-ListOption = SCons.Options.ListOption
-PackageOption = SCons.Options.PackageOption
-PathOption = SCons.Options.PathOption
Platform = SCons.Platform.Platform
Return = _SConscript.Return
Scanner = SCons.Scanner.Base
Tool = SCons.Tool.Tool
WhereIs = SCons.Util.WhereIs
+#
+BoolVariable = SCons.Variables.BoolVariable
+EnumVariable = SCons.Variables.EnumVariable
+ListVariable = SCons.Variables.ListVariable
+PackageVariable = SCons.Variables.PackageVariable
+PathVariable = SCons.Variables.PathVariable
+
+# Deprecated names that will go away some day.
+BoolOption = SCons.Options.BoolOption
+EnumOption = SCons.Options.EnumOption
+ListOption = SCons.Options.ListOption
+PackageOption = SCons.Options.PackageOption
+PathOption = SCons.Options.PathOption
+
# Action factories.
Chmod = SCons.Defaults.Chmod
Copy = SCons.Defaults.Copy
sconscript_reading = 0
#
+def Variables(files=[], args=ARGUMENTS):
+ return SCons.Variables.Variables(files, args)
+
def Options(files=[], args=ARGUMENTS):
return SCons.Options.Options(files, args)
# except KeyError:
# Subst_List_Strings[strSubst] = 1
# import SCons.Debug
-# SCons.Debug.caller(1)
+# SCons.Debug.caller_trace(1)
class ListSubber(UserList.UserList):
"""A class to construct the results of a scons_subst_list() call.
import SCons.compat
+from itertools import chain
import operator
import string
import sys
import traceback
-import SCons.Node
import SCons.Errors
+import SCons.Node
StateString = SCons.Node.StateString
-
+NODE_NO_STATE = SCons.Node.no_state
+NODE_PENDING = SCons.Node.pending
+NODE_EXECUTING = SCons.Node.executing
+NODE_UP_TO_DATE = SCons.Node.up_to_date
+NODE_EXECUTED = SCons.Node.executed
+NODE_FAILED = SCons.Node.failed
# A subsystem for recording stats about how different Nodes are handled by
self.display(self.tm.message)
self.tm.message = None
+ # Let the targets take care of any necessary preparations.
+ # This includes verifying that all of the necessary sources
+ # and dependencies exist, removing the target file(s), etc.
+ #
+ # As of April 2008, the get_executor().prepare() method makes
+ # sure that all of the aggregate sources necessary to build this
+ # Task's target(s) exist in one up-front check. The individual
+ # target t.prepare() methods check that each target's explicit
+ # or implicit dependencies exists, and also initialize the
+ # .sconsign info.
+ self.targets[0].get_executor().prepare()
for t in self.targets:
t.prepare()
for s in t.side_effects:
"""
return self.node
+ def needs_execute(self):
+ """
+ Called to determine whether the task's execute() method should
+ be run.
+
+ This method allows one to skip the somethat costly execution
+ of the execute() method in a seperate thread. For example,
+ that would be unnecessary for up-to-date targets.
+ """
+ return True
+
def execute(self):
"""
Called to execute the task.
break
if not everything_was_cached:
self.targets[0].build()
- except KeyboardInterrupt:
- raise
except SystemExit:
exc_value = sys.exc_info()[1]
raise SCons.Errors.ExplicitExit(self.targets[0], exc_value.code)
the Node's callback methods.
"""
for t in self.targets:
- if t.get_state() == SCons.Node.executing:
+ if t.get_state() == NODE_EXECUTING:
for side_effect in t.side_effects:
- side_effect.set_state(SCons.Node.no_state)
- t.set_state(SCons.Node.executed)
+ side_effect.set_state(NODE_NO_STATE)
+ t.set_state(NODE_EXECUTED)
def executed_with_callbacks(self):
"""
or not the target was an actual built target or a source Node.
"""
for t in self.targets:
- if t.get_state() == SCons.Node.executing:
+ if t.get_state() == NODE_EXECUTING:
for side_effect in t.side_effects:
- side_effect.set_state(SCons.Node.no_state)
- t.set_state(SCons.Node.executed)
+ side_effect.set_state(NODE_NO_STATE)
+ t.set_state(NODE_EXECUTED)
t.built()
t.visited()
"""
Explicit stop-the-build failure.
"""
- for t in self.targets:
- t.set_state(SCons.Node.failed)
+
+ # Invoke fail_continue() to clean-up the pending children
+ # list.
+ self.fail_continue()
+
+ # Tell the taskmaster to not start any new tasks
self.tm.stop()
# We're stopping because of a build failure, but give the
This sets failure status on the target nodes and all of
their dependent parent nodes.
"""
+
+ pending_children = self.tm.pending_children
+
+ to_visit = set()
for t in self.targets:
# Set failure state on all of the parents that were dependent
# on this failed build.
- def set_state(node): node.set_state(SCons.Node.failed)
- t.call_for_all_waiting_parents(set_state)
+ if t.state != NODE_FAILED:
+ t.state = NODE_FAILED
+ parents = t.waiting_parents
+ to_visit = to_visit | parents
+ pending_children = pending_children - parents
+
+ try:
+ while 1:
+ try:
+ node = to_visit.pop()
+ except AttributeError:
+ # Python 1.5.2
+ if len(to_visit):
+ node = to_visit[0]
+ to_visit.remove(node)
+ else:
+ break
+ if node.state != NODE_FAILED:
+ node.state = NODE_FAILED
+ parents = node.waiting_parents
+ to_visit = to_visit | parents
+ pending_children = pending_children - parents
+ except KeyError:
+ # The container to_visit has been emptied.
+ pass
+
+ # We have the stick back the pending_children list into the
+ # task master because the python 1.5.2 compatibility does not
+ # allow us to use in-place updates
+ self.tm.pending_children = pending_children
def make_ready_all(self):
"""
"""
self.out_of_date = self.targets[:]
for t in self.targets:
- t.disambiguate().set_state(SCons.Node.executing)
+ t.disambiguate().set_state(NODE_EXECUTING)
for s in t.side_effects:
- s.set_state(SCons.Node.executing)
+ s.set_state(NODE_EXECUTING)
def make_ready_current(self):
"""
This is the default behavior for building only what's necessary.
"""
self.out_of_date = []
+ needs_executing = False
for t in self.targets:
try:
t.disambiguate().make_ready()
(not t.always_build and t.is_up_to_date())
except EnvironmentError, e:
raise SCons.Errors.BuildError(node=t, errstr=e.strerror, filename=e.filename)
- if is_up_to_date:
- t.set_state(SCons.Node.up_to_date)
- else:
+
+ if not is_up_to_date:
self.out_of_date.append(t)
- t.set_state(SCons.Node.executing)
+ needs_executing = True
+
+ if needs_executing:
+ for t in self.targets:
+ t.set_state(NODE_EXECUTING)
for s in t.side_effects:
- s.set_state(SCons.Node.executing)
+ s.set_state(NODE_EXECUTING)
+ else:
+ for t in self.targets:
+ # We must invoke visited() to ensure that the node
+ # information has been computed before allowing the
+ # parent nodes to execute. (That could occur in a
+ # parallel build...)
+ t.visited()
+ t.set_state(NODE_UP_TO_DATE)
make_ready = make_ready_current
parents = {}
for t in targets:
- for p in t.waiting_parents.keys():
+ for p in t.waiting_parents:
parents[p] = parents.get(p, 0) + 1
for t in targets:
for s in t.side_effects:
- if s.get_state() == SCons.Node.executing:
- s.set_state(SCons.Node.no_state)
- for p in s.waiting_parents.keys():
- if not parents.has_key(p):
- parents[p] = 1
- for p in s.waiting_s_e.keys():
+ if s.get_state() == NODE_EXECUTING:
+ s.set_state(NODE_NO_STATE)
+ for p in s.waiting_parents:
+ parents[p] = parents.get(p, 0) + 1
+ for p in s.waiting_s_e:
if p.ref_count == 0:
self.tm.candidates.append(p)
+ self.tm.pending_children.discard(p)
for p, subtract in parents.items():
p.ref_count = p.ref_count - subtract
if p.ref_count == 0:
self.tm.candidates.append(p)
+ self.tm.pending_children.discard(p)
for t in targets:
t.postprocess()
raise exc_type, exc_value, exc_traceback
-def find_cycle(stack):
- if stack[0] == stack[-1]:
- return stack
- for n in stack[-1].waiting_parents.keys():
+def find_cycle(stack, visited):
+ if stack[-1] in visited:
+ return None
+ visited.add(stack[-1])
+ for n in stack[-1].waiting_parents:
stack.append(n)
- if find_cycle(stack):
+ if stack[0] == stack[-1]:
+ return stack
+ if find_cycle(stack, visited):
return stack
stack.pop()
return None
self.message = None
self.trace = trace
self.next_candidate = self.find_next_candidate
+ self.pending_children = set()
+
def find_next_candidate(self):
"""
self.ready_exc = None
T = self.trace
+ if T: T.write('\nTaskmaster: Looking for a node to evaluate\n')
while 1:
node = self.next_candidate()
if node is None:
+ if T: T.write('Taskmaster: No candidate anymore.\n\n')
return None
node = node.disambiguate()
S.considered = S.considered + 1
else:
S = None
-
- if T: T.write('Taskmaster: %s:' % repr(str(node)))
-
- # Skip this node if it has already been evaluated:
- if state > SCons.Node.pending:
+
+ if T: T.write('Taskmaster: Considering node <%-10s %s> and its children:\n' %
+ (StateString[node.get_state()], repr(str(node))))
+
+ if state == NODE_NO_STATE:
+ # Mark this node as being on the execution stack:
+ node.set_state(NODE_PENDING)
+ elif state > NODE_PENDING:
+ # Skip this node if it has already been evaluated:
if S: S.already_handled = S.already_handled + 1
- if T: T.write(' already handled (%s)\n' % StateString[state])
+ if T: T.write('Taskmaster: already handled (executed)\n')
continue
- # Mark this node as being on the execution stack:
- node.set_state(SCons.Node.pending)
-
try:
- children = node.children() + node.prerequisites
+ children = node.children()
except SystemExit:
exc_value = sys.exc_info()[1]
e = SCons.Errors.ExplicitExit(node, exc_value.code)
self.ready_exc = (SCons.Errors.ExplicitExit, e)
- if T: T.write(' SystemExit\n')
+ if T: T.write('Taskmaster: SystemExit\n')
return node
- except KeyboardInterrupt:
- if T: T.write(' KeyboardInterrupt\n')
- raise
except:
# We had a problem just trying to figure out the
# children (like a child couldn't be linked in to a
# raise the exception when the Task is "executed."
self.ready_exc = sys.exc_info()
if S: S.problem = S.problem + 1
- if T: T.write(' exception\n')
+ if T: T.write('Taskmaster: exception while scanning children.\n')
return node
- if T and children:
- c = map(str, children)
- c.sort()
- T.write(' children:\n %s\n ' % c)
-
- childstate = map(lambda N: (N, N.get_state()), children)
-
- # Detect dependency cycles:
- pending_nodes = filter(lambda I: I[1] == SCons.Node.pending, childstate)
- if pending_nodes:
- for p in pending_nodes:
- cycle = find_cycle([p[0], node])
- if cycle:
- desc = "Dependency cycle: " + string.join(map(str, cycle), " -> ")
- if T: T.write(' dependency cycle\n')
- raise SCons.Errors.UserError, desc
-
- not_built = filter(lambda I: I[1] <= SCons.Node.executing, childstate)
- if not_built:
- # We're waiting on one or more derived targets that have
- # not yet finished building.
-
- not_visited = filter(lambda I: not I[1], not_built)
- if not_visited:
- # Some of them haven't even been visited yet.
- # Add them to the list so that on some next pass
- # we can take a stab at evaluating them (or
- # their children).
- not_visited = map(lambda I: I[0], not_visited)
- not_visited.reverse()
- self.candidates.extend(self.order(not_visited))
-
- n_b_nodes = map(lambda I: I[0], not_built)
-
- # Add this node to the waiting parents lists of anything
- # we're waiting on, with a reference count so we can be
- # put back on the list for re-evaluation when they've
- # all finished.
- map(lambda n, P=node: n.add_to_waiting_parents(P), n_b_nodes)
- node.ref_count = len(set(n_b_nodes))
-
- if S: S.not_built = S.not_built + 1
- if T:
- c = map(str, n_b_nodes)
- c.sort()
- T.write(' waiting on unfinished children:\n %s\n' % c)
- continue
+ children_not_visited = []
+ children_pending = set()
+ children_not_ready = []
+ children_failed = False
- # Skip this node if it has side-effects that are
- # currently being built:
- side_effects = filter(lambda N:
- N.get_state() == SCons.Node.executing,
- node.side_effects)
- if side_effects:
- map(lambda n, P=node: n.add_to_waiting_s_e(P), side_effects)
- if S: S.side_effects = S.side_effects + 1
- if T:
- c = map(str, side_effects)
- c.sort()
- T.write(' waiting on side effects:\n %s\n' % c)
- continue
+ for child in chain(children,node.prerequisites):
+ childstate = child.get_state()
+
+ if T: T.write('Taskmaster: <%-10s %s>\n' %
+ (StateString[childstate], repr(str(child))))
+
+ if childstate == NODE_NO_STATE:
+ children_not_visited.append(child)
+ elif childstate == NODE_PENDING:
+ children_pending.add(child)
+ elif childstate == NODE_FAILED:
+ children_failed = True
+
+ if childstate <= NODE_EXECUTING:
+ children_not_ready.append(child)
+
+
+ # These nodes have not even been visited yet. Add
+ # them to the list so that on some next pass we can
+ # take a stab at evaluating them (or their children).
+ children_not_visited.reverse()
+ self.candidates.extend(self.order(children_not_visited))
# Skip this node if any of its children have failed.
#
# Note that even if one of the children fails, we still
# added the other children to the list of candidate nodes
# to keep on building (--keep-going).
- failed_children = filter(lambda I: I[1] == SCons.Node.failed,
- childstate)
- if failed_children:
- node.set_state(SCons.Node.failed)
+ if children_failed:
+ node.set_state(NODE_FAILED)
+
if S: S.child_failed = S.child_failed + 1
- if T:
- c = map(lambda I: str(I[0]), failed_children)
- c.sort()
- T.write(' children failed:\n %s\n' % c)
+ if T: T.write('Taskmaster:****** <%-10s %s>\n' %
+ (StateString[node.get_state()], repr(str(node))))
+ continue
+
+ if children_not_ready:
+ for child in children_not_ready:
+ # We're waiting on one or more derived targets
+ # that have not yet finished building.
+ if S: S.not_built = S.not_built + 1
+
+ # Add this node to the waiting parents lists of
+ # anything we're waiting on, with a reference
+ # count so we can be put back on the list for
+ # re-evaluation when they've all finished.
+ node.ref_count = node.ref_count + child.add_to_waiting_parents(node)
+
+ self.pending_children = self.pending_children | children_pending
+
+ continue
+
+ # Skip this node if it has side-effects that are
+ # currently being built:
+ wait_side_effects = False
+ for se in node.side_effects:
+ if se.get_state() == NODE_EXECUTING:
+ se.add_to_waiting_s_e(node)
+ wait_side_effects = True
+
+ if wait_side_effects:
+ if S: S.side_effects = S.side_effects + 1
continue
# The default when we've gotten through all of the checks above:
# this node is ready to be built.
if S: S.build = S.build + 1
- if T: T.write(' evaluating %s\n' % node)
+ if T: T.write('Taskmaster: Evaluating <%-10s %s>\n' %
+ (StateString[node.get_state()], repr(str(node))))
return node
return None
task = self.tasker(self, tlist, node in self.original_top, node)
try:
task.make_ready()
- except KeyboardInterrupt:
- raise
except:
# We had a problem just trying to get this task ready (like
# a child couldn't be linked in to a VariantDir when deciding
Stops the current build completely.
"""
self.next_candidate = self.no_next_candidate
+
+ def cleanup(self):
+ """
+ Check for dependency cycles.
+ """
+ if self.pending_children:
+ desc = 'Found dependency cycle(s):\n'
+ for node in self.pending_children:
+ cycle = find_cycle([node], set())
+ if cycle:
+ desc = desc + " " + string.join(map(str, cycle), " -> ") + "\n"
+ else:
+ desc = desc + " Internal Error: no cycle found for node %s (%s)\n" % \
+ (node, repr(node))
+ raise SCons.Errors.UserError, desc
self.state = SCons.Node.no_state
self.prepared = None
self.ref_count = 0
- self.waiting_parents = {}
- self.waiting_s_e = {}
+ self.waiting_parents = set()
+ self.waiting_s_e = set()
self.side_effect = 0
self.side_effects = []
self.alttargets = []
def add_to_waiting_parents(self, node):
wp = self.waiting_parents
- if wp.has_key(node):
- result = 0
- else:
- result = 1
- wp[node] = 1
- return result
-
- def call_for_all_waiting_parents(self, func):
- func(self)
- for parent in self.waiting_parents.keys():
- parent.call_for_all_waiting_parents(func)
+ if node in wp:
+ return 0
+ wp.add(node)
+ return 1
def get_state(self):
return self.state
def postprocess(self):
self.postprocessed = 1
+ self.waiting_parents = set()
def get_executor(self):
- class Executor:
- pass
- e = Executor()
- e.targets = self.targets
- return e
+ if not hasattr(self, 'executor'):
+ class Executor:
+ def prepare(self):
+ pass
+ self.executor = Executor()
+ self.executor.targets = self.targets
+ return self.executor
class OtherError(Exception):
pass
t.postprocess()
s = n1.get_state()
- assert s == SCons.Node.up_to_date, s
+ assert s == SCons.Node.executed, s
s = n2.get_state()
assert s == SCons.Node.executed, s
assert n9.prepared
assert n10.prepared
+ # Make sure we call an Executor's prepare() method.
+ class ExceptionExecutor:
+ def prepare(self):
+ raise Exception, "Executor.prepare() exception"
+
+ n11 = Node("n11")
+ n11.executor = ExceptionExecutor()
+ tm = SCons.Taskmaster.Taskmaster([n11])
+ t = tm.next_task()
+ try:
+ t.prepare()
+ except Exception, e:
+ assert str(e) == "Executor.prepare() exception", e
+ else:
+ raise AssertionError, "did not catch expected exception"
+
def test_execute(self):
"""Test executing a task
"""
]
assert str(exc_value) in exception_values, exc_value
- t.exception_set(("exception 1", None))
+ class Exception1(Exception):
+ pass
+
+ t.exception_set((Exception1, None))
try:
t.exception_raise()
except:
exc_type, exc_value = sys.exc_info()[:2]
- assert exc_type == "exception 1", exc_type
- assert exc_value is None, exc_value
+ assert exc_type == Exception1, exc_type
+ assert str(exc_value) == '', exc_value
else:
assert 0, "did not catch expected exception"
- t.exception_set(("exception 2", "xyzzy"))
+ class Exception2(Exception):
+ pass
+
+ t.exception_set((Exception2, "xyzzy"))
try:
t.exception_raise()
except:
exc_type, exc_value = sys.exc_info()[:2]
- assert exc_type == "exception 2", exc_type
- assert exc_value == "xyzzy", exc_value
+ assert exc_type == Exception2, exc_type
+ assert str(exc_value) == "xyzzy", exc_value
else:
assert 0, "did not catch expected exception"
+ class Exception3(Exception):
+ pass
+
try:
1/0
except:
tb = sys.exc_info()[2]
- t.exception_set(("exception 3", "arg", tb))
+ t.exception_set((Exception3, "arg", tb))
try:
t.exception_raise()
except:
exc_type, exc_value, exc_tb = sys.exc_info()
- assert exc_type == 'exception 3', exc_type
- assert exc_value == "arg", exc_value
+ assert exc_type == Exception3, exc_type
+ assert str(exc_value) == "arg", exc_value
import traceback
x = traceback.extract_tb(tb)[-1]
y = traceback.extract_tb(exc_tb)[-1]
value = trace.getvalue()
expect = """\
-Taskmaster: 'n1': evaluating n1
-Taskmaster: 'n1': already handled (executed)
-Taskmaster: 'n3': children:
- ['n1', 'n2']
- waiting on unfinished children:
- ['n2']
-Taskmaster: 'n2': evaluating n2
-Taskmaster: 'n3': children:
- ['n1', 'n2']
- evaluating n3
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'n1'> and its children:
+Taskmaster: Evaluating <pending 'n1'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <executed 'n1'> and its children:
+Taskmaster: already handled (executed)
+Taskmaster: Considering node <no_state 'n3'> and its children:
+Taskmaster: <executed 'n1'>
+Taskmaster: <no_state 'n2'>
+Taskmaster: Considering node <no_state 'n2'> and its children:
+Taskmaster: Evaluating <pending 'n2'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <pending 'n3'> and its children:
+Taskmaster: <executed 'n1'>
+Taskmaster: <executed 'n2'>
+Taskmaster: Evaluating <pending 'n3'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: No candidate anymore.
+
"""
assert value == expect, value
t = SCons.Tool.Tool('g++')
t(env)
assert (env['CXX'] == 'c++' or env['CXX'] == 'g++'), env['CXX']
- assert env['CXXFLAGS'] == ['$CCFLAGS'], env['CXXFLAGS']
assert env['INCPREFIX'] == '-I', env['INCPREFIX']
assert env['TOOLS'] == ['g++'], env['TOOLS']
kw = self.init_kw
env.Append(TOOLS = [ self.name ])
if hasattr(self, 'options'):
- from SCons.Options import Options
+ import SCons.Variables
if not env.has_key('options'):
from SCons.Script import ARGUMENTS
- env['options']=Options(args=ARGUMENTS)
+ env['options']=SCons.Variables.Variables(args=ARGUMENTS)
opts=env['options']
self.options(opts)
shared_obj.add_emitter(suffix, SCons.Defaults.SharedObjectEmitter)
SCons.Tool.cc.add_common_cc_variables(env)
-
+
env['CXX'] = 'c++'
- env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
- env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $_CCCOMCOM $SOURCES'
+ env['CXXFLAGS'] = SCons.Util.CLVar('')
+ env['CXXCOM'] = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
env['SHCXX'] = '$CXX'
- env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
- env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $_CCCOMCOM $SOURCES'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('')
+ env['SHCXXCOM'] = '$SHCXX -o $TARGET -c $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM $SOURCES'
env['CPPDEFPREFIX'] = '-D'
env['CPPDEFSUFFIX'] = ''
blah.lib from the directory where SConstruct resides.
Compiler variables:
- DC - The name of the D compiler to use. Defaults to dmd.
+ DC - The name of the D compiler to use. Defaults to dmd or gdmd,
+ whichever is found.
DPATH - List of paths to search for import modules.
DVERSIONS - List of version tags to enable when compiling.
DDEBUG - List of debug tags to enable when compiling.
Linker related variables:
LIBS - List of library files to link in.
- DLINK - Name of the linker to use. Defaults to dmd.
+ DLINK - Name of the linker to use. Defaults to dmd or gdmd.
DLINKFLAGS - List of linker flags.
Lib tool variables:
static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
- env['DC'] = 'dmd'
+ dc = env.Detect(['dmd', 'gdmd'])
+ env['DC'] = dc
env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -of$TARGET $SOURCES'
env['_DINCFLAGS'] = '$( ${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
env['_DVERFLAGS'] = '$( ${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)} $)'
env['DVERSIONS'] = []
env['DDEBUG'] = []
- # Add the path to the standard library.
- # This is merely for the convenience of the dependency scanner.
- dmd_path = env.WhereIs('dmd')
- if dmd_path:
- x = string.rindex(dmd_path, 'dmd')
- phobosDir = dmd_path[:x] + '/../src/phobos'
- if os.path.isdir(phobosDir):
- env.Append(DPATH = [phobosDir])
+ if dc:
+ # Add the path to the standard library.
+ # This is merely for the convenience of the dependency scanner.
+ dmd_path = env.WhereIs(dc)
+ if dmd_path:
+ x = string.rindex(dmd_path, dc)
+ phobosDir = dmd_path[:x] + '/../src/phobos'
+ if os.path.isdir(phobosDir):
+ env.Append(DPATH = [phobosDir])
env['DINCPREFIX'] = '-I'
env['DINCSUFFIX'] = ''
except KeyError:
libs = []
if 'phobos' not in libs:
- env.Append(LIBS = ['phobos'])
+ if dc is 'dmd':
+ env.Append(LIBS = ['phobos'])
+ elif dc is 'gdmd':
+ env.Append(LIBS = ['gphobos'])
if 'pthread' not in libs:
env.Append(LIBS = ['pthread'])
if 'm' not in libs:
env['LINKCOM'] = '$SMART_LINKCOM '
def exists(env):
- return env.Detect('dmd')
+ return env.Detect(['dmd', 'gdmd'])
-->
<tool name="dmd">
<summary>
-Sets construction variables for the Digital Mars D compiler.
+Sets construction variables for D language compilers
+(the Digital Mars D compiler, or GDC).
</summary>
<sets>
<!--
env['SHOBJSUFFIX'] = '$OBJSUFFIX'
elif env['PLATFORM'] == 'hpux':
# Original line from Christian Engel added -DPIC:
- #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
- env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -DPIC')
env['SHOBJSUFFIX'] = '.pic.o'
elif env['PLATFORM'] == 'sunos':
# Original line from Christian Engel added -DPIC:
- #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
- env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -DPIC')
env['SHOBJSUFFIX'] = '.pic.o'
else:
# Original line from Christian Engel added -DPIC:
- #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC -DPIC')
- env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -fPIC')
+ #env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -DPIC')
+ pass
# determine compiler version
if env['CXX']:
line = os.popen(env['CXX'] + ' --version').readline()
'LIB' : 'lib',
'PATH' : 'bin',
'LD_LIBRARY_PATH' : 'lib'}
- for p in paths:
+ for p in paths.keys():
env.PrependENVPath(p, os.path.join(topdir, paths[p]))
if is_mac:
paths={'INCLUDE' : 'include',
'LIB' : 'lib',
'PATH' : 'bin',
'LD_LIBRARY_PATH' : 'lib'}
- for p in paths:
+ for p in paths.keys():
env.PrependENVPath(p, os.path.join(topdir, paths[p]))
if is_windows:
# env key reg valname default subdir of top
if version is None:
version = ''
# Each path has a registry entry, use that or default to subdir
- for p in paths:
+ for p in paths.keys():
try:
path=get_intel_registry_value(p[1], version, abi)
# These paths may have $(ICInstallDir)
raise SCons.Errors.UserError("Java source must be File or Dir, not '%s'" % entry.__class__)
version = env.get('JAVAVERSION', '1.4')
- tlist = []
+ full_tlist = []
for f in slist:
+ tlist = []
source_file_based = True
pkg_dir = None
if not f.is_derived():
t.attributes.java_classname = classname(base)
tlist.append(t)
- return tlist, slist
+ for t in tlist:
+ t.set_specific_source([f])
+
+ full_tlist.extend(tlist)
+
+ return full_tlist, slist
JavaAction = SCons.Action.Action('$JAVACCOM', '$JAVACCOMSTR')
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
env['SHLINKCOM'] = shlib_action
+ env['LDMODULECOM'] = shlib_action
env.Append(SHLIBEMITTER = [shlib_emitter])
env['AS'] = 'as'
SHCXXFLAGS
SHLINKFLAGS
SHLINKCOM
+LDMODULECOM
AS
WINDOWSDEFPREFIX
WINDOWSDEFSUFFIX
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Environment
-from SCons.Options import *
+from SCons.Variables import *
from SCons.Errors import *
from SCons.Util import is_List, make_path_relative
from SCons.Warnings import warn, Warning
# XXX
def options(opts):
- opts.AddOptions(
- EnumOption( 'PACKAGETYPE',
- 'the type of package to create.',
- None, allowed_values=map( str, __all__ ),
- ignorecase=2
+ opts.AddVariables(
+ EnumVariable( 'PACKAGETYPE',
+ 'the type of package to create.',
+ None, allowed_values=map( str, __all__ ),
+ ignorecase=2
)
)
if "-python" in flags and "-noproxy" not in flags:
if mnames is None:
mnames = _reModule.findall(open(src).read())
- target.extend(map(lambda m: m + ".py", mnames))
+ target.extend(map(lambda m, d=target[0].dir:
+ d.File(m + ".py"), mnames))
if "-java" in flags:
if mnames is None:
mnames = _reModule.findall(open(src).read())
path = string.upper(drive) + rest
return path
-#
-# Generic convert-to-string functions that abstract away whether or
-# not the Python we're executing has Unicode support. The wrapper
-# to_String_for_signature() will use a for_signature() method if the
-# specified object has one.
-#
-if hasattr(types, 'UnicodeType'):
- UnicodeType = types.UnicodeType
- def to_String(s):
- if isinstance(s, UserString):
- t = type(s.data)
- else:
- t = type(s)
- if t is UnicodeType:
- return unicode(s)
- else:
- return str(s)
-else:
- to_String = str
-
-def to_String_for_signature(obj):
- try:
- f = obj.for_signature
- except AttributeError:
- return to_String_for_subst(obj)
- else:
- return f()
-
-def to_String_for_subst(s):
- if is_Sequence( s ):
- return string.join( map(to_String_for_subst, s) )
-
- return to_String( s )
-
-
class CallableComposite(UserList):
"""A simple composite callable class that, when called, will invoke all
of its contained callables with the same arguments."""
def print_it(self, text, append_newline=1):
if append_newline: text = text + '\n'
- sys.stdout.write(text)
+ try:
+ sys.stdout.write(text)
+ except IOError:
+ # Stdout might be connected to a pipe that has been closed
+ # by now. The most likely reason for the pipe being closed
+ # is that the user has press ctrl-c. It this is the case,
+ # then SCons is currently shutdown. We therefore ignore
+ # IOError's here so that SCons can continue and shutdown
+ # properly so that the .sconsign is correctly written
+ # before SCons exits.
+ pass
def dont_print(self, text, append_newline=1):
pass
else:
flatten_sequence(item, result)
return result
+
+ #
+ # Generic convert-to-string functions that abstract away whether or
+ # not the Python we're executing has Unicode support. The wrapper
+ # to_String_for_signature() will use a for_signature() method if the
+ # specified object has one.
+ #
+ if hasattr(types, 'UnicodeType'):
+ UnicodeType = types.UnicodeType
+ def to_String(s):
+ if isinstance(s, UserString):
+ t = type(s.data)
+ else:
+ t = type(s)
+ if t is UnicodeType:
+ return unicode(s)
+ else:
+ return str(s)
+ else:
+ to_String = str
+
+ def to_String_for_signature(obj):
+ try:
+ f = obj.for_signature
+ except AttributeError:
+ return to_String_for_subst(obj)
+ else:
+ return f()
+
+ def to_String_for_subst(s):
+ if is_Sequence( s ):
+ return string.join( map(to_String_for_subst, s) )
+
+ return to_String( s )
+
else:
# A modern Python version with new-style classes, so we can just use
# isinstance().
# with basestring. (at least on Python 2.5.1)
StringTypes = (str, unicode, UserString)
+ # Empirically, it is faster to check explicitely for str and
+ # unicode than for basestring.
+ BaseStringTypes = (str, unicode)
+
def is_Dict(obj, isinstance=isinstance, DictTypes=DictTypes):
return isinstance(obj, DictTypes)
return result
+ #
+ # Generic convert-to-string functions that abstract away whether or
+ # not the Python we're executing has Unicode support. The wrapper
+ # to_String_for_signature() will use a for_signature() method if the
+ # specified object has one.
+ #
+ def to_String(s,
+ isinstance=isinstance, str=str,
+ UserString=UserString, BaseStringTypes=BaseStringTypes):
+ if isinstance(s,BaseStringTypes):
+ # Early out when already a string!
+ return s
+ elif isinstance(s, UserString):
+ # s.data can only be either a unicode or a regular
+ # string. Please see the UserString initializer.
+ return s.data
+ else:
+ return str(s)
+
+ def to_String_for_subst(s,
+ isinstance=isinstance, join=string.join, str=str, to_String=to_String,
+ BaseStringTypes=BaseStringTypes, SequenceTypes=SequenceTypes,
+ UserString=UserString):
+
+ # Note that the test cases are sorted by order of probability.
+ if isinstance(s, BaseStringTypes):
+ return s
+ elif isinstance(s, SequenceTypes):
+ l = []
+ for e in s:
+ l.append(to_String_for_subst(e))
+ return join( s )
+ elif isinstance(s, UserString):
+ # s.data can only be either a unicode or a regular
+ # string. Please see the UserString initializer.
+ return s.data
+ else:
+ return str(s)
+
+ def to_String_for_signature(obj, to_String_for_subst=to_String_for_subst,
+ AttributeError=AttributeError):
+ try:
+ f = obj.for_signature
+ except AttributeError:
+ return to_String_for_subst(obj)
+ else:
+ return f()
+
+
+
# The SCons "semi-deep" copy.
#
# This makes separate copies of lists (including UserList objects)
def __init__(self, file):
self.file = file
def write(self, arg):
- self.file.write(arg)
- self.file.flush()
+ try:
+ self.file.write(arg)
+ self.file.flush()
+ except IOError:
+ # Stdout might be connected to a pipe that has been closed
+ # by now. The most likely reason for the pipe being closed
+ # is that the user has press ctrl-c. It this is the case,
+ # then SCons is currently shutdown. We therefore ignore
+ # IOError's here so that SCons can continue and shutdown
+ # properly so that the .sconsign is correctly written
+ # before SCons exits.
+ pass
def __getattr__(self, attr):
return getattr(self.file, attr)
-"""engine.SCons.Options.BoolOption
+"""engine.SCons.Variables.BoolVariable
This file defines the option type for SCons implementing true/false values.
Usage example:
- opts = Options()
- opts.Add(BoolOption('embedded', 'build for an embedded system', 0))
+ opts = Variables()
+ opts.Add(BoolVariable('embedded', 'build for an embedded system', 0))
...
if env['embedded'] == 1:
...
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-__all__ = ('BoolOption')
+__all__ = ['BoolVariable',]
import string
See '__true_strings' and '__false_strings' for values considered
'true' or 'false respectivly.
- This is usable as 'converter' for SCons' Options.
+ This is usable as 'converter' for SCons' Variables.
"""
lval = string.lower(val)
if lval in __true_strings: return True
"""
Validates the given value to be either '0' or '1'.
- This is usable as 'validator' for SCons' Options.
+ This is usable as 'validator' for SCons' Variables.
"""
if not env[key] in (True, False):
raise SCons.Errors.UserError(
'Invalid value for boolean option %s: %s' % (key, env[key]))
-def BoolOption(key, help, default):
+def BoolVariable(key, help, default):
"""
The input parameters describe a boolen option, thus they are
returned with the correct converter and validator appended. The
import unittest
import SCons.Errors
-import SCons.Options
+import SCons.Variables
-class BoolOptionTestCase(unittest.TestCase):
- def test_BoolOption(self):
- """Test BoolOption creation"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.BoolOption('test', 'test option help', 0))
+class BoolVariableTestCase(unittest.TestCase):
+ def test_BoolVariable(self):
+ """Test BoolVariable creation"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.BoolVariable('test', 'test option help', 0))
o = opts.options[0]
assert o.key == 'test', o.key
assert not o.converter is None, o.converter
def test_converter(self):
- """Test the BoolOption converter"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.BoolOption('test', 'test option help', 0))
+ """Test the BoolVariable converter"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.BoolVariable('test', 'test option help', 0))
o = opts.options[0]
assert caught, "did not catch expected ValueError"
def test_validator(self):
- """Test the BoolOption validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.BoolOption('test', 'test option help', 0))
+ """Test the BoolVariable validator"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.BoolVariable('test', 'test option help', 0))
o = opts.options[0]
if __name__ == "__main__":
- suite = unittest.makeSuite(BoolOptionTestCase, 'test_')
+ suite = unittest.makeSuite(BoolVariableTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
-"""engine.SCons.Options.EnumOption
+"""engine.SCons.Variables.EnumVariable
This file defines the option type for SCons allowing only specified
input-values.
Usage example:
- opts = Options()
- opts.Add(EnumOption('debug', 'debug output and symbols', 'no',
+ opts = Variables()
+ opts.Add(EnumVariable('debug', 'debug output and symbols', 'no',
allowed_values=('yes', 'no', 'full'),
map={}, ignorecase=2))
...
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-__all__ = ('EnumOption',)
+__all__ = ['EnumVariable',]
import string
'Invalid value for option %s: %s' % (key, val))
-def EnumOption(key, help, default, allowed_values, map={}, ignorecase=0):
+def EnumVariable(key, help, default, allowed_values, map={}, ignorecase=0):
"""
The input parameters describe a option with only certain values
allowed. They are returned with an appropriate converter and
validator appended. The result is usable for input to
- Options.Add().
+ Variables.Add().
- 'key' and 'default' are the values to be passed on to Options.Add().
+ 'key' and 'default' are the values to be passed on to Variables.Add().
'help' will be appended by the allowed values automatically
import unittest
import SCons.Errors
-import SCons.Options
+import SCons.Variables
-class EnumOptionTestCase(unittest.TestCase):
- def test_EnumOption(self):
- """Test EnumOption creation"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.EnumOption('test', 'test option help', 0,
+class EnumVariableTestCase(unittest.TestCase):
+ def test_EnumVariable(self):
+ """Test EnumVariable creation"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.EnumVariable('test', 'test option help', 0,
['one', 'two', 'three'],
{}))
assert not o.converter is None, o.converter
def test_converter(self):
- """Test the EnumOption converter"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.EnumOption('test', 'test option help', 0,
+ """Test the EnumVariable converter"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.EnumVariable('test', 'test option help', 0,
['one', 'two', 'three']))
o = opts.options[0]
x = o.converter(a)
assert x == a, x
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.EnumOption('test', 'test option help', 0,
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.EnumVariable('test', 'test option help', 0,
['one', 'two', 'three'],
{'1' : 'one',
'2' : 'two',
x = o.converter('3')
assert x == 'three', x
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.EnumOption('test0', 'test option help', 0,
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.EnumVariable('test0', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
'c' : 'three'},
ignorecase=0))
- opts.Add(SCons.Options.EnumOption('test1', 'test option help', 0,
+ opts.Add(SCons.Variables.EnumVariable('test1', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
'c' : 'three'},
ignorecase=1))
- opts.Add(SCons.Options.EnumOption('test2', 'test option help', 0,
+ opts.Add(SCons.Variables.EnumVariable('test2', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
assert x == l[2], "o2 got %s, expected %s" % (x, l[2])
def test_validator(self):
- """Test the EnumOption validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.EnumOption('test0', 'test option help', 0,
+ """Test the EnumVariable validator"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.EnumVariable('test0', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
'c' : 'three'},
ignorecase=0))
- opts.Add(SCons.Options.EnumOption('test1', 'test option help', 0,
+ opts.Add(SCons.Variables.EnumVariable('test1', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
'c' : 'three'},
ignorecase=1))
- opts.Add(SCons.Options.EnumOption('test2', 'test option help', 0,
+ opts.Add(SCons.Variables.EnumVariable('test2', 'test option help', 0,
['one', 'two', 'three'],
{'a' : 'one',
'b' : 'two',
if __name__ == "__main__":
- suite = unittest.makeSuite(EnumOptionTestCase, 'test_')
+ suite = unittest.makeSuite(EnumVariableTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
-"""engine.SCons.Options.ListOption
+"""engine.SCons.Variables.ListVariable
This file defines the option type for SCons implementing 'lists'.
list_of_libs = Split('x11 gl qt ical')
- opts = Options()
- opts.Add(ListOption('shared',
+ opts = Variables()
+ opts.Add(ListVariable('shared',
'libraries to build as shared libraries',
'all',
elems = list_of_libs))
# Know Bug: This should behave like a Set-Type, but does not really,
# since elements can occur twice.
-__all__ = ('ListOption',)
+__all__ = ['ListVariable',]
import string
import UserList
import SCons.Util
-class _ListOption(UserList.UserList):
+class _ListVariable(UserList.UserList):
def __init__(self, initlist=[], allowedElems=[]):
UserList.UserList.__init__(self, filter(None, initlist))
self.allowedElems = allowedElems[:]
if notAllowed:
raise ValueError("Invalid value(s) for option: %s" %
string.join(notAllowed, ','))
- return _ListOption(val, allowedElems)
+ return _ListVariable(val, allowedElems)
## def _validator(key, val, env):
## return 1
-def ListOption(key, help, default, names, map={}):
+def ListVariable(key, help, default, names, map={}):
"""
The input parameters describe a 'package list' option, thus they
are returned with the correct converter and validater appended. The
import unittest
import SCons.Errors
-import SCons.Options
+import SCons.Variables
-class ListOptionTestCase(unittest.TestCase):
- def test_ListOption(self):
- """Test ListOption creation"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.ListOption('test', 'test option help', 'all',
+class ListVariableTestCase(unittest.TestCase):
+ def test_ListVariable(self):
+ """Test ListVariable creation"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all',
['one', 'two', 'three']))
o = opts.options[0]
assert o.validator is None, o.validator
assert not o.converter is None, o.converter
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.ListOption('test2', 'test2 help',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.ListVariable('test2', 'test2 help',
['one', 'three'],
['one', 'two', 'three']))
assert o.default == 'one,three'
def test_converter(self):
- """Test the ListOption converter"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.ListOption('test', 'test option help', 'all',
+ """Test the ListVariable converter"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all',
['one', 'two', 'three'],
{'ONE':'one', 'TWO':'two'}))
assert caught, "did not catch expected ValueError"
def test_copy(self):
- """Test copying a ListOption like an Environment would"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.ListOption('test', 'test option help', 'all',
+ """Test copying a ListVariable like an Environment would"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.ListVariable('test', 'test option help', 'all',
['one', 'two', 'three']))
o = opts.options[0]
n = l.__class__(copy.copy(l))
if __name__ == "__main__":
- suite = unittest.makeSuite(ListOptionTestCase, 'test_')
+ suite = unittest.makeSuite(ListVariableTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
-"""engine.SCons.Options.PackageOption
+"""engine.SCons.Variables.PackageVariable
This file defines the option type for SCons implementing 'package
activation'.
To replace autoconf's --with-xxx=yyy
- opts = Options()
- opts.Add(PackageOption('x11',
+ opts = Variables()
+ opts.Add(PackageVariable('x11',
'use X11 installed here (yes = search some places',
'yes'))
...
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-__all__ = ('PackageOption')
+__all__ = ['PackageVariable',]
import string
'Path does not exist for option %s: %s' % (key, val))
-def PackageOption(key, help, default, searchfunc=None):
+def PackageVariable(key, help, default, searchfunc=None):
# NB: searchfunc is currenty undocumented and unsupported
"""
The input parameters describe a 'package list' option, thus they
import unittest
import SCons.Errors
-import SCons.Options
+import SCons.Variables
import TestCmd
-class PackageOptionTestCase(unittest.TestCase):
- def test_PackageOption(self):
- """Test PackageOption creation"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PackageOption('test', 'test option help', '/default/path'))
+class PackageVariableTestCase(unittest.TestCase):
+ def test_PackageVariable(self):
+ """Test PackageVariable creation"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path'))
o = opts.options[0]
assert o.key == 'test', o.key
assert not o.converter is None, o.converter
def test_converter(self):
- """Test the PackageOption converter"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PackageOption('test', 'test option help', '/default/path'))
+ """Test the PackageVariable converter"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path'))
o = opts.options[0]
# Make sure the converter returns True if we give it str(True) and
# False when we give it str(False). This assures consistent operation
- # through a cycle of Options.Save(<file>) -> Options(<file>).
+ # through a cycle of Variables.Save(<file>) -> Variables(<file>).
x = o.converter(str(True))
assert x == True, "converter returned a string when given str(True)"
assert x == False, "converter returned a string when given str(False)"
def test_validator(self):
- """Test the PackageOption validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PackageOption('test', 'test option help', '/default/path'))
+ """Test the PackageVariable validator"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PackageVariable('test', 'test option help', '/default/path'))
test = TestCmd.TestCmd(workdir='')
test.write('exists', 'exists\n')
if __name__ == "__main__":
- suite = unittest.makeSuite(PackageOptionTestCase, 'test_')
+ suite = unittest.makeSuite(PackageVariableTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
-"""SCons.Options.PathOption
+"""SCons.Variables.PathVariable
This file defines an option type for SCons implementing path settings.
To be used whenever a a user-specified path override should be allowed.
-Arguments to PathOption are:
+Arguments to PathVariable are:
option-name = name of this option on the command line (e.g. "prefix")
option-help = help string for option
option-dflt = default value for this option
Examples:
prefix=/usr/local
- opts = Options()
+ opts = Variables()
- opts = Options()
- opts.Add(PathOption('qtdir',
+ opts = Variables()
+ opts.Add(PathVariable('qtdir',
'where the root of Qt is installed',
qtdir, PathIsDir))
- opts.Add(PathOption('qt_includes',
+ opts.Add(PathVariable('qt_includes',
'where the Qt includes are installed',
'$qtdir/includes', PathIsDirCreate))
- opts.Add(PathOption('qt_libraries',
+ opts.Add(PathVariable('qt_libraries',
'where the Qt library is installed',
'$qtdir/lib'))
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+__all__ = ['PathVariable',]
+
import os
import os.path
import SCons.Errors
-class _PathOptionClass:
+class _PathVariableClass:
def PathAccept(self, key, val, env):
"""Accepts any path, no checking done."""
return (key, '%s ( /path/to/%s )' % (help, key), default,
validator, None)
-PathOption = _PathOptionClass()
+PathVariable = _PathVariableClass()
import unittest
import SCons.Errors
-import SCons.Options
+import SCons.Variables
import TestCmd
-class PathOptionTestCase(unittest.TestCase):
- def test_PathOption(self):
- """Test PathOption creation"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+class PathVariableTestCase(unittest.TestCase):
+ def test_PathVariable(self):
+ """Test PathVariable creation"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path'))
def test_PathExists(self):
"""Test the PathExists validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path',
- SCons.Options.PathOption.PathExists))
+ SCons.Variables.PathVariable.PathExists))
test = TestCmd.TestCmd(workdir='')
test.write('exists', 'exists\n')
def test_PathIsDir(self):
"""Test the PathIsDir validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path',
- SCons.Options.PathOption.PathIsDir))
+ SCons.Variables.PathVariable.PathIsDir))
test = TestCmd.TestCmd(workdir='')
test.subdir('dir')
def test_PathIsDirCreate(self):
"""Test the PathIsDirCreate validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path',
- SCons.Options.PathOption.PathIsDirCreate))
+ SCons.Variables.PathVariable.PathIsDirCreate))
test = TestCmd.TestCmd(workdir='')
test.write('file', "file\n")
def test_PathIsFile(self):
"""Test the PathIsFile validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path',
- SCons.Options.PathOption.PathIsFile))
+ SCons.Variables.PathVariable.PathIsFile))
test = TestCmd.TestCmd(workdir='')
test.subdir('dir')
def test_PathAccept(self):
"""Test the PathAccept validator"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path',
- SCons.Options.PathOption.PathAccept))
+ SCons.Variables.PathVariable.PathAccept))
test = TestCmd.TestCmd(workdir='')
test.subdir('dir')
o.validator('X', dne, {})
def test_validator(self):
- """Test the PathOption validator argument"""
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test',
+ """Test the PathVariable validator argument"""
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test',
'test option help',
'/default/path'))
def my_validator(key, val, env):
raise Exception, "my_validator() got called for %s, %s!" % (key, val)
- opts = SCons.Options.Options()
- opts.Add(SCons.Options.PathOption('test2',
+ opts = SCons.Variables.Variables()
+ opts.Add(SCons.Variables.PathVariable('test2',
'more help',
'/default/path/again',
my_validator))
if __name__ == "__main__":
- suite = unittest.makeSuite(PathOptionTestCase, 'test_')
+ suite = unittest.makeSuite(PathVariableTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
import unittest
import TestSCons
-import SCons.Options
+import SCons.Variables
import SCons.Subst
import SCons.Warnings
execfile(file, gdict, ldict)
assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict)
-class OptionsTestCase(unittest.TestCase):
+class VariablesTestCase(unittest.TestCase):
def test_keys(self):
- """Test the Options.keys() method"""
- opts = SCons.Options.Options()
+ """Test the Variables.keys() method"""
+ opts = SCons.Variables.Variables()
opts.Add('VAR1')
opts.Add('VAR2',
assert keys == ['VAR1', 'VAR2'], keys
def test_Add(self):
- """Test adding to an Options object"""
- opts = SCons.Options.Options()
+ """Test adding to a Variables object"""
+ opts = SCons.Variables.Variables()
opts.Add('VAR')
opts.Add('ANSWER',
test_it('foo-bar')
test_it('foo.bar')
- def test_AddOptions(self):
- """Test adding a list of options to an Options object"""
- opts = SCons.Options.Options()
+ def test_AddVariables(self):
+ """Test adding a list of options to a Variables object"""
+ opts = SCons.Variables.Variables()
- opts.AddOptions(('VAR2',),
+ opts.AddVariables(('VAR2',),
('ANSWER2',
'THE answer to THE question',
"42",
# Test that a default value is validated correctly.
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=54')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=42')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=10')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=10')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
'THE answer to THE question',
# or args.
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
help='THE answer to THE question',
# Test that a default value of None is all right.
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
- opts = SCons.Options.Options(file)
+ opts = SCons.Variables.Variables(file)
opts.Add('ANSWER',
"This is the answer",
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=42')
- opts = SCons.Options.Options(file, {'ANSWER':54})
+ opts = SCons.Variables.Variables(file, {'ANSWER':54})
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=54')
- opts = SCons.Options.Options(file, {'ANSWER':42})
+ opts = SCons.Variables.Variables(file, {'ANSWER':42})
opts.Add('ANSWER',
'THE answer to THE question',
test = TestSCons.TestSCons()
file = test.workpath('custom.py')
test.write('custom.py', 'ANSWER=54')
- opts = SCons.Options.Options(file, {'ANSWER':54})
+ opts = SCons.Variables.Variables(file, {'ANSWER':54})
opts.Add('ANSWER',
'THE answer to THE question',
assert env['ANSWER'] == 54
def test_Save(self):
- """Testing saving Options"""
+ """Testing saving Variables"""
test = TestSCons.TestSCons()
cache_file = test.workpath('cached.options')
- opts = SCons.Options.Options()
+ opts = SCons.Variables.Variables()
def bool_converter(val):
if val in [1, 'y']: val = 1
test = TestSCons.TestSCons()
cache_file = test.workpath('cached.options')
- opts = SCons.Options.Options()
+ opts = SCons.Variables.Variables()
opts.Add('THIS_USED_TO_BREAK',
'An option to test',
def test_GenerateHelpText(self):
"""Test generating the default format help text"""
- opts = SCons.Options.Options()
+ opts = SCons.Variables.Variables()
opts.Add('ANSWER',
'THE answer to THE question',
text = opts.GenerateHelpText(env, sort=cmp)
assert text == expectAlpha, text
- def test_FormatOptionHelpText(self):
+ def test_FormatVariableHelpText(self):
"""Test generating custom format help text"""
- opts = SCons.Options.Options()
+ opts = SCons.Variables.Variables()
def my_format(env, opt, help, default, actual, aliases):
return '%s %s %s %s %s\n' % (opt, default, actual, help, aliases)
- opts.FormatOptionHelpText = my_format
+ opts.FormatVariableHelpText = my_format
opts.Add('ANSWER',
'THE answer to THE question',
-class UnknownOptionsTestCase(unittest.TestCase):
+class UnknownVariablesTestCase(unittest.TestCase):
def test_unknown(self):
- """Test the UnknownOptions() method"""
- opts = SCons.Options.Options()
+ """Test the UnknownVariables() method"""
+ opts = SCons.Variables.Variables()
opts.Add('ANSWER',
'THE answer to THE question',
env = Environment()
opts.Update(env, args)
- r = opts.UnknownOptions()
+ r = opts.UnknownVariables()
assert r == {'UNKNOWN' : 'unknown'}, r
assert env['ANSWER'] == 'answer', env['ANSWER']
if __name__ == "__main__":
suite = unittest.TestSuite()
- tclasses = [ OptionsTestCase,
- UnknownOptionsTestCase ]
+ tclasses = [ VariablesTestCase,
+ UnknownVariablesTestCase ]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
suite.addTests(map(tclass, names))
-"""engine.SCons.Options
+"""engine.SCons.Variables
-This file defines the Options class that is used to add user-friendly
+This file defines the Variables class that is used to add user-friendly
customizable variables to an SCons build.
"""
import SCons.Util
import SCons.Warnings
-from BoolOption import BoolOption # okay
-from EnumOption import EnumOption # okay
-from ListOption import ListOption # naja
-from PackageOption import PackageOption # naja
-from PathOption import PathOption # okay
+from BoolVariable import BoolVariable # okay
+from EnumVariable import EnumVariable # okay
+from ListVariable import ListVariable # naja
+from PackageVariable import PackageVariable # naja
+from PathVariable import PathVariable # okay
-class Options:
+class Variables:
instance=None
"""
# create the singleton instance
if is_global:
- self=Options.instance
+ self=Variables.instance
- if not Options.instance:
- Options.instance=self
+ if not Variables.instance:
+ Variables.instance=self
def _do_add(self, key, help="", default=None, validator=None, converter=None):
- class Option:
+ class Variable:
pass
- option = Option()
+ option = Variable()
# if we get a list or a tuple, we take the first element as the
# option key and store the remaining in aliases.
if not SCons.Util.is_String(key) or \
not SCons.Environment.is_valid_construction_var(key):
- raise SCons.Errors.UserError, "Illegal Options.Add() key `%s'" % str(key)
+ raise SCons.Errors.UserError, "Illegal Variables.Add() key `%s'" % str(key)
self._do_add(key, help, default, validator, converter)
- def AddOptions(self, *optlist):
+ def AddVariables(self, *optlist):
"""
Add a list of options.
to the underlying method for adding options.
Example:
- opt.AddOptions(
+ opt.AddVariables(
('debug', '', 0),
('CC', 'The C compiler'),
('VALIDATE', 'An option for testing validation', 'notset',
if option.validator and values.has_key(option.key):
option.validator(option.key, env.subst('${%s}'%option.key), env)
- def UnknownOptions(self):
+ def UnknownVariables(self):
"""
Returns any options in the specified arguments lists that
were not known, declared options in this object.
actual = env.subst('${%s}' % opt.key)
else:
actual = None
- return self.FormatOptionHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases)
+ return self.FormatVariableHelpText(env, opt.key, opt.help, opt.default, actual, opt.aliases)
lines = filter(None, map(format, options))
return string.join(lines, '')
format = '\n%s: %s\n default: %s\n actual: %s\n'
format_ = '\n%s: %s\n default: %s\n actual: %s\n aliases: %s\n'
- def FormatOptionHelpText(self, env, key, help, default, actual, aliases=[]):
+ def FormatVariableHelpText(self, env, key, help, default, actual, aliases=[]):
# Don't display the key name itself as an alias.
aliases = filter(lambda a, k=key: a != k, aliases)
if len(aliases)==0:
return result
fnmatch.filter = filter
del filter
-
+
+try:
+ import itertools
+except ImportError:
+ # Pre-2.3 Python has no itertools module.
+ import_as('_scons_itertools', 'itertools')
# If we need the compatibility version of textwrap, it must be imported
# before optparse, which uses it.
--- /dev/null
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__doc__ = """
+Implementations of itertools functions for Python versions that don't
+have iterators.
+
+These implement the functions by creating the entire list, not returning
+it element-by-element as the real itertools functions do. This means
+that early Python versions won't get the performance benefit of using
+the itertools, but we can still use them so the later Python versions
+do get the advantages of using iterators.
+
+Because we return the entire list, we intentionally do not implement the
+itertools functions that "return" infinitely-long lists: the count(),
+cycle() and repeat() functions. Other functions below have remained
+unimplemented simply because they aren't being used (yet) and it wasn't
+obvious how to do it. Or, conversely, we only implemented those functions
+that *were* easy to implement (mostly because the Python documentation
+contained examples of equivalent code).
+
+Note that these do not have independent unit tests, so it's possible
+that there are bugs.
+"""
+
+def chain(*iterables):
+ result = []
+ for x in iterables:
+ result.extend(list(x))
+ return result
+
+def count(n=0):
+ # returns infinite length, should not be supported
+ raise NotImplementedError
+
+def cycle(iterable):
+ # returns infinite length, should not be supported
+ raise NotImplementedError
+
+def dropwhile(predicate, iterable):
+ result = []
+ for x in iterable:
+ if not predicate(x):
+ result.append(x)
+ break
+ result.extend(iterable)
+ return result
+
+def groupby(iterable, *args):
+ raise NotImplementedError
+
+def ifilter(predicate, iterable):
+ result = []
+ if predicate is None:
+ predicate = bool
+ for x in iterable:
+ if predicate(x):
+ result.append(x)
+ return result
+
+def ifilterfalse(predicate, iterable):
+ result = []
+ if predicate is None:
+ predicate = bool
+ for x in iterable:
+ if not predicate(x):
+ result.append(x)
+ return result
+
+def imap(function, *iterables):
+ return apply(map, (function,) + tuple(iterables))
+
+def islice(*args, **kw):
+ raise NotImplementedError
+
+def izip(*iterables):
+ return apply(zip, iterables)
+
+def repeat(*args, **kw):
+ # returns infinite length, should not be supported
+ raise NotImplementedError
+
+def starmap(*args, **kw):
+ raise NotImplementedError
+
+def takewhile(predicate, iterable):
+ result = []
+ for x in iterable:
+ if predicate(x):
+ result.append(x)
+ else:
+ break
+ return result
+
+def tee(*args, **kw):
+ raise NotImplementedError
if seq:
for elem in seq:
if elem not in self.elems:
+ hash(elem)
self.elems.append(elem)
def __str__(self):
- return "{%s}" % string.join(map(str, self.elems), ", ")
+ return "set([%s])" % string.join(map(str, self.elems), ", ")
def copy(self):
def add(self, elem):
"""Add one element to the set."""
if elem not in self.elems:
+ hash(elem)
self.elems.append(elem)
def remove(self, elem):
return 0
else:
return len(self - other) == 0
+
+ def __cmp__(self, other):
+ """Returns 1 if the sets are equal."""
+ if self.__lt__(other):
+ return -1
+ elif other.__lt__(self):
+ return 1
+ else:
+ return 0
# splits into
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
# (after stripping out empty strings).
- wordsep_re = re.compile(r'(\s+|' # any whitespace
- r'-*\w{2,}-(?=\w{2,}))') # hyphenated words
- # Earlier Python's don't have the (?<=
- # negative look-behind assertion. It doesn't
- # matter for the simple input SCons is going to
- # give it, so just comment it out.
- #r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
+ try:
+ wordsep_re = re.compile(r'(\s+|' # any whitespace
+ r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words
+ r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
+ except re.error:
+ # Pre-2.0 Python versions don't have the (?<= negative look-behind
+ # assertion. It mostly doesn't matter for the simple input
+ # SCons is going to give it, so just leave it out.
+ wordsep_re = re.compile(r'(\s+|' # any whitespace
+ r'-*\w{2,}-(?=\w{2,}))') # hyphenated words
# XXX will there be a locale-or-charset-aware version of
# string.lowercase in 2.3?
import time
import shutil
import os
-import os.path
import types
import __builtin__
-_open = __builtin__.open # avoid name clash
-
keep_all_files = 00000
ignore_corrupt_dbfiles = 0
class dblite:
+ # Squirrel away references to the functions in various modules
+ # that we'll use when our __del__() method calls our sync() method
+ # during shutdown. We might get destroyed when Python is in the midst
+ # of tearing down the different modules we import in an essentially
+ # arbitrary order, and some of the various modules's global attributes
+ # may already be wiped out from under us.
+ #
+ # See the discussion at:
+ # http://mail.python.org/pipermail/python-bugs-list/2003-March/016877.html
+
+ _open = __builtin__.open
+ _cPickle_dump = cPickle.dump
+ _os_chmod = os.chmod
+ _os_rename = os.rename
+ _os_unlink = os.unlink
+ _shutil_copyfile = shutil.copyfile
+ _time_time = time.time
+
def __init__(self, file_base_name, flag, mode):
assert flag in (None, "r", "w", "c", "n")
if (flag is None): flag = "r"
self._dict = {}
self._needs_sync = 00000
if (self._flag == "n"):
- _open(self._file_name, "wb", self._mode)
+ self._open(self._file_name, "wb", self._mode)
else:
try:
- f = _open(self._file_name, "rb")
+ f = self._open(self._file_name, "rb")
except IOError, e:
if (self._flag != "c"):
raise e
- _open(self._file_name, "wb", self._mode)
+ self._open(self._file_name, "wb", self._mode)
else:
p = f.read()
if (len(p) > 0):
def sync(self):
self._check_writable()
- f = _open(self._tmp_name, "wb", self._mode)
- cPickle.dump(self._dict, f, 1)
+ f = self._open(self._tmp_name, "wb", self._mode)
+ self._cPickle_dump(self._dict, f, 1)
f.close()
# Windows doesn't allow renaming if the file exists, so unlink
# it first, chmod'ing it to make sure we can do so. On UNIX, we
# (e.g. from a previous run as root). We should still be able to
# unlink() the file if the directory's writable, though, so ignore
# any OSError exception thrown by the chmod() call.
- try: os.chmod(self._file_name, 0777)
+ try: self._os_chmod(self._file_name, 0777)
except OSError: pass
- os.unlink(self._file_name)
- os.rename(self._tmp_name, self._file_name)
+ self._os_unlink(self._file_name)
+ self._os_rename(self._tmp_name, self._file_name)
self._needs_sync = 00000
if (keep_all_files):
- shutil.copyfile(
+ self._shutil_copyfile(
self._file_name,
- self._file_name + "_" + str(int(time.time())))
+ self._file_name + "_" + str(int(self._time_time())))
def _check_writable(self):
if (self._flag == "r"):
@REM no way to set exit status of this script for 9x/Me\r
goto endscons\r
:WinNT\r
-@REM set path=%path%;%~dp0\r
+setlocal\r
+@REM ensure the script will be executed with the Python it was installed for\r
+set path=%~dp0;%~dp0..;%path%\r
python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-__VERSION__'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-__VERSION__'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %*\r
-if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endscons\r
+if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endsconsnt\r
if errorlevel 9009 echo you do not have python in your PATH\r
@REM color 00 causes this script to exit with non-zero exit status\r
if errorlevel 1 color 00\r
+:endsconsnt\r
+endlocal\r
:endscons\r
'packages' : ["SCons",
"SCons.compat",
"SCons.Node",
- "SCons.Options",
"SCons.Platform",
"SCons.Scanner",
"SCons.Script",
"SCons.Tool",
- "SCons.Tool.packaging"],
+ "SCons.Tool.packaging",
+ "SCons.Variables",
+ ],
'package_dir' : {'' : 'engine'},
'data_files' : [('man/man1', man_pages)],
'scripts' : scripts,
import SCons.Action
import SCons.Builder
-options = Options()
-options.AddOptions(
+options = Variables()
+options.AddVariables(
('header', 'Header string (default cell argument)', 'Head:'),
('trailer', 'Trailer string (default cell argument)', 'Tail'),
('NbDeps', 'Number of dependencies', '2'),
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that an Action list with a string command containing a Unicode file
+name, and a Python function action, works corectly. This verifies that
+the signatures of the two actions can be concatenated without encoding
+Unicode problems.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+try:
+ unicode
+except NameError:
+ import sys
+ msg = "Unicode not supported by Python version %s; skipping test\n"
+ test.skip_test(msg % sys.version[:3])
+
+test.write('SConstruct', """
+fnode = File(u'foo.txt')
+
+def funcact(target, source, env):
+ open(str(target[0]), 'wb').write("funcact\\n")
+ for i in range(300):
+ pass
+ return 0
+
+env = Environment()
+
+env.Command(fnode, [], ["echo $TARGET", funcact])
+""")
+
+test.run(arguments = '.')
+
+test.must_match('foo.txt', "funcact\n")
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that we can set both $CCFLAGS and $CXXFLAGS and have them
+both show up on the compilation lines for C++ source files.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+foo = Environment(CCFLAGS = '-DFOO', CXXFLAGS = '-DCXX')
+bar = Environment(CCFLAGS = '-DBAR', CXXFLAGS = '-DCXX')
+foo_obj = foo.Object(target = 'foo', source = 'prog.cpp')
+bar_obj = bar.Object(target = 'bar', source = 'prog.cpp')
+foo.Program(target = 'foo', source = foo_obj)
+bar.Program(target = 'bar', source = bar_obj)
+""")
+
+test.write('prog.cpp', r"""
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+#ifdef FOO
+ printf("prog.c: FOO\n");
+#endif
+#ifdef BAR
+ printf("prog.c: BAR\n");
+#endif
+ exit (0);
+}
+""")
+
+test.run(arguments = '.')
+
+test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n")
+test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n")
+
+test.pass_test()
sys.exit(0)
""")
-if os.path.normcase('.c') == os.path.normcase('.C'):
- alt_cpp_suffix = '.cpp'
-else:
- alt_cpp_suffix = '.C'
+alt_cpp_suffix=test.get_alt_cpp_suffix()
test.write('SConstruct', """
env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
sys.exit(0)
""")
-if os.path.normcase('.c') == os.path.normcase('.C'):
- alt_cpp_suffix = '.cpp'
-else:
- alt_cpp_suffix = '.C'
+alt_cpp_suffix=test.get_alt_cpp_suffix()
test.write('SConstruct', """
env = Environment(CXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
sys.exit(0)
""")
-if os.path.normcase('.c') == os.path.normcase('.C'):
- alt_cpp_suffix = '.cpp'
-else:
- alt_cpp_suffix = '.C'
+alt_cpp_suffix=test.get_alt_cpp_suffix()
test.write('SConstruct', """
env = Environment(SHCXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
sys.exit(0)
""")
-if os.path.normcase('.c') == os.path.normcase('.C'):
- alt_cpp_suffix = '.cpp'
-else:
- alt_cpp_suffix = '.C'
+alt_cpp_suffix=test.get_alt_cpp_suffix()
test.write('SConstruct', """
env = Environment(SHCXXCOM = r'%(_python_)s mycc.py $TARGET $SOURCE',
}
""")
-if sys.platform == 'darwin':
- test.skip_test("Skipping test on Darwin/OSX; it has partial case sensitivity.")
+if sys.platform[:6] == 'darwin':
+ test.skip_test("Skipping test on Darwin/OSX; it has partial case sensitivity.\n")
if sys.platform in ['cygwin', 'win32']:
sys.stdout.write("Using case-insensitive filesystem, testing for failure\n")
CF = test.CF # cached build failure
test.write('SConstruct', """\
-opts = Options()
+opts = Variables()
opts.Add('chdir')
env = Environment(options=opts)
if env['chdir'] == 'yes':
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Test that setting Options in an Environment doesn't prevent the
+Test that setting Variables in an Environment doesn't prevent the
Environment from being copied.
"""
gpib_options = ['NI_GPIB', 'NI_ENET']
gpib_include = '/'
-#0.96 broke copying ListOptions ???
-opts = Options('config.py', ARGUMENTS)
-opts.AddOptions(
- BoolOption('gpib', 'enable gpib support', 1),
- ListOption('gpib_options',
+#0.96 broke copying ListVariables ???
+opts = Variables('config.py', ARGUMENTS)
+opts.AddVariables(
+ BoolVariable('gpib', 'enable gpib support', 1),
+ ListVariable('gpib_options',
'whether and what kind of gpib support shall be enabled',
'all',
gpib_options),
import TestSCons
+
test = TestSCons.TestSCons()
SConstruct_path = test.workpath('SConstruct')
check(['all', '1', 'gl ical qt x11', 'gl ical qt x11',
"['gl ical qt x11']"])
-test.must_match(test.workpath('scons.options'), "shared = 'all'"+os.linesep)
+test.must_match(test.workpath('scons.options'),
+ "shared = 'all'"+os.linesep,
+ mode='r')
check(['all', '1', 'gl ical qt x11', 'gl ical qt x11',
"['gl ical qt x11']"])
test.run(arguments = "--debug=stree foo.xxx",
stderr = stderr)
-test.fail_test(string.find(test.stdout(), stree) == -1)
+test.fail_test(string.count(test.stdout(), stree) != 1)
stree2 = """
E = exists
test.run(arguments = "--no-exec --debug=stree foo.xxx",
stderr = stderr)
-test.fail_test(string.find(test.stdout(), stree2) == -1)
+test.fail_test(string.count(test.stdout(), stree2) != 1)
test.pass_test()
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f77pp = 'f77'
else:
f77pp = 'f77pp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f90pp = 'f90'
else:
f90pp = 'f90pp'
-
test.write('SConstruct', """
env = Environment(F90COM = r'%(_python_)s myfc.py f90 $TARGET $SOURCES',
F90COMSTR = 'Building f90 $TARGET from $SOURCES',
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f95pp = 'f95'
else:
f95pp = 'f95pp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
fortranpp = 'fortran'
else:
fortranpp = 'fortranpp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f77pp = 'f77'
else:
f77pp = 'f77pp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f90pp = 'f90'
else:
f90pp = 'f90pp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
f95pp = 'f95'
else:
f95pp = 'f95pp'
sys.exit(0)
""")
-if os.path.normcase('.f') == os.path.normcase('.F'):
+if not TestSCons.case_sensitive_suffixes('.f','.F'):
fortranpp = 'fortran'
else:
fortranpp = 'fortranpp'
expect_stdout = """\
scons>>> Copy("foo.out", "foo.in")
Touch("1")
-scons>>> Taskmaster: 'foo.out': children:
- ['foo.in']
- waiting on unfinished children:
- ['foo.in']
-Taskmaster: 'foo.in': evaluating foo.in
-Taskmaster: 'foo.out': children:
- ['foo.in']
- evaluating foo.out
+scons>>>
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'foo.out'> and its children:
+Taskmaster: <no_state 'foo.in'>
+Taskmaster: Considering node <no_state 'foo.in'> and its children:
+Taskmaster: Evaluating <pending 'foo.in'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <pending 'foo.out'> and its children:
+Taskmaster: <up_to_date 'foo.in'>
+Taskmaster: Evaluating <pending 'foo.out'>
Copy("foo.out", "foo.in")
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: No candidate anymore.
+
scons>>> Touch("2")
scons>>> scons: `foo.out' is up to date.
scons>>>
+-foo.in
scons>>> Touch("2")
scons>>> scons: `foo.out' is up to date.
-+-foo.out
- +-foo.in
scons>>>
"""
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+XXX Put a description of the test here.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('markers',
+ 'work',
+ ['work', 'sub1'])
+
+marker_1 = test.workpath('markers', '1')
+marker_2 = test.workpath('markers', '2')
+
+test.write(['work', 'SConstruct'], """\
+# build the plugin binaries
+basepath = str(Dir('#').abspath)
+env = Environment()
+env.Append(BASEPATH=basepath)
+env.Append(ENV = {'BASEPATH' : str(Dir('#').abspath)})
+SConscript( 'sub1/SConscript',
+ variant_dir = 'build',
+ duplicate=False,
+ exports='env')
+Command(r'%(marker_1)s', [], Touch('$TARGET'))
+Command(r'%(marker_2)s', [], Touch('$TARGET'))
+""" % locals())
+
+test.write(['work', 'sub1', 'SConscript'], """\
+Import('env')
+env.Program('hello.c')
+""")
+
+test.write(['work', 'sub1', 'hello.c'], """\
+#include <stdio.h>
+#include <stdlib.h>
+int main( int iArgC, char *cpArgV[] )
+{
+ printf("hello\\n");
+ exit (0);
+}
+""")
+
+
+
+# The "chdir =" keyword argument in the test.start() call has no effect.
+# Work around it for now.
+import os
+os.chdir('work/sub1')
+scons = test.start(chdir = 'work/sub1', arguments = '-Q -u --interactive')
+
+scons.send("shell pwd\n")
+
+scons.send("build\n")
+
+scons.send("build %s\n" % marker_1)
+
+test.wait_for(marker_1)
+
+test.run(program = test.workpath('work/build/hello'), stdout="hello\n")
+
+
+
+test.write(['work', 'sub1', 'hello.c'], """\
+#include <stdio.h>
+#include <stdlib.h>
+int main( int iArgC, char *cpArgV[] )
+{
+ printf("hello 2\\n");
+ exit (0);
+}
+""")
+
+scons.send("build\n")
+
+scons.send("build %s\n" % marker_2)
+
+test.wait_for(marker_2)
+
+test.run(program = test.workpath('work/build/hello'), stdout="hello 2\n")
+
+
+
+test.finish(scons)
+
+
+
+test.pass_test()
# by the packaging build.
copyright_marker = '__' + 'COPYRIGHT' + '__'
-copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007'
-
fmt = '(%s|Copyright \\(c\\) %s The SCons Foundation)\n'
-copyright_line = fmt % (copyright_marker, copyright_years)
+copyright_line = fmt % (copyright_marker, TestSCons.copyright_years)
env.VariantDir('buildout', 'src', duplicate=0)
-if sys.platform=='darwin':
+if sys.platform[:6]=='darwin':
env.Append(CPPPATH=['/System/Library/Frameworks/JavaVM.framework/Headers'])
#If you do not have swig on your system please remove 'buildout/jni/SConscript' line from next call
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that we handle keyboard interrupts (CTRL-C) correctly.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if 'killpg' not in dir(os) or 'setpgrp' not in dir(os):
+ test.skip_test("This Python version does not support killing process groups; skipping test.\n")
+
+test.write('toto.c', r"""
+void foo()
+{}
+""")
+
+test.write('SConstruct', r"""
+import os
+import signal
+
+# Make sure that SCons is a process group leader.
+os.setpgrp()
+
+all = []
+
+def explode(env, target, source):
+ os.killpg(0, signal.SIGINT)
+
+for i in xrange(40):
+ all += Object('toto%5d' % i, 'toto.c')
+
+all+= Command( 'broken', 'toto.c', explode)
+
+Default( Alias('all', all))
+"""
+)
+
+interruptedStr = """\
+.*\
+scons: Build interrupted\\.
+.*\
+scons: building terminated because of errors\\.
+.*\
+scons: writing .sconsign file\\.
+.*\
+"""
+
+def runtest(arguments):
+ test.run(arguments='-c')
+ test.run(arguments=arguments, status=2,
+ stdout=interruptedStr, stderr=r'.*', match=TestSCons.match_re_dotall)
+
+for i in range(2):
+ runtest('-j1')
+ runtest('-j4')
+ runtest('-j8')
+ runtest('-j16')
+ runtest('-j32')
+ runtest('-j64')
+
+ runtest('-j1 --random')
+ runtest('-j4 --random')
+ runtest('-j8 --random')
+ runtest('-j16 --random')
+ runtest('-j32 --random')
+ runtest('-j64 --random')
dlopen_line = {
'darwin' : no_dl_lib,
+ 'darwin8' : no_dl_lib, # ONLY NEEDED FOR 1.5.2
'freebsd4' : no_dl_lib,
'linux2' : use_dl_lib,
}
env.LoadableModule(target = 'foo1', source = 'f1.c')
""" + dlopen_line.get(sys.platform, ''))
-
+
test.write('f1.c', r"""
#include <stdio.h>
}
"""
-# Darwin dlopen()s a bundle name "foo1",
+# Darwin dlopen()s a bundle named "foo1",
# other systems dlopen() a traditional libfoo1.so file.
-foo1_name = {'darwin' : 'foo1'}.get(sys.platform, dll_+'foo1'+_dll)
+foo1_name = {'darwin' : 'foo1'}.get(sys.platform[:6], dll_+'foo1'+_dll)
test.write('dlopenprog.c',
string.replace(dlopenprog, '__foo1_name__', foo1_name))
os.environ['LD_LIBRARY_PATH'] = test.workpath()
test.run(program = test.workpath('dlopenprog'),
stdout = "f1.c\ndlopenprog.c\n")
-
+
test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+"""
+Verify that a failed build action with -j works as expected.
+"""
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+_python_ = TestSCons._python_
+
+try:
+ import threading
+except ImportError:
+ # if threads are not supported, then
+ # there is nothing to test
+ TestCmd.no_result()
+ sys.exit()
+
+
+test = TestSCons.TestSCons()
+
+# Test that we can handle parallel builds with a dependency graph
+# where:
+# a) Some nodes have multiple parents
+# b) Some targets fail building
+# c) Some targets succeed building
+# d) Some children are ignored
+# e) Some children are pre-requesites
+# f) Some sources are missing
+
+test.write('SConstruct', """
+def fail_action(target = None, source = None, env = None):
+ return 2
+
+failed0 = Command(target='failed00', source='', action=fail_action)
+ok0 = Command(target='ok00', source='', action=Touch('${TARGET}'))
+prereq0 = Command(target='prereq00', source='', action=Touch('${TARGET}'))
+ignore0 = Command(target='ignore00', source='', action=Touch('${TARGET}'))
+igreq0 = Command(target='igreq00', source='', action=Touch('${TARGET}'))
+missing0 = Command(target='missing00', source='MissingSrc', action=Touch('${TARGET}'))
+
+prev_level = failed0 + ok0 + ignore0
+prev_prereq = prereq0
+prev_ignore = ignore0
+prev_igreq = igreq0
+
+for i in range(1,20):
+
+ failed = Command(target='failed%02d' % i, source='', action=fail_action)
+ ok = Command(target='ok%02d' % i, source='', action=Touch('${TARGET}'))
+ prereq = Command(target='prereq%02d' % i, source='', action=Touch('${TARGET}'))
+ ignore = Command(target='ignore%02d' % i, source='', action=Touch('${TARGET}'))
+ igreq = Command(target='igreq%02d' % i, source='', action=Touch('${TARGET}'))
+ missing = Command(target='missing%02d' %i, source='MissingSrc', action=Touch('${TARGET}'))
+
+ next_level = failed + ok + ignore + igreq + missing
+
+ for j in range(1,10):
+ a = Alias('a%02d%02d' % (i,j), prev_level)
+
+ Requires(a, prev_prereq)
+ Ignore(a, prev_ignore)
+
+ Requires(a, prev_igreq)
+ Ignore(a, prev_igreq)
+
+ next_level = next_level + a
+
+ prev_level = next_level
+ prev_prereq = prereq
+ prev_ignore = ignore
+ prev_igreq = igreq
+
+all = Alias('all', prev_level)
+
+Requires(all, prev_prereq)
+Ignore(all, prev_ignore)
+
+Requires(all, prev_igreq)
+Ignore(all, prev_igreq)
+
+Default(all)
+""")
+
+re_error = """\
+(scons: \\*\\*\\* \\[failed\\d+] Error 2\\n)|\
+(scons: \\*\\*\\* Source `MissingSrc' not found, needed by target `missing\\d+'\\.( Stop\\.)?\\n)\
+"""
+
+re_errors = "(" + re_error + ")+"
+
+test.run(arguments = 'all',
+ status = 2,
+ stderr = "scons: *** [failed19] Error 2\n")
+test.must_not_exist(test.workpath('ok'))
+
+
+for i in range(5):
+ test.run(arguments = '-c all')
+
+ test.run(arguments = '-j8 all',
+ status = 2,
+ stderr = re_errors,
+ match=TestSCons.match_re_dotall)
+
+
+for i in range(5):
+ test.run(arguments = '-c all')
+
+ test.run(arguments = '-j 8 -k all',
+ status = 2,
+ stderr = re_errors,
+ match=TestSCons.match_re_dotall)
+ for i in range(20):
+ test.must_exist(test.workpath('ok%02d' % i))
+ test.must_exist(test.workpath('prereq%02d' % i))
+ test.must_not_exist(test.workpath('ignore%02d' % i))
+ test.must_exist(test.workpath('igreq%02d' % i))
+
+
+for i in range(5):
+ test.run(arguments = 'all --random',
+ status = 2,
+ stderr = re_errors,
+ match=TestSCons.match_re_dotall)
+ test.must_not_exist(test.workpath('ok'))
+
+for i in range(5):
+ test.run(arguments = '-c all')
+
+ test.run(arguments = '-j8 --random all',
+ status = 2,
+ stderr = re_errors,
+ match=TestSCons.match_re_dotall)
+
+for i in range(5):
+ test.run(arguments = '-c all')
+
+ test.run(arguments = '-j 8 -k --random all',
+ status = 2,
+ stderr = re_errors,
+ match=TestSCons.match_re_dotall)
+ for i in range(20):
+ test.must_exist(test.workpath('ok%02d' % i))
+ test.must_exist(test.workpath('prereq%02d' % i))
+ test.must_not_exist(test.workpath('ignore%02d' % i))
+ test.must_exist(test.workpath('igreq%02d' % i))
+
+test.pass_test()
env = Environment(CPPPATH=['.'], LIBPATH=['.'], LIBS=[])
-opts = Options('lprof.conf')
-opts.Add(PathOption("qt_directory", "Path to Qt directory", "/"))
+opts = Variables('lprof.conf')
+opts.Add(PathVariable("qt_directory", "Path to Qt directory", "/"))
opts.Update(env)
env['QT_LIB'] = 'qt-mt'
x = SConscript('SConscript2')
y, z = SConscript('SConscript3')
a4, b4 = SConscript('SConscript4')
+foo, bar = SConscript('SConscript5')
print "x =", x
print "y =", y
print "z =", z
print "a4 =", a4
print "b4 =", b4
+print "foo =", foo
+print "bar =", bar
""")
test.write('SConscript1', """\
print "line 8"
""")
+test.write('SConscript5', """\
+foo = 'foo'
+bar = 'bar'
+Return(["foo", "bar"])
+print "line 9"
+""")
+
expect = """\
line 1
line 3
z = 9
a4 = aaa
b4 = bbb
+foo = foo
+bar = bar
"""
test.run(arguments = '-q -Q', stdout=expect)
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that we expect the .py file created by the -python flag to be in
+the same subdirectory as the taget.
+"""
+
+import os
+import sys
+
+import TestSCons
+
+# swig-python expects specific filenames.
+# the platform specific suffix won't necessarily work.
+if sys.platform == 'win32':
+ _dll = '.dll'
+else:
+ _dll = '.so'
+
+test = TestSCons.TestSCons()
+
+test.subdir('sub')
+
+swig = test.where_is('swig')
+
+if not swig:
+ test.skip_test('Can not find installed "swig", skipping test.\n')
+
+python = test.get_platform_python()
+_python_ = test.get_quoted_platform_python()
+
+# handle testing on other platforms:
+ldmodule_prefix = '_'
+
+python_include_dir = test.get_python_inc()
+
+Python_h = os.path.join(python_include_dir, 'Python.h')
+
+if not os.path.exists(Python_h):
+ test.skip_test('Can not find %s, skipping test.\n' % Python_h)
+
+python_frameworks_flags = test.get_python_frameworks_flags()
+
+test.write('SConstruct', """
+env = Environment(SWIGFLAGS='-python',
+ CPPPATH='%(python_include_dir)s/',
+ LDMODULEPREFIX='%(ldmodule_prefix)s',
+ LDMODULESUFFIX='%(_dll)s',
+ FRAMEWORKSFLAGS='%(python_frameworks_flags)s',
+ )
+
+import sys
+if sys.version[0] == '1':
+ # SWIG requires the -classic flag on pre-2.0 Python versions.
+ env.Append(SWIGFLAGS = ' -classic')
+
+env.LoadableModule('sub/_foo',
+ ['sub/foo.i', 'sub/foo.c'],
+ LDMODULEPREFIX='')
+""" % locals())
+
+test.write(['sub', 'foo.i'], """\
+%module foo
+%{
+/* Put header files here (optional) */
+/*
+ * This duplication shouldn't be necessary, I guess, but it seems
+ * to suppress "cast to pointer from integer of different size"
+ * warning messages on some systems.
+ */
+extern char *foo_string();
+%}
+
+extern char *foo_string();
+""")
+
+test.write(['sub', 'foo.c'], """\
+char *
+foo_string()
+{
+ return "This is foo.c!";
+}
+""")
+
+test.run(arguments = '.')
+
+test.up_to_date(options = '--debug=explain', arguments = '.')
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the BoolVariable canned Variable type.
+"""
+
+import os.path
+import string
+
+try:
+ True, False
+except NameError:
+ True = (0 == 0)
+ False = (0 != 0)
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
+
+
+
+test.write(SConstruct_path, """\
+from SCons.Variables import BoolVariable
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
+ BoolVariable('profile', 'create profiling informations', 0),
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['warnings']
+print env['profile']
+
+Default(env.Alias('dummy', None))
+""")
+
+
+
+test.run()
+check([str(True), str(False)])
+
+test.run(arguments='warnings=0 profile=no profile=true')
+check([str(False), str(True)])
+
+expect_stderr = """
+scons: *** Error converting option: warnings
+Invalid value for boolean option: irgendwas
+""" + test.python_file_line(SConstruct_path, 9)
+
+test.run(arguments='warnings=irgendwas', stderr = expect_stderr, status=2)
+
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the EnumVariable canned Variable type.
+"""
+
+import os.path
+import string
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
+
+
+
+test.write(SConstruct_path, """\
+from SCons.Variables import EnumVariable
+
+list_of_libs = Split('x11 gl qt ical')
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ EnumVariable('debug', 'debug output and symbols', 'no',
+ allowed_values=('yes', 'no', 'full'),
+ map={}, ignorecase=0), # case sensitive
+ EnumVariable('guilib', 'gui lib to use', 'gtk',
+ allowed_values=('motif', 'gtk', 'kde'),
+ map={}, ignorecase=1), # case insensitive
+ EnumVariable('some', 'some option', 'xaver',
+ allowed_values=('xaver', 'eins'),
+ map={}, ignorecase=2), # make lowercase
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['debug']
+print env['guilib']
+print env['some']
+
+Default(env.Alias('dummy', None))
+""")
+
+
+test.run(); check(['no', 'gtk', 'xaver'])
+
+test.run(arguments='debug=yes guilib=Motif some=xAVER')
+check(['yes', 'Motif', 'xaver'])
+
+test.run(arguments='debug=full guilib=KdE some=EiNs')
+check(['full', 'KdE', 'eins'])
+
+expect_stderr = """
+scons: *** Invalid value for option debug: FULL
+""" + test.python_file_line(SConstruct_path, 18)
+
+test.run(arguments='debug=FULL', stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Invalid value for option guilib: irgendwas
+""" + test.python_file_line(SConstruct_path, 18)
+
+test.run(arguments='guilib=IrGeNdwas', stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Invalid value for option some: irgendwas
+""" + test.python_file_line(SConstruct_path, 18)
+
+test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2)
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ListVariable canned Variable type.
+"""
+
+import os
+import os.path
+import string
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ r = result[1:len(expect)+1]
+ assert r == expect, (r, expect)
+
+
+
+test.write(SConstruct_path, """\
+from SCons.Variables import ListVariable
+
+list_of_libs = Split('x11 gl qt ical')
+
+optsfile = 'scons.variables'
+opts = Variables(optsfile, args=ARGUMENTS)
+opts.AddVariables(
+ ListVariable('shared',
+ 'libraries to build as shared libraries',
+ 'all',
+ names = list_of_libs,
+ map = {'GL':'gl', 'QT':'qt'}),
+ )
+
+env = Environment(variables=opts)
+opts.Save(optsfile, env)
+Help(opts.GenerateHelpText(env))
+
+print env['shared']
+if 'ical' in env['shared']: print '1'
+else: print '0'
+for x in env['shared']:
+ print x,
+print
+print env.subst('$shared')
+# Test subst_path() because it's used in $CPPDEFINES expansions.
+print env.subst_path('$shared')
+Default(env.Alias('dummy', None))
+""")
+
+test.run()
+check(['all', '1', 'gl ical qt x11', 'gl ical qt x11',
+ "['gl ical qt x11']"])
+
+test.must_match(test.workpath('scons.variables'), "shared = 'all'"+os.linesep)
+
+check(['all', '1', 'gl ical qt x11', 'gl ical qt x11',
+ "['gl ical qt x11']"])
+
+test.run(arguments='shared=none')
+check(['none', '0', '', '', "['']"])
+
+test.run(arguments='shared=')
+check(['none', '0', '', '', "['']"])
+
+test.run(arguments='shared=x11,ical')
+check(['ical,x11', '1', 'ical x11', 'ical x11',
+ "['ical x11']"])
+
+test.run(arguments='shared=x11,,ical,,')
+check(['ical,x11', '1', 'ical x11', 'ical x11',
+ "['ical x11']"])
+
+test.run(arguments='shared=GL')
+check(['gl', '0', 'gl', 'gl'])
+
+test.run(arguments='shared=QT,GL')
+check(['gl,qt', '0', 'gl qt', 'gl qt', "['gl qt']"])
+
+
+expect_stderr = """
+scons: *** Error converting option: shared
+Invalid value(s) for option: foo
+""" + test.python_file_line(SConstruct_path, 15)
+
+test.run(arguments='shared=foo', stderr=expect_stderr, status=2)
+
+# be paranoid in testing some more combinations
+
+expect_stderr = """
+scons: *** Error converting option: shared
+Invalid value(s) for option: foo
+""" + test.python_file_line(SConstruct_path, 15)
+
+test.run(arguments='shared=foo,ical', stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Error converting option: shared
+Invalid value(s) for option: foo
+""" + test.python_file_line(SConstruct_path, 15)
+
+test.run(arguments='shared=ical,foo', stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Error converting option: shared
+Invalid value(s) for option: foo
+""" + test.python_file_line(SConstruct_path, 15)
+
+test.run(arguments='shared=ical,foo,x11', stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Error converting option: shared
+Invalid value(s) for option: foo,bar
+""" + test.python_file_line(SConstruct_path, 15)
+
+test.run(arguments='shared=foo,x11,,,bar', stderr=expect_stderr, status=2)
+
+
+
+test.write('SConstruct', """
+from SCons.Variables import ListVariable
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ ListVariable('gpib',
+ 'comment',
+ ['ENET', 'GPIB'],
+ names = ['ENET', 'GPIB', 'LINUX_GPIB', 'NO_GPIB']),
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['gpib']
+Default(env.Alias('dummy', None))
+""")
+
+test.run(stdout=test.wrap_stdout(read_str="ENET,GPIB\n", build_str="""\
+scons: Nothing to be done for `dummy'.
+"""))
+
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the PackageVariable canned Variable type.
+"""
+
+import os.path
+import string
+
+try:
+ True, False
+except NameError:
+ True = (0 == 0)
+ False = (0 != 0)
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
+
+
+
+test.write(SConstruct_path, """\
+from SCons.Variables import PackageVariable
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PackageVariable('x11',
+ 'use X11 installed here (yes = search some places',
+ 'yes'),
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['x11']
+Default(env.Alias('dummy', None))
+""")
+
+test.run()
+check([str(True)])
+
+test.run(arguments='x11=no')
+check([str(False)])
+
+test.run(arguments='x11=0')
+check([str(False)])
+
+test.run(arguments=['x11=%s' % test.workpath()])
+check([test.workpath()])
+
+expect_stderr = """
+scons: *** Path does not exist for option x11: /non/existing/path/
+""" + test.python_file_line(SConstruct_path, 10)
+
+test.run(arguments='x11=/non/existing/path/', stderr=expect_stderr, status=2)
+
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the PathVariable canned option type, with tests for its
+various canned validators.
+"""
+
+import os.path
+import string
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
+
+#### test PathVariable ####
+
+test.subdir('lib', 'qt', ['qt', 'lib'], 'nolib' )
+workpath = test.workpath()
+libpath = os.path.join(workpath, 'lib')
+
+test.write(SConstruct_path, """\
+from SCons.Variables import PathVariable
+
+qtdir = r'%s'
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PathVariable('qtdir', 'where the root of Qt is installed', qtdir),
+ PathVariable('qt_libraries', 'where the Qt library is installed', r'%s'),
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['qtdir']
+print env['qt_libraries']
+print env.subst('$qt_libraries')
+
+Default(env.Alias('dummy', None))
+""" % (workpath, os.path.join('$qtdir', 'lib') ))
+
+qtpath = workpath
+libpath = os.path.join(qtpath, 'lib')
+test.run()
+check([qtpath, os.path.join('$qtdir', 'lib'), libpath])
+
+qtpath = os.path.join(workpath, 'qt')
+libpath = os.path.join(qtpath, 'lib')
+test.run(arguments=['qtdir=%s' % qtpath])
+check([qtpath, os.path.join('$qtdir', 'lib'), libpath])
+
+qtpath = workpath
+libpath = os.path.join(qtpath, 'nolib')
+test.run(arguments=['qt_libraries=%s' % libpath])
+check([qtpath, libpath, libpath])
+
+qtpath = os.path.join(workpath, 'qt')
+libpath = os.path.join(workpath, 'nolib')
+test.run(arguments=['qtdir=%s' % qtpath, 'qt_libraries=%s' % libpath])
+check([qtpath, libpath, libpath])
+
+qtpath = os.path.join(workpath, 'non', 'existing', 'path')
+SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 11)[:-1]
+
+expect_stderr = """
+scons: *** Path for option qtdir does not exist: %(qtpath)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['qtdir=%s' % qtpath], stderr=expect_stderr, status=2)
+
+expect_stderr = """
+scons: *** Path for option qt_libraries does not exist: %(qtpath)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['qt_libraries=%s' % qtpath], stderr=expect_stderr, status=2)
+
+
+
+default_file = test.workpath('default_file')
+default_subdir = test.workpath('default_subdir')
+
+existing_subdir = test.workpath('existing_subdir')
+test.subdir(existing_subdir)
+
+existing_file = test.workpath('existing_file')
+test.write(existing_file, "existing_file\n")
+
+non_existing_subdir = test.workpath('non_existing_subdir')
+non_existing_file = test.workpath('non_existing_file')
+
+
+
+test.write('SConstruct', """\
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PathVariable('X', 'X variable', r'%s', validator=PathVariable.PathAccept),
+ )
+
+env = Environment(variables=opts)
+
+print env['X']
+
+Default(env.Alias('dummy', None))
+""" % default_subdir)
+
+test.run()
+check([default_subdir])
+
+test.run(arguments=['X=%s' % existing_file])
+check([existing_file])
+
+test.run(arguments=['X=%s' % non_existing_file])
+check([non_existing_file])
+
+test.run(arguments=['X=%s' % existing_subdir])
+check([existing_subdir])
+
+test.run(arguments=['X=%s' % non_existing_subdir])
+check([non_existing_subdir])
+
+test.must_not_exist(non_existing_file)
+test.must_not_exist(non_existing_subdir)
+
+
+
+test.write(SConstruct_path, """\
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PathVariable('X', 'X variable', r'%s', validator=PathVariable.PathIsFile),
+ )
+
+env = Environment(variables=opts)
+
+print env['X']
+
+Default(env.Alias('dummy', None))
+""" % default_file)
+
+SConstruct_file_line = test.python_file_line(test.workpath('SConstruct'), 6)[:-1]
+
+expect_stderr = """
+scons: *** File path for option X does not exist: %(default_file)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(status=2, stderr=expect_stderr)
+
+test.write(default_file, "default_file\n")
+
+test.run()
+check([default_file])
+
+expect_stderr = """
+scons: *** File path for option X is a directory: %(existing_subdir)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['X=%s' % existing_subdir], status=2, stderr=expect_stderr)
+
+test.run(arguments=['X=%s' % existing_file])
+check([existing_file])
+
+expect_stderr = """
+scons: *** File path for option X does not exist: %(non_existing_file)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['X=%s' % non_existing_file], status=2, stderr=expect_stderr)
+
+
+
+test.write('SConstruct', """\
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PathVariable('X', 'X variable', r'%s', validator=PathVariable.PathIsDir),
+ )
+
+env = Environment(variables=opts)
+
+print env['X']
+
+Default(env.Alias('dummy', None))
+""" % default_subdir)
+
+expect_stderr = """
+scons: *** Directory path for option X does not exist: %(default_subdir)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(status=2, stderr=expect_stderr)
+
+test.subdir(default_subdir)
+
+test.run()
+check([default_subdir])
+
+expect_stderr = """
+scons: *** Directory path for option X is a file: %(existing_file)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['X=%s' % existing_file],
+ status=2,
+ stderr=expect_stderr)
+
+test.run(arguments=['X=%s' % existing_subdir])
+check([existing_subdir])
+
+expect_stderr = """
+scons: *** Directory path for option X does not exist: %(non_existing_subdir)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['X=%s' % non_existing_subdir],
+ status=2,
+ stderr=expect_stderr)
+
+
+
+test.write('SConstruct', """\
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ PathVariable('X', 'X variable', r'%s', validator=PathVariable.PathIsDirCreate),
+ )
+
+env = Environment(variables=opts)
+
+print env['X']
+
+Default(env.Alias('dummy', None))
+""" % default_subdir)
+
+test.run()
+check([default_subdir])
+
+expect_stderr = """
+scons: *** Path for option X is a file, not a directory: %(existing_file)s
+%(SConstruct_file_line)s
+""" % locals()
+
+test.run(arguments=['X=%s' % existing_file], status=2, stderr=expect_stderr)
+
+test.run(arguments=['X=%s' % existing_subdir])
+check([existing_subdir])
+
+test.run(arguments=['X=%s' % non_existing_subdir])
+check([non_existing_subdir])
+
+test.must_exist(non_existing_subdir)
+
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+import string
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+import string
+env = Environment()
+print env['CC']
+print string.join(env['CCFLAGS'])
+Default(env.Alias('dummy', None))
+""")
+test.run()
+cc, ccflags = string.split(test.stdout(), '\n')[1:3]
+
+test.write('SConstruct', """
+import string
+
+# test validator. Change a key and add a new one to the environment
+def validator(key, value, environ):
+ environ[key] = "v"
+ environ["valid_key"] = "v"
+
+
+def old_converter (value):
+ return "old_converter"
+
+def new_converter (value, env):
+ return "new_converter"
+
+
+opts = Variables('custom.py')
+opts.Add('RELEASE_BUILD',
+ 'Set to 1 to build a release build',
+ 0,
+ None,
+ int)
+
+opts.Add('DEBUG_BUILD',
+ 'Set to 1 to build a debug build',
+ 1,
+ None,
+ int)
+
+opts.Add('CC',
+ 'The C compiler')
+
+opts.Add('VALIDATE',
+ 'An option for testing validation',
+ "notset",
+ validator,
+ None)
+
+opts.Add('OLD_CONVERTER',
+ 'An option for testing converters that take one parameter',
+ "foo",
+ None,
+ old_converter)
+
+opts.Add('NEW_CONVERTER',
+ 'An option for testing converters that take two parameters',
+ "foo",
+ None,
+ new_converter)
+
+opts.Add('UNSPECIFIED',
+ 'An option with no value')
+
+def test_tool(env):
+ if env['RELEASE_BUILD']:
+ env.Append(CCFLAGS = '-O')
+ if env['DEBUG_BUILD']:
+ env.Append(CCFLAGS = '-g')
+
+
+env = Environment(variables=opts, tools=['default', test_tool])
+
+Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env))
+
+print env['RELEASE_BUILD']
+print env['DEBUG_BUILD']
+print env['CC']
+print string.join(env['CCFLAGS'])
+print env['VALIDATE']
+print env['valid_key']
+
+# unspecified variables should not be set:
+assert not env.has_key('UNSPECIFIED')
+
+# undeclared variables should be ignored:
+assert not env.has_key('UNDECLARED')
+
+# calling Update() should not effect variables that
+# are not declared on the variables object:
+r = env['RELEASE_BUILD']
+opts = Variables()
+opts.Update(env)
+assert env['RELEASE_BUILD'] == r
+
+Default(env.Alias('dummy', None))
+
+""")
+
+def check(expect):
+ result = string.split(test.stdout(), '\n')
+ assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
+
+test.run()
+check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v'])
+
+test.run(arguments='RELEASE_BUILD=1')
+check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v'])
+
+test.run(arguments='RELEASE_BUILD=1 DEBUG_BUILD=0')
+check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v'])
+
+test.run(arguments='CC=not_a_c_compiler')
+check(['0', '1', 'not_a_c_compiler', string.strip(ccflags + ' -g'), 'v', 'v'])
+
+test.run(arguments='UNDECLARED=foo')
+check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v'])
+
+test.run(arguments='CCFLAGS=--taco')
+check(['0', '1', cc, string.strip(ccflags + ' -g'), 'v', 'v'])
+
+test.write('custom.py', """
+DEBUG_BUILD=0
+RELEASE_BUILD=1
+""")
+
+test.run()
+check(['1', '0', cc, string.strip(ccflags + ' -O'), 'v', 'v'])
+
+test.run(arguments='DEBUG_BUILD=1')
+check(['1', '1', cc, string.strip(ccflags + ' -O -g'), 'v', 'v'])
+
+test.run(arguments='-h',
+ stdout = """\
+scons: Reading SConscript files ...
+1
+0
+%s
+%s
+v
+v
+scons: done reading SConscript files.
+Variables settable in custom.py or on the command line:
+
+RELEASE_BUILD: Set to 1 to build a release build
+ default: 0
+ actual: 1
+
+DEBUG_BUILD: Set to 1 to build a debug build
+ default: 1
+ actual: 0
+
+CC: The C compiler
+ default: None
+ actual: %s
+
+VALIDATE: An option for testing validation
+ default: notset
+ actual: v
+
+OLD_CONVERTER: An option for testing converters that take one parameter
+ default: foo
+ actual: old_converter
+
+NEW_CONVERTER: An option for testing converters that take two parameters
+ default: foo
+ actual: new_converter
+
+UNSPECIFIED: An option with no value
+ default: None
+ actual: None
+
+Use scons -H for help about command-line options.
+"""%(cc, ccflags and ccflags + ' -O' or '-O', cc))
+
+# Test saving of variables and multi loading
+#
+test.write('SConstruct', """
+opts = Variables(['custom.py', 'variables.saved'])
+opts.Add('RELEASE_BUILD',
+ 'Set to 1 to build a release build',
+ 0,
+ None,
+ int)
+
+opts.Add('DEBUG_BUILD',
+ 'Set to 1 to build a debug build',
+ 1,
+ None,
+ int)
+
+opts.Add('UNSPECIFIED',
+ 'An option with no value')
+
+env = Environment(variables = opts)
+
+print env['RELEASE_BUILD']
+print env['DEBUG_BUILD']
+
+opts.Save('variables.saved', env)
+""")
+
+# Check the save file by executing and comparing against
+# the expected dictionary
+def checkSave(file, expected):
+ gdict = {}
+ ldict = {}
+ execfile(file, gdict, ldict)
+ assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict)
+
+# First test with no command line variables
+# This should just leave the custom.py settings
+test.run()
+check(['1','0'])
+checkSave('variables.saved', { 'RELEASE_BUILD':1, 'DEBUG_BUILD':0})
+
+# Override with command line arguments
+test.run(arguments='DEBUG_BUILD=3')
+check(['1','3'])
+checkSave('variables.saved', {'RELEASE_BUILD':1, 'DEBUG_BUILD':3})
+
+# Now make sure that saved variables are overridding the custom.py
+test.run()
+check(['1','3'])
+checkSave('variables.saved', {'DEBUG_BUILD':3, 'RELEASE_BUILD':1})
+
+# Load no variables from file(s)
+# Used to test for correct output in save option file
+test.write('SConstruct', """
+opts = Variables()
+opts.Add('RELEASE_BUILD',
+ 'Set to 1 to build a release build',
+ '0',
+ None,
+ int)
+
+opts.Add('DEBUG_BUILD',
+ 'Set to 1 to build a debug build',
+ '1',
+ None,
+ int)
+
+opts.Add('UNSPECIFIED',
+ 'An option with no value')
+
+opts.Add('LISTOPTION_TEST',
+ 'testing list option persistence',
+ 'none',
+ names = ['a','b','c',])
+
+env = Environment(variables = opts)
+
+print env['RELEASE_BUILD']
+print env['DEBUG_BUILD']
+print env['LISTOPTION_TEST']
+
+opts.Save('variables.saved', env)
+""")
+
+# First check for empty output file when nothing is passed on command line
+test.run()
+check(['0','1'])
+checkSave('variables.saved', {})
+
+# Now specify one option the same as default and make sure it doesn't write out
+test.run(arguments='DEBUG_BUILD=1')
+check(['0','1'])
+checkSave('variables.saved', {})
+
+# Now specify same option non-default and make sure only it is written out
+test.run(arguments='DEBUG_BUILD=0 LISTOPTION_TEST=a,b')
+check(['0','0'])
+checkSave('variables.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'})
+
+test.write('SConstruct', """
+opts = Variables('custom.py')
+opts.Add('RELEASE_BUILD',
+ 'Set to 1 to build a release build',
+ 0,
+ None,
+ int)
+
+opts.Add('DEBUG_BUILD',
+ 'Set to 1 to build a debug build',
+ 1,
+ None,
+ int)
+
+opts.Add('CC',
+ 'The C compiler')
+
+opts.Add('UNSPECIFIED',
+ 'An option with no value')
+
+env = Environment(variables=opts)
+
+Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env,sort=cmp))
+
+""")
+
+test.run(arguments='-h',
+ stdout = """\
+scons: Reading SConscript files ...
+scons: done reading SConscript files.
+Variables settable in custom.py or on the command line:
+
+CC: The C compiler
+ default: None
+ actual: %s
+
+DEBUG_BUILD: Set to 1 to build a debug build
+ default: 1
+ actual: 0
+
+RELEASE_BUILD: Set to 1 to build a release build
+ default: 0
+ actual: 1
+
+UNSPECIFIED: An option with no value
+ default: None
+ actual: None
+
+Use scons -H for help about command-line options.
+"""%cc)
+
+test.write('SConstruct', """
+import SCons.Variables
+env1 = Environment(variables = Variables())
+env2 = Environment(variables = SCons.Variables.Variables())
+""")
+
+test.run()
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that we can chdir() to the directory in which an Variables
+file lives by using the __name__ value.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('bin', 'subdir')
+
+test.write('SConstruct', """\
+opts = Variables('../bin/opts.cfg', ARGUMENTS)
+opts.Add('VARIABLE')
+Export("opts")
+SConscript('subdir/SConscript')
+""")
+
+SConscript_contents = """\
+Import("opts")
+env = Environment()
+opts.Update(env)
+print "VARIABLE =", repr(env['VARIABLE'])
+"""
+
+test.write(['bin', 'opts.cfg'], """\
+import os
+import os.path
+os.chdir(os.path.split(__name__)[0])
+execfile('opts2.cfg')
+""")
+
+test.write(['bin', 'opts2.cfg'], """\
+VARIABLE = 'opts2.cfg value'
+""")
+
+test.write(['subdir', 'SConscript'], SConscript_contents)
+
+expect = """\
+VARIABLE = 'opts2.cfg value'
+"""
+
+test.run(arguments = '-q -Q .', stdout=expect)
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the Variables help messages.
+"""
+
+import os.path
+import string
+
+try:
+ True, False
+except NameError:
+ True = (0 == 0)
+ False = (0 != 0)
+
+str_True = str(True)
+str_False = str(False)
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+
+
+workpath = test.workpath()
+qtpath = os.path.join(workpath, 'qt')
+libpath = os.path.join(qtpath, 'lib')
+libdirvar = os.path.join('$qtdir', 'lib')
+
+test.subdir(qtpath)
+test.subdir(libpath)
+
+test.write('SConstruct', """
+from SCons.Variables import BoolVariable, EnumVariable, ListVariable, \
+ PackageVariable, PathVariable
+
+list_of_libs = Split('x11 gl qt ical')
+qtdir = r'%(qtpath)s'
+
+opts = Variables(args=ARGUMENTS)
+opts.AddVariables(
+ BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
+ BoolVariable('profile', 'create profiling informations', 0),
+ EnumVariable('debug', 'debug output and symbols', 'no',
+ allowed_values=('yes', 'no', 'full'),
+ map={}, ignorecase=0), # case sensitive
+ EnumVariable('guilib', 'gui lib to use', 'gtk',
+ allowed_values=('motif', 'gtk', 'kde'),
+ map={}, ignorecase=1), # case insensitive
+ EnumVariable('some', 'some option', 'xaver',
+ allowed_values=('xaver', 'eins'),
+ map={}, ignorecase=2), # make lowercase
+ ListVariable('shared',
+ 'libraries to build as shared libraries',
+ 'all',
+ names = list_of_libs),
+ PackageVariable('x11',
+ 'use X11 installed here (yes = search some places)',
+ 'yes'),
+ PathVariable('qtdir', 'where the root of Qt is installed', qtdir),
+ PathVariable('qt_libraries',
+ 'where the Qt library is installed',
+ r'%(libdirvar)s'),
+ )
+
+env = Environment(variables=opts)
+Help(opts.GenerateHelpText(env))
+
+print env['warnings']
+print env['profile']
+
+Default(env.Alias('dummy', None))
+""" % locals())
+
+
+test.run(arguments='-h',
+ stdout = """\
+scons: Reading SConscript files ...
+%(str_True)s
+%(str_False)s
+scons: done reading SConscript files.
+
+warnings: compilation with -Wall and similiar (yes|no)
+ default: 1
+ actual: %(str_True)s
+
+profile: create profiling informations (yes|no)
+ default: 0
+ actual: %(str_False)s
+
+debug: debug output and symbols (yes|no|full)
+ default: no
+ actual: no
+
+guilib: gui lib to use (motif|gtk|kde)
+ default: gtk
+ actual: gtk
+
+some: some option (xaver|eins)
+ default: xaver
+ actual: xaver
+
+shared: libraries to build as shared libraries
+ (all|none|comma-separated list of names)
+ allowed names: x11 gl qt ical
+ default: all
+ actual: x11 gl qt ical
+
+x11: use X11 installed here (yes = search some places)
+ ( yes | no | /path/to/x11 )
+ default: yes
+ actual: %(str_True)s
+
+qtdir: where the root of Qt is installed ( /path/to/qtdir )
+ default: %(qtpath)s
+ actual: %(qtpath)s
+
+qt_libraries: where the Qt library is installed ( /path/to/qt_libraries )
+ default: %(libdirvar)s
+ actual: %(libpath)s
+
+Use scons -H for help about command-line options.
+""" % locals())
+
+
+
+test.pass_test()
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that an Variables file in a different directory can import
+a module in that directory.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+workpath = test.workpath('')
+
+test.subdir('bin', 'subdir')
+
+test.write('SConstruct', """\
+opts = Variables('../bin/opts.cfg', ARGUMENTS)
+opts.Add('VARIABLE')
+Export("opts")
+SConscript('subdir/SConscript')
+""")
+
+SConscript_contents = """\
+Import("opts")
+env = Environment()
+opts.Update(env)
+print "VARIABLE =", env.get('VARIABLE')
+"""
+
+test.write(['bin', 'opts.cfg'], """\
+import sys
+from local_options import VARIABLE
+""" % locals())
+
+test.write(['bin', 'local_options.py'], """\
+VARIABLE = 'bin/local_options.py'
+""")
+
+test.write(['subdir', 'SConscript'], SConscript_contents)
+
+expect = "VARIABLE = bin/local_options.py\n"
+
+test.run(arguments = '-q -Q .', stdout = expect)
+
+test.pass_test()
""")
import sys
-if sys.platform == 'darwin':
+if sys.platform[:6] == 'darwin':
file_hpp = 'file.cpp.h'
else:
file_hpp = 'file.hpp'
""")
test.run(arguments = ".", stderr=r"""
-scons: \*\*\* Dependency cycle: .*foo1.* -> .*foo3.* -> .*foo2.* -> .*foo1.*
+scons: \*\*\* Found dependency cycle\(s\):
+ .*foo1.* -> .*foo3.* -> .*foo2.* -> .*foo1.*
+ .*foo3.* -> .*foo2.* -> .*foo1.* -> .*foo3.*
+
.*
""", status=2)
--- /dev/null
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that specifying a source file more than once works correctly
+and dos not cause a rebuild.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """\
+def cat(target, source, env):
+ t = open(str(target[0]), 'wb')
+ for s in source:
+ t.write(open(str(s), 'rb').read())
+ t.close()
+env = Environment(BUILDERS = {'Cat' : Builder(action = cat)})
+env.Cat('out.txt', ['f1.in', 'f2.in', 'f1.in'])
+""")
+
+test.write('f1.in', "f1.in\n")
+test.write('f2.in', "f2.in\n")
+
+test.run(arguments='--debug=explain .')
+
+test.must_match('out.txt', "f1.in\nf2.in\nf1.in\n")
+
+test.up_to_date(options='--debug=explain', arguments='.')
+
+test.pass_test()
expected_stderr_list = [
"scons: *** [out.f1] Error 1\n",
- "scons: *** Source `in.f2' not found, needed by target `out.f2'. Stop.\n",
+ "scons: *** Source `in.f2' not found, needed by target `out.f2'.\n",
"scons: *** [out.f3] Error 1\n",
]
# walk of '.' and are already considered up-to-date when we kick off the
# "simultaneous" builds of the output (target) files.
-test.run(arguments = '-j7 .', status = 2, stderr = None)
+test.run(arguments = '-j7 -k .', status = 2, stderr = None)
missing = []
for es in expected_stderr_list:
test.subdir('dir2')
test.write('SConstruct', """\
-opts = Options()
-opts.AddOptions(
- BoolOption('view_all_dependencies', 'View all dependencies', True),
- BoolOption('duplicate', 'Duplicate sources to variant dir', True)
+opts = Variables()
+opts.AddVariables(
+ BoolVariable('view_all_dependencies', 'View all dependencies', True),
+ BoolVariable('duplicate', 'Duplicate sources to variant dir', True)
)
env = Environment(options=opts)
# by the packaging build.
copyright_marker = '__' + 'COPYRIGHT' + '__'
-copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008'
-
fmt = '(%s|Copyright \\(c\\) %s The SCons Foundation)\n'
-copyright_line = fmt % (copyright_marker, copyright_years)
+copyright_line = fmt % (copyright_marker, TestSCons.copyright_years)
# Windows may or may not print a line for the script version
# depending on whether it's invoked through scons.py or scons.bat.
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Verify that the -d option is ignored.
+"""
+
import TestSCons
test = TestSCons.TestSCons()
-test.pass_test() #XXX Short-circuit until this is supported.
+test.write('SConstruct', "")
+
+test.run(arguments = '-d .',
+ stderr = "Warning: ignoring -d option\n")
+
+test.pass_test()
+
+#
test.subdir('subdir')
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Verify that the -e and --environment-overrides options are ignored.
+"""
+
import TestSCons
-import string
-import sys
test = TestSCons.TestSCons()
test.write('SConstruct', "")
test.run(arguments = '-e .',
- stderr = "Warning: the -e option is not yet implemented\n")
+ stderr = "Warning: ignoring -e option\n")
test.run(arguments = '--environment-overrides .',
- stderr = "Warning: the --environment-overrides option is not yet implemented\n")
+ stderr = "Warning: ignoring --environment-overrides option\n")
test.pass_test()
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-import copy
+"""
+Verify behavior of the -H and --help-options options.
+"""
+
+import re
import string
-import sys
import TestSCons
# Validate that the help output lists the options in case-insensitive
# alphabetical order.
-lines = string.split(test.stdout(), '\n')
+
+# Don't include in the sorted comparison the options that are ignored
+# for compatibility. They're all printed at the top of the list.
+ignored_re = re.compile('.*Ignored for compatibility\\.\n', re.S)
+stdout = ignored_re.sub('', test.stdout())
+
+lines = string.split(stdout, '\n')
lines = filter(lambda x: x[:3] == ' -', lines)
lines = map(lambda x: x[3:], lines)
lines = map(lambda x: x[0] == '-' and x[1:] or x, lines)
options = map(lambda x: string.split(x)[0], lines)
options = map(lambda x: x[-1] == ',' and x[:-1] or x, options)
lowered = map(lambda x: string.lower(x), options)
-sorted = copy.copy(lowered)
+sorted = lowered[:]
sorted.sort()
-test.fail_test(lowered != sorted)
+if lowered != sorted:
+ print "lowered =", lowered
+ print "sorted =", sorted
+ test.fail_test()
test.pass_test()
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Verify that the --no-print-directory option is ignored.
+"""
+
import TestSCons
-import string
-import sys
test = TestSCons.TestSCons()
test.write('SConstruct', "")
test.run(arguments = '--no-print-directory .',
- stderr = "Warning: the --no-print-directory option is not yet implemented\n")
+ stderr = "Warning: ignoring --no-print-directory option\n")
test.pass_test()
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Verify that the -w and --print-directory options are ignored.
+"""
+
import TestSCons
-import string
-import sys
test = TestSCons.TestSCons()
test.write('SConstruct', "")
test.run(arguments = '-w .',
- stderr = "Warning: the -w option is not yet implemented\n")
+ stderr = "Warning: ignoring -w option\n")
test.run(arguments = '--print-directory .',
- stderr = "Warning: the --print-directory option is not yet implemented\n")
+ stderr = "Warning: ignoring --print-directory option\n")
test.pass_test()
test.write('Tfile.in', "Tfile.in\n")
expect_stdout = test.wrap_stdout("""\
-Taskmaster: '.': children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
- waiting on unfinished children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
-Taskmaster: 'SConstruct': evaluating SConstruct
-Taskmaster: 'Tfile.in': evaluating Tfile.in
-Taskmaster: 'Tfile.mid': children:
- ['Tfile.in']
- evaluating Tfile.mid
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state '.'> and its children:
+Taskmaster: <no_state 'SConstruct'>
+Taskmaster: <no_state 'Tfile.in'>
+Taskmaster: <no_state 'Tfile.mid'>
+Taskmaster: <no_state 'Tfile.out'>
+Taskmaster: Considering node <no_state 'SConstruct'> and its children:
+Taskmaster: Evaluating <pending 'SConstruct'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.in'> and its children:
+Taskmaster: Evaluating <pending 'Tfile.in'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.mid'> and its children:
+Taskmaster: <up_to_date 'Tfile.in'>
+Taskmaster: Evaluating <pending 'Tfile.mid'>
Copy("Tfile.mid", "Tfile.in")
-Taskmaster: 'Tfile.out': children:
- ['Tfile.mid']
- evaluating Tfile.out
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.out'> and its children:
+Taskmaster: <executed 'Tfile.mid'>
+Taskmaster: Evaluating <pending 'Tfile.out'>
Copy("Tfile.out", "Tfile.mid")
-Taskmaster: '.': children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
- evaluating .
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <pending '.'> and its children:
+Taskmaster: <up_to_date 'SConstruct'>
+Taskmaster: <up_to_date 'Tfile.in'>
+Taskmaster: <executed 'Tfile.mid'>
+Taskmaster: <executed 'Tfile.out'>
+Taskmaster: Evaluating <pending '.'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: No candidate anymore.
+
""")
test.run(arguments='--taskmastertrace=- .', stdout=expect_stdout)
test.run(arguments='--taskmastertrace=trace.out .', stdout=expect_stdout)
expect_trace = """\
-Taskmaster: '.': children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
- waiting on unfinished children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
-Taskmaster: 'SConstruct': evaluating SConstruct
-Taskmaster: 'Tfile.in': evaluating Tfile.in
-Taskmaster: 'Tfile.mid': children:
- ['Tfile.in']
- evaluating Tfile.mid
-Taskmaster: 'Tfile.out': children:
- ['Tfile.mid']
- evaluating Tfile.out
-Taskmaster: '.': children:
- ['SConstruct', 'Tfile.in', 'Tfile.mid', 'Tfile.out']
- evaluating .
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state '.'> and its children:
+Taskmaster: <no_state 'SConstruct'>
+Taskmaster: <no_state 'Tfile.in'>
+Taskmaster: <no_state 'Tfile.mid'>
+Taskmaster: <no_state 'Tfile.out'>
+Taskmaster: Considering node <no_state 'SConstruct'> and its children:
+Taskmaster: Evaluating <pending 'SConstruct'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.in'> and its children:
+Taskmaster: Evaluating <pending 'Tfile.in'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.mid'> and its children:
+Taskmaster: <up_to_date 'Tfile.in'>
+Taskmaster: Evaluating <pending 'Tfile.mid'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <no_state 'Tfile.out'> and its children:
+Taskmaster: <executed 'Tfile.mid'>
+Taskmaster: Evaluating <pending 'Tfile.out'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: Considering node <pending '.'> and its children:
+Taskmaster: <up_to_date 'SConstruct'>
+Taskmaster: <up_to_date 'Tfile.in'>
+Taskmaster: <executed 'Tfile.mid'>
+Taskmaster: <executed 'Tfile.out'>
+Taskmaster: Evaluating <pending '.'>
+
+Taskmaster: Looking for a node to evaluate
+Taskmaster: No candidate anymore.
+
"""
test.must_match('trace.out', expect_trace)
""" % locals()
test.run(arguments = "--tree=all Foo.xxx")
-if string.find(test.stdout(), tree1) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree1) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
""" % locals()
test.run(arguments = "--tree=all,prune .")
-if string.find(test.stdout(), tree3) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree3) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
test.run(arguments = "--tree=prune .")
-if string.find(test.stdout(), tree3) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree3) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
test.run(arguments = '-c Foo.xxx')
test.run(arguments = "--no-exec --tree=all,status Foo.xxx")
-if string.find(test.stdout(), tree4) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree4) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
test.run(arguments = "--no-exec --tree=status Foo.xxx")
-if string.find(test.stdout(), tree4) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree4) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
test.run(arguments = "--tree=all Foo.xxx",
status = 2,
stderr = None)
-if string.find(test.stdout(), tree1) == -1:
- sys.stdout.write('Did not find expected tree in the following output:\n')
+if string.count(test.stdout(), tree1) != 1:
+ sys.stdout.write('Did not find expected tree (or found duplicate) in the following output:\n')
sys.stdout.write(test.stdout())
test.fail_test()
EXESUFFIX='.exe')
env.AppendENVPath('PATH', '.')
l = env.Library( 'util.lib', 'util.c' )
-p = env.Program( 'test.exe', 'main.c', LIBS=l )
+p = env.Program( 'test_tree_lib.exe', 'main.c', LIBS=l )
env.Command( 'foo.h', p, '$SOURCE > $TARGET')
""")
""")
expect = """
- +-test.exe
+ +-test_tree_lib.exe
+-main.obj
+-util.lib
+-util.obj
test.symlink('nonexistent', 'foo.h')
expect = """\
-scons: *** Source `foo.h' not found, needed by target `%s'. Stop.
+scons: *** Implicit dependency `foo.h' not found, needed by target `%s'. Stop.
"""% foo_obj
test.run(arguments = '.', status = 2, stderr = expect)