3 .\" Permission is hereby granted, free of charge, to any person obtaining
4 .\" a copy of this software and associated documentation files (the
5 .\" "Software"), to deal in the Software without restriction, including
6 .\" without limitation the rights to use, copy, modify, merge, publish,
7 .\" distribute, sublicense, and/or sell copies of the Software, and to
8 .\" permit persons to whom the Software is furnished to do so, subject to
9 .\" the following conditions:
11 .\" The above copyright notice and this permission notice shall be included
12 .\" in all copies or substantial portions of the Software.
14 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
15 .\" KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
16 .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 .\" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 .\" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 .\" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 .\" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 .\" __FILE__ __REVISION__ __DATE__ __DEVELOPER__
24 .\" ES - Example Start - indents and turns off line fill
29 .\" EE - Example End - ends indent and turns line fill back on
34 .TH SCONS 1 "October 2004"
36 scons \- a software construction tool
52 utility builds software (or other files) by determining which
53 component pieces must be rebuilt and executing the necessary commands to
58 searches for a file named
63 (in that order) in the current directory and reads its
64 configuration from the first file found.
65 An alternate file name may be
72 file can specify subsidiary
73 configuration files using the
77 these subsidiary files are named
79 although any name may be used.
80 (Because of this naming convention,
81 the term "SConscript files"
82 is sometimes used to refer
86 regardless of actual file name.)
88 The configuration files
89 specify the target files to be built, and
90 (optionally) the rules to build those targets. Reasonable default
91 rules exist for building common software components (executable
92 programs, object files, libraries), so that for most software
93 projects, only the target and input files need be specified.
96 reads and executes the SConscript files as Python scripts,
97 so you may use normal Python scripting capabilities
98 (such as flow control, data manipulation, and imported Python libraries)
99 to handle complicated build situations.
101 however, reads and executes all of the SConscript files
103 it begins building any targets.
104 To make this obvious,
106 prints the following messages about what it is doing:
110 scons: Reading SConscript files ...
111 scons: done reading SConscript files.
112 scons: Building targets ...
114 scons: done building targets.
119 (everything except the line that reads "cp foo.in foo.out")
120 may be suppressed using the
125 does not automatically propagate
126 the external environment used to execute
128 to the commands used to build target files.
129 This is so that builds will be guaranteed
130 repeatable regardless of the environment
131 variables set at the time
134 This also means that if the compiler or other commands
135 that you want to use to build your target files
136 are not in standard system locations,
138 will not find them unless
139 you explicitly set the PATH
140 to include those locations.
141 Whenever you create an
143 construction environment,
144 you can propagate the value of PATH
145 from your external environment as follows:
149 env = Environment(ENV = {'PATH' : os.environ['PATH']})
153 can scan known input files automatically for dependency
154 information (for example, #include statements
155 in C or C++ files) and will rebuild dependent files appropriately
156 whenever any "included" input file changes.
159 ability to define new scanners for unknown input file types.
162 knows how to fetch files automatically from
163 SCCS or RCS subdirectories
164 using SCCS, RCS or BitKeeper.
167 is normally executed in a top-level directory containing a
169 file, optionally specifying
170 as command-line arguments
171 the target file or files to be built.
173 By default, the command
179 will build all target files in or below the current directory.
180 Explicit default targets
181 (to be built when no targets are specified on the command line)
182 may be defined the SConscript file(s)
185 function, described below.
189 targets are specified in the SConscript file(s),
190 all target files in or below the current directory
191 may be built by explicitly specifying
192 the current directory (.)
193 as a command-line target:
199 Building all target files,
200 including any files outside of the current directory,
201 may be specified by supplying a command-line target
202 of the root directory (on POSIX systems):
208 or the path name(s) of the volume(s) in which all the targets
209 should be built (on Windows systems):
215 To build only specific targets,
216 supply them as command-line arguments:
222 in which case only the specified targets will be built
223 (along with any derived files on which they depend).
225 Specifying "cleanup" targets in SConscript files is not
228 flag removes all files
229 necessary to build the specified target:
235 to remove all target files, or:
238 scons -c build export
241 to remove target files under build and export.
242 Additional files or directories to remove can be specified using the
245 A subset of a hierarchical tree may be built by
246 remaining at the top-level directory (where the
248 file lives) and specifying the subdirectory as the target to be
255 or by changing directory and invoking scons with the
257 option, which traverses up the directory
258 hierarchy until it finds the
260 file, and then builds
261 targets relatively to the current subdirectory:
269 supports building multiple targets in parallel via a
271 option that takes, as its argument, the number
272 of simultaneous tasks that may be spawned:
278 builds four targets in parallel, for example.
281 can maintain a cache of target (derived) files that can
282 be shared between multiple builds. When caching is enabled in a
283 SConscript file, any target files built by
286 to the cache. If an up-to-date target file is found in the cache, it
287 will be retrieved from the cache instead of being rebuilt locally.
288 Caching behavior may be disabled and controlled in other ways by the
290 .BR --cache-disable ,
293 command-line options. The
295 option is useful to prevent multiple builds
296 from trying to update the cache simultaneously.
298 Values of variables to be passed to the SConscript file(s)
299 may be specified on the command line:
305 These variables are available in SConscript files
306 through the ARGUMENTS dictionary,
307 and can be used in the SConscript file(s) to modify
308 the build in any way:
311 if ARGUMENTS.get('debug', 0):
312 env = Environment(CCFLAGS = '-g')
317 The command-line variable arguments are also available
319 indexed by their order on the command line.
320 This allows you to process them in order rather than by name,
322 ARGLIST[0] returns a tuple
323 containing (argname, argvalue).
324 A Python exception is thrown if you
325 try to access a list member that
329 requires Python version 1.5.2 or later.
330 There should be no other dependencies or requirements to run
333 .\" The following paragraph reflects the default tool search orders
334 .\" currently in SCons/Tool/__init__.py. If any of those search orders
335 .\" change, this documentation should change, too.
338 knows how to search for available programming tools
342 searches in order for the
343 Microsoft Visual C++ tools,
344 the MinGW tool chain,
345 the Intel compiler tools,
346 and the PharLap ETS compiler.
349 searches in order for the
352 and the Microsoft Visual C++ tools,
353 On SGI IRIX, IBM AIX, Hewlett Packard HP-UX, and Sun Solaris systems,
355 searches for the native compiler tools
356 (MIPSpro, Visual Age, aCC, and Forte tools respectively)
357 and the GCC tool chain.
358 On all other platforms,
359 including POSIX (Linux and UNIX) platforms,
362 for the GCC tool chain,
363 the Microsoft Visual C++ tools,
364 and the Intel compiler tools.
365 You may, of course, override these default values
366 by appropriate configuration of
367 Environment construction variables.
372 supports the same command-line options as GNU
374 and many of those supported by
379 Ignored for compatibility with non-GNU versions of
383 -c, --clean, --remove
384 Clean up by removing all target files for which a construction
385 command is specified.
386 Also remove any files or directories associated to the construction command
387 using the Clean() function.
390 --cache-disable, --no-cache
391 Disable the derived-file caching specified by
394 will neither retrieve files from the cache
395 nor copy files to the cache.
398 --cache-force, --cache-populate
401 populate a cache by copying any already-existing, up-to-date
402 derived files to the cache,
403 in addition to files built by this invocation.
404 This is useful to populate a new cache with
405 all the current derived files,
406 or to add to the cache any derived files
407 recently built with caching disabled via the
415 and retrieving a derived file from the cache,
417 that would have been executed to build the file,
418 instead of the usual report,
419 "Retrieved `file' from cache."
420 This will produce consistent output for build logs,
421 regardless of whether a target
422 file was rebuilt or retrieved from the cache.
426 This specifies how the
428 call should use or generate the
429 results of configuration tests.
430 The option should be specified from
431 among the following choices:
435 scons will use its normal dependency mechanisms
436 to decide if a test must be rebuilt or not.
437 This saves time by not running the same configuration tests
438 every time you invoke scons,
439 but will overlook changes in system header files
440 or external commands (such as compilers)
441 if you don't specify those dependecies explicitly.
442 This is the default behavior.
446 If this option is specified,
447 all configuration tests will be re-run
448 regardless of whether the
449 cached results are out of date.
450 This can be used to explicitly
451 force the configuration tests to be updated
452 in response to an otherwise unconfigured change
453 in a system header file or compiler.
457 If this option is specified,
458 no configuration tests will be rerun
459 and all results will be taken from cache.
460 Note that scons will still consider it an error
461 if --config=cache is specified
462 and a necessary test does not
463 yet have any results in the cache.
466 .RI "-C" " directory" ", --directory=" directory
467 Change to the specified
469 before searching for the
474 file, or doing anything
477 options are interpreted
478 relative to the previous one, and the right-most
480 option wins. (This option is nearly
482 .BR "-f directory/SConstruct" ,
483 except that it will search for
488 in the specified directory.)
492 .\" Display dependencies while building target files. Useful for
493 .\" figuring out why a specific file is being rebuilt, as well as
494 .\" general debugging of the build process.
498 Works exactly the same way as the
500 option except for the way default targets are handled.
501 When this option is used and no targets are specified on the command line,
502 all default targets are built, whether or not they are below the current
507 Debug the build process.
509 specifies what type of debugging:
513 Print a count of how many objects are created
514 of the various classes used internally by SCons.
515 This only works when run under Python 2.1 or later.
519 Print the dependency tree
520 after each top-level target is built. This prints out only derived files.
524 Instruct the scanner that searches for libraries
525 to print a message about each potential library
526 name it is searching for,
527 and about the actual libraries it finds.
531 Print the include tree after each top-level target is built.
532 This is generally used to find out what files are included by the sources
533 of a given derived file:
536 $ scons --debug=includes foo.o
541 Prints how much memory SCons uses
542 before and after reading the SConscript files
543 and before and after building.
547 Prints a list of the various objects
548 of the various classes used internally by SCons.
549 This only works when run under Python 2.1 or later.
553 Re-run SCons under the control of the
560 Print the raw command line used to build each target
561 before the construction environment variables are substituted.
562 Also shows which targets are being built by this command.
563 Output looks something like this:
565 $ scons --debug=presub
566 Building myprog.o with action(s):
567 $SHCC $SHCCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES
573 Prints an internal Python stack trace
574 when encountering an otherwise unexplained error.
578 Prints various time profiling information: the time spent
579 executing each build command, the total build time, the total time spent
580 executing build commands, the total time spent executing SConstruct and
581 SConscript files, and the total time spent executing SCons itself.
585 Print the dependency tree
586 after each top-level target is built. This prints out the complete
587 dependency tree including implicit dependencies and ignored
591 .\" -e, --environment-overrides
592 .\" Variables from the execution environment override construction
593 .\" variables from the SConscript files.
596 .RI -f " file" ", --file=" file ", --makefile=" file ", --sconstruct=" file
599 as the initial SConscript file.
603 Print a local help message for this build, if one is defined in
604 the SConscript file(s), plus a line that describes the
606 option for command-line option help. If no local help message
607 is defined, prints the standard help message about command-line
608 options. Exits after displaying the appropriate message.
612 Print the standard help message about command-line options and
617 Ignore all errors from commands executed to rebuild files.
620 .RI -I " directory" ", --include-dir=" directory
624 imported Python modules. If several
627 are used, the directories are searched in the order specified.
631 Cache implicit dependencies. This can cause
633 to miss changes in the implicit dependencies in cases where a new implicit
634 dependency is added earlier in the implicit dependency search path
635 (e.g. CPPPATH) than a current implicit dependency with the same name.
638 --implicit-deps-changed
639 Force SCons to ignore the cached implicit dependencies. This causes the
640 implicit dependencies to be rescanned and recached. This implies
641 .BR --implicit-cache .
644 --implicit-deps-unchanged
645 Force SCons to ignore changes in the implicit dependencies.
646 This causes cached implicit dependencies to always be used.
648 .BR --implicit-cache .
651 .RI -j " N" ", --jobs=" N
652 Specifies the number of jobs (commands) to run simultaneously.
653 If there is more than one
655 option, the last one is effective.
659 .\" is specified without an argument,
661 .\" will not limit the number of
662 .\" simultaneous jobs.
666 Continue as much as possible after an error. The target that
667 failed and those that depend on it will not be remade, but other
668 targets specified on the command line will still be processed.
671 .\" .RI -l " N" ", --load-average=" N ", --max-load=" N
672 .\" No new jobs (commands) will be started if
673 .\" there are other jobs running and the system load
674 .\" average is at least
676 .\" (a floating-point number).
679 .RI --duplicate= ORDER
680 There are three ways to duplicate files in a build tree: hard links,
681 soft (symbolic) links and copies. The default behaviour of SCons is to
682 prefer hard links to soft links to copies. You can specify different
683 behaviours with this option.
693 SCons will attempt to duplicate files using
694 the mechanisms in the specified order.
699 .\" List derived files (targets, dependencies) that would be built,
700 .\" but do not build them.
701 .\" [XXX This can probably go away with the right
702 .\" combination of other options. Revisit this issue.]
706 .\" List derived files that would be built, with the actions
707 .\" (commands) that build them. Does not build the files.
708 .\" [XXX This can probably go away with the right
709 .\" combination of other options. Revisit this issue.]
713 .\" List derived files that would be built, plus where the file is
714 .\" defined (file name and line number). Does not build the files.
715 .\" [XXX This can probably go away with the right
716 .\" combination of other options. Revisit this issue.]
720 Ignored for compatibility with non-GNU versions of
724 .RI --max-drift= SECONDS
725 Set the maximum expected drift in the modification time of files to
727 This value determines how old a file must be before its content signature
728 is cached. The default value is 2 days, which means a file must have a
729 modification time of at least two days ago in order to have its content
730 signature cached. A negative value means to never cache the content
731 signature and to ignore the cached value if there already is one. A value
732 of 0 means to always cache the signature, no matter how old the file is.
735 -n, --just-print, --dry-run, --recon
736 No execute. Print the commands that would be executed to build
737 any out-of-date target files, but do not execute the commands.
740 .\" .RI -o " file" ", --old-file=" file ", --assume-old=" file
744 .\" not rebuild anything due to changes in the contents of
747 .\" .RI --override " file"
748 .\" Read values to override specific build environment variables
749 .\" from the specified
753 .\" Print the data base (construction environments,
754 .\" Builder and Scanner objects) that are defined
755 .\" after reading the SConscript files.
756 .\" After printing, a normal build is performed
757 .\" as usual, as specified by other command-line options.
758 .\" This also prints version information
763 .\" To print the database without performing a build do:
771 Run SCons under the Python profiler
772 and save the results in the specified
774 The results may be analyzed using the Python
778 Do not run any commands, or print anything. Just return an exit
779 status that is zero if the specified targets are already up to
780 date, non-zero otherwise.
783 Quiets SCons status messages about
784 reading SConscript files,
786 and entering directories.
787 Commands that are executed
788 to rebuild target files are still printed.
791 .\" -r, -R, --no-builtin-rules, --no-builtin-variables
792 .\" Clear the default construction variables. Construction
793 .\" environments that are created will be completely empty.
797 Build dependencies in a random order. This is useful when
798 building multiple trees simultaneously with caching enabled,
799 to prevent multiple builds from simultaneously trying to build
800 or retrieve the same target files.
803 -s, --silent, --quiet
804 Silent. Do not print commands that are executed to rebuild
806 Also suppresses SCons status messages.
809 -S, --no-keep-going, --stop
810 Ignored for compatibility with GNU
815 Ignored for compatibility with GNU
817 (Touching a file to make it
818 appear up-to-date is unnecessary when using
822 -u, --up, --search-up
823 Walks up the directory structure until an
828 file is found, and uses that
829 as the top of the directory tree.
830 If no targets are specified on the command line,
831 only targets at or below the
832 current directory will be built.
836 Works exactly the same way as the
838 option except for the way default targets are handled.
839 When this option is used and no targets are specified on the command line,
840 all default targets that are defined in the SConscript(s) in the current
841 directory are built, regardless of what directory the resultant targets end
848 version, copyright information,
849 list of authors, and any other relevant information.
853 -w, --print-directory
854 Print a message containing the working directory before and
855 after other processing.
858 .RI --warn= type ", --warn=no-" type
859 Enable or disable warnings.
861 specifies the type of warnings to be enabled or disabled:
864 --warn=all, --warn=no-all
865 Enables or disables all warnings.
868 --warn=dependency, --warn=no-dependency
869 Enables or disables warnings about dependencies.
870 These warnings are disabled by default.
873 --warn=deprecated, --warn=no-deprecated
874 Enables or disables warnings about use of deprecated features.
875 These warnings are enabled by default.
878 --warn=missing-sconscript, --warn=no-missing-sconscript
879 Enables or disables warnings about missing SConscript files.
880 These warnings are enabled by default.
884 Turn off -w, even if it was turned on implicitly.
887 .\" .RI --write-filenames= file
888 .\" Write all filenames considered into
892 .\" .RI -W " file" ", --what-if=" file ", --new-file=" file ", --assume-new=" file
893 .\" Pretend that the target
896 .\" modified. When used with the
899 .\" show you what would be rebuilt if you were to modify that file.
905 .\" --warn-undefined-variables
906 .\" Warn when an undefined variable is referenced.
909 .RI -Y " repository" ", --repository=" repository
910 Search the specified repository for any input and target
911 files not found in the local directory hierarchy. Multiple
913 options may specified, in which case the
914 repositories are searched in the order specified.
916 .SH CONFIGURATION FILE REFERENCE
917 .\" .SS Python Basics
918 .\" XXX Adding this in the future would be a help.
919 .SS Construction Environments
920 A construction environment is the basic means by which the SConscript
921 files communicate build information to
923 A new construction environment is created using the
931 By default, a new construction environment is
932 initialized with a set of builder methods
933 and construction variables that are appropriate
934 for the current platform.
935 An optional platform keyword argument may be
936 used to specify that an environment should
937 be initialized for a different platform:
940 env = Environment(platform = 'cygwin')
941 env = Environment(platform = 'os2')
942 env = Environment(platform = 'posix')
943 env = Environment(platform = 'win32')
946 Specifying a platform initializes the appropriate
947 construction variables in the environment
948 to use and generate file names with prefixes
949 and suffixes appropriate for the platform.
955 variable from the user's external environment
956 to the construction environment's
959 This is so that any executed commands
960 that use sockets to connect with other systems
961 (such as fetching source files from
962 external CVS repository specifications like
963 .BR :pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons )
964 will work on Win32 systems.
966 The platform argument may be function or callable object,
967 in which case the Environment() method
968 will call the specified argument to update
969 the new construction environment:
972 def my_platform(env):
975 env = Environment(platform = my_platform)
978 Additionally, a specific set of tools
979 with which to initialize the environment
980 may specified as an optional keyword argument:
983 env = Environment(tools = ['msvc', 'lex'])
986 Non-built-in tools may be specified using the toolpath argument:
989 env = Environment(tools = ['default', 'foo'], toolpath = ['tools'])
992 This looks for a tool specification in tools/foo.py (as well as
993 using the ordinary default tools for the platform). foo.py should
994 have two functions: generate(env, **kw) and exists(env).
998 modifies the passed in environment
999 to set up variables so that the tool
1001 it may use any keyword arguments
1002 that the user supplies (see below)
1003 to vary its initialization.
1006 function should return a true
1007 value if the tool is available.
1008 Tools in the toolpath are used before
1009 any of the built-in ones. For example, adding gcc.py to the toolpath
1010 would override the built-in gcc tool.
1012 The elements of the tools list may also
1013 be functions or callable objects,
1014 in which case the Environment() method
1015 will call the specified elements
1016 to update the new construction environment:
1020 env['XYZZY'] = 'xyzzy'
1022 env = Environment(tools = [my_tool])
1025 The individual elements of the tools list
1026 may also themselves be two-element lists of the form
1027 .RI ( toolname ", " kw_dict ).
1028 SCons searches for the
1030 specification file as described above, and
1033 which must be a dictionary, as keyword arguments to the tool's
1038 function can use the arguments to modify the tool's behavior
1039 by setting up the environment in different ways
1040 or otherwise changing its initialization.
1043 # in tools/my_tool.py:
1044 def generate(env, **kw):
1045 # Sets MY_TOOL to the value of keyword argument 'arg1' or 1.
1046 env['MY_TOOL'] = kw.get('arg1', '1')
1051 env = Environment(tools = ['default', ('my_tool', {'arg1': 'abc'})],
1055 The tool definition (i.e. my_tool()) can use the PLATFORM variable from
1056 the environment it receives to customize the tool for different platforms.
1058 If no tool list is specified, then SCons will auto-detect the installed
1059 tools using the PATH variable in the ENV construction variable and the
1060 platform name when the Environment is constructed. Changing the PATH
1061 variable after the Environment is constructed will not cause the tools to
1064 SCons supports the following tool specifications out of the box:
1137 Additionally, there is a "tool" named
1139 which configures the
1140 environment with a default set of tools for the current platform.
1142 On posix and cygwin platforms
1143 the GNU tools (e.g. gcc) are preferred by SCons,
1144 on win32 the Microsoft tools (e.g. msvc)
1145 followed by MinGW are preferred by SCons,
1146 and in OS/2 the IBM tools (e.g. icc) are preferred by SCons.
1150 Build rules are specified by calling a construction
1151 environment's builder methods.
1152 The arguments to the builder methods are
1154 (a list of target files)
1157 (a list of source files).
1159 Because long lists of file names
1160 can lead to a lot of quoting,
1165 and a same-named environment method
1166 that split a single string
1167 into a list, separated on
1168 strings of white-space characters.
1169 (These are similar to the
1170 string.split() method
1171 from the standard Python library,
1172 but work even if the input isn't a string.)
1174 Like all Python arguments,
1175 the target and source arguments to a builder method
1176 can be specified either with or without
1177 the "target" and "source" keywords.
1178 When the keywords are omitted,
1179 the target is first,
1180 followed by the source.
1181 The following are equivalent examples of calling the Program builder method:
1184 env.Program('bar', ['bar.c', 'foo.c'])
1185 env.Program('bar', Split('bar.c foo.c'))
1186 env.Program('bar', env.Split('bar.c foo.c'))
1187 env.Program(source = ['bar.c', 'foo.c'], target = 'bar')
1188 env.Program(target = 'bar', Split('bar.c foo.c'))
1189 env.Program(target = 'bar', env.Split('bar.c foo.c'))
1190 env.Program('bar', source = string.split('bar.c foo.c'))
1193 When the target shares the same base name
1194 as the source and only the suffix varies,
1195 and if the builder method has a suffix defined for the target file type,
1196 then the target argument may be omitted completely,
1199 will deduce the target file name from
1200 the source file name.
1201 The following examples all build the
1207 (on Windows systems)
1208 from the bar.c source file:
1211 env.Program(target = 'bar', source = 'bar.c')
1212 env.Program('bar', source = 'bar.c')
1213 env.Program(source = 'bar.c')
1214 env.Program('bar.c')
1217 It is possible to override or add construction variables when calling a
1218 builder method by passing additional keyword arguments.
1219 These overridden or added
1220 variables will only be in effect when building the target, so they will not
1221 affect other parts of the build. For example, if you want to add additional
1222 libraries for just one program:
1225 env.Program('hello', 'hello.c', LIBS=['gl', 'glut'])
1228 or generate a shared library with a nonstandard suffix:
1231 env.SharedLibrary('word', 'word.cpp', SHLIBSUFFIX='.ocx')
1234 Although the builder methods defined by
1237 methods of a construction environment object,
1238 they may also be called without an explicit environment:
1241 Program('hello', 'hello.c')
1242 SharedLibrary('word', 'word.cpp')
1246 the methods are called internally using a default construction
1247 environment that consists of the tools and values that
1249 has determined are appropriate for the local system.
1251 All builder methods return a list of Nodes
1252 that represent the target or targets that will be built.
1255 is an internal SCons object
1257 build targets or sources.
1259 The returned Node(s)
1260 can be passed to other builder methods as source(s)
1261 or passed to any SCons function or method
1262 where a filename would normally be accepted.
1263 For example, if it were necessary
1266 flag when compiling one specific object file:
1269 bar_obj_list = env.StaticObject('bar.c', CCFLAGS='-DBAR')
1270 env.Program(source = ['foo.c', bar_obj_list, 'main.c'])
1273 Using a Node in this way
1274 makes for a more portable build
1275 by avoiding having to specify
1276 a platform-specific object suffix
1277 when calling the Program() builder method.
1279 Note that Builder calls will automatically "flatten"
1280 the source and target file lists,
1281 so it's all right to have the bar_obj list
1282 return by the StaticObject() call
1283 in the middle of the source file list.
1284 If you need to manipulate a list of lists returned by Builders
1285 directly using Python,
1286 you can either build the list by hand:
1289 foo = Object('foo.c')
1290 bar = Object('bar.c')
1291 objects = ['begin.o'] + foo + ['middle.o'] + bar + ['end.o']
1292 for object in objects:
1299 to create a list containing just the Nodes,
1300 which may be more convenient:
1303 foo = Object('foo.c')
1304 bar = Object('bar.c')
1305 objects = Flatten(['begin.o', foo, 'middle.o', bar, 'end.o'])
1306 for object in objects:
1310 The path name for a Node's file may be used
1311 by passing the Node to the Python-builtin
1316 bar_obj_list = env.StaticObject('bar.c', CCFLAGS='-DBAR')
1317 print "The path to bar_obj is:", str(bar_obj_list[0])
1320 Note again that because the Builder call returns a list,
1321 we have to access the first element in the list
1322 .B (bar_obj_list[0])
1323 to get at the Node that actually represents
1326 Builder calls support a
1328 keyword argument that
1329 specifies that the Builder's action(s)
1331 after changing directory.
1335 a string or a directory Node,
1336 scons will change to the specified directory.
1339 is not a string or Node
1341 then scons will change to the
1342 target file's directory.
1345 # scons will change to the "sub" subdirectory
1346 # before executing the "cp" command.
1347 env.Command('sub/dir/foo.out', 'sub/dir/foo.in',
1348 "cp dir/foo.in dir/foo.out",
1351 # Because chdir is not a string, scons will change to the
1352 # target's directory ("sub/dir") before executing the
1354 env.Command('sub/dir/foo.out', 'sub/dir/foo.in',
1355 "cp foo.in foo.out",
1359 Note that scons will
1361 automatically modify
1363 construction variables like
1367 when using the chdir
1368 keyword argument--that is,
1369 the expanded file names
1370 will still be relative to
1371 the top-level SConstruct directory,
1372 and consequently incorrect
1373 relative to the chdir directory.
1374 If you use the chdir keyword argument,
1375 you will typically need to supply a different
1381 to use just the filename portion of the
1385 provides the following builder methods:
1387 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1390 Builds a C source file given a lex (.l) or yacc (.y) input file.
1391 The suffix specified by the $CFILESUFFIX construction variable
1393 is automatically added to the target
1394 if it is not already present. Example:
1398 env.CFile(target = 'foo.c', source = 'foo.l')
1400 env.CFile(target = 'bar', source = 'bar.y')
1403 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1406 Builds a C++ source file given a lex (.ll) or yacc (.yy)
1408 The suffix specified by the $CXXFILESUFFIX construction variable
1410 is automatically added to the target
1411 if it is not already present. Example:
1415 env.CXXFile(target = 'foo.cc', source = 'foo.ll')
1417 env.CXXFile(target = 'bar', source = 'bar.yy')
1420 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1423 Builds a .dvi file from a .tex, .ltx or .latex input file.
1424 If the source file suffix is .tex,
1426 will examine the contents of the file;
1431 is found, the file is assumed to be a LaTeX file and
1432 the target is built by invoking the $LATEXCOM command line;
1433 otherwise, the $TEXCOM command line is used.
1434 If the file is a LaTeX file,
1437 builder method will also examine the contents
1440 and invoke the $BIBTEX command line
1444 and will examine the contents
1446 file and re-run the $LATEXCOM command
1447 if the log file says it is necessary.
1450 (hard-coded within TeX itself)
1451 is automatically added to the target
1452 if it is not already present. Examples:
1455 # builds from aaa.tex
1456 env.DVI(target = 'aaa.dvi', source = 'aaa.tex')
1458 env.DVI(target = 'bbb', source = 'bbb.ltx')
1459 # builds from ccc.latex
1460 env.DVI(target = 'ccc.dvi', source = 'ccc.latex')
1463 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1466 Builds a Java archive (.jar) file
1467 from a source tree of .class files.
1468 If the $JARCHDIR value is set, the
1470 command will change to the specified directory using the
1473 If the contents any of the source files begin with the string
1474 .BR Manifest-Version ,
1475 the file is assumed to be a manifest
1476 and is passed to the
1483 env.Jar(target = 'foo.jar', source = 'classes')
1486 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1489 Builds one or more Java class files
1490 from one or more source trees of .java files.
1491 The class files will be placed underneath
1492 the specified target directory.
1493 SCons will parse each source .java file
1495 (including inner classes)
1496 defined within that file,
1497 and from that figure out the
1498 target .class files that will be created.
1499 SCons will also search each Java file
1500 for the Java package name,
1501 which it assumes can be found on a line
1502 beginning with the string
1504 in the first column;
1505 the resulting .class files
1506 will be placed in a directory reflecting
1507 the specified package name.
1511 defining a single public
1514 containing a package name of
1516 will generate a corresponding
1517 .IR sub/dir/Foo.class
1523 env.Java(target = 'classes', source = 'src')
1524 env.Java(target = 'classes', source = ['src1', 'src2'])
1527 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1530 Builds C header and source files for
1531 implementing Java native methods.
1532 The target can be either a directory
1533 in which the header files will be written,
1534 or a header file name which
1535 will contain all of the definitions.
1536 The source can be either the names of .class files,
1537 or the objects returned from the
1541 If the construction variable
1543 is set, either in the environment
1544 or in the call to the
1546 builder method itself,
1547 then the value of the variable
1548 will be stripped from the
1549 beginning of any .class file names.
1554 # builds java_native.h
1555 classes = env.Java(target = 'classdir', source = 'src')
1556 env.JavaH(target = 'java_native.h', source = classes)
1558 # builds include/package_foo.h and include/package_bar.h
1559 env.JavaH(target = 'include',
1560 source = ['package/foo.class', 'package/bar.class'])
1562 # builds export/foo.h and export/bar.h
1563 env.JavaH(target = 'export',
1564 source = ['classes/foo.class', 'classes/bar.class'],
1565 JAVACLASSDIR = 'classes')
1568 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1575 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1578 Builds an output file from an M4 input file.
1579 This uses a default $M4FLAGS value of
1581 which considers all warnings to be fatal
1582 and stops on the first warning
1583 when using the GNU version of m4.
1587 env.M4(target = 'foo.c', source = 'foo.c.m4')
1590 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1593 Builds an output file from a moc input file. Moc input files are either
1594 header files or cxx files. This builder is only available after using the
1595 tool 'qt'. See the QTDIR variable for more information.
1599 env.Moc('foo.h') # generates moc_foo.cc
1600 env.Moc('foo.cpp') # generates foo.moc
1603 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1605 .IP env.MSVSProject()
1606 Builds Microsoft Visual Studio project files.
1607 This builds a Visual Studio project file, based on the version of
1608 Visual Studio that is configured (either the latest installed version,
1609 or the version set by
1611 in the Environment constructor).
1612 For VS 6, it will generate
1616 files, for VS 7, it will
1623 It takes several lists of filenames to be placed into the project
1624 file, currently these are limited to
1625 .B srcs, incs, localincs, resources,
1628 These are pretty self explanatory, but it
1629 should be noted that the 'srcs' list is NOT added to the $SOURCES
1630 environment variable. This is because it represents a list of files
1631 to be added to the project file, not the source used to build the
1632 project file (in this case, the 'source' is the SConscript file used
1633 to call MSVSProject).
1635 In addition to these values (which are all optional, although not
1636 specifying any of them results in an empty project file), the
1637 following values must be specified:
1639 target: The name of the target .dsp or .vcproj file. The correct
1640 suffix for the version of Visual Studio must be used, but the value
1642 env['MSVSPROJECTSUFFIX']
1644 will be defined to the correct value (see example below).
1646 variant: The name of this particular variant. These are typically
1647 things like "Debug" or "Release", but really can be anything you want.
1648 Multiple calls to MSVSProject with different variants are allowed: all
1649 variants will be added to the project file with their appropriate
1650 build targets and sources.
1652 buildtarget: A list of SCons.Node.FS objects which is returned from
1653 the command which builds the target. This is used to tell SCons what
1654 to build when the 'build' button is pressed inside of the IDE.
1659 barsrcs = ['bar.cpp'],
1660 barincs = ['bar.h'],
1661 barlocalincs = ['StdAfx.h']
1662 barresources = ['bar.rc','resource.h']
1663 barmisc = ['bar_readme.txt']
1665 dll = local.SharedLibrary(target = 'bar.dll',
1668 local.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'],
1671 localincs = barlocalincs,
1672 resources = barresources,
1675 variant = 'Release')
1678 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1685 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1688 Builds a Microsoft Visual C++ precompiled header.
1689 Calling this builder method
1690 returns a list of two targets: the PCH as the first element, and the object
1691 file as the second element. Normally the object file is ignored.
1692 This builder method is only
1693 provided when Microsoft Visual C++ is being used as the compiler.
1694 The PCH builder method is generally used in
1695 conjuction with the PCH construction variable to force object files to use
1696 the precompiled header:
1699 env['PCH'] = env.PCH('StdAfx.cpp')[0]
1702 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1705 Builds a .pdf file from a .dvi input file
1706 (or, by extension, a .tex, .ltx, or .latex input file).
1707 The suffix specified by the $PDFSUFFIX construction variable
1709 is added automatically to the target
1710 if it is not already present. Example:
1713 # builds from aaa.tex
1714 env.PDF(target = 'aaa.pdf', source = 'aaa.tex')
1715 # builds bbb.pdf from bbb.dvi
1716 env.PDF(target = 'bbb', source = 'bbb.dvi')
1719 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1721 .IP env.PostScript()
1722 Builds a .ps file from a .dvi input file
1723 (or, by extension, a .tex, .ltx, or .latex input file).
1724 The suffix specified by the $PSSUFFIX construction variable
1726 is added automatically to the target
1727 if it is not already present. Example:
1730 # builds from aaa.tex
1731 env.PostScript(target = 'aaa.ps', source = 'aaa.tex')
1732 # builds bbb.ps from bbb.dvi
1733 env.PostScript(target = 'bbb', source = 'bbb.dvi')
1736 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1739 Builds an executable given one or more object files
1740 or C, C++, D, or Fortran source files.
1741 If any C, C++, D or Fortran source files are specified,
1742 then they will be automatically
1743 compiled to object files using the
1746 see that builder method's description for
1747 a list of legal source file suffixes
1748 and how they are interpreted.
1749 The target executable file prefix
1750 (specified by the $PROGPREFIX construction variable; nothing by default)
1752 (specified by the $PROGSUFFIX construction variable;
1753 by default, .exe on Windows systems, nothing on POSIX systems)
1754 are automatically added to the target if not already present.
1758 env.Program(target = 'foo', source = ['foo.o', 'bar.c', 'baz.f'])
1761 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1764 Builds a Microsoft Visual C++ resource file.
1765 This builder method is only provided
1766 when Microsoft Visual C++ or MinGW is being used as the compiler. The
1770 for MinGW) suffix is added to the target name if no other suffix is given. The source
1771 file is scanned for implicit dependencies as though it were a C file. Example:
1774 env.RES('resource.rc')
1777 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1780 Builds stub and skeleton class files
1782 from Java .class files.
1783 The target is a directory
1784 relative to which the stub
1785 and skeleton class files will be written.
1786 The source can be the names of .class files,
1787 or the objects return from the
1791 If the construction variable
1793 is set, either in the environment
1794 or in the call to the
1796 builder method itself,
1797 then the value of the variable
1798 will be stripped from the
1799 beginning of any .class file names.
1802 classes = env.Java(target = 'classdir', source = 'src')
1803 env.RMIC(target = 'outdir1', source = classes)
1805 env.RMIC(target = 'outdir2',
1806 source = ['package/foo.class', 'package/bar.class'])
1808 env.RMIC(target = 'outdir3',
1809 source = ['classes/foo.class', 'classes/bar.class'],
1810 JAVACLASSDIR = 'classes')
1813 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1815 .IP env.RPCGenClient()
1816 Generates an RPC client stub (_clnt.c) file
1817 from a specified RPC (.x) source file.
1818 Because rpcgen only builds output files
1819 in the local directory,
1820 the command will be executed
1821 in the source file's directory by default.
1824 # Builds src/rpcif_clnt.c
1825 env.RPCGenClient('src/rpcif.x')
1828 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1830 .IP env.RPCGenHeader()
1831 Generates an RPC header (.h) file
1832 from a specified RPC (.x) source file.
1833 Because rpcgen only builds output files
1834 in the local directory,
1835 the command will be executed
1836 in the source file's directory by default.
1839 # Builds src/rpcif.h
1840 env.RPCGenHeader('src/rpcif.x')
1843 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1845 .IP env.RPCGenService()
1846 Generates an RPC server-skeleton (_svc.c) file
1847 from a specified RPC (.x) source file.
1848 Because rpcgen only builds output files
1849 in the local directory,
1850 the command will be executed
1851 in the source file's directory by default.
1854 # Builds src/rpcif_svc.c
1855 env.RPCGenClient('src/rpcif.x')
1858 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1861 Generates an RPC XDR routine (_xdr.c) file
1862 from a specified RPC (.x) source file.
1863 Because rpcgen only builds output files
1864 in the local directory,
1865 the command will be executed
1866 in the source file's directory by default.
1869 # Builds src/rpcif_xdr.c
1870 env.RPCGenClient('src/rpcif.x')
1873 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1875 .IP env.SharedLibrary()
1876 Builds a shared library
1877 (.so on a POSIX system, .dll on WIN32)
1878 given one or more object files
1879 or C, C++, D or Fortran source files.
1880 If any source files are given,
1881 then they will be automatically
1882 compiled to object files.
1883 The static library prefix and suffix (if any)
1884 are automatically added to the target.
1885 The target library file prefix
1886 (specified by the $SHLIBPREFIX construction variable;
1887 by default, lib on POSIX systems, nothing on Windows systems)
1889 (specified by the $SHLIBSUFFIX construction variable;
1890 by default, .dll on Windows systems, .so on POSIX systems)
1891 are automatically added to the target if not already present.
1895 env.SharedLibrary(target = 'bar', source = ['bar.c', 'foo.o'])
1898 On WIN32 systems, the
1900 builder method will always build an import (.lib) library
1901 in addition to the shared (.dll) library,
1902 adding a .lib library with the same basename
1903 if there is not already a .lib file explicitly
1904 listed in the targets.
1906 Any object files listed in the
1908 must have been built for a shared library
1913 will raise an error if there is any mismatch.
1915 On WIN32 systems, specifying "register=1" will cause the dll to be
1916 registered after it is built using REGSVR32. The command that is run
1917 ("regsvr32" by default) is determined by $REGSVR construction
1918 variable, and the flags passed are determined by $REGSVRFLAGS. By
1919 default, $REGSVRFLAGS includes "/s", to prevent dialogs from popping
1920 up and requiring user attention when it is run. If you change
1921 $REGSVRFLAGS, be sure to include "/s". For example,
1924 env.SharedLibrary(target = 'bar',
1925 source = ['bar.cxx', 'foo.obj'],
1930 will register "bar.dll" as a COM object when it is done linking it.
1932 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1934 .IP env.SharedObject()
1935 Builds an object file for
1936 inclusion in a shared library.
1937 Source files must have one of the same set of extensions
1938 specified above for the
1941 On some platforms building a shared object requires additional
1942 compiler options (e.g. -fPIC for gcc) in addition to those needed to build a
1943 normal (static) object, but on some platforms there is no difference between a
1944 shared object and a normal (static) one. When there is a difference, SCons
1945 will only allow shared objects to be linked into a shared library, and will
1946 use a different suffix for shared objects. On platforms where there is no
1947 difference, SCons will allow both normal (static)
1948 and shared objects to be linked into a
1949 shared library, and will use the same suffix for shared and normal
1951 The target object file prefix
1952 (specified by the $SHOBJPREFIX construction variable;
1953 by default, the same as $OBJPREFIX)
1955 (specified by the $SHOBJSUFFIX construction variable)
1956 are automatically added to the target if not already present.
1960 env.SharedObject(target = 'ddd', source = 'ddd.c')
1961 env.SharedObject(target = 'eee.o', source = 'eee.cpp')
1962 env.SharedObject(target = 'fff.obj', source = 'fff.for')
1965 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1967 .IP env.StaticLibrary()
1968 Builds a static library given one or more object files
1969 or C, C++, D or Fortran source files.
1970 If any source files are given,
1971 then they will be automatically
1972 compiled to object files.
1973 The static library prefix and suffix (if any)
1974 are automatically added to the target.
1975 The target library file prefix
1976 (specified by the $LIBPREFIX construction variable;
1977 by default, lib on POSIX systems, nothing on Windows systems)
1979 (specified by the $LIBSUFFIX construction variable;
1980 by default, .lib on Windows systems, .a on POSIX systems)
1981 are automatically added to the target if not already present.
1985 env.StaticLibrary(target = 'bar', source = ['bar.c', 'foo.o'])
1989 Any object files listed in the
1991 must have been built for a static library
1996 will raise an error if there is any mismatch.
1998 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2000 .IP env.StaticObject()
2001 Builds a static object file
2002 from one or more C, C++, D, or Fortran source files.
2003 Source files must have one of the following extensions:
2006 .asm assembly language file
2007 .ASM assembly language file
2019 .F WIN32: Fortran file
2020 POSIX: Fortran file + C pre-processor
2023 .fpp Fortran file + C pre-processor
2024 .FPP Fortran file + C pre-processor
2025 .s assembly language file
2026 .S WIN32: assembly language file
2027 POSIX: assembly language file + C pre-processor
2028 .spp assembly language file + C pre-processor
2029 .SPP assembly language file + C pre-processor
2032 The target object file prefix
2033 (specified by the $OBJPREFIX construction variable; nothing by default)
2035 (specified by the $OBJSUFFIX construction variable;
2036 \.obj on Windows systems, .o on POSIX systems)
2037 are automatically added to the target if not already present.
2041 env.StaticObject(target = 'aaa', source = 'aaa.c')
2042 env.StaticObject(target = 'bbb.o', source = 'bbb.c++')
2043 env.StaticObject(target = 'ccc.obj', source = 'ccc.f')
2046 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2049 Builds a tar archive of the specified files
2051 Unlike most builder methods,
2054 builder method may be called multiple times
2056 each additional call
2057 adds to the list of entries
2058 that will be built into the archive.
2061 env.Tar('src.tar', 'src')
2063 # Create the stuff.tar file.
2064 env.Tar('stuff', ['subdir1', 'subdir2'])
2065 # Also add "another" to the stuff.tar file.
2066 env.Tar('stuff', 'another')
2068 # Set TARFLAGS to create a gzip-filtered archive.
2069 env = Environment(TARFLAGS = '-c -z')
2070 env.Tar('foo.tar.gz', 'foo')
2072 # Also set the suffix to .tgz.
2073 env = Environment(TARFLAGS = '-c -z',
2078 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2080 .IP env.TypeLibrary()
2081 Builds a Windows type library (.tlb) file from and input IDL file
2082 (.idl). In addition, it will build the associated inteface stub and
2083 proxy source files. It names them according to the base name of the .idl file.
2088 env.TypeLibrary(source="foo.idl")
2091 Will create foo.tlb, foo.h, foo_i.c, foo_p.c, and foo_data.c.
2093 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2096 Builds a header file, an implementation file and a moc file from an ui file.
2097 and returns the corresponding nodes in the above order.
2098 This builder is only available after using the tool 'qt'. Note: you can
2099 specify .ui files directly as inputs for Program, Library and SharedLibrary
2100 without using this builder. Using the builder lets you override the standard
2101 naming conventions (be careful: prefixes are always prepended to names of
2102 built files; if you don't want prefixes, you may set them to ``).
2103 See the QTDIR variable for more information.
2107 env.Uic('foo.ui') # -> ['foo.h', 'uic_foo.cc', 'moc_foo.cc']
2108 env.Uic(target = Split('include/foo.h gen/uicfoo.cc gen/mocfoo.cc'),
2109 source = 'foo.ui') # -> ['include/foo.h', 'gen/uicfoo.cc', 'gen/mocfoo.cc']
2112 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2115 Builds a zip archive of the specified files
2117 Unlike most builder methods,
2120 builder method may be called multiple times
2122 each additional call
2123 adds to the list of entries
2124 that will be built into the archive.
2127 env.Zip('src.zip', 'src')
2129 # Create the stuff.zip file.
2130 env.Zip('stuff', ['subdir1', 'subdir2'])
2131 # Also add "another" to the stuff.tar file.
2132 env.Zip('stuff', 'another')
2137 C source files, C++ source files,
2138 Fortran source files with
2140 (POSIX systems only),
2145 and assembly language files with
2147 (POSIX systems only),
2152 for C preprocessor dependencies,
2153 so the dependencies do not need to be specified explicitly.
2155 targets of builder methods automatically depend on their sources.
2156 An explicit dependency can
2157 be specified using the
2159 method of a construction environment (see below).
2161 .SS Methods and Functions to Do Things
2162 In addition to Builder methods,
2164 provides a number of other construction environment methods
2165 and global functions to
2166 manipulate the build configuration.
2168 Usually, a construction environment method
2169 and global function with the same name both exist
2170 so that you don't have to remember whether
2171 to a specific bit of functionality
2172 must be called with or without a construction environment.
2173 In the following list,
2174 if you call something as a global function
2177 .RI Function( arguments )
2179 and if you call something through a construction
2180 environment it looks like:
2182 .RI env.Function( arguments )
2184 If you can call the functionality in both ways,
2185 then both forms are listed.
2187 Except where otherwise noted,
2189 construction environment method
2191 provide the exact same functionality.
2192 The only difference is that,
2194 calling the functionality through a construction environment will
2195 substitute construction variables into
2196 any supplied strings.
2199 env = Environment(FOO = 'foo')
2203 the first call to the global
2205 function will actually add a target named
2207 to the list of default targets,
2208 while the second call to the
2210 construction environment method
2211 will expand the value
2212 and add a target named
2214 to the list of default targets.
2215 For more on construction variable expansion,
2216 see the next section on
2217 construction variables.
2219 Construction environment methods
2220 and global functions supported by
2224 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2226 .RI Action( action ", [" strfunction ", " varlist ])
2228 .RI env.Action( action ", [" strfunction ", " varlist ])
2229 Creates an Action object for
2232 See the section "Action Objects,"
2233 below, for a complete explanation of the arguments and behavior.
2235 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2237 .RI AddPostAction( target ", " action )
2239 .RI env.AddPostAction( target ", " action )
2240 Arranges for the specified
2246 The specified action(s) may be
2247 an Action object, or anything that
2248 can be converted into an Action object
2251 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2253 .RI AddPreAction( target ", " action )
2255 .RI env.AddPreAction( target ", " action )
2256 Arranges for the specified
2259 before the specified
2262 The specified action(s) may be
2263 an Action object, or anything that
2264 can be converted into an Action object
2267 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2269 .RI Alias( alias ", [" targets ])
2271 .RI env.Alias( alias ", [" targets ])
2272 Creates one or more phony targets that
2273 expand to one or more other targets.
2274 Returns the Node object representing the alias,
2275 which exists outside of any file system.
2276 This Node object, or the alias name,
2277 may be used as a dependency of any other target,
2278 including another alias.
2280 can be called multiple times for the same
2281 alias to add additional targets to the alias.
2285 Alias('install', '/usr/bin')
2286 Alias(['install', 'install-lib'], '/usr/local/lib')
2288 env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
2289 env.Alias('install', ['/usr/local/man'])
2292 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2294 .RI AlwaysBuild( target ", ...)"
2296 .RI env.AlwaysBuild( target ", ...)"
2299 so that it is always assumed to be out of date,
2300 and will always be rebuilt if needed.
2303 does not add its target(s) to the default target list,
2304 so the targets will only be built
2305 if they are specified on the command line,
2306 or are a dependent of a target specified on the command line--but
2309 be built if so specified.
2310 Multiple targets can be passed in to a single call to
2313 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2315 .RI env.Append( key = val ", [...])"
2316 Appends the specified keyword arguments
2317 to the end of construction variables in the environment.
2318 If the Environment does not have
2319 the specified construction variable,
2320 it is simply added to the environment.
2321 If the values of the construction variable
2322 and the keyword argument are the same type,
2323 then the two values will be simply added together.
2324 Otherwise, the construction variable
2325 and the value of the keyword argument
2326 are both coerced to lists,
2327 and the lists are added together.
2328 (See also the Prepend method, below.)
2331 env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
2334 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2336 .RI env.AppendENVPath( name ", " newpath ", [" envname ", " sep ])
2337 This appends new path elements to the given path in the
2338 specified external environment
2342 any particular path once (leaving the last one it encounters and
2343 ignoring the rest, to preserve path order),
2344 and to help assure this,
2345 will normalize all paths (using
2348 .BR os.path.normcase ).
2349 This can also handle the
2350 case where the given old path variable is a list instead of a
2351 string, in which case a list will be returned instead of a string.
2355 print 'before:',env['ENV']['INCLUDE']
2356 include_path = '/foo/bar:/foo'
2357 env.PrependENVPath('INCLUDE', include_path)
2358 print 'after:',env['ENV']['INCLUDE']
2362 after: /biz:/foo/bar:/foo
2365 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2367 .RI env.AppendUnique( key = val ", [...])"
2368 Appends the specified keyword arguments
2369 to the end of construction variables in the environment.
2370 If the Environment does not have
2371 the specified construction variable,
2372 it is simply added to the environment.
2373 If the construction variable being appended to is a list,
2374 then any value(s) that already exist in the
2375 construction variable will
2377 be added again to the list.
2380 env.AppendUnique(CCFLAGS = '-g', FOO = ['foo.yyy'])
2383 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2386 A factory function that
2387 returns a Builder object
2388 to be used to fetch source files
2390 The returned Builder
2391 is intended to be passed to the
2396 env.SourceCode('.', env.BitKeeper())
2399 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2401 .RI BuildDir( build_dir ", " src_dir ", [" duplicate ])
2403 .RI env.BuildDir( build_dir ", " src_dir ", [" duplicate ])
2404 This specifies a build directory
2406 in which to build all derived files
2407 that would normally be built under
2409 Multiple build directories can be set up for multiple build variants, for
2412 must be underneath the SConstruct file's directory,
2415 may not be underneath the
2418 The default behavior is for
2420 to duplicate all of the files in the tree underneath
2424 and then build the derived files within the copied tree.
2425 (The duplication is performed by
2427 depending on the platform; see also the
2430 This guarantees correct builds
2431 regardless of whether intermediate source files
2432 are generated during the build,
2433 where preprocessors or other scanners search
2435 or whether individual compilers or other invoked tools
2436 are hard-coded to put derived files in the same directory as source files.
2438 This behavior of making a complete copy of the source tree
2439 may be disabled by setting
2444 to invoke Builders using the
2445 path names of source files in
2447 and the path names of derived files within
2449 This is always more efficient than
2451 and is usually safe for most builds.
2455 may cause build problems
2456 if source files are generated during the build,
2457 if any invoked tools are hard-coded to
2458 put derived files in the same directory as the source files.
2460 Note that specifying a
2462 works most naturally
2463 with a subsidiary SConscript file
2464 in the source directory.
2466 you would then call the subsidiary SConscript file
2467 not in the source directory,
2472 had made a virtual copy of the source tree
2473 regardless of the value of
2475 This is how you tell
2477 which variant of a source tree to build.
2481 BuildDir('build-variant1', 'src')
2482 SConscript('build-variant1/SConscript')
2483 BuildDir('build-variant2', 'src')
2484 SConscript('build-variant2/SConscript')
2490 function, described below,
2492 specify a build directory
2493 in conjunction with calling a subsidiary
2496 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2498 .RI Builder( action ", [" arguments ])
2500 .RI env.Builder( action ", [" arguments ])
2501 Creates a Builder object for
2504 See the section "Builder Objects,"
2505 below, for a complete explanation of the arguments and behavior.
2507 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2509 .RI CacheDir( cache_dir )
2511 .RI env.CacheDir( cache_dir )
2514 will maintain a cache of derived files in
2516 The derived files in the cache will be shared
2517 among all the builds using the same
2525 finds a derived file that needs to be rebuilt,
2526 it will first look in the cache to see if a
2527 derived file has already been built
2528 from identical input files and an identical build action
2529 (as incorporated into the MD5 build signature).
2532 will retrieve the file from the cache.
2533 If the derived file is not present in the cache,
2536 then place a copy of the built file in the cache
2537 (identified by its MD5 build signature),
2538 so that it may be retrieved by other
2539 builds that need to build the same derived file
2540 from identical inputs.
2544 may be disabled for any invocation
2553 will place a copy of
2555 derived files in the cache,
2556 even if they already existed
2557 and were not built by this invocation.
2558 This is useful to populate a cache
2561 is added to a build,
2570 "Retrieved `file' from cache,"
2573 option is being used.
2578 will print the action that
2580 have been used to build the file,
2581 without any indication that
2582 the file was actually retrieved from the cache.
2583 This is useful to generate build logs
2584 that are equivalent regardless of whether
2585 a given derived file has been built in-place
2586 or retrieved from the cache.
2588 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2590 .RI Clean( targets ", " files_or_dirs )
2592 .RI env.Clean( targets ", " files_or_dirs )
2593 This specifies a list of files or directories which should be removed
2594 whenever the targets are specified with the
2596 command line option.
2597 The specified targets may be a list
2598 or an individual target.
2602 and create new targets or add files and directories to the
2603 clean list for the specified targets.
2605 Multiple files or directories should be specified
2606 either as separate arguments to the
2608 method, or as a list.
2610 will also accept the return value of any of the construction environment
2615 Clean('foo', ['bar', 'baz'])
2616 Clean('dist', env.Program('hello', 'hello.c'))
2617 Clean(['foo', 'bar'], 'something_else_to_clean')
2620 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2622 .RI Command( target ", " source ", " commands ", [" key = val ", ...])"
2624 .RI env.Command( target ", " source ", " commands ", [" key = val ", ...])"
2625 Executes a specific action
2626 (or list of actions)
2627 to build a target file or files.
2628 This is more convenient
2629 than defining a separate Builder object
2630 for a single special-case build.
2631 Any keyword arguments specified override any
2632 same-named existing construction variables.
2634 Note that an action can be an external command,
2635 specified as a string,
2636 or a callable Python object;
2637 see "Action Objects," below.
2641 env.Command('foo.out', 'foo.in',
2642 "$FOO_BUILD < $SOURCES > $TARGET")
2644 env.Command('bar.out', 'bar.in',
2646 "$BAR_BUILD < $SOURCES > $TARGET"],
2647 ENV = {'PATH' : '/usr/local/bin/'})
2649 def rename(env, target, source):
2651 os.rename('.tmp', str(target[0]))
2653 env.Command('baz.out', 'baz.in',
2654 ["$BAZ_BUILD < $SOURCES > .tmp",
2658 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2660 .RI Configure( env ", [" custom_tests ", " conf_dir ", " log_file ", " config_h ])
2662 .RI env.Configure([ custom_tests ", " conf_dir ", " log_file ", " config_h ])
2663 Creates a Configure object for integrated
2664 functionality similar to GNU autoconf.
2665 See the section "Configure Contexts,"
2666 below, for a complete explanation of the arguments and behavior.
2668 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2670 .RI env.Copy([ key = val ", ...])"
2671 Return a separate copy of a construction environment.
2672 If there are any keyword arguments specified,
2673 they are added to the returned copy,
2674 overwriting any existing values
2679 env3 = env.Copy(CCFLAGS = '-g')
2682 Additionally, a list of tools and a toolpath may be specified, as in
2683 the Environment constructor:
2686 def MyTool(env): env['FOO'] = 'bar'
2687 env4 = env.Copy(tools = ['msvc', MyTool])
2690 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2692 .RI env.CVS( repository ", " module )
2693 A factory function that
2694 returns a Builder object
2695 to be used to fetch source files
2699 The returned Builder
2700 is intended to be passed to the
2704 The optional specified
2706 will be added to the beginning
2707 of all repository path names;
2708 this can be used, in essence,
2709 to strip initial directory names
2710 from the repository path names,
2711 so that you only have to
2712 replicate part of the repository
2713 directory hierarchy in your
2714 local build directory:
2717 # Will fetch foo/bar/src.c
2718 # from /usr/local/CVSROOT/foo/bar/src.c.
2719 env.SourceCode('.', env.CVS('/usr/local/CVSROOT'))
2721 # Will fetch bar/src.c
2722 # from /usr/local/CVSROOT/foo/bar/src.c.
2723 env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo'))
2726 # from /usr/local/CVSROOT/foo/bar/src.c.
2727 env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo/bar'))
2730 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2732 .RI Default( targets )
2734 .RI env.Default( targets )
2735 This specifies a list of default targets,
2736 which will be built by
2738 if no explicit targets are given on the command line.
2742 and add to the list of default targets.
2744 Multiple targets should be specified as
2745 separate arguments to the
2747 method, or as a list.
2749 will also accept the Node returned by any
2750 of a construction environment's
2755 Default('foo', 'bar', 'baz')
2756 env.Default(['a', 'b', 'c'])
2757 hello = env.Program('hello', 'hello.c')
2765 will clear all default targets.
2768 will add to the (now empty) default-target list
2771 The current list of targets added using the
2773 function or method is available in the
2778 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2780 .RI DefaultEnvironment([ args ])
2781 Creates and returns a default construction environment object.
2782 This construction environment is used internally by SCons
2783 in order to execute many of the global functions in this list,
2784 and to fetch source files transparently
2785 from source code management systems.
2787 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2789 .RI Depends( target ", " dependency )
2791 .RI env.Depends( target ", " dependency )
2792 Specifies an explicit dependency;
2793 the target file(s) will be rebuilt
2794 whenever the dependency file(s) has changed.
2795 This should only be necessary
2796 for cases where the dependency
2797 is not caught by a Scanner
2801 env.Depends('foo', 'other-input-file-for-foo')
2804 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2806 .RI env.Dictionary([ vars ])
2807 Returns a dictionary object
2808 containing copies of all of the
2809 construction variables in the environment.
2810 If there are any variable names specified,
2811 only the specified construction
2812 variables are returned in the dictionary.
2815 dict = env.Dictionary()
2816 cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
2819 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2821 .RI Dir( name ", [" directory ])
2823 .RI env.Dir( name ", [" directory ])
2824 This returns a Directory Node,
2825 an object that represents the specified directory
2828 can be a relative or absolute path.
2830 is an optional directory that will be used as the parent directory.
2833 is specified, the current script's directory is used as the parent.
2835 Directory Nodes can be used anywhere you
2836 would supply a string as a directory name
2837 to a Builder method or function.
2838 Directory Nodes have attributes and methods
2839 that are useful in many situations;
2840 see "File and Directory Nodes," below.
2842 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2844 .RI env.Dump([ key ])
2845 Returns a pretty printable representation of the environment.
2849 should be a string containing the name of the variable of interest.
2854 print env.Dump('CCCOM')
2858 '$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES'
2868 'ARCOM': '$AR $ARFLAGS $TARGET $SOURCES\n$RANLIB $RANLIBFLAGS $TARGET',
2871 'ASCOM': '$AS $ASFLAGS -o $TARGET $SOURCES',
2876 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2878 .RI EnsurePythonVersion( major ", " minor )
2880 .RI env.EnsurePythonVersion( major ", " minor )
2881 Ensure that the Python version is at least
2884 print out an error message and exit SCons with a non-zero exit code if the
2885 actual Python version is not late enough.
2888 EnsurePythonVersion(2,2)
2891 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2893 .RI EnsureSConsVersion( major ", " minor )
2895 .RI env.EnsureSConsVersion( major ", " minor )
2896 Ensure that the SCons version is at least
2899 print out an error message and exit SCons with a non-zero exit code if the
2900 actual SCons version is not late enough.
2903 EnsureSConsVersion(0,9)
2906 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2908 .RI Environment([ key = value ", ...])"
2910 .RI env.Environment([ key = value ", ...])"
2911 Return a new construction environment
2912 initialized with the specified
2916 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2918 .RI Execute( action ", [" strfunction ", " varlist ])
2920 .RI env.Execute( action ", [" strfunction ", " varlist ])
2921 Executes an Action object.
2924 may be an Action object
2925 (see the section "Action Objects,"
2926 below, for a complete explanation of the arguments and behavior),
2927 or it may be a command-line string,
2929 or executable Python function,
2930 each of which will be converted
2931 into an Action object
2933 The exit value of the command
2934 or return value of the Python function
2937 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2941 .RI env.Exit([ value ])
2947 A default exit value of
2950 is used if no value is specified.
2952 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2956 .RI env.Export( vars )
2959 to export a list of variables from the current
2960 SConscript file to all other SConscript files.
2961 The exported variables are kept in a global collection,
2962 so subsequent calls to
2964 will over-write previous exports that have the same name.
2965 Multiple variable names can be passed to
2967 as separate arguments or as a list. A dictionary can be used to map
2968 variables to a different name when exported. Both local variables and
2969 global variables can be exported.
2974 # Make env available for all SConscript files to Import().
2978 # Make env and package available for all SConscript files:.
2979 Export("env", "package")
2981 # Make env and package available for all SConscript files:
2982 Export(["env", "package"])
2984 # Make env available using the name debug:.
2985 Export({"debug":env})
2991 function supports an
2993 argument that makes it easier to to export a variable or
2994 set of variables to a single SConscript file.
2995 See the description of the
2999 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3001 .RI File( name ", [" directory ])
3003 .RI env.File( name ", [" directory ])
3006 an object that represents the specified file
3009 can be a relative or absolute path.
3011 is an optional directory that will be used as the parent directory.
3013 File Nodes can be used anywhere you
3014 would supply a string as a file name
3015 to a Builder method or function.
3016 File Nodes have attributes and methods
3017 that are useful in many situations;
3018 see "File and Directory Nodes," below.
3020 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3022 .RI FindFile( file ", " dirs )
3024 .RI env.FindFile( file ", " dirs )
3027 in the path specified by
3030 may be a list of file names or a single file name. In addition to searching
3031 for files that exist in the filesytem, this function also searches for
3032 derived files that have not yet been built.
3035 foo = env.FindFile('foo', ['dir1', 'dir2'])
3038 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3040 .RI Flatten( sequence )
3042 .RI env.Flatten( sequence )
3043 Takes a sequence (that is, a Python list or tuple)
3044 that may contain nested sequences
3045 and returns a flattened list containing
3046 all of the individual elements in any sequence.
3047 This can be helpful for collecting
3048 the lists returned by calls to Builders;
3049 other Builders will automatically
3050 flatten lists specified as input,
3051 but direct Python manipulation of
3052 these lists does not:
3055 foo = Object('foo.c')
3056 bar = Object('bar.c')
3058 # Because `foo' and `bar' are lists returned by the Object() Builder,
3059 # `objects' will be a list containing nested lists:
3060 objects = ['f1.o', foo, 'f2.o', bar, 'f3.o']
3062 # Passing such a list to another Builder is all right because
3063 # the Builder will flatten the list automatically:
3064 Program(source = objects)
3066 # If you need to manipulate the list directly using Python, you need to
3067 # call Flatten() yourself, or otherwise handle nested lists:
3068 for object in Flatten(objects):
3072 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3074 .RI GetBuildPath( file ", [" ... ])
3076 .RI env.GetBuildPath( file ", [" ... ])
3079 path name (or names) for the specified
3087 Nodes or strings representing path names.
3089 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3093 .RI env.GetLaunchDir()
3094 Returns the absolute path name of the directory from which
3097 was initially invoked.
3098 This can be useful when using the
3103 options, which internally
3104 change to the directory in which the
3108 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3110 .RI GetOption( name )
3112 .RI env.GetOption( name )
3113 This function provides a way to query a select subset of the scons command line
3114 options from a SConscript file. See
3116 for a description of the options available.
3118 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3120 '\".RI GlobalBuilders( flag )
3124 '\"adds the names of the default builders
3125 '\"(Program, Library, etc.)
3126 '\"to the global name space
3127 '\"so they can be called without an explicit construction environment.
3128 '\"(This is the default.)
3132 '\"the names of the default builders are removed
3133 '\"from the global name space
3134 '\"so that an explicit construction environment is required
3135 '\"to call all builders.
3137 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3141 .RI env.Help( text )
3142 This specifies help text to be printed if the
3144 argument is given to
3148 is called multiple times, the text is appended together in the order
3153 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3155 .RI Ignore( target ", " dependency )
3157 .RI env.Ignore( target ", " dependency )
3158 The specified dependency file(s)
3159 will be ignored when deciding if
3160 the target file(s) need to be rebuilt.
3163 env.Ignore('foo', 'foo.c')
3164 env.Ignore('bar', ['bar1.h', 'bar2.h'])
3167 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3171 .RI env.Import( vars )
3174 to import a list of variables into the current SConscript file. This
3175 will import variables that were exported with
3181 Variables exported by
3184 Multiple variable names can be passed to
3186 as separate arguments or as a list. The variable "*" can be used
3187 to import all variables.
3192 Import("env", "variable")
3193 Import(["env", "variable"])
3197 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3199 .RI Install( dir ", " source )
3201 .RI env.Install( dir ", " source )
3202 Installs one or more files in a destination directory.
3203 The file names remain the same.
3206 env.Install(dir = '/usr/local/bin', source = ['foo', 'bar'])
3209 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3211 .RI InstallAs( target ", " source )
3213 .RI env.InstallAs( target ", " source )
3214 Installs one or more files as specific file names,
3215 allowing changing a file name as part of the
3217 It is an error if the target and source
3218 list different numbers of files.
3221 env.InstallAs(target = '/usr/local/bin/foo',
3222 source = 'foo_debug')
3223 env.InstallAs(target = ['../lib/libfoo.a', '../lib/libbar.a'],
3224 source = ['libFOO.a', 'libBAR.a'])
3227 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3229 .RI Literal( string )
3231 .RI env.Literal( string )
3234 will be preserved as-is
3235 and not have construction variables expanded.
3237 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3239 .RI Local( targets )
3241 .RI env.Local( targets )
3244 will have copies made in the local tree,
3245 even if an already up-to-date copy
3246 exists in a repository.
3247 Returns a list of the target Node or Nodes.
3249 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3251 .RI env.ParseConfig( command ", [" function ])
3254 to modify the environment as specified by the output of
3258 expects the output of a typical
3262 and parses the returned
3283 option gets added to both the
3290 option gets added to the
3293 Any other strings not associated with options
3294 are assumed to be the names of libraries
3297 construction variable.
3299 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3301 .RI ParseDepends( filename ", [" must_exist ])
3303 .RI env.ParseDepends( filename ", [" must_exist ])
3304 Parses the contents of the specified
3306 as a list of dependencies in the style of
3310 and explicitly establishes all of the listed dependencies.
3318 argument may be set to a non-zero
3321 throw an exception and
3322 generate an error if the file does not exist,
3323 or is otherwise inaccessible.
3326 and all of the files listed therein
3327 will be interpreted relative to
3328 the directory of the
3330 file which called the
3334 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3337 A factory function that
3338 returns a Builder object
3339 to be used to fetch source files
3340 from the Perforce source code management system.
3341 The returned Builder
3342 is intended to be passed to the
3347 env.SourceCode('.', env.Perforce())
3350 Perforce uses a number of external
3351 environment variables for its operation.
3352 Consequently, this function adds the
3353 following variables from the user's external environment
3354 to the construction environment's
3367 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3369 .RI Platform( string )
3370 Returns a callable object
3371 that can be used to initialize
3372 a construction environment using the
3373 platform keyword of the Environment() method:
3376 env = Environment(platform = Platform('win32'))
3379 .RI env.Platform( string )
3380 Applies the callable object for the specified platform
3382 to the environment through which the method was called.
3385 env.Platform('posix')
3392 variable from the user's external environment
3393 to the construction environment's
3396 This is so that any executed commands
3397 that use sockets to connect with other systems
3398 (such as fetching source files from
3399 external CVS repository specifications like
3400 .BR :pserver:anonymous@cvs.sourceforge.net:/cvsroot/scons )
3401 will work on Win32 systems.
3403 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3405 .RI Precious( target ", ...)"
3407 .RI env.Precious( target ", ...)"
3410 as precious so it is not deleted before it is rebuilt. Normally
3412 deletes a target before building it.
3413 Multiple targets can be passed in to a single call to
3416 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3418 .RI env.Prepend( key = val ", [...])"
3419 Appends the specified keyword arguments
3420 to the beginning of construction variables in the environment.
3421 If the Environment does not have
3422 the specified construction variable,
3423 it is simply added to the environment.
3424 If the values of the construction variable
3425 and the keyword argument are the same type,
3426 then the two values will be simply added together.
3427 Otherwise, the construction variable
3428 and the value of the keyword argument
3429 are both coerced to lists,
3430 and the lists are added together.
3431 (See also the Append method, above.)
3434 env.Prepend(CCFLAGS = '-g ', FOO = ['foo.yyy'])
3437 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3439 .RI env.PrependENVPath( name ", " newpath ", [" envname ", " sep ])
3440 This appends new path elements to the given path in the
3441 specified external environment
3445 any particular path once (leaving the first one it encounters and
3446 ignoring the rest, to preserve path order),
3447 and to help assure this,
3448 will normalize all paths (using
3451 .BR os.path.normcase ).
3452 This can also handle the
3453 case where the given old path variable is a list instead of a
3454 string, in which case a list will be returned instead of a string.
3458 print 'before:',env['ENV']['INCLUDE']
3459 include_path = '/foo/bar:/foo'
3460 env.PrependENVPath('INCLUDE', include_path)
3461 print 'after:',env['ENV']['INCLUDE']
3465 after: /foo/bar:/foo:/biz
3468 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3470 .RI env.AppendUnique( key = val ", [...])"
3471 Appends the specified keyword arguments
3472 to the beginning of construction variables in the environment.
3473 If the Environment does not have
3474 the specified construction variable,
3475 it is simply added to the environment.
3476 If the construction variable being appended to is a list,
3477 then any value(s) that already exist in the
3478 construction variable will
3480 be added again to the list.
3483 env.PrependUnique(CCFLAGS = '-g', FOO = ['foo.yyy'])
3486 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3489 A factory function that
3490 returns a Builder object
3491 to be used to fetch source files
3493 The returned Builder
3494 is intended to be passed to the
3499 env.SourceCode('.', env.RCS())
3504 will fetch source files
3505 from RCS subdirectories automatically,
3507 as demonstrated in the above example
3508 should only be necessary if
3509 you are fetching from
3512 directory as the source files,
3513 or if you need to explicitly specify RCS
3514 for a specific subdirectory.
3516 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3518 .RI env.Replace( key = val ", [...])"
3519 Replaces construction variables in the Environment
3520 with the specified keyword arguments.
3523 env.Replace(CCFLAGS = '-g', FOO = 'foo.xxx')
3526 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3528 .RI Repository( directory )
3530 .RI env.Repository( directory )
3533 is a repository to be searched for files.
3537 and each one adds to the list of
3538 repositories that will be searched.
3542 a repository is a copy of the source tree,
3543 from the top-level directory on down,
3545 both source files and derived files
3546 that can be used to build targets in
3547 the local source tree.
3548 The canonical example would be an
3549 official source tree maintained by an integrator.
3550 If the repository contains derived files,
3551 then the derived files should have been built using
3553 so that the repository contains the necessary
3554 signature information to allow
3556 to figure out when it is appropriate to
3557 use the repository copy of a derived file,
3558 instead of building one locally.
3560 Note that if an up-to-date derived file
3561 already exists in a repository,
3565 make a copy in the local directory tree.
3566 In order to guarantee that a local copy
3572 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3577 what variable(s) to use as the return value(s) of the current SConscript
3578 file. These variables will be returned to the "calling" SConscript file
3579 as the return value(s) of
3581 Multiple variable names should be passed to
3587 Return(["foo", "bar"])
3590 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3592 .RI Scanner( function ", [" argument ", " keys ", " path_function ", " node_class ", " node_factory ", " scan_check ", " recursive ])
3594 .RI env.Scanner( function ", [" argument ", " keys ", " path_function ", " node_class ", " node_factory ", " scan_check ", " recursive ])
3595 Creates a Scanner object for
3598 See the section "Scanner Objects,"
3599 below, for a complete explanation of the arguments and behavior.
3601 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3604 A factory function that
3605 returns a Builder object
3606 to be used to fetch source files
3608 The returned Builder
3609 is intended to be passed to the
3614 env.SourceCode('.', env.SCCS())
3619 will fetch source files
3620 from SCCS subdirectories automatically,
3622 as demonstrated in the above example
3623 should only be necessary if
3624 you are fetching from
3627 directory as the source files,
3628 or if you need to explicitly specify SCCS
3629 for a specific subdirectory.
3631 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3633 .RI SConscript( scripts ", [" exports ", " build_dir ", " src_dir ", " duplicate ])
3635 .RI env.SConscript( scripts ", [" exports ", " build_dir ", " src_dir ", " duplicate ])
3637 .RI SConscript(dirs= subdirs ", [name=" script ", " exports ", " build_dir ", " src_dir ", " duplicate ])
3639 .RI env.SConscript(dirs= subdirs ", [name=" script ", " exports ", " build_dir ", " src_dir ", " duplicate ])
3643 one or more subsidiary SConscript (configuration) files.
3644 There are two ways to call the
3648 The first way you can call
3650 is to explicitly specify one or more
3652 as the first argument.
3653 A single script may be specified as a string;
3654 multiple scripts must be specified as a list
3655 (either explicitly or as created by
3659 The second way you can call
3661 is to specify a list of (sub)directory names
3668 execute a subsidiary configuration file named
3670 in each of the specified directories.
3671 You may specify a name other than
3673 by supplying an optional
3679 argument provides a list of variable names or a dictionary of
3680 named values to export to the
3682 These variables are locally exported only to the specified
3684 and do not affect the
3685 global pool of variables used by
3689 '\"If multiple dirs are provided,
3690 '\"each script gets a fresh export.
3695 function to import the variables.
3699 argument specifies that all of the target files
3700 (for example, object files and executables)
3701 that would normally be built in the subdirectory in which
3703 resides should actually
3707 is interpreted relative to the directory
3708 of the calling SConscript file.
3712 argument specifies that the
3713 source files from which
3714 the target files should be built
3718 is interpreted relative to the directory
3719 of the calling SConscript file.
3723 will link or copy (depending on the platform)
3724 all the source files into the build directory.
3725 This behavior may be disabled by
3726 setting the optional
3729 (it is set to 1 by default),
3732 will refer directly to
3733 the source files in their source directory
3734 when building target files.
3737 is usually safe, and always more efficient
3740 but it may cause build problems in certain end-cases,
3741 such as compiling from source files that
3742 are generated by the build.)
3744 Any variables returned by
3748 will be returned by the call to
3754 SConscript('subdir/SConscript')
3755 foo = SConscript('sub/SConscript', exports='env')
3756 SConscript('dir/SConscript', exports=['env', 'variable'])
3757 SConscript('src/SConscript', build_dir='build', duplicate=0)
3758 SConscript('bld/SConscript', src_dir='src', exports='env variable')
3759 SConscript(dirs=['sub1', 'sub2'])
3760 SConscript(dirs=['sub3', 'sub4'], name='MySConscript')
3763 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3765 .RI SConscriptChdir( value )
3767 .RI env.SConscriptChdir( value )
3770 changes its working directory
3771 to the directory in which each
3772 subsidiary SConscript file lives.
3773 This behavior may be disabled
3774 by specifying either:
3778 env.SConscriptChdir(0)
3783 will stay in the top-level directory
3784 while reading all SConscript files.
3785 (This may be necessary when building from repositories,
3786 when all the directories in which SConscript files may be found
3787 don't necessarily exist locally.)
3789 You may enable and disable
3790 this ability by calling
3797 SConscript('foo/SConscript') # will not chdir to foo
3798 env.SConscriptChdir(1)
3799 SConscript('bar/SConscript') # will chdir to bar
3802 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3804 .RI SConsignFile([ file , dbm_module ])
3806 .RI env.SConsignFile([ file , dbm_module ])
3809 to store all file signatures
3819 is not an absolute path name,
3820 the file is placed in the same directory as the top-level
3826 argument can be used to specify
3827 which Python database module
3828 The default is to use a custom
3830 module that uses pickled
3831 Python data structures,
3832 and which works on all Python versions from 1.5.2 on.
3837 # Stores signatures in ".sconsign.dbm"
3838 # in the top-level SConstruct directory.
3841 # Stores signatures in the file "etc/scons-signatures"
3842 # relative to the top-level SConstruct directory.
3843 SConsignFile("etc/scons-signatures")
3845 # Stores signatures in the specified absolute file name.
3846 SConsignFile("/home/me/SCons/signatures")
3849 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3851 .RI env.SetDefault(key = val ", [...])"
3852 Sets construction variables to default values specified with the keyword
3853 arguments if (and only if) the variables are not already set.
3854 The following statements are equivalent:
3857 env.SetDefault(FOO = 'foo')
3859 if not env.has_key('FOO'): env['FOO'] = 'foo'
3862 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3864 .RI SetOption( name ", " value )
3866 .RI env.SetOption( name ", " value )
3867 This function provides a way to set a select subset of the scons command
3868 line options from a SConscript file. The options supported are:
3870 which corresponds to -c, --clean, and --remove;
3873 corresponds to --duplicate;
3875 which corresponds to --implicit-cache;
3877 which corresponds to --max-drift;
3879 which corresponds to -j and --jobs.
3880 See the documentation for the
3881 corresponding command line object for information about each specific
3885 SetOption('max_drift', 1)
3888 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3890 .RI SideEffect( side_effect ", " target )
3892 .RI env.SideEffect( side_effect ", " target )
3895 as a side effect of building
3901 can be a list, a file name, or a node.
3902 A side effect is a target that is created
3903 as a side effect of building other targets.
3904 For example, a Windows PDB
3905 file is created as a side effect of building the .obj
3906 files for a static library.
3907 If a target is a side effect of multiple build commands,
3909 will ensure that only one set of commands
3910 is executed at a time.
3911 Consequently, you only need to use this method
3912 for side-effect targets that are built as a result of
3913 multiple build commands.
3915 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3917 .RI SourceCode( entries ", " builder )
3919 .RI env.SourceCode( entries ", " builder )
3920 Arrange for non-existent source files to
3921 be fetched from a source code management system
3926 may be a Node, string or list of both,
3927 and may represent either individual
3928 source files or directories in which
3929 source files can be found.
3931 For any non-existent source files,
3933 will search up the directory tree
3943 will not use a builder to fetch
3944 source files for the specified
3948 builder has been specified
3949 for a directory higher up the tree.
3953 fetch files from SCCS or RCS subdirectories
3954 without explicit configuration.
3955 This takes some extra processing time
3956 to search for the necessary
3957 source code management files on disk.
3958 You can avoid these extra searches
3959 and speed up your build a little
3960 by disabling these searches as follows:
3963 env.SourceCode('.', None)
3967 Note that if the specified
3969 is one you create by hand,
3970 it must have an associated
3971 construction environment to use
3972 when fetching a source file.
3975 provides a set of canned factory
3976 functions that return appropriate
3977 Builders for various popular
3978 source code management systems.
3979 Canonical examples of invocation include:
3982 env.SourceCode('.', env.BitKeeper('/usr/local/BKsources'))
3983 env.SourceCode('src', env.CVS('/usr/local/CVSROOT'))
3984 env.SourceCode('/', env.RCS())
3985 env.SourceCode(['f1.c', 'f2.c'], env.SCCS())
3986 env.SourceCode('no_source.c', None)
3988 '\"env.SourceCode('.', env.Subversion('file:///usr/local/Subversion'))
3990 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
3992 '\".RI Subversion( repository ", " module )
3993 '\"A factory function that
3994 '\"returns a Builder object
3995 '\"to be used to fetch source files
3996 '\"from the specified Subversion
3998 '\"The returned Builder
3999 '\"is intended to be passed to the
4003 '\"The optional specified
4005 '\"will be added to the beginning
4006 '\"of all repository path names;
4007 '\"this can be used, in essence,
4008 '\"to strip initial directory names
4009 '\"from the repository path names,
4010 '\"so that you only have to
4011 '\"replicate part of the repository
4012 '\"directory hierarchy in your
4013 '\"local build directory:
4016 '\"# Will fetch foo/bar/src.c
4017 '\"# from /usr/local/Subversion/foo/bar/src.c.
4018 '\"env.SourceCode('.', env.Subversion('file:///usr/local/Subversion'))
4020 '\"# Will fetch bar/src.c
4021 '\"# from /usr/local/Subversion/foo/bar/src.c.
4022 '\"env.SourceCode('.', env.Subversion('file:///usr/local/Subversion', 'foo'))
4024 '\"# Will fetch src.c
4025 '\"# from /usr/local/Subversion/foo/bar/src.c.
4026 '\"env.SourceCode('.', env.Subversion('file:///usr/local/Subversion', 'foo/bar'))
4029 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4031 .RI SourceSignatures( type )
4033 .RI env.SourceSignatures( type )
4034 This function tells SCons what type of signature to use for source files:
4038 If the environment method is used,
4039 the specified type of source signature
4040 is only used when deciding whether targets
4041 built with that environment are up-to-date or must be rebuilt.
4042 If the global function is used,
4043 the specified type of source signature becomes the default
4044 used for all decisions
4045 about whether targets are up-to-date.
4047 "MD5" means the signature of a source file
4048 is the MD5 checksum of its contents.
4049 "timestamp" means the signature of a source file
4050 is its timestamp (modification time).
4051 There is no different between the two behaviors
4055 "MD5" signatures take longer to compute,
4056 but are more accurate than "timestamp" signatures.
4057 The default is "MD5".
4059 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4063 .RI env.Split( arg )
4064 Returns a list of file names or other objects.
4066 it will be split on strings of white-space characters
4068 making it easier to write long lists of file names.
4069 If arg is already a list,
4070 the list will be returned untouched.
4071 If arg is any other type of object,
4072 it will be returned as a list
4073 containing just the object.
4076 files = Split("f1.c f2.c f3.c")
4077 files = env.Split("f4.c f5.c f6.c")
4085 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4087 .RI TargetSignatures( type )
4089 .RI env.TargetSignatures( type )
4090 This function tells SCons what type of signatures to use
4095 If the environment method is used,
4096 the specified type of signature is only used
4097 for targets built with that environment.
4098 If the global function is used,
4099 the specified type of signature becomes the default
4100 used for all target files that
4101 don't have an explicit target signature type
4102 specified for their environments.
4104 "build" means the signature of a target file
4105 is made by concatenating all of the
4106 signatures of all its source files.
4107 "content" means the signature of a target
4108 file is an MD5 checksum of its contents.
4109 "build" signatures are usually faster to compute,
4110 but "content" signatures can prevent unnecessary rebuilds
4111 when a target file is rebuilt to the exact same contents
4112 as the previous build.
4113 The default is "build".
4115 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4117 .RI Tool( string [, toolpath ", " **kw ])
4118 Returns a callable object
4119 that can be used to initialize
4120 a construction environment using the
4121 tools keyword of the Environment() method.
4122 The object may be called with a construction
4123 environment as an argument,
4124 in which case the object will
4125 add the necessary variables
4126 to the construction environment
4127 and the name of the tool will be added to the
4129 construction variable.
4131 Additional keyword arguments are passed to the tool's
4136 env = Environment(tools = [ Tool('msvc') ])
4140 t(env) # adds 'msvc' to the TOOLS variable
4141 u = Tool('opengl', toolpath = ['tools'])
4142 u(env) # adds 'opengl' to the TOOLS variable
4145 .RI env.Tool( string [, toolpath ", " **kw ])
4146 Applies the callable object for the specified tool
4148 to the environment through which the method was called.
4150 Additional keyword arguments are passed to the tool's
4156 env.Tool('opengl', toolpath = ['build/tools'])
4159 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4163 .RI env.Value( value )
4164 Returns a Node object representing the specified Python value. Value
4165 nodes can be used as dependencies of targets. If the result of
4168 changes between SCons runs, any targets depending on
4170 will be rebuilt. When using timestamp source signatures, Value nodes'
4171 timestamps are equal to the system time when the node is created.
4174 def create(target, source, env):
4175 f = open(str(target[0]), 'wb')
4176 f.write('prefix=' + source[0].get_contents())
4178 prefix = ARGUMENTS.get('prefix', '/usr/local')
4180 env['BUILDERS']['Config'] = Builder(action = create)
4181 env.Config(target = 'package-config', source = Value(prefix))
4184 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4186 .RI WhereIs( program ", [" path ", " pathext ", " reject ])
4188 .RI env.WhereIs( program ", [" path ", " pathext ", " reject ])
4190 Searches for the specified executable
4192 returning the full path name to the program
4194 and returning None if not.
4195 Searches the specified
4197 the value of the calling environment's PATH
4198 (env['ENV']['PATH']),
4199 or the user's current external PATH
4200 (os.environ['PATH'])
4202 On Win32 systems, searches for executable
4203 programs with any of the file extensions
4204 listed in the specified
4206 the calling environment's PATHEXT
4207 (env['ENV']['PATHEXT'])
4208 or the user's current PATHEXT
4209 (os.environ['PATHEXT'])
4217 .SS SConscript Variables
4218 In addition to the global functions and methods,
4220 supports a number of Python variables
4221 that can be used in SConscript files
4222 to affect how you want the build to be performed.
4224 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4229 arguments specified on the command line.
4230 Each element in the list is a tuple
4232 .RI ( keyword , value )
4238 elements of the tuple
4240 subscripting for element
4244 of the tuple, respectively.
4247 print "first keyword, value =", ARGLIST[0][0], ARGLIST[0][1]
4248 print "second keyword, value =", ARGLIST[1][0], ARGLIST[1][1]
4249 third_tuple = ARGLIST[2]
4250 print "third keyword, value =", third_tuple[0], third_tuple[1]
4251 for key, value in ARGLIST:
4252 # process key and value
4255 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4258 A dictionary of all the
4260 arguments specified on the command line.
4261 The dictionary is not in order,
4262 and if a given keyword has
4263 more than one value assigned to it
4264 on the command line,
4265 the last (right-most) value is
4271 if ARGUMENTS.get('debug', 0):
4272 env = Environment(CCFLAGS = '-g')
4277 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4280 A list of the targets which
4282 will actually try to build,
4283 regardless of whether they were specified on
4284 the command line or via the
4287 The elements of this list may be strings
4289 nodes, so you should run the list through the Python
4291 function to make sure any Node path names
4292 are converted to strings.
4294 Because this list may be taken from the
4295 list of targets specified using the
4298 the contents of the list may change
4299 on each successive call to
4304 for additional information.
4307 if 'foo' in BUILD_TARGETS:
4308 print "Don't forget to test the `foo' program!"
4309 if 'special/program' in BUILD_TARGETS:
4310 SConscript('special')
4315 list only contains targets expected listed
4316 on the command line or via calls to the
4321 contain all dependent targets that will be built as
4322 a result of making the sure the explicitly-specified
4323 targets are up to date.
4325 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4327 COMMAND_LINE_TARGETS
4328 A list of the targets explicitly specified on
4330 If there are no targets specified on the command line,
4332 This can be used, for example,
4333 to take specific actions only
4334 when a certain target or targets
4335 is explicitly being built:
4338 if 'foo' in COMMAND_LINE_TARGETS:
4339 print "Don't forget to test the `foo' program!"
4340 if 'special/program' in COMMAND_LINE_TARGETS:
4341 SConscript('special')
4344 '\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
4347 A list of the target
4349 that have been specified using the
4352 The elements of the list are nodes,
4353 so you need to run them through the Python
4355 function to get at the path name for each Node.
4358 print str(DEFAULT_TARGETS[0])
4359 if 'foo' in map(str, DEFAULT_TARGETS):
4360 print "Don't forget to test the `foo' program!"
4365 list change on on each successive call to the
4370 print map(str, DEFAULT_TARGETS) # originally []
4372 print map(str, DEFAULT_TARGETS) # now a node ['foo']
4374 print map(str, DEFAULT_TARGETS) # now a node ['foo', 'bar']
4376 print map(str, DEFAULT_TARGETS) # back to []
4379 Consequently, be sure to use
4381 only after you've made all of your
4384 or else simply be careful of the order
4385 of these statements in your SConscript files
4386 so that you don't look for a specific
4387 default target before it's actually been added to the list.
4389 .SS Construction Variables
4390 .\" XXX From Gary Ruben, 23 April 2002:
4391 .\" I think it would be good to have an example with each construction
4392 .\" variable description in the documentation.
4394 .\" CC The C compiler
4395 .\" Example: env["CC"] = "c68x"
4396 .\" Default: env["CC"] = "cc"
4398 .\" CCCOM The command line ...
4400 .\" To generate the compiler line c68x -ps -qq -mr -o $TARGET $SOURCES
4401 .\" env["CC"] = "c68x"
4402 .\" env["CFLAGS"] = "-ps -qq -mr"
4403 .\" env["CCCOM"] = "$CC $CFLAGS -o $TARGET $SOURCES
4405 .\" (I dunno what this is ;-)
4406 A construction environment has an associated dictionary of
4407 .I construction variables
4408 that are used by built-in or user-supplied build rules.
4409 Construction variables must follow the same rules for
4411 the initial character must be an underscore or letter,
4412 followed by any number of underscores, letters, or digits.
4414 A number of useful construction variables are automatically defined by
4415 scons for each supported platform, and additional construction variables
4416 can be defined by the user. The following is a list of the automatically
4417 defined construction variables:
4420 The static library archiver.
4423 The command line used to generate a static library from object files.
4426 General options passed to the static library archiver.
4432 The command line used to generate an object file
4433 from an assembly-language source file.
4436 General options passed to the assembler.
4439 The command line used to assemble an assembly-language
4440 source file into an object file
4441 after first running the file through the C preprocessor.
4442 Any options specified in the $ASFLAGS and $CPPFLAGS construction variables
4443 are included on this command line.
4446 The bibliography generator for the TeX formatter and typesetter and the
4447 LaTeX structured formatter and typesetter.
4450 The command line used to call the bibliography generator for the
4451 TeX formatter and typesetter and the LaTeX structured formatter and
4455 General options passed to the bibliography generator for the TeX formatter
4456 and typesetter and the LaTeX structured formatter and typesetter.
4459 The BitKeeper executable.
4462 The command line for
4463 fetching source files using BitKEeper.
4466 The command ($BITKEEPER) and subcommand
4467 for fetching source files using BitKeeper.
4469 .IP BITKEEPERGETFLAGS
4470 Options that are passed to the BitKeeper
4475 A dictionary mapping the names of the builders
4476 available through this environment
4477 to underlying Builder objects.
4479 Alias, CFile, CXXFile, DVI, Library, Object, PDF, PostScript, and Program
4480 are available by default.
4481 If you initialize this variable when an
4482 Environment is created:
4485 env = Environment(BUILDERS = {'NewBuilder' : foo})
4488 the default Builders will no longer be available.
4489 To use a new Builder object in addition to the default Builders,
4490 add your new Builder object like this:
4494 env.Append(BUILDERS = {'NewBuilder' : foo})
4501 env['BUILDERS]['NewBuilder'] = foo
4508 The command line used to compile a C source file to a (static) object file.
4509 Any options specified in the $CCFLAGS and $CPPFLAGS construction variables
4510 are included on this command line.
4513 General options that are passed to the C compiler.
4516 The suffix for C source files.
4517 This is used by the internal CFile builder
4518 when generating C files from Lex (.l) or YACC (.y) input files.
4519 The default suffix, of course, is
4522 On case-insensitive systems (like Win32),
4529 The version number of the C compiler.
4530 This may or may not be set,
4531 depending on the specific C compiler being used.
4534 A function used to produce variables like $_CPPINCFLAGS. It takes
4536 arguments: a prefix to concatenate onto each element, a list of
4537 elements, a suffix to concatenate onto each element, an environment
4538 for variable interpolation, and an optional function that will be
4539 called to transform the list before concatenation.
4542 env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)',
4546 A platform independent specification of C preprocessor definitions.
4547 The definitions will be added to command lines
4548 through the automatically-generated
4549 $_CPPDEFFLAGS construction variable (see below),
4550 which is constructed according to
4551 the type of value of $CPPDEFINES:
4554 If $CPPDEFINES is a string,
4556 $CPPDEFPREFIX and $CPPDEFSUFFIX
4557 construction variables
4558 will be added to the beginning and end.
4561 # Will add -Dxyz to POSIX compiler command lines,
4562 # and /Dxyz to Microsoft Visual C++ command lines.
4563 env = Environment(CPPDEFINES='xyz')
4567 If $CPPDEFINES is a list,
4569 $CPPDEFPREFIX and $CPPDEFSUFFIX
4570 construction variables
4571 will be appended to the beginning and end
4572 of each element in the list.
4573 If any element is a list or tuple,
4574 then the first item is the name being
4575 defined and the second item is its value:
4578 # Will add -DB=2 -DA to POSIX compiler command lines,
4579 # and /DB=2 /DA to Microsoft Visual C++ command lines.
4580 env = Environment(CPPDEFINES=[('B', 2), 'A'])
4584 If $CPPDEFINES is a dictionary,
4586 $CPPDEFPREFIX and $CPPDEFSUFFIX
4587 construction variables
4588 will be appended to the beginning and end
4589 of each item from the dictionary.
4590 The key of each dictionary item
4591 is a name being defined
4592 to the dictionary item's corresponding value;
4595 then the name is defined without an explicit value.
4596 Note that the resulting flags are sorted by keyword
4597 to ensure that the order of the options on the
4598 command line is consistent each time
4603 # Will add -DA -DB=2 to POSIX compiler command lines,
4604 # and /DA /DB=2 to Microsoft Visual C++ command lines.
4605 env = Environment(CPPDEFINES={'B':2, 'A':None})
4609 An automatically-generated construction variable
4610 containing the C preprocessor command-line options
4612 The value of $_CPPDEFFLAGS is created
4613 by appending $CPPDEFPREFIX and $CPPDEFSUFFIX
4614 to the beginning and end
4615 of each directory in $CPPDEFINES.
4618 The prefix used to specify preprocessor definitions
4619 on the C compiler command line.
4620 This will be appended to the beginning of each definition
4621 in the $CPPDEFINES construction variable
4622 when the $_CPPDEFFLAGS variable is automatically generated.
4625 The suffix used to specify preprocessor definitions
4626 on the C compiler command line.
4627 This will be appended to the end of each definition
4628 in the $CPPDEFINES construction variable
4629 when the $_CPPDEFFLAGS variable is automatically generated.
4632 User-specified C preprocessor options.
4633 These will be included in any command that uses the C preprocessor,
4634 including not just compilation of C and C++ source files
4635 via the $CCCOM, $SHCCCOM, $CXXCOM and $SHCXXCOM command lines,
4636 but also the $FORTRANPPCOM, $SHFORTRANPPCOM,
4637 $F77PPCOM and $SHF77PPCOM command lines
4638 used to compile a Fortran source file,
4639 and the $ASPPCOM command line
4640 used to assemble an assembly language source file,
4641 after first running each file through the C preprocessor.
4642 Note that this variable does
4646 (or similar) include search path options
4647 that scons generates automatically from $CPPPATH.
4651 for the variable that expands to those options.
4654 An automatically-generated construction variable
4655 containing the C preprocessor command-line options
4656 for specifying directories to be searched for include files.
4657 The value of $_CPPINCFLAGS is created
4658 by appending $INCPREFIX and $INCSUFFIX
4659 to the beginning and end
4660 of each directory in $CPPPATH.
4663 The list of directories that the C preprocessor will search for include
4664 directories. The C/C++ implicit dependency scanner will search these
4665 directories for include files. Don't explicitly put include directory
4666 arguments in CCFLAGS or CXXFLAGS because the result will be non-portable
4667 and the directories will not be searched by the dependency scanner. Note:
4668 directory names in CPPPATH will be looked-up relative to the SConscript
4669 directory when they are used in a command. To force
4671 to look-up a directory relative to the root of the source tree use #:
4674 env = Environment(CPPPATH='#/include')
4678 The directory look-up can also be forced using the
4683 include = Dir('include')
4684 env = Environment(CPPPATH=include)
4688 The directory list will be added to command lines
4689 through the automatically-generated
4691 construction variable,
4692 which is constructed by
4693 appending the values of the
4694 $INCPREFIX and $INCSUFFIX
4695 construction variables
4696 to the beginning and end
4697 of each directory in $CPPPATH.
4698 Any command lines you define that need
4699 the CPPPATH directory list should
4700 include $_CPPINCFLAGS:
4703 env = Environment(CCCOM="my_compiler $_CPPINCFLAGS -c -o $TARGET $SOURCE")
4707 The list of suffixes of files that will be scanned
4708 for C preprocessor implicit dependencies
4710 The default list is:
4713 [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
4714 ".h", ".H", ".hxx", ".hpp", ".hh",
4715 ".F", ".fpp", ".FPP",
4716 ".S", ".spp", ".SPP"]
4723 Options that are passed to the CVS checkout subcommand.
4726 The command line used to
4727 fetch source files from a CVS repository.
4730 General options that are passed to CVS.
4731 By default, this is set to
4733 to specify from where the files must be fetched.
4736 The path to the CVS repository.
4737 This is referenced in the default
4744 The suffix for C++ source files.
4745 This is used by the internal CXXFile builder
4746 when generating C++ files from Lex (.ll) or YACC (.yy) input files.
4747 The default suffix is
4749 SCons also treats files with the suffixes
4756 On case-sensitive systems (Linux, UNIX, and other POSIX-alikes),
4763 The command line used to compile a C++ source file to an object file.
4764 Any options specified in the $CXXFLAGS and $CPPFLAGS construction variables
4765 are included on this command line.
4768 General options that are passed to the C++ compiler.
4771 The version number of the C++ compiler.
4772 This may or may not be set,
4773 depending on the specific C++ compiler being used.
4776 A function that converts a file name into a Dir instance relative to the
4780 The list of suffixes of files that will be scanned
4781 for imported D package files.
4782 The default list is:
4789 The TeX DVI file to PDF file converter.
4792 General options passed to the TeX DVI file to PDF file converter.
4795 The command line used to convert TeX DVI files into a PDF file.
4798 The TeX DVI file to PostScript converter.
4801 General options passed to the TeX DVI file to PostScript converter.
4804 A dictionary of environment variables
4805 to use when invoking commands. When ENV is used in a command all list
4806 values will be joined using the path separator and any other non-string
4807 values will simply be coerced to a string.
4808 Note that, by default,
4812 propagate the environment in force when you
4815 to the commands used to build target files.
4816 This is so that builds will be guaranteed
4817 repeatable regardless of the environment
4818 variables set at the time
4822 If you want to propagate your
4823 environment variables
4824 to the commands executed
4825 to build target files,
4826 you must do so explicitly:
4830 env = Environment(ENV = os.environ)
4834 Note that you can choose only to propagate
4835 certain environment variables.
4839 environment variable,
4842 uses the same utilities
4843 as the invoking shell (or other process):
4848 env = Environment(ENV = {'PATH' : os.environ['PATH']})
4852 A function that will be called to escape shell special characters in
4853 command lines. The function should take one argument: the command line
4854 string to escape; and should return the escaped command line.
4857 The Fortran 77 compiler.
4858 You should normally set the $FORTRAN variable,
4859 which specifies the default Fortran compiler
4860 for all Fortran versions.
4861 You only need to set $F77 if you need to use a specific compiler
4862 or compiler version for Fortran 77 files.
4865 The command line used to compile a Fortran 77 source file to an object file.
4866 You only need to set $F77COM if you need to use a specific
4867 command line for Fortran 77 files.
4868 You should normally set the $FORTRANCOM variable,
4869 which specifies the default command line
4870 for all Fortran versions.
4873 General user-specified options that are passed to the Fortran 77 compiler.
4874 Note that this variable does
4878 (or similar) include search path options
4879 that scons generates automatically from $F77PATH.
4883 for the variable that expands to those options.
4884 You only need to set $F77FLAGS if you need to define specific
4885 user options for Fortran 77 files.
4886 You should normally set the $FORTRANFLAGS variable,
4887 which specifies the user-specified options
4888 passed to the default Fortran compiler
4889 for all Fortran versions.
4892 An automatically-generated construction variable
4893 containing the Fortran 77 compiler command-line options
4894 for specifying directories to be searched for include files.
4895 The value of $_F77INCFLAGS is created
4896 by appending $INCPREFIX and $INCSUFFIX
4897 to the beginning and end
4898 of each directory in $F77PATH.
4901 The list of directories that the Fortran 77 compiler will search for include
4902 directories. The implicit dependency scanner will search these
4903 directories for include files. Don't explicitly put include directory
4904 arguments in $F77FLAGS because the result will be non-portable
4905 and the directories will not be searched by the dependency scanner. Note:
4906 directory names in $F77PATH will be looked-up relative to the SConscript
4907 directory when they are used in a command. To force
4909 to look-up a directory relative to the root of the source tree use #:
4910 You only need to set $F77PATH if you need to define a specific
4911 include path for Fortran 77 files.
4912 You should normally set the $FORTRANPATH variable,
4913 which specifies the include path
4914 for the default Fortran compiler
4915 for all Fortran versions.
4918 env = Environment(F77PATH='#/include')
4922 The directory look-up can also be forced using the
4927 include = Dir('include')
4928 env = Environment(F77PATH=include)
4932 The directory list will be added to command lines
4933 through the automatically-generated
4935 construction variable,
4936 which is constructed by
4937 appending the values of the
4938 $INCPREFIX and $INCSUFFIX
4939 construction variables
4940 to the beginning and end
4941 of each directory in $F77PATH.
4942 Any command lines you define that need
4943 the F77PATH directory list should
4944 include $_F77INCFLAGS:
4947 env = Environment(F77COM="my_compiler $_F77INCFLAGS -c -o $TARGET $SOURCE")
4951 The command line used to compile a Fortran 77 source file to an object file
4952 after first running the file through the C preprocessor.
4953 Any options specified in the $F77FLAGS and $CPPFLAGS construction variables
4954 are included on this command line.
4955 You only need to set $F77PPCOM if you need to use a specific
4956 C-preprocessor command line for Fortran 77 files.
4957 You should normally set the $FORTRANPPCOM variable,
4958 which specifies the default C-preprocessor command line
4959 for all Fortran versions.
4962 The Fortran 90 compiler.
4963 You should normally set the $FORTRAN variable,
4964 which specifies the default Fortran compiler
4965 for all Fortran versions.
4966 You only need to set $F90 if you need to use a specific compiler
4967 or compiler version for Fortran 90 files.
4970 The command line used to compile a Fortran 90 source file to an object file.
4971 You only need to set $F90COM if you need to use a specific
4972 command line for Fortran 90 files.
4973 You should normally set the $FORTRANCOM variable,
4974 which specifies the default command line
4975 for all Fortran versions.
4978 General user-specified options that are passed to the Fortran 90 compiler.
4979 Note that this variable does
4983 (or similar) include search path options
4984 that scons generates automatically from $F90PATH.
4988 for the variable that expands to those options.
4989 You only need to set $F90FLAGS if you need to define specific
4990 user options for Fortran 90 files.
4991 You should normally set the $FORTRANFLAGS variable,
4992 which specifies the user-specified options
4993 passed to the default Fortran compiler
4994 for all Fortran versions.
4997 An automatically-generated construction variable
4998 containing the Fortran 90 compiler command-line options
4999 for specifying directories to be searched for include files.
5000 The value of $_F90INCFLAGS is created
5001 by appending $INCPREFIX and $INCSUFFIX
5002 to the beginning and end
5003 of each directory in $F90PATH.
5006 The list of directories that the Fortran 90 compiler will search for include
5007 directories. The implicit dependency scanner will search these
5008 directories for include files. Don't explicitly put include directory
5009 arguments in $F90FLAGS because the result will be non-portable
5010 and the directories will not be searched by the dependency scanner. Note:
5011 directory names in $F90PATH will be looked-up relative to the SConscript
5012 directory when they are used in a command. To force
5014 to look-up a directory relative to the root of the source tree use #:
5015 You only need to set $F90PATH if you need to define a specific
5016 include path for Fortran 90 files.
5017 You should normally set the $FORTRANPATH variable,
5018 which specifies the include path
5019 for the default Fortran compiler
5020 for all Fortran versions.
5023 env = Environment(F90PATH='#/include')
5027 The directory look-up can also be forced using the
5032 include = Dir('include')
5033 env = Environment(F90PATH=include)
5037 The directory list will be added to command lines
5038 through the automatically-generated
5040 construction variable,
5041 which is constructed by
5042 appending the values of the
5043 $INCPREFIX and $INCSUFFIX
5044 construction variables
5045 to the beginning and end
5046 of each directory in $F90PATH.
5047 Any command lines you define that need
5048 the F90PATH directory list should
5049 include $_F90INCFLAGS:
5052 env = Environment(F90COM="my_compiler $_F90INCFLAGS -c -o $TARGET $SOURCE")
5056 The command line used to compile a Fortran 90 source file to an object file
5057 after first running the file through the C preprocessor.
5058 Any options specified in the $F90FLAGS and $CPPFLAGS construction variables
5059 are included on this command line.
5060 You only need to set $F90PPCOM if you need to use a specific
5061 C-preprocessor command line for Fortran 90 files.
5062 You should normally set the $FORTRANPPCOM variable,
5063 which specifies the default C-preprocessor command line
5064 for all Fortran versions.
5067 The Fortran 95 compiler.
5068 You should normally set the $FORTRAN variable,
5069 which specifies the default Fortran compiler
5070 for all Fortran versions.
5071 You only need to set $F95 if you need to use a specific compiler
5072 or compiler version for Fortran 95 files.
5075 The command line used to compile a Fortran 95 source file to an object file.
5076 You only need to set $F95COM if you need to use a specific
5077 command line for Fortran 95 files.
5078 You should normally set the $FORTRANCOM variable,
5079 which specifies the default command line
5080 for all Fortran versions.
5083 General user-specified options that are passed to the Fortran 95 compiler.
5084 Note that this variable does
5088 (or similar) include search path options
5089 that scons generates automatically from $F95PATH.
5093 for the variable that expands to those options.
5094 You only need to set $F95FLAGS if you need to define specific
5095 user options for Fortran 95 files.
5096 You should normally set the $FORTRANFLAGS variable,
5097 which specifies the user-specified options
5098 passed to the default Fortran compiler
5099 for all Fortran versions.
5102 An automatically-generated construction variable
5103 containing the Fortran 95 compiler command-line options
5104 for specifying directories to be searched for include files.
5105 The value of $_F95INCFLAGS is created
5106 by appending $INCPREFIX and $INCSUFFIX
5107 to the beginning and end
5108 of each directory in $F95PATH.
5111 The list of directories that the Fortran 95 compiler will search for include
5112 directories. The implicit dependency scanner will search these
5113 directories for include files. Don't explicitly put include directory
5114 arguments in $F95FLAGS because the result will be non-portable
5115 and the directories will not be searched by the dependency scanner. Note:
5116 directory names in $F95PATH will be looked-up relative to the SConscript
5117 directory when they are used in a command. To force
5119 to look-up a directory relative to the root of the source tree use #:
5120 You only need to set $F95PATH if you need to define a specific
5121 include path for Fortran 95 files.
5122 You should normally set the $FORTRANPATH variable,
5123 which specifies the include path
5124 for the default Fortran compiler
5125 for all Fortran versions.
5128 env = Environment(F95PATH='#/include')
5132 The directory look-up can also be forced using the
5137 include = Dir('include')
5138 env = Environment(F95PATH=include)
5142 The directory list will be added to command lines
5143 through the automatically-generated
5145 construction variable,
5146 which is constructed by
5147 appending the values of the
5148 $INCPREFIX and $INCSUFFIX
5149 construction variables
5150 to the beginning and end
5151 of each directory in $F95PATH.
5152 Any command lines you define that need
5153 the F95PATH directory list should
5154 include $_F95INCFLAGS:
5157 env = Environment(F95COM="my_compiler $_F95INCFLAGS -c -o $TARGET $SOURCE")
5161 The command line used to compile a Fortran 95 source file to an object file
5162 after first running the file through the C preprocessor.
5163 Any options specified in the $F95FLAGS and $CPPFLAGS construction variables
5164 are included on this command line.
5165 You only need to set $F95PPCOM if you need to use a specific
5166 C-preprocessor command line for Fortran 95 files.
5167 You should normally set the $FORTRANPPCOM variable,
5168 which specifies the default C-preprocessor command line
5169 for all Fortran versions.
5172 The default Fortran compiler
5173 for all versions of Fortran.
5176 The command line used to compile a Fortran source file to an object file.
5177 By default, any options specified
5178 in the $FORTRANFLAGS, $CPPFLAGS, $_CPPDEFFLAGS,
5179 $_FORTRANMODFLAG, and $_FORTRANINCFLAGS construction variables
5180 are included on this command line.
5183 General user-specified options that are passed to the Fortran compiler.
5184 Note that this variable does
5188 (or similar) include or module search path options
5189 that scons generates automatically from $FORTRANPATH.
5191 .BR _FORTRANINCFLAGS and _FORTRANMODFLAGS,
5193 for the variables that expand those options.
5195 .IP _FORTRANINCFLAGS
5196 An automatically-generated construction variable
5197 containing the Fortran compiler command-line options
5198 for specifying directories to be searched for include
5199 files and module files.
5200 The value of $_FORTRANINCFLAGS is created
5201 by prepending/appending $INCPREFIX and $INCSUFFIX
5202 to the beginning and end
5203 of each directory in $FORTRANPATH.
5206 Directory location where the Fortran compiler should place
5207 any module files it generates. This variable is empty, by default. Some
5208 Fortran compilers will internally append this directory in the search path
5209 for module files, as well
5211 .IP FORTRANMODDIRPREFIX
5212 The prefix used to specify a module directory on the Fortran compiler command
5214 This will be appended to the beginning of the directory
5215 in the $FORTRANMODDIR construction variables
5216 when the $_FORTRANMODFLAG variables is automatically generated.
5218 .IP FORTRANMODDIRSUFFIX
5219 The suffix used to specify a module directory on the Fortran compiler command
5221 This will be appended to the beginning of the directory
5222 in the $FORTRANMODDIR construction variables
5223 when the $_FORTRANMODFLAG variables is automatically generated.
5226 An automatically-generated construction variable
5227 containing the Fortran compiler command-line option
5228 for specifying the directory location where the Fortran
5229 compiler should place any module files that happen to get
5230 generated during compilation.
5231 The value of $_FORTRANMODFLAG is created
5232 by prepending/appending $FORTRANMODDIRPREFIX and $FORTRANMODDIRSUFFIX
5233 to the beginning and end of the directory in $FORTRANMODDIR.
5235 .IP FORTRANMODPREFIX
5236 The module file prefix used by the Fortran compiler. SCons assumes that
5237 the Fortran compiler follows the quasi-standard naming convention for
5239 .I <module_name>.mod.
5240 As a result, this variable is left empty, by default. For situations in
5241 which the compiler does not necessarily follow the normal convention,
5242 the user may use this variable. Its value will be appended to every
5243 module file name as scons attempts to resolve dependencies.
5245 .IP FORTRANMODSUFFIX
5246 The module file suffix used by the Fortran compiler. SCons assumes that
5247 the Fortran compiler follows the quasi-standard naming convention for
5249 .I <module_name>.mod.
5250 As a result, this variable is set to ".mod", by default. For situations
5251 in which the compiler does not necessarily follow the normal convention,
5252 the user may use this variable. Its value will be appended to every
5253 module file name as scons attempts to resolve dependencies.
5256 The list of directories that the Fortran compiler will search for
5257 include files and (for some compilers) module files. The Fortran implicit
5258 dependency scanner will search these directories for include files (but
5259 not module files since they are autogenerated and, as such, may not
5260 actually exist at the time the scan takes place). Don't explicitly put
5261 include directory arguments in FORTRANFLAGS because the result will be
5262 non-portable and the directories will not be searched by the dependency
5263 scanner. Note: directory names in FORTRANPATH will be looked-up relative
5264 to the SConscript directory when they are used in a command. To force
5266 to look-up a directory relative to the root of the source tree use #:
5269 env = Environment(FORTRANPATH='#/include')
5273 The directory look-up can also be forced using the
5278 include = Dir('include')
5279 env = Environment(FORTRANPATH=include)
5283 The directory list will be added to command lines
5284 through the automatically-generated
5286 construction variable,
5287 which is constructed by
5288 appending the values of the
5289 $INCPREFIX and $INCSUFFIX
5290 construction variables
5291 to the beginning and end
5292 of each directory in $FORTRANPATH.
5293 Any command lines you define that need
5294 the FORTRANPATH directory list should
5295 include $_FORTRANINCFLAGS:
5298 env = Environment(FORTRANCOM="my_compiler $_FORTRANINCFLAGS -c -o $TARGET $SOURCE")
5302 The command line used to compile a Fortran source file to an object file
5303 after first running the file through the C preprocessor.
5304 By default, any options specified in the $FORTRANFLAGS, $CPPFLAGS,
5305 _CPPDEFFLAGS, $_FORTRANMODFLAG, and $_FORTRANINCFLAGS
5306 construction variables are included on this command line.
5309 The list of suffixes of files that will be scanned
5310 for Fortran implicit dependencies
5311 (INCLUDE lines & USE statements).
5312 The default list is:
5315 [".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
5316 ".f77", ".F77", ".f90", ".F90", ".f95", ".F95"]
5320 A function that converts a file name into a File instance relative to the
5324 The Ghostscript program used to convert PostScript to PDF files.
5327 General options passed to the Ghostscript program
5328 when converting PostScript to PDF files.
5331 The Ghostscript command line used to convert PostScript to PDF files.
5334 The list of suffixes of files that will be scanned
5335 for IDL implicit dependencies
5336 (#include or import lines).
5337 The default list is:
5344 The prefix used to specify an include directory on the C compiler command
5346 This will be appended to the beginning of each directory
5347 in the $CPPPATH and $FORTRANPATH construction variables
5348 when the $_CPPINCFLAGS and $_FORTRANINCFLAGS
5349 variables are automatically generated.
5352 The suffix used to specify an include directory on the C compiler command
5354 This will be appended to the end of each directory
5355 in the $CPPPATH and $FORTRANPATH construction variables
5356 when the $_CPPINCFLAGS and $_FORTRANINCFLAGS
5357 variables are automatically generated.
5360 A function to be called to install a file into a
5361 destination file name.
5362 The default function copies the file into the destination
5363 (and sets the destination file's mode and permission bits
5364 to match the source file's).
5365 The function takes the following arguments:
5368 def install(dest, source, env):
5372 is the path name of the destination file.
5374 is the path name of the source file.
5376 is the construction environment
5377 (a dictionary of construction values)
5378 in force for this file installation.
5381 The Java archive tool.
5384 The directory to which the Java archive tool should change
5390 The command line used to call the Java archive tool.
5393 General options passed to the Java archive tool.
5394 By default this is set to
5396 to create the necessary
5401 The suffix for Java archives:
5409 The command line used to compile a directory tree containing
5410 Java source files to
5411 corresponding Java class files.
5412 Any options specified in the $JAVACFLAGS construction variable
5413 are included on this command line.
5416 General options that are passed to the Java compiler.
5419 The directory in which Java class files may be found.
5420 This is stripped from the beginning of any Java .class
5421 file names supplied to the
5426 The suffix for Java class files;
5431 The Java generator for C header and stub files.
5434 The command line used to generate C header and stub files
5436 Any options specified in the $JAVAHFLAGS construction variable
5437 are included on this command line.
5440 General options passed to the C header and stub file generator
5444 The suffix for Java files;
5449 The LaTeX structured formatter and typesetter.
5452 The command line used to call the LaTeX structured formatter and typesetter.
5455 General options passed to the LaTeX structured formatter and typesetter.
5458 The lexical analyzer generator.
5461 General options passed to the lexical analyzer generator.
5464 The command line used to call the lexical analyzer generator
5465 to generate a source file.
5468 An automatically-generated construction variable
5469 containing the linker command-line options
5470 for specifying directories to be searched for library.
5471 The value of $_LIBDIRFLAGS is created
5472 by appending $LIBDIRPREFIX and $LIBDIRSUFFIX
5473 to the beginning and end
5474 of each directory in $LIBPATH.
5477 The prefix used to specify a library directory on the linker command line.
5478 This will be appended to the beginning of each directory
5479 in the $LIBPATH construction variable
5480 when the $_LIBDIRFLAGS variable is automatically generated.
5483 The suffix used to specify a library directory on the linker command line.
5484 This will be appended to the end of each directory
5485 in the $LIBPATH construction variable
5486 when the $_LIBDIRFLAGS variable is automatically generated.
5489 An automatically-generated construction variable
5490 containing the linker command-line options
5491 for specifying libraries to be linked with the resulting target.
5492 The value of $_LIBFLAGS is created
5493 by appending $LIBLINKPREFIX and $LIBLINKSUFFIX
5494 to the beginning and end
5495 of each directory in $LIBS.
5498 The prefix used to specify a library to link on the linker command line.
5499 This will be appended to the beginning of each library
5500 in the $LIBS construction variable
5501 when the $_LIBFLAGS variable is automatically generated.
5504 The suffix used to specify a library to link on the linker command line.
5505 This will be appended to the end of each library
5506 in the $LIBS construction variable
5507 when the $_LIBFLAGS variable is automatically generated.
5510 The list of directories that will be searched for libraries.
5511 The implicit dependency scanner will search these
5512 directories for include files. Don't explicitly put include directory
5513 arguments in $LINKFLAGS or $SHLINKFLAGS
5514 because the result will be non-portable
5515 and the directories will not be searched by the dependency scanner. Note:
5516 directory names in LIBPATH will be looked-up relative to the SConscript
5517 directory when they are used in a command. To force
5519 to look-up a directory relative to the root of the source tree use #:
5522 env = Environment(LIBPATH='#/libs')
5526 The directory look-up can also be forced using the
5532 env = Environment(LIBPATH=libs)
5536 The directory list will be added to command lines
5537 through the automatically-generated
5539 construction variable,
5540 which is constructed by
5541 appending the values of the
5542 $LIBDIRPREFIX and $LIBDIRSUFFIX
5543 construction variables
5544 to the beginning and end
5545 of each directory in $LIBPATH.
5546 Any command lines you define that need
5547 the LIBPATH directory list should
5548 include $_LIBDIRFLAGS:
5551 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
5555 The prefix used for (static) library file names.
5556 A default value is set for each platform
5557 (posix, win32, os2, etc.),
5558 but the value is overridden by individual tools
5559 (ar, mslib, sgiar, sunar, tlib, etc.)
5560 to reflect the names of the libraries they create.
5563 An array of legal prefixes for library file names.
5566 A list of one or more libraries
5567 that will be linked with
5568 any executable programs
5569 created by this environment.
5572 The library list will be added to command lines
5573 through the automatically-generated
5575 construction variable,
5576 which is constructed by
5577 appending the values of the
5578 $LIBLINKPREFIX and $LIBLINKSUFFIX
5579 construction variables
5580 to the beginning and end
5581 of each directory in $LIBS.
5582 Any command lines you define that need
5583 the LIBS library list should
5587 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
5591 The suffix used for (static) library file names.
5592 A default value is set for each platform
5593 (posix, win32, os2, etc.),
5594 but the value is overridden by individual tools
5595 (ar, mslib, sgiar, sunar, tlib, etc.)
5596 to reflect the names of the libraries they create.
5599 An array of legal suffixes for library file names.
5605 General user options passed to the linker.
5606 Note that this variable should
5610 (or similar) options for linking with the libraries listed in $LIBS,
5613 (or similar) library search path options
5614 that scons generates automatically from $LIBPATH.
5618 for the variable that expands to library-link options,
5622 for the variable that expands to library search path options.
5625 The command line used to link object files into an executable.
5628 The M4 macro preprocessor.
5631 General options passed to the M4 macro preprocessor.
5634 The command line used to pass files through the macro preprocessor.
5637 The maximum number of characters allowed on an external command line.
5639 link lines longer than this many characters
5640 are linke via a temporary file name.
5643 When the Microsoft Visual Studio tools are initialized, they set up
5644 this dictionary with the following keys:
5647 the version of MSVS being used (can be set via
5651 the available versions of MSVS installed
5654 installed directory of Visual C++
5657 installed directory of Visual Studio
5660 installed directory of the .NET framework
5662 .B FRAMEWORKVERSIONS:
5663 list of installed versions of the .NET framework, sorted latest to oldest.
5665 .B FRAMEWORKVERSION:
5666 latest installed version of the .NET framework
5669 installed location of the .NET SDK.
5672 installed location of the Platform SDK.
5674 .B PLATFORMSDK_MODULES:
5675 dictionary of installed Platform SDK modules,
5676 where the dictionary keys are keywords for the various modules, and
5677 the values are 2-tuples where the first is the release date, and the
5678 second is the version number.
5680 If a value isn't set, it wasn't available in the registry.
5682 .IP MSVS_IGNORE_IDE_PATHS
5683 Tells the MS Visual Studio tools to use minimal INCLUDE, LIB, and PATH settings,
5684 instead of the settings from the IDE.
5686 For Visual Studio, SCons will (by default) automatically determine
5687 where MSVS is installed, and use the LIB, INCLUDE, and PATH variables
5688 set by the IDE. You can override this behavior by setting these
5689 variables after Environment initialization, or by setting
5690 .B MSVS_IGNORE_IDE_PATHS = 1
5691 in the Environment initialization.
5692 Specifying this will not leave these unset, but will set them to a
5693 minimal set of paths needed to run the tools successfully.
5696 For VS6, the mininimal set is:
5697 INCLUDE:'<VSDir>\\VC98\\ATL\\include;<VSDir>\\VC98\\MFC\\include;<VSDir>\\VC98\\include'
5698 LIB:'<VSDir>\\VC98\\MFC\\lib;<VSDir>\\VC98\\lib'
5699 PATH:'<VSDir>\\Common\\MSDev98\\bin;<VSDir>\\VC98\\bin'
5701 INCLUDE:'<VSDir>\\Vc7\\atlmfc\\include;<VSDir>\\Vc7\\include'
5702 LIB:'<VSDir>\\Vc7\\atlmfc\\lib;<VSDir>\\Vc7\\lib'
5703 PATH:'<VSDir>\\Common7\\Tools\\bin;<VSDir>\\Common7\\Tools;<VSDir>\\Vc7\\bin'
5707 Where '<VSDir>' is the installed location of Visual Studio.
5709 .IP MSVS_USE_MFC_DIRS
5710 Tells the MS Visual Studio tool(s) to use
5711 the MFC directories in its default paths
5712 for compiling and linking.
5713 Under MSVS version 6,
5715 .B MSVS_USE_MFC_DIRS
5724 external environment variable,
5730 external environment variable.
5731 Under MSVS version 7,
5733 .B MSVS_USE_MFC_DIRS
5736 .B "atlmfc\\\\include"
5737 directory to the default
5739 external environment variable,
5742 directory to the default
5744 external environment variable.
5745 The current default value is
5747 which means these directories
5748 are added to the paths by default.
5749 This default value is likely to change
5750 in a future release,
5751 so users who want the ATL and MFC
5752 values included in their paths
5753 are encouraged to enable the
5754 .B MSVS_USE_MFC_DIRS
5756 to avoid future incompatibility.
5757 This variable has no effect if the
5761 environment variables are set explictly.
5764 Sets the preferred version of MSVS to use.
5766 SCons will (by default) select the latest version of MSVS
5767 installed on your machine. So, if you have version 6 and version 7
5768 (MSVS .NET) installed, it will prefer version 7. You can override this by
5771 variable in the Environment initialization, setting it to the
5772 appropriate version ('6.0' or '7.0', for example).
5773 If the given version isn't installed, tool initialization will fail.
5776 The action used to generate Microsoft Visual Studio
5777 project and solution files.
5779 .IP MSVSPROJECTSUFFIX
5780 The suffix used for Microsoft Visual Studio project (DSP) files.
5781 The default value is
5783 when using Visual Studio version 7.x (.NET),
5786 when using earlier versions of Visual Studio.
5788 .IP MSVSSOLUTIONSUFFIX
5789 The suffix used for Microsoft Visual Studio solution (DSW) files.
5790 The default value is
5792 when using Visual Studio version 7.x (.NET),
5795 when using earlier versions of Visual Studio.
5798 When set to non-zero,
5799 suppresses creation of a corresponding Win32 static import lib by the
5801 builder when used with
5802 MinGW or Microsoft Visual Studio.
5803 This also suppresses creation
5804 of an export (.exp) file
5805 when using Microsoft Visual Studio.
5808 The prefix used for (static) object file names.
5811 The suffix used for (static) object file names.
5814 The Perforce executable.
5817 The command line used to
5818 fetch source files from Perforce.
5821 General options that are passed to Perforce.
5824 The Microsoft Visual C++ precompiled header that will be used when compiling
5825 object files. This variable is ignored by tools other than Microsoft Visual C++.
5826 When this variable is
5827 defined SCons will add options to the compiler command line to
5828 cause it to use the precompiled header, and will also set up the
5829 dependencies for the PCH file. Example:
5832 env['PCH'] = 'StdAfx.pch'
5836 This variable specifies how much of a source file is precompiled. This
5837 variable is ignored by tools other than Microsoft Visual C++, or when
5838 the PCH variable is not being used. When this variable is define it
5839 must be a string that is the name of the header that
5840 is included at the end of the precompiled portion of the source files, or
5841 the empty string if the "#pragma hrdstop" construct is being used:
5844 env['PCHSTOP'] = 'StdAfx.h'
5848 The Microsoft Visual C++ PDB file that will store debugging information for
5849 object files, shared libraries, and programs. This variable is ignored by
5850 tools other than Microsoft Visual C++.
5851 When this variable is
5852 defined SCons will add options to the compiler and linker command line to
5853 cause them to generate external debugging information, and will also set up the
5854 dependencies for the PDB file. Example:
5857 env['PDB'] = 'hello.pdb'
5861 A deprecated synonym for $DVIPDFCOM.
5864 The prefix used for PDF file names.
5867 The suffix used for PDF file names.
5870 The name of the platform used to create the Environment. If no platform is
5871 specified when the Environment is created,
5873 autodetects the platform.
5876 env = Environment(tools = [])
5877 if env['PLATFORM'] == 'cygwin':
5883 .IP PRINT_CMD_LINE_FUNC
5884 A Python function used to print the command lines as they are executed
5885 (assuming command printing is not disabled by the
5889 options or their equivalents).
5890 The function should take four arguments:
5892 the command being executed (a string),
5894 the target being built (file node, list, or string name(s)),
5896 the source(s) used (file node, list, or string name(s)), and
5898 the environment being used.
5900 The function must do the printing itself. The default implementation,
5901 used if this variable is not set or is None, is:
5903 def print_cmd_line(s, target, source, env):
5904 sys.stdout.write(s + "\n")
5907 Here's an example of a more interesting function:
5909 def print_cmd_line(s, target, source, env):
5910 sys.stdout.write("Building %s -> %s...\n" %
5911 (' and '.join([str(x) for x in source]),
5912 ' and '.join([str(x) for x in target])))
5913 env=Environment(PRINT_CMD_LINE_FUNC=print_cmd_line)
5914 env.Program('foo', 'foo.c')
5917 This just prints "Building <targetname> from <sourcename>..." instead
5918 of the actual commands.
5919 Such a function could also log the actual commands to a log file,
5923 The prefix used for executable file names.
5926 The suffix used for executable file names.
5929 The command line used to convert TeX DVI files into a PostScript file.
5932 The prefix used for PostScript file names.
5935 The prefix used for PostScript file names.
5938 The qt tool tries to take this from os.environ.
5939 It also initializes all QT_*
5940 construction variables listed below.
5941 (Note that all paths are constructed
5942 with python's os.path.join() method,
5943 but are listed here with the '/' separator
5944 for easier reading.)
5945 In addition, the construction environment
5946 variables CPPPATH, LIBPATH and LIBS may be modified
5948 PROGEMITTER, SHLIBEMITTER and LIBEMITTER
5949 are modified. Because the build-performance is affected when using this tool,
5950 you have to explicitly specify it at Environment creation:
5953 Environment(tools=['default','qt'])
5956 The qt tool supports the following operations:
5958 .B Automatic moc file generation from header files.
5959 You do not have to specify moc files explicitly, the tool does it for you.
5960 However, there are a few preconditions to do so: Your header file must have
5961 the same filebase as your implementation file and must stay in the same
5962 directory. It must have one of the suffixes .h, .hpp, .H, .hxx, .hh. You
5963 can turn off automatic moc file generation by setting QT_AUTOSCAN to 0.
5964 See also the corresponding builder method
5967 .B Automatic moc file generation from cxx files.
5968 As stated in the qt documentation, include the moc file at the end of
5969 the cxx file. Note that you have to include the file, which is generated
5970 by the transformation ${QT_MOCCXXPREFIX}<basename>${QT_MOCCXXSUFFIX}, by default
5971 <basename>.moc. A warning is generated after building the moc file, if you
5972 do not include the correct file. If you are using BuildDir, you may
5973 need to specify duplicate=1. You can turn off automatic moc file generation
5974 by setting QT_AUTOSCAN to 0. See also the corresponding builder method
5977 .B Automatic handling of .ui files.
5978 The implementation files generated from .ui files are handled much the same
5979 as yacc or lex files. Each .ui file given as a source of Program, Library or
5980 SharedLibrary will generate three files, the declaration file, the
5981 implementation file and a moc file. Because there are also generated headers,
5982 you may need to specify duplicate=1 in calls to BuildDir. See also the corresponding builder method
5986 Turn off scanning for mocable files. Use the Moc Builder to explicitely
5987 specify files to run moc on.
5990 The path where the qt binaries are installed.
5991 The default value is '$QTDIR/bin'.
5994 The path where the qt header files are installed.
5995 The default value is '$QTDIR/include'.
5996 Note: If you set this variable to None, the tool won't change the CPPPATH
5997 construction variable.
6000 Prints lots of debugging information while scanning for moc files.
6003 The path where the qt libraries are installed.
6004 The default value is '$QTDIR/lib'.
6005 Note: If you set this variable to None, the tool won't change the LIBPATH
6006 construction variable.
6009 Default value is 'qt'. You may want to set this to 'qt-mt'. Note: If you set
6010 this variable to None, the tool won't change the LIBS variable.
6013 Default value is '$QT_BINPATH/moc'.
6016 Default value is ''. Prefix for moc output files, when source is a cxx file.
6019 Default value is '.moc'. Suffix for moc output files, when source is a cxx
6022 .IP QT_MOCFROMCPPFLAGS
6023 Default value is '-i'. These flags are passed to moc, when moccing a
6026 .IP QT_MOCFROMCXXCOM
6027 Command to generate a moc file from a cpp file.
6030 Command to generate a moc file from a header.
6032 .IP QT_MOCFROMHFLAGS
6033 Default value is ''. These flags are passed to moc, when moccing a header
6037 Default value is 'moc_'. Prefix for moc output files, when source is a header.
6040 Default value is '$CXXFILESUFFIX'. Suffix for moc output files, when source is
6044 Default value is '$QT_BINPATH/uic'.
6047 Command to generate header files from .ui files.
6050 Default value is ''. These flags are passed to uic, when creating a a h
6051 file from a .ui file.
6053 .IP QT_UICDECLPREFIX
6054 Default value is ''. Prefix for uic generated header files.
6056 .IP QT_UICDECLSUFFIX
6057 Default value is '.h'. Suffix for uic generated header files.
6060 Command to generate cxx files from .ui files.
6063 Default value is ''. These flags are passed to uic, when creating a cxx
6064 file from a .ui file.
6066 .IP QT_UICIMPLPREFIX
6067 Default value is 'uic_'. Prefix for uic generated implementation files.
6069 .IP QT_UICIMPLSUFFIX
6070 Default value is '$CXXFILESUFFIX'. Suffix for uic generated implementation
6074 Default value is '.ui'. Suffix of designer input files.
6077 The archive indexer.
6080 General options passed to the archive indexer.
6083 The resource compiler used by the RES builder.
6086 The command line used by the RES builder.
6089 The flags passed to the resource compiler by the RES builder.
6093 Note that this variable is not actually used
6094 for the command to fetch source files from RCS;
6097 construction variable, below.
6100 The RCS "checkout" executable,
6101 used to fetch source files from RCS.
6104 The command line used to
6105 fetch (checkout) source files from RCS.
6108 Options that are passed to the $RCS_CO command.
6111 A function that converts a file name into a list of Dir instances by
6112 searching the repositories.
6115 The Java RMI stub compiler.
6118 The command line used to compile stub
6119 and skeleton class files
6120 from Java classes that contain RMI implementations.
6121 Any options specified in the $RMICFLAGS construction variable
6122 are included on this command line.
6125 General options passed to the Java RMI stub compiler.
6128 The RPC protocol compiler.
6130 .IP RPCGENCLIENTFLAGS
6131 Options passed to the RPC protocol compiler
6132 when generating client side stubs.
6133 These are in addition to any flags specified in the
6135 construction variable.
6138 General options passed to the RPC protocol compiler.
6140 .IP RPCGENHEADERFLAGS
6141 Options passed to the RPC protocol compiler
6142 when generating a header file.
6143 These are in addition to any flags specified in the
6145 construction variable.
6147 .IP RPCGENSERVICEFLAGS
6148 Options passed to the RPC protocol compiler
6149 when generating server side stubs.
6150 These are in addition to any flags specified in the
6152 construction variable.
6155 Options passed to the RPC protocol compiler
6156 when generating XDR routines.
6157 These are in addition to any flags specified in the
6159 construction variable.
6162 A list of paths to search for shared libraries when running programs.
6163 Currently only used in the GNU linker (gnulink) and IRIX linker (sgilink).
6164 Ignored on platforms and toolchains that don't support it.
6165 Note that the paths added to RPATH
6166 are not transformed by
6168 in any way: if you want an absolute
6169 path, you must make it absolute yourself.
6172 A list of the available implicit dependency scanners.
6173 New file scanners may be added by
6174 appending to this list,
6175 although the more flexible approach
6176 is to associate scanners
6177 with a specific Builder.
6178 See the sections "Builder Objects"
6179 and "Scanner Objects,"
6180 below, for more information.
6183 The SCCS executable.
6186 The command line used to
6187 fetch source files from SCCS.
6190 General options that are passed to SCCS.
6193 Options that are passed specifically to the SCCS "get" subcommand.
6194 This can be set, for example, to
6196 to check out editable files from SCCS.
6199 The C compiler used for generating shared-library objects.
6202 The command line used to compile a C source file
6203 to a shared-library object file.
6204 Any options specified in the $SHCCFLAGS and $CPPFLAGS construction variables
6205 are included on this command line.
6208 Options that are passed to the C compiler
6209 to generate shared-library objects.
6212 The C++ compiler used for generating shared-library objects.
6215 The command line used to compile a C++ source file
6216 to a shared-library object file.
6217 Any options specified in the $SHCXXFLAGS and $CPPFLAGS construction variables
6218 are included on this command line.
6221 Options that are passed to the C++ compiler
6222 to generate shared-library objects.
6225 A string naming the shell program that will be passed to the
6230 construction variable for more information.
6233 The Fortran 77 compiler used for generating shared-library objects.
6234 You should normally set the $SHFORTRANC variable,
6235 which specifies the default Fortran compiler
6236 for all Fortran versions.
6237 You only need to set $SHF77 if you need to use a specific compiler
6238 or compiler version for Fortran 77 files.
6241 The command line used to compile a Fortran 77 source file
6242 to a shared-library object file.
6243 You only need to set $SHF77COM if you need to use a specific
6244 command line for Fortran 77 files.
6245 You should normally set the $SHFORTRANCOM variable,
6246 which specifies the default command line
6247 for all Fortran versions.
6250 Options that are passed to the Fortran 77 compiler
6251 to generated shared-library objects.
6252 You only need to set $SHF77FLAGS if you need to define specific
6253 user options for Fortran 77 files.
6254 You should normally set the $SHFORTRANFLAGS variable,
6255 which specifies the user-specified options
6256 passed to the default Fortran compiler
6257 for all Fortran versions.
6260 The command line used to compile a Fortran 77 source file to a
6261 shared-library object file
6262 after first running the file through the C preprocessor.
6263 Any options specified in the $SHF77FLAGS and $CPPFLAGS construction variables
6264 are included on this command line.
6265 You only need to set $SHF77PPCOM if you need to use a specific
6266 C-preprocessor command line for Fortran 77 files.
6267 You should normally set the $SHFORTRANPPCOM variable,
6268 which specifies the default C-preprocessor command line
6269 for all Fortran versions.
6272 The Fortran 90 compiler used for generating shared-library objects.
6273 You should normally set the $SHFORTRANC variable,
6274 which specifies the default Fortran compiler
6275 for all Fortran versions.
6276 You only need to set $SHF90 if you need to use a specific compiler
6277 or compiler version for Fortran 90 files.
6280 The command line used to compile a Fortran 90 source file
6281 to a shared-library object file.
6282 You only need to set $SHF90COM if you need to use a specific
6283 command line for Fortran 90 files.
6284 You should normally set the $SHFORTRANCOM variable,
6285 which specifies the default command line
6286 for all Fortran versions.
6289 Options that are passed to the Fortran 90 compiler
6290 to generated shared-library objects.
6291 You only need to set $SHF90FLAGS if you need to define specific
6292 user options for Fortran 90 files.
6293 You should normally set the $SHFORTRANFLAGS variable,
6294 which specifies the user-specified options
6295 passed to the default Fortran compiler
6296 for all Fortran versions.
6299 The command line used to compile a Fortran 90 source file to a
6300 shared-library object file
6301 after first running the file through the C preprocessor.
6302 Any options specified in the $SHF90FLAGS and $CPPFLAGS construction variables
6303 are included on this command line.
6304 You only need to set $SHF90PPCOM if you need to use a specific
6305 C-preprocessor command line for Fortran 90 files.
6306 You should normally set the $SHFORTRANPPCOM variable,
6307 which specifies the default C-preprocessor command line
6308 for all Fortran versions.
6311 The Fortran 95 compiler used for generating shared-library objects.
6312 You should normally set the $SHFORTRANC variable,
6313 which specifies the default Fortran compiler
6314 for all Fortran versions.
6315 You only need to set $SHF95 if you need to use a specific compiler
6316 or compiler version for Fortran 95 files.
6319 The command line used to compile a Fortran 95 source file
6320 to a shared-library object file.
6321 You only need to set $SHF95COM if you need to use a specific
6322 command line for Fortran 95 files.
6323 You should normally set the $SHFORTRANCOM variable,
6324 which specifies the default command line
6325 for all Fortran versions.
6328 Options that are passed to the Fortran 95 compiler
6329 to generated shared-library objects.
6330 You only need to set $SHF95FLAGS if you need to define specific
6331 user options for Fortran 95 files.
6332 You should normally set the $SHFORTRANFLAGS variable,
6333 which specifies the user-specified options
6334 passed to the default Fortran compiler
6335 for all Fortran versions.
6338 The command line used to compile a Fortran 95 source file to a
6339 shared-library object file
6340 after first running the file through the C preprocessor.
6341 Any options specified in the $SHF95FLAGS and $CPPFLAGS construction variables
6342 are included on this command line.
6343 You only need to set $SHF95PPCOM if you need to use a specific
6344 C-preprocessor command line for Fortran 95 files.
6345 You should normally set the $SHFORTRANPPCOM variable,
6346 which specifies the default C-preprocessor command line
6347 for all Fortran versions.
6350 The default Fortran compiler used for generating shared-library objects.
6353 The command line used to compile a Fortran source file
6354 to a shared-library object file.
6357 Options that are passed to the Fortran compiler
6358 to generate shared-library objects.
6361 The command line used to compile a Fortran source file to a
6362 shared-library object file
6363 after first running the file through the C preprocessor.
6364 Any options specified
6365 in the $SHFORTRANFLAGS and $CPPFLAGS construction variables
6366 are included on this command line.
6369 The prefix used for shared library file names.
6372 The suffix used for shared library file names.
6375 The linker for programs that use shared libraries.
6378 General user options passed to the linker for programs using shared libraries.
6379 Note that this variable should
6383 (or similar) options for linking with the libraries listed in $LIBS,
6386 (or similar) include search path options
6387 that scons generates automatically from $LIBPATH.
6391 for the variable that expands to library-link options,
6395 for the variable that expands to library search path options.
6398 The prefix used for shared object file names.
6401 The suffix used for shared object file names.
6404 A reserved variable name
6405 that may not be set or used in a construction environment.
6406 (See "Variable Substitution," below.)
6409 A reserved variable name
6410 that may not be set or used in a construction environment.
6411 (See "Variable Substitution," below.)
6414 A command interpreter function that will be called to execute command line
6415 strings. The function must expect the following arguments:
6418 def spawn(shell, escape, cmd, args, env):
6422 is a string naming the shell program to use.
6424 is a function that can be called to escape shell special characters in
6427 is the path to the command to be executed.
6429 is the arguments to the command.
6431 is a dictionary of the environment variables
6432 in which the command should be executed.
6435 '\"The Subversion executable (usually named
6439 '\"The command line used to
6440 '\"fetch source files from a Subversion repository.
6443 '\"General options that are passed to Subversion.
6446 The scripting language wrapper and interface generator.
6449 The suffix that will be used for intermediate C
6450 source files generated by
6451 the scripting language wrapper and interface generator.
6452 The default value is
6453 .BR _wrap$CFILESUFFIX .
6454 By default, this value is used whenever the
6458 specified as part of the
6460 construction variable.
6463 The command line used to call
6464 the scripting language wrapper and interface generator.
6466 .IP SWIGCXXFILESUFFIX
6467 The suffix that will be used for intermediate C++
6468 source files generated by
6469 the scripting language wrapper and interface generator.
6470 The default value is
6471 .BR _wrap$CFILESUFFIX .
6472 By default, this value is used whenever the
6474 option is specified as part of the
6476 construction variable.
6479 General options passed to
6480 the scripting language wrapper and interface generator.
6481 This is where you should set
6485 or whatever other options you want to specify to SWIG.
6488 option in this variable,
6491 generate a C++ intermediate source file
6492 with the extension that is specified as the
6500 The command line used to call the tar archiver.
6503 General options passed to the tar archiver.
6506 A reserved variable name
6507 that may not be set or used in a construction environment.
6508 (See "Variable Substitution," below.)
6511 A reserved variable name
6512 that may not be set or used in a construction environment.
6513 (See "Variable Substitution," below.)
6516 The suffix used for tar file names.
6519 The TeX formatter and typesetter.
6522 The command line used to call the TeX formatter and typesetter.
6525 General options passed to the TeX formatter and typesetter.
6528 A list of the names of the Tool specifications
6529 that are part of this construction environment.
6531 .IP WIN32_INSERT_DEF
6532 When this is set to true,
6533 a library build of a WIN32 shared library (.dll file)
6534 will also build a corresponding .def file at the same time,
6535 if a .def file is not already listed as a build target.
6536 The default is 0 (do not build a .def file).
6539 The prefix used for WIN32 .def file names.
6542 The suffix used for WIN32 .def file names.
6545 The parser generator.
6548 The command line used to call the parser generator
6549 to generate a source file.
6552 General options passed to the parser generator.
6553 If $YACCFLAGS contains a \-d option,
6554 SCons assumes that the call will also create a .h file
6555 (if the yacc source file ends in a .y suffix)
6557 (if the yacc source file ends in a .yy suffix)
6560 The zip compression and file packaging utility.
6563 The command line used to call the zip utility,
6564 or the internal Python function used to create a
6573 module used by the internal Python function
6574 to control whether the zip archive
6575 is compressed or not.
6576 The default value is
6577 .BR zipfile.ZIP_DEFLATED ,
6578 which creates a compressed zip archive.
6579 This value has no effect when using Python 1.5.2
6582 module is otherwise unavailable.
6585 General options passed to the zip utility.
6588 Construction variables can be retrieved and set using the
6590 method of the construction environment:
6593 dict = env.Dictionary()
6597 or using the [] operator:
6603 Construction variables can also be passed to the construction environment
6607 env = Environment(CC="cc")
6610 or when copying a construction environment using the
6615 env2 = env.Copy(CC="cl.exe")
6618 .SS Configure Contexts
6622 .I configure contexts,
6623 an integrated mechanism similar to the
6624 various AC_CHECK macros in GNU autoconf
6625 for testing for the existence of C header
6626 files, libraries, etc.
6627 In contrast to autoconf,
6629 does not maintain an explicit cache of the tested values,
6630 but uses its normal dependency tracking to keep the checked values
6631 up to date. However, users may override this behaviour with the
6633 command line option.
6635 The following methods can be used to perform checks:
6638 .RI Configure( env ", [" custom_tests ", " conf_dir ", " log_file ", " config_h ])
6640 .RI env.Configure([ custom_tests ", " conf_dir ", " log_file ", " config_h ])
6641 This creates a configure context, which can be used to perform checks.
6643 specifies the environment for building the tests.
6644 This environment may be modified when performing checks.
6646 is a dictionary containing custom tests.
6647 See also the section about custom tests below.
6648 By default, no custom tests are added to the configure context.
6650 specifies a directory where the test cases are built.
6651 Note that this directory is not used for building
6653 The default value is the directory
6656 specifies a file which collects the output from commands
6657 that are executed to check for the existence of header files, libraries, etc.
6658 The default is the file #/config.log.
6659 If you are using the
6662 you may want to specify a subdirectory under your build directory.
6664 specifies a C header file where the results of tests
6665 will be written, e.g. #define HAVE_STDIO_H, #define HAVE_LIBM, etc.
6666 The default is to not write a
6669 You can specify the same
6671 file in multiple calls to Configure,
6674 will concatenate all results in the specified file.
6676 uses its normal dependency checking
6677 to decide if it's necessary to rebuild
6681 This means that the file is not necessarily re-built each
6683 but is only rebuilt if its contents will have changed
6684 and some target that depends on the
6686 file is being built.
6691 instance has the following associated methods:
6694 .RI Configure.Finish( self )
6695 This method should be called after configuration is done.
6696 It returns the environment as modified
6697 by the configuration checks performed.
6698 After this method is called, no further checks can be performed
6699 with this configuration context.
6700 However, you can create a new
6702 context to perform additional checks.
6703 Only one context should be active at a time.
6705 The following Checks are predefined.
6706 (This list will likely grow larger as time
6707 goes by and developers contribute new useful tests.)
6710 .RI Configure.CheckHeader( self ", " header ", [" include_quotes ", " language ])
6713 is usable in the specified language.
6716 in which case the last item in the list
6717 is the header file to be checked,
6718 and the previous list items are
6721 lines should precede the
6722 header line being checked for.
6723 The optional argument
6726 a two character string, where the first character denotes the opening
6727 quote and the second character denotes the closing quote.
6728 By default, both characters are " (double quote).
6729 The optional argument
6735 and selects the compiler to be used for the check.
6736 Returns 1 on success and 0 on failure.
6739 .RI Configure.CheckCHeader( self ", " header ", [" include_quotes ])
6740 This is a wrapper around
6741 .B Configure.CheckHeader
6744 is usable in the C language.
6747 in which case the last item in the list
6748 is the header file to be checked,
6749 and the previous list items are
6752 lines should precede the
6753 header line being checked for.
6754 The optional argument
6757 a two character string, where the first character denotes the opening
6758 quote and the second character denotes the closing quote (both default
6760 Returns 1 on success and 0 on failure.
6763 .RI Configure.CheckCXXHeader( self ", " header ", [" include_quotes ])
6764 This is a wrapper around
6765 .B Configure.CheckHeader
6768 is usable in the C++ language.
6771 in which case the last item in the list
6772 is the header file to be checked,
6773 and the previous list items are
6776 lines should precede the
6777 header line being checked for.
6778 The optional argument
6781 a two character string, where the first character denotes the opening
6782 quote and the second character denotes the closing quote (both default
6784 Returns 1 on success and 0 on failure.
6787 .RI Configure.CheckFunc( self ", " function_name ", [" header ", " language ])
6788 Checks if the specified
6789 C or C++ function is available.
6791 is the name of the function to check for.
6794 argument is a string
6798 that will be compiled
6799 to check if the function exists;
6805 char function_name();
6813 and selects the compiler to be used for the check;
6817 .RI Configure.CheckLib( self ", [" library ", " symbol ", " header ", " language ", " autoadd ])
6824 is 1 and the library provides the specified
6826 appends the library to the LIBS construction environment variable.
6828 may also be None (the default),
6831 is checked with the current LIBS variable,
6832 or a list of library names,
6833 in which case each library in the list
6840 you can link against the specified
6848 and selects the compiler to be used for the check;
6850 The default value for
6853 It is assumed, that the C-language is used.
6854 This method returns 1 on success and 0 on error.
6857 .RI Configure.CheckLibWithHeader( self ", " library ", " header ", " language ", [" call ", " autoadd ])
6860 .RI Configure.CheckLib
6861 call, this call provides a more sophisticated way to check against libraries.
6864 specifies the library or a list of libraries to check.
6866 specifies a header to check for.
6869 in which case the last item in the list
6870 is the header file to be checked,
6871 and the previous list items are
6874 lines should precede the
6875 header line being checked for.
6877 may be one of 'C','c','CXX','cxx','C++' and 'c++'.
6879 can be any valid expression (with a trailing ';'). The default is 'main();'.
6881 specifies whether to add the library to the environment (only if the check
6882 succeeds). This method returns 1 on success and 0 on error.
6885 .RI Configure.CheckType( self ", " type_name ", [" includes ", " language ])
6886 Checks for the existence of a type defined by
6889 specifies the typedef name to check for.
6891 is a string containing one or more
6893 lines that will be inserted into the program
6894 that will be run to test for the existence of the type.
6901 and selects the compiler to be used for the check;
6905 Example of a typical Configure usage:
6909 conf = Configure( env )
6910 if not conf.CheckCHeader( 'math.h' ):
6911 print 'We really need math.h!'
6913 if conf.CheckLibWithHeader( 'qt', 'qapp.h', 'c++', 'QApplication qapp(0,0);' ):
6914 # do stuff for qt - usage, e.g.
6915 conf.env.Append( CPPFLAGS = '-DWITH_QT' )
6920 You can define your own custom checks.
6921 in addition to the predefined checks.
6922 These are passed in a dictionary to the Configure function.
6923 This dictionary maps the names of the checks
6924 to user defined Python callables
6925 (either Python functions or class instances implementing the
6928 The first argument of the call is always a
6930 instance followed by the arguments,
6931 which must be supplied by the user of the check.
6932 These CheckContext instances define the following methods:
6935 .RI CheckContext.Message( self ", " text )
6937 Usually called before the check is started.
6939 will be displayed to the user, e.g. 'Checking for library X...'
6942 .RI CheckContext.Result( self, ", " res )
6944 Usually called after the check is done.
6946 can be either an integer or a string. In the former case, 'ok' (res != 0)
6947 or 'failed' (res == 0) is displayed to the user, in the latter case the
6948 given string is displayed.
6951 .RI CheckContext.TryCompile( self ", " text ", " extension )
6952 Checks if a file with the specified
6954 (e.g. '.c') containing
6956 can be compiled using the environment's
6958 builder. Returns 1 on success and 0 on failure.
6961 .RI CheckContext.TryLink( self ", " text ", " extension )
6962 Checks, if a file with the specified
6964 (e.g. '.c') containing
6966 can be compiled using the environment's
6968 builder. Returns 1 on success and 0 on failure.
6971 .RI CheckContext.TryRun( self ", " text ", " extension )
6972 Checks, if a file with the specified
6974 (e.g. '.c') containing
6976 can be compiled using the environment's
6978 builder. On success, the program is run. If the program
6979 executes successfully
6980 (that is, its return status is 0),
6985 is the standard output of the
6987 If the program fails execution
6988 (its return status is non-zero),
6989 then (0, '') is returned.
6992 .RI CheckContext.TryAction( self ", " action ", [" text ", " extension ])
6993 Checks if the specified
6995 with an optional source file (contents
7002 may be anything which can be converted to a
7009 is the content of the target file.
7015 .RI CheckContext.TryBuild( self ", " builder ", [" text ", " extension ])
7016 Low level implementation for testing specific builds;
7017 the methods above are based on this method.
7018 Given the Builder instance
7022 of a source file with optional
7024 this method returns 1 on success and 0 on failure. In addition,
7026 is set to the build target node, if the build was successful.
7029 Example for implementing and using custom tests:
7032 def CheckQt(context, qtdir):
7033 context.Message( 'Checking for qt ...' )
7034 lastLIBS = context.env['LIBS']
7035 lastLIBPATH = context.env['LIBPATH']
7036 lastCPPPATH= context.env['CPPPATH']
7037 context.env.Append(LIBS = 'qt', LIBPATH = qtdir + '/lib', CPPPATH = qtdir + '/include' )
7038 ret = context.TryLink("""
7040 int main(int argc, char **argv) {
7041 QApplication qapp(argc, argv);
7046 context.env.Replace(LIBS = lastLIBS, LIBPATH=lastLIBPATH, CPPPATH=lastCPPPATH)
7047 context.Result( ret )
7051 conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } )
7052 if not conf.CheckQt('/usr/lib/qt'):
7053 print 'We really need qt!'
7058 .SS Construction Variable Options
7060 Often when building software, various options need to be specified at build
7061 time that are not known when the SConstruct/SConscript files are
7062 written. For example, libraries needed for the build may be in non-standard
7063 locations, or site-specific compiler options may need to be passed to the
7066 provides a mechanism for overridding construction variables from the
7067 command line or a text-based SConscript file through an Options
7068 object. To create an Options object, call the Options() function:
7071 .RI Options([ files "], [" args ])
7072 This creates an Options object that will read construction variables from
7073 the file or list of filenames specified in
7075 If no files are specified,
7080 then no files will be read.
7081 The optional argument
7084 values that will override anything read from the specified files;
7085 it is primarily intended to be passed the
7087 dictionary that holds variables
7088 specified on the command line.
7092 opts = Options('custom.py')
7093 opts = Options('overrides.py', ARGUMENTS)
7094 opts = Options(None, {FOO:'expansion', BAR:7})
7097 Options objects have the following methods:
7100 .RI Add( key ", [" help ", " default ", " validator ", " converter ])
7101 This adds a customizable construction variable to the Options object.
7103 is the name of the variable.
7105 is the help text for the variable.
7107 is the default value of the variable;
7108 if the default value is
7110 and there is no explicit value specified,
7111 the construction variable will
7113 be added to the construction environment.
7115 is called to validate the value of the variable, and should take three
7116 arguments: key, value, and environment
7118 is called to convert the value before putting it in the environment, and
7119 should take a single argument: value. Example:
7122 opts.Add('CC', 'The C compiler')
7126 .RI AddOptions( list )
7127 A wrapper script that adds
7128 multiple customizable construction variables
7129 to an Options object.
7131 is a list of tuple or list objects
7132 that contain the arguments
7133 for an individual call to the
7140 ('CC', 'The C compiler'),
7141 ('VALIDATE', 'An option for testing validation',
7142 'notset', validator, None),
7147 .RI Update( env ", [" args ])
7148 This updates a construction environment
7150 with the customized construction variables. Normally this method is not
7151 called directly, but is called indirectly by passing the Options object to
7152 the Environment() function:
7155 env = Environment(options=opts)
7159 .RI Save( filename ", " env )
7160 This saves the currently set options into a script file named
7162 that can be used on the next invocation to automatically load the current
7163 settings. This method combined with the Options method can be used to
7164 support caching of options between runs.
7168 opts = Options(['options.cache', 'custom.py'])
7171 opts.Save('options.cache', env)
7175 .RI GenerateHelpText( env ", [" sort ])
7176 This generates help text documenting the customizable construction
7177 variables suitable to passing in to the Help() function.
7179 is the construction environment that will be used to get the actual values
7180 of customizable variables. Calling with
7184 will cause the output to be sorted
7185 by the specified argument.
7189 should take two arguments
7192 (like the standard Python
7197 Help(opts.GenerateHelpText(env))
7198 Help(opts.GenerateHelpText(env, sort=cmp))
7201 The text based SConscript file is executed as a Python script, and the
7202 global variables are queried for customizable construction
7209 To make it more convenient to work with customizable Options,
7211 provides a number of functions
7212 that make it easy to set up
7213 various types of Options:
7216 .RI BoolOption( key ", " help ", " default )
7217 Return a tuple of arguments
7218 to set up a Boolean option.
7222 have a default value of
7224 and display the specified
7227 The option will interpret the values
7249 .RI EnumOption( key ", " help ", " default ", " allowed_values ", [" map ", " ignorecase ])
7250 Return a tuple of arguments
7252 whose value may be one
7253 of a specified list of legal enumerated values.
7257 have a default value of
7259 and display the specified
7262 The option will only support those
7268 argument is a dictionary
7269 that can be used to convert
7270 input values into specific legal values
7279 then the values are case-sensitive.
7284 then values will be matched
7290 then values will be matched
7292 and all input values will be
7293 converted to lower case.
7296 .RI ListOption( key ", " help ", " default ", " names )
7297 Return a tuple of arguments
7299 whose value may be one or more
7300 of a specified list of legal enumerated values.
7304 have a default value of
7306 and display the specified
7309 The option will only support the values
7312 or the values in the
7315 More than one value may be specified,
7316 with all values separated by commas.
7317 The default may be a string of
7318 comma-separated default values,
7319 or a list of the default values.
7322 .RI PackageOption( key ", " help ", " default )
7323 Return a tuple of arguments
7325 whose value is a path name
7326 of a package that may be
7327 enabled, disabled or
7328 given an explicit path name.
7332 have a default value of
7334 and display the specified
7337 The option will support the values
7344 in which case the specified
7347 or the option may be set to an
7349 (typically the path name to a package
7350 that is being enabled).
7351 The option will also support the values
7357 to disable use of the specified option.
7360 .RI PathOption( key ", " help ", " default ", [" validator ])
7361 Return a tuple of arguments
7363 whose value is expected to be a path name.
7367 have a default value of
7369 and display the specified
7375 that will be called to
7376 verify that the specified path
7379 following ready-made validators:
7380 .BR PathOption.PathExists
7382 which verifies that the specified path exists;
7383 .BR PathOption.PathIsFile ,
7384 which verifies that the specified path is an existing file;
7385 .BR PathOption.PathIsDir ,
7386 which verifies that the specified path is an existing directory;
7388 .BR PathOption.PathIsDirCreate ,
7389 which verifies that the specified path is a directory,
7390 and will create the specified directory if the path exist.
7391 You may supply your own
7394 which must take three arguments
7396 the name of the options variable to be set;
7398 the specified value being checked;
7401 the construction environment)
7402 and should raise an exception
7403 if the specified value is not acceptable.
7406 These functions make it
7407 convenient to create a number
7408 of options with consistent behavior
7409 in a single call to the
7415 BoolOption('warnings', 'compilation with -Wall and similiar', 1),
7416 EnumOption('debug', 'debug output and symbols', 'no'
7417 allowed_values=('yes', 'no', 'full'),
7418 map={}, ignorecase=0), # case sensitive
7419 ListOption('shared',
7420 'libraries to build as shared libraries',
7422 names = list_of_libs),
7423 PackageOption('x11',
7424 'use X11 installed here (yes = search some places)',
7426 PathOption('qtdir', 'where the root of Qt is installed', qtdir),
7427 PathOption('foopath', 'where the foo library is installed', foopath,
7428 PathOption.PathIsDir),
7433 .SS File and Directory Nodes
7443 Nodes, respectively.
7444 python objects, respectively.
7445 Those objects have several user-visible attributes
7446 and methods that are often useful:
7452 This path is relative to the top-level directory
7456 The build path is the same as the source path if
7461 The absolute build path of the given file or directory.
7471 object representing the
7480 # Get the current build dir's path, relative to top.
7482 # Current dir's absolute path
7484 # Next line is always '.', because it is the top dir's path relative to itself.
7486 File('foo.c').srcnode().path # source path of the given source file.
7488 # Builders also return File objects:
7489 foo = env.Program('foo.c')
7490 print "foo will be built in %s"%foo.path
7496 can be extended to build different types of targets
7497 by adding new Builder objects
7498 to a construction environment.
7500 you should only need to add a new Builder object
7501 when you want to build a new type of file or other external target.
7502 If you just want to invoke a different compiler or other tool
7503 to build a Program, Object, Library, or any other
7504 type of output file for which
7506 already has an existing Builder,
7507 it is generally much easier to
7508 use those existing Builders
7509 in a construction environment
7510 that sets the appropriate construction variables
7513 Builder objects are created
7519 function accepts the following arguments:
7522 The command line string used to build the target from the source.
7525 a list of strings representing the command
7526 to be executed and its arguments
7527 (suitable for enclosing white space in an argument),
7529 mapping source file name suffixes to
7530 any combination of command line strings
7531 (if the builder should accept multiple source file extensions),
7534 (see the next section);
7535 or a list of any of the above.
7538 takes three arguments:
7540 - a list of source nodes,
7542 - a list of target nodes,
7544 - the construction environment.
7547 The prefix that will be prepended to the target file name.
7548 This may be specified as a:
7558 - a function or other callable that takes
7559 two arguments (a construction environment and a list of sources)
7560 and returns a prefix,
7565 - specifies a mapping from a specific source suffix (of the first
7566 source specified) to a corresponding target prefix. Both the source
7567 suffix and target prefix specifications may use environment variable
7568 substitution, and the target prefix (the 'value' entries in the
7569 dictionary) may also be a callable object. The default target prefix
7570 may be indicated by a dictionary entry with a key value of None.
7575 b = Builder("build_it < $SOURCE > $TARGET"
7578 def gen_prefix(env, sources):
7579 return "file-" + env['PLATFORM'] + '-'
7580 b = Builder("build_it < $SOURCE > $TARGET",
7581 prefix = gen_prefix)
7583 b = Builder("build_it < $SOURCE > $TARGET",
7584 suffix = { None: "file-",
7585 "$SRC_SFX_A": gen_prefix })
7589 The suffix that will be appended to the target file name.
7590 This may be specified in the same manner as the prefix above.
7591 If the suffix is a string, then
7593 will append a '.' to the beginning of the suffix if it's not already
7594 there. The string returned by callable object (or obtained from the
7595 dictionary) is untouched and must append its own '.' to the beginning
7599 b = Builder("build_it < $SOURCE > $TARGET"
7602 def gen_suffix(env, sources):
7603 return "." + env['PLATFORM'] + "-file"
7604 b = Builder("build_it < $SOURCE > $TARGET",
7605 suffix = gen_suffix)
7607 b = Builder("build_it < $SOURCE > $TARGET",
7608 suffix = { None: ".sfx1",
7609 "$SRC_SFX_A": gen_suffix })
7613 The expected source file name suffix. This may be a string or a list
7617 A Scanner object that
7618 will be invoked to find
7619 implicit dependencies for this target file.
7620 This keyword argument should be used
7621 for Scanner objects that find
7622 implicit dependencies
7623 based only on the target file
7624 and the construction environment,
7627 (See the section "Scanner Objects," below,
7628 for information about creating Scanner objects.)
7631 A Scanner object that
7633 find implicit dependences in
7635 used to build this target file.
7636 This is where you would
7637 specify a scanner to
7640 lines in source files.
7641 (See the section "Scanner Objects," below,
7642 for information about creating Scanner objects.)
7645 A factory function that the Builder will use
7646 to turn any targets specified as strings into SCons Nodes.
7648 SCons assumes that all targets are files.
7649 Other useful target_factory
7652 for when a Builder creates a directory target,
7655 for when a Builder can create either a file
7656 or directory target.
7661 MakeDirectoryBuilder = Builder(action=my_mkdir, target_factory=Dir)
7663 env.Append(BUILDERS = {'MakeDirectory':MakeDirectoryBuilder})
7664 env.MakeDirectory('new_directory', [])
7668 A factory function that the Builder will use
7669 to turn any sources specified as strings into SCons Nodes.
7671 SCons assumes that all source are files.
7672 Other useful source_factory
7675 for when a Builder uses a directory as a source,
7678 for when a Builder can use files
7679 or directories (or both) as sources.
7684 CollectBuilder = Builder(action=my_mkdir, source_factory=Entry)
7686 env.Append(BUILDERS = {'Collect':CollectBuilder})
7687 env.Collect('archive', ['directory_name', 'file_name'])
7691 A function or list of functions to manipulate the target and source
7692 lists before dependencies are established
7693 and the target(s) are actually built.
7695 can also be a string containing a construction variable to expand
7696 to an emitter function or list of functions,
7697 or a dictionary mapping source file suffixes
7698 to emitter functions.
7699 (Only the suffix of the first source file
7700 is used to select the actual emitter function
7701 from an emitter dictionary.)
7704 takes three arguments:
7706 - a list of source nodes,
7708 - a list of target nodes,
7710 - the construction environment.
7711 An emitter must return a tuple containing two lists,
7712 the list of targets to be built by this builder,
7713 and the list of sources for this builder.
7718 def e(target, source, env):
7719 return (target + ['foo.foo'], source + ['foo.src'])
7721 # Simple association of an emitter function with a Builder.
7722 b = Builder("my_build < $TARGET > $SOURCE",
7725 def e2(target, source, env):
7726 return (target + ['bar.foo'], source + ['bar.src'])
7728 # Simple association of a list of emitter functions with a Builder.
7729 b = Builder("my_build < $TARGET > $SOURCE",
7732 # Calling an emitter function through a construction variable.
7733 env = Environment(MY_EMITTER = e)
7734 b = Builder("my_build < $TARGET > $SOURCE",
7735 emitter = '$MY_EMITTER')
7737 # Calling a list of emitter functions through a construction variable.
7738 env = Environment(EMITTER_LIST = [e, e2])
7739 b = Builder("my_build < $TARGET > $SOURCE",
7740 emitter = '$EMITTER_LIST')
7742 # Associating multiple emitters with different file
7743 # suffixes using a dictionary.
7744 def e_suf1(target, source, env):
7745 return (target + ['another_target_file'], source)
7746 def e_suf2(target, source, env):
7747 return (target, source + ['another_source_file'])
7748 b = Builder("my_build < $TARGET > $SOURCE",
7749 emitter = {'.suf1' : e_suf1,
7757 arguments must not both be used for the same Builder.
7760 Specifies whether this builder is allowed to be called multiple times for
7761 the same target file(s). The default is 0, which means the builder
7762 can not be called multiple times for the same target file(s). Calling a
7763 builder multiple times for the same target simply adds additional source
7764 files to the target; it is not allowed to change the environment associated
7765 with the target, specify addition environment overrides, or associate a different
7766 builder with the target.
7769 A construction environment that can be used
7770 to fetch source code using this Builder.
7771 (Note that this environment is
7773 used for normal builds of normal target files,
7774 which use the environment that was
7775 used to call the Builder for the target file.)
7778 A function that returns a list of actions that will be executed to build
7779 the target(s) from the source(s).
7780 The returned action(s) may be
7781 an Action object, or anything that
7782 can be converted into an Action object
7783 (see the next section).
7785 The generator function
7786 takes four arguments:
7788 - a list of source nodes,
7790 - a list of target nodes,
7792 - the construction environment,
7794 - a Boolean value that specifies
7795 whether the generator is being called
7796 for generating a build signature
7797 (as opposed to actually executing the command).
7801 def g(source, target, env, for_signature):
7802 return [["gcc", "-c", "-o"] + target + source]
7804 b = Builder(generator=g)
7808 Specifies a builder to use when a source file name suffix does not match
7809 any of the suffixes of the builder. Using this argument produces a
7810 multi-stage builder.
7813 Specifies that this builder expects exactly one source file per call. Giving
7814 more than one source files without target files results in implicitely calling
7815 the builder multiple times (once for each source given). Giving multiple
7816 source files together with target files results in a UserError exception.
7824 arguments must not both be used for the same Builder.
7827 A construction environment that can be used
7828 to fetch source code using this Builder.
7829 (Note that this environment is
7831 used for normal builds of normal target files,
7832 which use the environment that was
7833 used to call the Builder for the target file.)
7836 b = Builder(action="build < $SOURCE > $TARGET")
7837 env = Environment(BUILDERS = {'MyBuild' : b})
7838 env.MyBuild('foo.out', 'foo.in', my_arg = 'xyzzy')
7842 A directory from which scons
7849 a string or a directory Node,
7850 scons will change to the specified directory.
7853 is not a string or Node
7855 then scons will change to the
7856 target file's directory.
7858 Note that scons will
7860 automatically modify
7862 construction variables like
7866 when using the chdir
7867 keyword argument--that is,
7868 the expanded file names
7869 will still be relative to
7870 the top-level SConstruct directory,
7871 and consequently incorrect
7872 relative to the chdir directory.
7873 Builders created using chdir keyword argument,
7874 will need to use construction variable
7879 to use just the filename portion of the
7883 b = Builder(action="build < ${SOURCE.file} > ${TARGET.file}",
7885 env = Environment(BUILDERS = {'MyBuild' : b})
7886 env.MyBuild('sub/dir/foo.out', 'sub/dir/foo.in')
7890 Any additional keyword arguments supplied
7891 when a Builder object is created
7892 (that is, when the Builder() function is called)
7893 will be set in the executing construction
7894 environment when the Builder object is called.
7895 The canonical example here would be
7896 to set a construction variable to
7897 the repository of a source code system.
7899 Any additional keyword arguments supplied
7903 will only be associated with the target
7904 created by that particular Builder call
7905 (and any other files built as a
7906 result of the call).
7908 These extra keyword arguments are passed to the
7909 following functions:
7910 command generator functions,
7912 and emitter functions.
7918 function will turn its
7920 keyword argument into an appropriate
7921 internal Action object.
7922 You can also explicity create Action objects
7926 which can then be passed to the
7929 This can be used to configure
7930 an Action object more flexibly,
7931 or it may simply be more efficient
7932 than letting each separate Builder object
7933 create a separate Action
7935 Builder objects need to do the same thing.
7940 returns an appropriate object for the action
7941 represented by the type of the first argument:
7944 If the first argument is already an Action object,
7945 the object is simply returned.
7948 If the first argument is a string,
7949 a command-line Action is returned.
7952 Action('$CC -c -o $TARGET $SOURCES')
7955 .\" XXX From Gary Ruben, 23 April 2002:
7956 .\" What would be useful is a discussion of how you execute command
7957 .\" shell commands ie. what is the process used to spawn the shell, pass
7958 .\" environment variables to it etc., whether there is one shell per
7959 .\" environment or one per command etc. It might help to look at the Gnu
7960 .\" make documentation to see what they think is important to discuss about
7961 .\" a build system. I'm sure you can do a better job of organising the
7962 .\" documentation than they have :-)
7966 If the first argument is a list,
7967 then a list of Action objects is returned.
7968 An Action object is created as necessary
7969 for each element in the list.
7972 the list is itself a list,
7973 the internal list is the
7974 command and arguments to be executed via
7976 This allows white space to be enclosed
7977 in an argument by defining
7978 a command in a list within a list:
7981 Action([['cc', '-c', '-DWHITE SPACE', '-o', '$TARGET', '$SOURCES']])
7985 If the first argument is a Python function,
7986 a function Action is returned.
7987 The Python function takes three keyword arguments,
7989 (a Node object representing the target file),
7991 (a Node object representing the source file)
7994 (the construction environment
7995 used for building the target file).
8000 arguments may be lists of Node objects if there is
8001 more than one target file or source file.
8002 The actual target and source file name(s) may
8003 be retrieved from their Node objects
8004 via the built-in Python str() function:
8007 target_file_name = str(target)
8008 source_file_names = map(lambda x: str(x), source)
8011 The function should return
8015 to indicate a successful build of the target file(s).
8016 The function may raise an exception
8017 or return a non-zero exit status
8018 to indicate an unsuccessful build.
8021 def build_it(target = None, source = None, env = None):
8022 # build the target from the source
8025 a = Action(build_it)
8028 If the action argument is not one of the above,
8031 The second, optional argument
8032 is a Python function that returns
8033 a string to be printed to describe the action being executed.
8034 Like a function to build a file,
8035 this function takes three arguments:
8037 (a Node object representing the target file),
8039 (a Node object representing the source file)
8042 (a construction environment).
8047 arguments may be lists of Node objects if there is
8048 more than one target file or source file.
8052 def build_it(target, source, env):
8053 # build the target from the source
8056 def string_it(target, source, env):
8057 return "building '%s' from '%s'" % (target[0], source[0])
8059 # Use a positional argument.
8060 a = Action(build_it, string_it)
8062 # Alternatively, use a keyword argument.
8063 a = Action(build_it, strfunction=string_it)
8066 The third, also optional argument
8067 is a list of construction variables
8068 whose values will be included
8069 in the signature of the Action
8070 when deciding whether a target should
8071 be rebuilt because the action changed.
8072 This is necessary whenever you want a target to
8073 be rebuilt when a specific
8074 construction variable changes,
8075 because the underlying Python code for a function
8076 will not change when the value of the construction variable does.
8079 def build_it(target, source, env):
8080 # build the target from the 'XXX' construction variable
8081 open(target[0], 'w').write(env['XXX'])
8084 def string_it(target, source):
8085 return "building '%s' from '%s'" % (target[0], source[0])
8087 # Use positional arguments.
8088 a = Action(build_it, string_it, ['XXX'])
8090 # Alternatively, use a keyword argument.
8091 a = Action(build_it, varlist=['XXX'])
8101 which specifies that
8102 scons will execute the action
8103 after changing to the specified directory.
8104 If the chdir argument is
8105 a string or a directory Node,
8106 scons will change to the specified directory.
8107 If the chdir argument
8108 is not a string or Node
8110 then scons will change to the
8111 target file's directory.
8113 Note that scons will
8115 automatically modify
8117 construction variables like
8121 when using the chdir
8122 keyword argument--that is,
8123 the expanded file names
8124 will still be relative to
8125 the top-level SConstruct directory,
8126 and consequently incorrect
8127 relative to the chdir directory.
8128 Builders created using chdir keyword argument,
8129 will need to use construction variable
8134 to use just the filename portion of the
8138 a = Action("build < ${SOURCE.file} > ${TARGET.file}",
8142 .SS Miscellaneous Action Functions
8145 supplies a number of functions
8146 that arrange for various common
8147 file and directory manipulations
8149 These are similar in concept to "tasks" in the
8151 although the implementation is slightly different.
8152 These functions do not actually
8153 perform the specified action
8154 at the time the function is called,
8155 but instead return an Action object
8156 that can be executed at the
8158 (In Object-Oriented terminology,
8163 that return Action objects.)
8166 there are two natural ways
8169 are intended to be used.
8173 to perform the action
8174 at the time the SConscript
8178 global function to do so:
8180 Execute(Touch('file'))
8184 you can use these functions
8185 to supply Actions in a list
8189 This can allow you to
8190 perform more complicated
8191 sequences of file manipulation
8193 on platform-specific
8197 env = Environment(TMPBUILD = '/tmp/builddir')
8198 env.Command('foo.out', 'foo.in',
8199 [Mkdir('$TMPBUILD'),
8200 Copy('${SOURCE.dir}', '$TMPBUILD')
8201 "cd $TMPBUILD && make",
8202 Delete('$TMPBUILD')])
8206 .RI Chmod( dest ", " mode )
8207 Returns an Action object that
8208 changes the permissions on the specified
8210 file or directory to the specified
8215 Execute(Chmod('file', 0755))
8217 env.Command('foo.out', 'foo.in',
8218 [Copy('$TARGET', '$SOURCE'),
8219 Chmod('$TARGET', 0755)])
8223 .RI Copy( dest ", " src )
8224 Returns an Action object
8227 source file or directory to the
8229 destination file or directory.
8233 Execute(Copy('foo.output', 'foo.input'))
8235 env.Command('bar.out', 'bar.in',
8236 Copy('$TARGET', '$SOURCE'))
8240 .RI Delete( entry ", [" must_exist ])
8241 Returns an Action that
8242 deletes the specified
8244 which may be a file or a directory tree.
8245 If a directory is specified,
8246 the entire directory tree
8251 then a Python error will be thrown
8252 if the specified entry does not exist;
8255 that is, the Action will silently do nothing
8256 if the entry does not exist.
8260 Execute(Delete('/tmp/buildroot'))
8262 env.Command('foo.out', 'foo.in',
8263 [Delete('${TARGET.dir}'),
8266 Execute(Delete('file_that_must_exist', must_exist=1))
8272 that creates the specified
8278 Execute(Mkdir('/tmp/outputdir'))
8280 env.Command('foo.out', 'foo.in',
8281 [Mkdir('/tmp/builddir',
8282 Copy('$SOURCE', '/tmp/builddir')
8283 "cd /tmp/builddir && ])
8288 .RI Move( dest ", " src )
8290 that moves the specified
8292 file or directory to
8299 Execute(Move('file.destination', 'file.source'))
8301 env.Command('output_file', 'input_file',
8303 Move('$TARGET', 'file_created_by_MyBuildAction')])
8309 that updates the modification time
8315 Execute(Touch('file_to_be_touched'))
8317 env.Command('marker', 'input_file',
8322 .SS Variable Substitution
8324 Before executing a command,
8326 performs construction variable interpolation on the strings that make up
8327 the command line of builders.
8328 Variables are introduced by a
8331 Besides construction variables, scons provides the following
8332 variables for each command execution:
8335 The file name of the target being built, or the file name of the first
8336 target if multiple targets are being built.
8339 The file names of all targets being built.
8342 The file name of the source of the build command, or the file name of the
8343 first source if multiple sources are being built.
8346 The file names of the sources of the build command.
8348 (Note that the above variables are reserved
8349 and may not be set in a construction environment.)
8352 For example, given the construction variable CC='cc', targets=['foo'], and
8353 sources=['foo.c', 'bar.c']:
8356 action='$CC -c -o $TARGET $SOURCES'
8359 would produce the command line:
8362 cc -c -o foo foo.c bar.c
8365 Variable names may be surrounded by curly braces ({})
8366 to separate the name from the trailing characters.
8367 Within the curly braces, a variable name may have
8368 a Python slice subscript appended to select one
8369 or more items from a list.
8370 In the previous example, the string:
8382 Additionally, a variable name may
8383 have the following special
8384 modifiers appended within the enclosing curly braces
8385 to modify the interpolated string:
8388 The base path of the file name,
8389 including the directory path
8390 but excluding any suffix.
8393 The name of the directory in which the file exists.
8397 minus any directory portion.
8400 Just the basename of the file,
8402 and minus the directory.
8405 Just the file suffix.
8408 The absolute path name of the file.
8411 The POSIX form of the path,
8412 with directories separated by
8416 This is sometimes necessary on Win32 systems
8417 when a path references a file on other (POSIX) systems.
8420 The directory and file name to the source file linked to this file
8421 through BuildDir. If this file isn't linked, it just returns the
8422 directory and filename unchanged.
8425 The directory containing the source file linked to this file
8426 through BuildDir. If this file isn't linked, it just returns the
8427 directory part of the filename.
8430 The directory and file name to the source file linked to this file
8431 through BuildDir. If the file does not exist locally but exists in
8432 a Repository, the path in the Repository is returned.
8433 If this file isn't linked, it just returns the
8434 directory and filename unchanged.
8437 The Repository directory containing the source file linked to this file
8438 through BuildDir. If this file isn't linked, it just returns the
8439 directory part of the filename.
8442 For example, the specified target will
8443 expand as follows for the corresponding modifiers:
8446 $TARGET => sub/dir/file.x
8447 ${TARGET.base} => sub/dir/file
8448 ${TARGET.dir} => sub/dir
8449 ${TARGET.file} => file.x
8450 ${TARGET.filebase} => file
8451 ${TARGET.suffix} => .x
8452 ${TARGET.abspath} => /top/dir/sub/dir/file.x
8454 BuildDir('sub/dir','src')
8455 $SOURCE => sub/dir/file.x
8456 ${SOURCE.srcpath} => src/file.x
8457 ${SOURCE.srcdir} => src
8459 Repository('/usr/repository')
8460 $SOURCE => sub/dir/file.x
8461 ${SOURCE.rsrcpath} => /usr/repository/src/file.x
8462 ${SOURCE.rsrcdir} => /usr/repository/src
8465 Lastly, a variable name
8466 may be a callable Python function
8468 construction variable in the environment.
8470 take four arguments:
8472 - a list of target nodes,
8474 - a list of source nodes,
8476 - the construction environment,
8478 - a Boolean value that specifies
8479 whether the function is being called
8480 for generating a build signature.
8481 SCons will insert whatever
8482 the called function returns
8483 into the expanded string:
8486 def foo(target, source, env, for_signature):
8489 # Will expand $BAR to "bar baz"
8490 env=Environment(FOO=foo, BAR="$FOO baz")
8493 You can use this feature to pass arguments to a
8494 Python function by creating a callable class
8495 that stores one or more arguments in an object,
8496 and then uses them when the
8499 Note that in this case,
8500 the entire variable expansion must
8501 be enclosed by curly braces
8502 so that the arguments will
8503 be associated with the
8504 instantiation of the class:
8508 def __init__(self, arg):
8511 def __call__(self, target, source, env, for_signature):
8514 # Will expand $BAR to "my argument bar baz"
8515 env=Environment(FOO=foo, BAR="${FOO('my argument')} baz")
8519 The special pseudo-variables
8523 may be used to surround parts of a command line
8526 causing a rebuild--that is,
8527 which are not included in the signature
8528 of target files built with this command.
8533 will be removed from the command line
8534 before it is added to file signatures,
8539 will be removed before the command is executed.
8540 For example, the command line:
8543 echo Last build occurred $( $TODAY $). > $TARGET
8547 would execute the command:
8550 echo Last build occurred $TODAY. > $TARGET
8554 but the command signature added to any target files would be:
8557 echo Last build occurred . > $TARGET
8560 SCons uses the following rules when converting construction variables into
8564 When the value is a string it is interpreted as a space delimited list of
8565 command line arguments.
8568 When the value is a list it is interpreted as a list of command line
8569 arguments. Each element of the list is converted to a string.
8572 Anything that is not a list or string is converted to a string and
8573 interpreted as a single command line argument.
8576 Newline characters (\\n) delimit lines. The newline parsing is done after
8577 all other parsing, so it is not possible for arguments (e.g. file names) to
8578 contain embedded newline characters. This limitation will likely go away in
8579 a future version of SCons.
8587 new file types for implicit dependencies.
8588 Scanner accepts the following arguments:
8591 A Python function that will process
8593 and return a list of strings (file names)
8594 representing the implicit
8595 dependencies found in the contents.
8596 The function takes three or four arguments:
8598 def scanner_function(node, env, path):
8600 def scanner_function(node, env, path, arg):
8604 argument is the internal
8605 SCons node representing the file.
8608 to fetch the name of the file, and
8609 .B node.get_contents()
8610 to fetch contents of the file.
8614 argument is the construction environment for the scan.
8615 Fetch values from it using the
8621 argument is a tuple (or list)
8622 of directories that can be searched
8624 This will usually be the tuple returned by the
8626 argument (see below).
8630 argument is the argument supplied
8631 when the scanner was created, if any.
8634 The name of the Scanner.
8636 to identify the Scanner internally.
8639 An optional argument that, if specified,
8640 will be passed to the scanner function
8642 and the path function
8646 An optional list that can be used to
8647 determine which scanner should be used for
8649 In the usual case of scanning for file names,
8650 this argument will be a list of suffixes
8651 for the different file types that this
8652 Scanner knows how to scan.
8653 If the argument is a string,
8654 then it will be expanded
8655 into a list by the current environment.
8658 A Python function that takes
8659 two or three arguments:
8660 a construction environment, directory Node,
8661 and optional argument supplied
8662 when the scanner was created.
8665 returns a tuple of directories
8666 that can be searched for files to be returned
8667 by this Scanner object.
8670 The class of Node that should be returned
8671 by this Scanner object.
8672 Any strings or other objects returned
8673 by the scanner function
8674 that are not of this class
8675 will be run through the
8680 A Python function that will take a string
8682 and turn it into the appropriate class of Node
8683 to be returned by this Scanner object.
8686 An optional Python function that takes two arguments,
8687 a Node (file) and a construction environment,
8688 and returns whether the
8689 Node should, in fact,
8690 be scanned for dependencies.
8691 This check can be used to eliminate unnecessary
8692 calls to the scanner function when,
8693 for example, the underlying file
8694 represented by a Node does not yet exist.
8697 An optional flag that
8698 specifies whether this scanner should be re-invoked
8699 on the dependency files returned by the scanner.
8700 When this flag is not set,
8701 the Node subsystem will
8702 only invoke the scanner on the file being scanned,
8703 and not (for example) also on the files
8704 specified by the #include lines
8705 in the file being scanned.
8707 .SH SYSTEM-SPECIFIC BEHAVIOR
8708 SCons and its configuration files are very portable,
8709 due largely to its implementation in Python.
8710 There are, however, a few portability
8711 issues waiting to trap the unwary.
8713 SCons handles the upper-case
8715 file suffix differently,
8716 depending on the capabilities of
8717 the underlying system.
8718 On a case-sensitive system
8719 such as Linux or UNIX,
8720 SCons treats a file with a
8722 suffix as a C++ source file.
8723 On a case-insensitive system
8725 SCons treats a file with a
8727 suffix as a C source file.
8729 SCons handles the upper-case
8731 file suffix differently,
8732 depending on the capabilities of
8733 the underlying system.
8734 On a case-sensitive system
8735 such as Linux or UNIX,
8736 SCons treats a file with a
8738 suffix as a Fortran source file
8739 that is to be first run through
8740 the standard C preprocessor.
8741 On a case-insensitive system
8743 SCons treats a file with a
8745 suffix as a Fortran source file that should
8747 be run through the C preprocessor.
8748 .SS WIN32: Cygwin Tools and Cygwin Python vs. Windows Pythons
8749 Cygwin supplies a set of tools and utilities
8750 that let users work on a
8751 Windows system using a more POSIX-like environment.
8752 The Cygwin tools, including Cygwin Python,
8754 by sharing an ability to interpret UNIX-like path names.
8755 For example, the Cygwin tools
8756 will internally translate a Cygwin path name
8757 like /cygdrive/c/mydir
8758 to an equivalent Windows pathname
8759 of C:/mydir (equivalent to C:\\mydir).
8762 that are built for native Windows execution,
8763 such as the python.org and ActiveState versions,
8764 do not have the Cygwin path name semantics.
8765 This means that using a native Windows version of Python
8766 to build compiled programs using Cygwin tools
8767 (such as gcc, bison, and flex)
8768 may yield unpredictable results.
8769 "Mixing and matching" in this way
8770 can be made to work,
8771 but it requires careful attention to the use of path names
8772 in your SConscript files.
8774 In practice, users can sidestep
8775 the issue by adopting the following rules:
8777 use the Cygwin-supplied Python interpreter
8779 when using Microsoft Visual C/C++
8780 (or some other Windows compiler)
8781 use the python.org or ActiveState version of Python
8783 .SS WIN32: scons.bat file
8785 SCons is executed via a wrapper
8788 This has (at least) two ramifications:
8790 First, Windows command-line users
8791 that want to use variable assignment
8793 may have to put double quotes
8794 around the assignments:
8797 scons "FOO=BAR" "BAZ=BLEH"
8800 Second, the Cygwin shell does not
8801 recognize this file as being the same
8804 command issued at the command-line prompt.
8805 You can work around this either by
8808 from the Cygwin command line,
8809 or by creating a wrapper shell
8815 The MinGW bin directory must be in your PATH environment variable or the
8816 PATH variable under the ENV construction variable for SCons
8817 to detect and use the MinGW tools. When running under the native Windows
8818 Python interpreter, SCons will prefer the MinGW tools over the Cygwin
8819 tools, if they are both installed, regardless of the order of the bin
8820 directories in the PATH variable. If you have both MSVC and MinGW
8821 installed and you want to use MinGW instead of MSVC,
8822 then you must explictly tell SCons to use MinGW by passing
8828 to the Environment() function, because SCons will prefer the MSVC tools
8829 over the MinGW tools.
8833 To help you get started using SCons,
8834 this section contains a brief overview of some common tasks.
8836 .SS Basic Compilation From a Single Source File
8840 env.Program(target = 'foo', source = 'foo.c')
8843 Note: Build the file by specifying
8844 the target as an argument
8845 ("scons foo" or "scons foo.exe").
8846 or by specifying a dot ("scons .").
8848 .SS Basic Compilation From Multiple Source Files
8852 env.Program(target = 'foo', source = Split('f1.c f2.c f3.c'))
8855 .SS Setting a Compilation Flag
8858 env = Environment(CCFLAGS = '-g')
8859 env.Program(target = 'foo', source = 'foo.c')
8862 .SS Search The Local Directory For .h Files
8866 need to set CCFLAGS to specify -I options by hand.
8867 SCons will construct the right -I options from CPPPATH.
8870 env = Environment(CPPPATH = ['.'])
8871 env.Program(target = 'foo', source = 'foo.c')
8874 .SS Search Multiple Directories For .h Files
8877 env = Environment(CPPPATH = ['include1', 'include2'])
8878 env.Program(target = 'foo', source = 'foo.c')
8881 .SS Building a Static Library
8885 env.StaticLibrary(target = 'foo', source = Split('l1.c l2.c'))
8886 env.StaticLibrary(target = 'bar', source = ['l3.c', 'l4.c'])
8889 .SS Building a Shared Library
8893 env.SharedLibrary(target = 'foo', source = ['l5.c', 'l6.c'])
8894 env.SharedLibrary(target = 'bar', source = Split('l7.c l8.c'))
8897 .SS Linking a Local Library Into a Program
8900 env = Environment(LIBS = 'mylib', LIBPATH = ['.'])
8901 env.Library(target = 'mylib', source = Split('l1.c l2.c'))
8902 env.Program(target = 'prog', source = ['p1.c', 'p2.c'])
8905 .SS Defining Your Own Builder Object
8907 Notice that when you invoke the Builder,
8908 you can leave off the target file suffix,
8909 and SCons will add it automatically.
8912 bld = Builder(action = 'pdftex < $SOURCES > $TARGET'
8914 src_suffix = '.tex')
8915 env = Environment(BUILDERS = {'PDFBuilder' : bld})
8916 env.PDFBuilder(target = 'foo.pdf', source = 'foo.tex')
8918 # The following creates "bar.pdf" from "bar.tex"
8919 env.PDFBuilder(target = 'bar', source = 'bar')
8922 Note also that the above initialization
8923 overwrites the default Builder objects,
8924 so the Environment created above
8925 can not be used call Builders like env.Program(),
8926 env.Object(), env.StaticLibrary(), etc.
8928 .SS Adding Your Own Builder Object to an Environment
8931 bld = Builder(action = 'pdftex < $SOURCES > $TARGET'
8933 src_suffix = '.tex')
8935 env.Append(BUILDERS = {'PDFBuilder' : bld})
8936 env.PDFBuilder(target = 'foo.pdf', source = 'foo.tex')
8937 env.Program(target = 'bar', source = 'bar.c')
8940 You also can use other Pythonic techniques to add
8941 to the BUILDERS construction variable, such as:
8945 env['BUILDERS]['PDFBuilder'] = bld
8948 .SS Defining Your Own Scanner Object
8953 include_re = re.compile(r'^include\\s+(\\S+)$', re.M)
8955 def kfile_scan(node, env, path, arg):
8956 contents = node.get_contents()
8957 includes = include_re.findall(contents)
8960 kscan = Scanner(name = 'kfile',
8961 function = kfile_scan,
8964 scanners = Environment().Dictionary('SCANNERS')
8965 env = Environment(SCANNERS = scanners + [kscan])
8967 env.Command('foo', 'foo.k', 'kprocess < $SOURCES > $TARGET')
8969 bar_in = File('bar.in')
8970 env.Command('bar', bar_in, 'kprocess $SOURCES > $TARGET')
8971 bar_in.target_scanner = kscan
8974 .SS Creating a Hierarchical Build
8976 Notice that the file names specified in a subdirectory's
8978 file are relative to that subdirectory.
8984 env.Program(target = 'foo', source = 'foo.c')
8986 SConscript('sub/SConscript')
8991 # Builds sub/foo from sub/foo.c
8992 env.Program(target = 'foo', source = 'foo.c')
8994 SConscript('dir/SConscript')
8999 # Builds sub/dir/foo from sub/dir/foo.c
9000 env.Program(target = 'foo', source = 'foo.c')
9003 .SS Sharing Variables Between SConscript Files
9005 You must explicitly Export() and Import() variables that
9006 you want to share between SConscript files.
9012 env.Program(target = 'foo', source = 'foo.c')
9015 SConscript('subdirectory/SConscript')
9017 subdirectory/SConscript:
9020 env.Program(target = 'foo', source = 'foo.c')
9023 .SS Building Multiple Variants From the Same Source
9025 Use the BuildDir() method to establish
9026 one or more separate build directories for
9027 a given source directory,
9028 then use the SConscript() method
9029 to specify the SConscript files
9030 in the build directories:
9037 BuildDir('foo', 'src')
9038 SConscript('foo/SConscript')
9042 BuildDir('bar', 'src')
9043 SConscript('bar/SConscript')
9048 env = Environment(CCFLAGS = ccflags)
9049 env.Program(target = 'src', source = 'src.c')
9052 Note the use of the Export() method
9053 to set the "ccflags" variable to a different
9054 value for each variant build.
9056 .SS Hierarchical Build of Two Libraries Linked With a Program
9061 env = Environment(LIBPATH = ['#libA', '#libB'])
9063 SConscript('libA/SConscript')
9064 SConscript('libB/SConscript')
9065 SConscript('Main/SConscript')
9070 env.Library('a', Split('a1.c a2.c a3.c'))
9075 env.Library('b', Split('b1.c b2.c b3.c'))
9080 e = env.Copy(LIBS = ['a', 'b'])
9081 e.Program('foo', Split('m1.c m2.c m3.c'))
9084 The '#' in the LIBPATH directories specify that they're relative to the
9085 top-level directory, so they don't turn into "Main/libA" when they're
9086 used in Main/SConscript.
9088 Specifying only 'a' and 'b' for the library names
9089 allows SCons to append the appropriate library
9090 prefix and suffix for the current platform
9091 (for example, 'liba.a' on POSIX systems,
9092 'a.lib' on Windows).
9094 .SS Customizing contruction variables from the command line.
9096 The following would allow the C compiler to be specified on the command
9097 line or in the file custom.py.
9100 opts = Options('custom.py')
9101 opts.Add('CC', 'The C compiler.')
9102 env = Environment(options=opts)
9103 Help(opts.GenerateHelpText(env))
9106 The user could specify the C compiler on the command line:
9112 or in the custom.py file:
9118 or get documentation on the options:
9129 .SS Using Microsoft Visual C++ precompiled headers
9131 Since windows.h includes everything and the kitchen sink, it can take quite
9132 some time to compile it over and over again for a bunch of object files, so
9133 Microsoft provides a mechanism to compile a set of headers once and then
9134 include the previously compiled headers in any object file. This
9135 technology is called precompiled headers. The general recipe is to create a
9136 file named "StdAfx.cpp" that includes a single header named "StdAfx.h", and
9137 then include every header you want to precompile in "StdAfx.h", and finally
9138 include "StdAfx.h" as the first header in all the source files you are
9139 compiling to object files. For example:
9143 #include <windows.h>
9144 #include <my_big_header.h>
9163 /* do some other stuff */
9169 env['PCHSTOP'] = 'StdAfx.h'
9170 env['PCH'] = env.PCH('StdAfx.cpp')[0]
9171 env.Program('MyApp', ['Foo.cpp', 'Bar.cpp'])
9174 For more information see the document for the PCH builder, and the PCH and
9175 PCHSTOP construction variables. To learn about the details of precompiled
9176 headers consult the MSDN documention for /Yc, /Yu, and /Yp.
9178 .SS Using Microsoft Visual C++ external debugging information
9180 Since including debugging information in programs and shared libraries can
9181 cause their size to increase significantly, Microsoft provides a mechanism
9182 for including the debugging information in an external file called a PDB
9183 file. SCons supports PDB files through the PDB construction
9189 env['PDB'] = 'MyApp.pdb'
9190 env.Program('MyApp', ['Foo.cpp', 'Bar.cpp'])
9193 For more information see the document for the PDB construction variable.
9198 Specifies the directory that contains the SCons Python module directory
9199 (e.g. /home/aroach/scons-src-0.01/src/engine).
9202 A string of options that will be used by scons in addition to those passed
9203 on the command line.
9214 Steven Knight <knight@baldmt.com>
9216 Anthony Roach <aroach@electriceyeball.com>