1SCONS(1) General Commands Manual SCONS(1)
2
3
4
6 scons - a software construction tool
7
9 scons [ options... ] [ name=val... ] [ targets... ]
10
12 The scons utility builds software (or other files) by determining which
13 component pieces must be rebuilt and executing the necessary commands
14 to rebuild them.
15
16 By default, scons searches for a file named SConstruct, Sconstruct, or
17 sconstruct (in that order) in the current directory and reads its con‐
18 figuration from the first file found. An alternate file name may be
19 specified via the -f option.
20
21 The SConstruct file can specify subsidiary configuration files using
22 the SConscript() function. By convention, these subsidiary files are
23 named SConscript, although any name may be used. (Because of this nam‐
24 ing convention, the term "SConscript files" is sometimes used to refer
25 generically to all scons configuration files, regardless of actual file
26 name.)
27
28 The configuration files specify the target files to be built, and
29 (optionally) the rules to build those targets. Reasonable default
30 rules exist for building common software components (executable pro‐
31 grams, object files, libraries), so that for most software projects,
32 only the target and input files need be specified.
33
34 Before reading the SConstruct file, scons looks for a directory named
35 site_scons in various system directories (see below) and the directory
36 containing the SConstruct file; for each of those dirs which exists,
37 site_scons is prepended to sys.path, the file site_scons/site_init.py,
38 is evaluated if it exists, and the directory site_scons/site_tools is
39 prepended to the default toolpath if it exists. See the --no-site-dir
40 and --site-dir options for more details.
41
42 scons reads and executes the SConscript files as Python scripts, so you
43 may use normal Python scripting capabilities (such as flow control,
44 data manipulation, and imported Python libraries) to handle complicated
45 build situations. scons, however, reads and executes all of the SCon‐
46 script files before it begins building any targets. To make this obvi‐
47 ous, scons prints the following messages about what it is doing:
48
49 $ scons foo.out
50 scons: Reading SConscript files ...
51 scons: done reading SConscript files.
52 scons: Building targets ...
53 cp foo.in foo.out
54 scons: done building targets.
55 $
56
57 The status messages (everything except the line that reads "cp foo.in
58 foo.out") may be suppressed using the -Q option.
59
60 scons does not automatically propagate the external environment used to
61 execute scons to the commands used to build target files. This is so
62 that builds will be guaranteed repeatable regardless of the environment
63 variables set at the time scons is invoked. This also means that if
64 the compiler or other commands that you want to use to build your tar‐
65 get files are not in standard system locations, scons will not find
66 them unless you explicitly set the PATH to include those locations.
67 Whenever you create an scons construction environment, you can propa‐
68 gate the value of PATH from your external environment as follows:
69
70 import os
71 env = Environment(ENV = {'PATH' : os.environ['PATH']})
72
73 Similarly, if the commands use external environment variables like
74 $PATH, $HOME, $JAVA_HOME, $LANG, $SHELL, $TERM, etc., these variables
75 can also be explicitly propagated:
76
77 import os
78 env = Environment(ENV = {'PATH' : os.environ['PATH'],
79 'HOME' : os.environ['HOME']})
80
81 Or you may explicitly propagate the invoking user's complete external
82 environment:
83
84 import os
85 env = Environment(ENV = os.environ)
86
87 This comes at the expense of making your build dependent on the user's
88 environment being set correctly, but it may be more convenient for many
89 configurations.
90
91 scons can scan known input files automatically for dependency informa‐
92 tion (for example, #include statements in C or C++ files) and will
93 rebuild dependent files appropriately whenever any "included" input
94 file changes. scons supports the ability to define new scanners for
95 unknown input file types.
96
97 scons knows how to fetch files automatically from SCCS or RCS subdirec‐
98 tories using SCCS, RCS or BitKeeper.
99
100 scons is normally executed in a top-level directory containing a SCon‐
101 struct file, optionally specifying as command-line arguments the target
102 file or files to be built.
103
104 By default, the command
105
106 scons
107
108 will build all target files in or below the current directory.
109 Explicit default targets (to be built when no targets are specified on
110 the command line) may be defined the SConscript file(s) using the
111 Default() function, described below.
112
113 Even when Default() targets are specified in the SConscript file(s),
114 all target files in or below the current directory may be built by
115 explicitly specifying the current directory (.) as a command-line tar‐
116 get:
117
118 scons .
119
120 Building all target files, including any files outside of the current
121 directory, may be specified by supplying a command-line target of the
122 root directory (on POSIX systems):
123
124 scons /
125
126 or the path name(s) of the volume(s) in which all the targets should be
127 built (on Windows systems):
128
129 scons C:\ D:\
130
131 To build only specific targets, supply them as command-line arguments:
132
133 scons foo bar
134
135 in which case only the specified targets will be built (along with any
136 derived files on which they depend).
137
138 Specifying "cleanup" targets in SConscript files is not usually neces‐
139 sary. The -c flag removes all files necessary to build the specified
140 target:
141
142 scons -c .
143
144 to remove all target files, or:
145
146 scons -c build export
147
148 to remove target files under build and export. Additional files or
149 directories to remove can be specified using the Clean() function.
150 Conversely, targets that would normally be removed by the -c invocation
151 can be prevented from being removed by using the NoClean() function.
152
153 A subset of a hierarchical tree may be built by remaining at the top-
154 level directory (where the SConstruct file lives) and specifying the
155 subdirectory as the target to be built:
156
157 scons src/subdir
158
159 or by changing directory and invoking scons with the -u option, which
160 traverses up the directory hierarchy until it finds the SConstruct
161 file, and then builds targets relatively to the current subdirectory:
162
163 cd src/subdir
164 scons -u .
165
166 scons supports building multiple targets in parallel via a -j option
167 that takes, as its argument, the number of simultaneous tasks that may
168 be spawned:
169
170 scons -j 4
171
172 builds four targets in parallel, for example.
173
174 scons can maintain a cache of target (derived) files that can be shared
175 between multiple builds. When caching is enabled in a SConscript file,
176 any target files built by scons will be copied to the cache. If an up-
177 to-date target file is found in the cache, it will be retrieved from
178 the cache instead of being rebuilt locally. Caching behavior may be
179 disabled and controlled in other ways by the --cache-force, --cache-
180 disable, and --cache-show command-line options. The --random option is
181 useful to prevent multiple builds from trying to update the cache
182 simultaneously.
183
184 Values of variables to be passed to the SConscript file(s) may be spec‐
185 ified on the command line:
186
187 scons debug=1 .
188
189 These variables are available in SConscript files through the ARGUMENTS
190 dictionary, and can be used in the SConscript file(s) to modify the
191 build in any way:
192
193 if ARGUMENTS.get('debug', 0):
194 env = Environment(CCFLAGS = '-g')
195 else:
196 env = Environment()
197
198 The command-line variable arguments are also available in the ARGLIST
199 list, indexed by their order on the command line. This allows you to
200 process them in order rather than by name, if necessary. ARGLIST[0]
201 returns a tuple containing (argname, argvalue). A Python exception is
202 thrown if you try to access a list member that does not exist.
203
204 scons requires Python version 2.4 or later. There should be no other
205 dependencies or requirements to run scons.
206
207 By default, scons knows how to search for available programming tools
208 on various systems. On Windows systems, scons searches in order for
209 the Microsoft Visual C++ tools, the MinGW tool chain, the Intel com‐
210 piler tools, and the PharLap ETS compiler. On OS/2 systems, scons
211 searches in order for the OS/2 compiler, the GCC tool chain, and the
212 Microsoft Visual C++ tools, On SGI IRIX, IBM AIX, Hewlett Packard HP-
213 UX, and Sun Solaris systems, scons searches for the native compiler
214 tools (MIPSpro, Visual Age, aCC, and Forte tools respectively) and the
215 GCC tool chain. On all other platforms, including POSIX (Linux and
216 UNIX) platforms, scons searches in order for the GCC tool chain, the
217 Microsoft Visual C++ tools, and the Intel compiler tools. You may, of
218 course, override these default values by appropriate configuration of
219 Environment construction variables.
220
221
223 In general, scons supports the same command-line options as GNU make,
224 and many of those supported by cons.
225
226
227 -b Ignored for compatibility with non-GNU versions of make.
228
229
230 -c, --clean, --remove
231 Clean up by removing all target files for which a construction
232 command is specified. Also remove any files or directories
233 associated to the construction command using the Clean() func‐
234 tion. Will not remove any targets specified by the NoClean()
235 function.
236
237
238 --cache-debug=file
239 Print debug information about the CacheDir() derived-file
240 caching to the specified file. If file is - (a hyphen), the
241 debug information are printed to the standard output. The
242 printed messages describe what signature file names are being
243 looked for in, retrieved from, or written to the CacheDir()
244 directory tree.
245
246
247 --cache-disable, --no-cache
248 Disable the derived-file caching specified by CacheDir(). scons
249 will neither retrieve files from the cache nor copy files to the
250 cache.
251
252
253 --cache-force, --cache-populate
254 When using CacheDir(), populate a cache by copying any already-
255 existing, up-to-date derived files to the cache, in addition to
256 files built by this invocation. This is useful to populate a
257 new cache with all the current derived files, or to add to the
258 cache any derived files recently built with caching disabled via
259 the --cache-disable option.
260
261
262 --cache-show
263 When using CacheDir() and retrieving a derived file from the
264 cache, show the command that would have been executed to build
265 the file, instead of the usual report, "Retrieved `file' from
266 cache." This will produce consistent output for build logs,
267 regardless of whether a target file was rebuilt or retrieved
268 from the cache.
269
270
271 --config=mode
272 This specifies how the Configure call should use or generate the
273 results of configuration tests. The option should be specified
274 from among the following choices:
275
276
277 --config=auto
278 scons will use its normal dependency mechanisms to decide if a
279 test must be rebuilt or not. This saves time by not running the
280 same configuration tests every time you invoke scons, but will
281 overlook changes in system header files or external commands
282 (such as compilers) if you don't specify those dependecies
283 explicitly. This is the default behavior.
284
285
286 --config=force
287 If this option is specified, all configuration tests will be re-
288 run regardless of whether the cached results are out of date.
289 This can be used to explicitly force the configuration tests to
290 be updated in response to an otherwise unconfigured change in a
291 system header file or compiler.
292
293
294 --config=cache
295 If this option is specified, no configuration tests will be
296 rerun and all results will be taken from cache. Note that scons
297 will still consider it an error if --config=cache is specified
298 and a necessary test does not yet have any results in the cache.
299
300
301 -C directory, --directory=directory
302 Change to the specified directory before searching for the SCon‐
303 struct, Sconstruct, or sconstruct file, or doing anything else.
304 Multiple -C options are interpreted relative to the previous
305 one, and the right-most -C option wins. (This option is nearly
306 equivalent to -f directory/SConstruct, except that it will
307 search for SConstruct, Sconstruct, or sconstruct in the speci‐
308 fied directory.)
309
310
311
312 -D Works exactly the same way as the -u option except for the way
313 default targets are handled. When this option is used and no
314 targets are specified on the command line, all default targets
315 are built, whether or not they are below the current directory.
316
317
318 --debug=type
319 Debug the build process. type specifies what type of debugging:
320
321
322 --debug=count
323 Print how many objects are created of the various classes used
324 internally by SCons before and after reading the SConscript
325 files and before and after building targets. This is not sup‐
326 ported when SCons is executed with the Python -O (optimized)
327 option or when the SCons modules have been compiled with opti‐
328 mization (that is, when executing from *.pyo files).
329
330
331 --debug=duplicate
332 Print a line for each unlink/relink (or copy) of a variant file
333 from its source file. Includes debugging info for unlinking
334 stale variant files, as well as unlinking old targets before
335 building them.
336
337
338 --debug=dtree
339 A synonym for the newer --tree=derived option. This will be
340 deprecated in some future release and ultimately removed.
341
342
343 --debug=explain
344 Print an explanation of precisely why scons is deciding to
345 (re-)build any targets. (Note: this does not print anything
346 for targets that are not rebuilt.)
347
348
349 --debug=findlibs
350 Instruct the scanner that searches for libraries to print a mes‐
351 sage about each potential library name it is searching for, and
352 about the actual libraries it finds.
353
354
355 --debug=includes
356 Print the include tree after each top-level target is built.
357 This is generally used to find out what files are included by
358 the sources of a given derived file:
359
360 $ scons --debug=includes foo.o
361
362
363 --debug=memoizer
364 Prints a summary of hits and misses using the Memoizer, an
365 internal subsystem that counts how often SCons uses cached val‐
366 ues in memory instead of recomputing them each time they're
367 needed.
368
369
370 --debug=memory
371 Prints how much memory SCons uses before and after reading the
372 SConscript files and before and after building targets.
373
374
375 --debug=nomemoizer
376 A deprecated option preserved for backwards compatibility.
377
378
379 --debug=objects
380 Prints a list of the various objects of the various classes used
381 internally by SCons.
382
383
384 --debug=pdb
385 Re-run SCons under the control of the pdb Python debugger.
386
387
388 --debug=prepare
389 Print a line each time any target (internal or external) is pre‐
390 pared for building. scons prints this for each target it con‐
391 siders, even if that target is up to date (see also
392 --debug=explain). This can help debug problems with targets
393 that aren't being built; it shows whether scons is at least con‐
394 sidering them or not.
395
396
397 --debug=presub
398 Print the raw command line used to build each target before the
399 construction environment variables are substituted. Also shows
400 which targets are being built by this command. Output looks
401 something like this:
402 $ scons --debug=presub
403 Building myprog.o with action(s):
404 $SHCC $SHCFLAGS $SHCCFLAGS $CPPFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES
405 ...
406
407
408 --debug=stacktrace
409 Prints an internal Python stack trace when encountering an oth‐
410 erwise unexplained error.
411
412
413 --debug=stree
414 A synonym for the newer --tree=all,status option. This will be
415 deprecated in some future release and ultimately removed.
416
417
418 --debug=time
419 Prints various time profiling information: the time spent exe‐
420 cuting each individual build command; the total build time (time
421 SCons ran from beginning to end); the total time spent reading
422 and executing SConscript files; the total time spent SCons
423 itself spend running (that is, not counting reading and execut‐
424 ing SConscript files); and both the total time spent executing
425 all build commands and the elapsed wall-clock time spent execut‐
426 ing those build commands. (When scons is executed without the
427 -j option, the elapsed wall-clock time will typically be
428 slightly longer than the total time spent executing all the
429 build commands, due to the SCons processing that takes place in
430 between executing each command. When scons is executed with the
431 -j option, and your build configuration allows good paralleliza‐
432 tion, the elapsed wall-clock time should be significantly
433 smaller than the total time spent executing all the build com‐
434 mands, since multiple build commands and intervening SCons pro‐
435 cessing should take place in parallel.)
436
437
438 --debug=tree
439 A synonym for the newer --tree=all option. This will be depre‐
440 cated in some future release and ultimately removed.
441
442
443 --diskcheck=types
444 Enable specific checks for whether or not there is a file on
445 disk where the SCons configuration expects a directory (or vice
446 versa), and whether or not RCS or SCCS sources exist when
447 searching for source and include files. The types argument can
448 be set to: all, to enable all checks explicitly (the default
449 behavior); none, to disable all such checks; match, to check
450 that files and directories on disk match SCons' expected config‐
451 uration; rcs, to check for the existence of an RCS source for
452 any missing source or include files; sccs, to check for the
453 existence of an SCCS source for any missing source or include
454 files. Multiple checks can be specified separated by commas;
455 for example, --diskcheck=sccs,rcs would still check for SCCS and
456 RCS sources, but disable the check for on-disk matches of files
457 and directories. Disabling some or all of these checks can pro‐
458 vide a performance boost for large configurations, or when the
459 configuration will check for files and/or directories across
460 networked or shared file systems, at the slight increased risk
461 of an incorrect build or of not handling errors gracefully (if
462 include files really should be found in SCCS or RCS, for exam‐
463 ple, or if a file really does exist where the SCons configura‐
464 tion expects a directory).
465
466
467 --duplicate=ORDER
468 There are three ways to duplicate files in a build tree: hard
469 links, soft (symbolic) links and copies. The default behaviour
470 of SCons is to prefer hard links to soft links to copies. You
471 can specify different behaviours with this option. ORDER must
472 be one of hard-soft-copy (the default), soft-hard-copy, hard-
473 copy, soft-copy or copy. SCons will attempt to duplicate files
474 using the mechanisms in the specified order.
475
476
477
478 -f file, --file=file, --makefile=file, --sconstruct=file
479 Use file as the initial SConscript file. Multiple -f options
480 may be specified, in which case scons will read all of the spec‐
481 ified files.
482
483
484 -h, --help
485 Print a local help message for this build, if one is defined in
486 the SConscript file(s), plus a line that describes the -H option
487 for command-line option help. If no local help message is
488 defined, prints the standard help message about command-line
489 options. Exits after displaying the appropriate message.
490
491
492 -H, --help-options
493 Print the standard help message about command-line options and
494 exit.
495
496
497 -i, --ignore-errors
498 Ignore all errors from commands executed to rebuild files.
499
500
501 -I directory, --include-dir=directory
502 Specifies a directory to search for imported Python modules. If
503 several -I options are used, the directories are searched in the
504 order specified.
505
506
507 --implicit-cache
508 Cache implicit dependencies. This causes scons to use the
509 implicit (scanned) dependencies from the last time it was run
510 instead of scanning the files for implicit dependencies. This
511 can significantly speed up SCons, but with the following limita‐
512 tions:
513
514 scons will not detect changes to implicit dependency search
515 paths (e.g. CPPPATH, LIBPATH) that would ordinarily cause dif‐
516 ferent versions of same-named files to be used.
517
518 scons will miss changes in the implicit dependencies in cases
519 where a new implicit dependency is added earlier in the implicit
520 dependency search path (e.g. CPPPATH, LIBPATH) than a current
521 implicit dependency with the same name.
522
523
524 --implicit-deps-changed
525 Forces SCons to ignore the cached implicit dependencies. This
526 causes the implicit dependencies to be rescanned and recached.
527 This implies --implicit-cache.
528
529
530 --implicit-deps-unchanged
531 Force SCons to ignore changes in the implicit dependencies.
532 This causes cached implicit dependencies to always be used.
533 This implies --implicit-cache.
534
535
536 --interactive
537 Starts SCons in interactive mode. The SConscript files are read
538 once and a scons>>> prompt is printed. Targets may now be
539 rebuilt by typing commands at interactive prompt without having
540 to re-read the SConscript files and re-initialize the dependency
541 graph from scratch.
542
543 SCons interactive mode supports the following commands:
544
545
546 build[OPTIONS] [TARGETS] ...
547 Builds the specified TARGETS (and their dependencies)
548 with the specified SCons command-line OPTIONS. b and
549 scons are synonyms.
550
551 The following SCons command-line options affect the
552 build command:
553
554 --cache-debug=FILE
555 --cache-disable, --no-cache
556 --cache-force, --cache-populate
557 --cache-show
558 --debug=TYPE
559 -i, --ignore-errors
560 -j N, --jobs=N
561 -k, --keep-going
562 -n, --no-exec, --just-print, --dry-run, --recon
563 -Q
564 -s, --silent, --quiet
565 --taskmastertrace=FILE
566 --tree=OPTIONS
567
568
569 Any other SCons command-line options that are specified
570 do not cause errors but have no effect on the build
571 command (mainly because they affect how the SConscript
572 files are read, which only happens once at the begin‐
573 ning of interactive mode).
574
575
576 clean[OPTIONS] [TARGETS] ...
577 Cleans the specified TARGETS (and their dependencies)
578 with the specified options. c is a synonym. This com‐
579 mand is itself a synonym for build --clean
580
581
582 exit Exits SCons interactive mode. You can also exit by
583 terminating input (CTRL+D on UNIX or Linux systems,
584 CTRL+Z on Windows systems).
585
586
587 help[COMMAND]
588 Provides a help message about the commands available in
589 SCons interactive mode. If COMMAND is specified, h and
590 ? are synonyms.
591
592
593 shell[COMMANDLINE]
594 Executes the specified COMMANDLINE in a subshell. If
595 no COMMANDLINE is specified, executes the interactive
596 command interpreter specified in the SHELL environment
597 variable (on UNIX and Linux systems) or the COMSPEC
598 environment variable (on Windows systems). sh and !
599 are synonyms.
600
601
602 version
603 Prints SCons version information.
604
605
606 An empty line repeats the last typed command. Command-line
607 editing can be used if the readline module is available.
608
609 $ scons --interactive
610 scons: Reading SConscript files ...
611 scons: done reading SConscript files.
612 scons>>> build -n prog
613 scons>>> exit
614
615
616 -j N, --jobs=N
617 Specifies the number of jobs (commands) to run simultaneously.
618 If there is more than one -j option, the last one is effective.
619
620
621 -k, --keep-going
622 Continue as much as possible after an error. The target that
623 failed and those that depend on it will not be remade, but other
624 targets specified on the command line will still be processed.
625
626
627
628
629 -m Ignored for compatibility with non-GNU versions of make.
630
631
632 --max-drift=SECONDS
633 Set the maximum expected drift in the modification time of files
634 to SECONDS. This value determines how long a file must be
635 unmodified before its cached content signature will be used
636 instead of calculating a new content signature (MD5 checksum) of
637 the file's contents. The default value is 2 days, which means a
638 file must have a modification time of at least two days ago in
639 order to have its cached content signature used. A negative
640 value means to never cache the content signature and to ignore
641 the cached value if there already is one. A value of 0 means to
642 always use the cached signature, no matter how old the file is.
643
644
645 --md5-chunksize=KILOBYTES
646 Set the block size used to compute MD5 signatures to KILOBYTES.
647 This value determines the size of the chunks which are read in
648 at once when computing MD5 signatures. Files below that size
649 are fully stored in memory before performing the signature com‐
650 putation while bigger files are read in block-by-block. A huge
651 block-size leads to high memory consumption while a very small
652 block-size slows down the build considerably.
653
654 The default value is to use a chunk size of 64 kilobytes, which
655 should be appropriate for most uses.
656
657
658 -n, --just-print, --dry-run, --recon
659 No execute. Print the commands that would be executed to build
660 any out-of-date target files, but do not execute the commands.
661
662
663 --no-site-dir
664 Prevents the automatic addition of the standard site_scons dirs
665 to sys.path. Also prevents loading the site_scons/site_init.py
666 modules if they exist, and prevents adding their
667 site_scons/site_tools dirs to the toolpath.
668
669
670
671 --profile=file
672 Run SCons under the Python profiler and save the results in the
673 specified file. The results may be analyzed using the Python
674 pstats module.
675
676
677 -q, --question
678 Do not run any commands, or print anything. Just return an exit
679 status that is zero if the specified targets are already up to
680 date, non-zero otherwise.
681
682 -Q Quiets SCons status messages about reading SConscript files,
683 building targets and entering directories. Commands that are
684 executed to rebuild target files are still printed.
685
686
687
688 --random
689 Build dependencies in a random order. This is useful when
690 building multiple trees simultaneously with caching enabled, to
691 prevent multiple builds from simultaneously trying to build or
692 retrieve the same target files.
693
694
695 -s, --silent, --quiet
696 Silent. Do not print commands that are executed to rebuild tar‐
697 get files. Also suppresses SCons status messages.
698
699
700 -S, --no-keep-going, --stop
701 Ignored for compatibility with GNU make.
702
703
704 --site-dir=dir
705 Uses the named dir as the site dir rather than the default
706 site_scons dirs. This dir will get prepended to sys.path, the
707 module dir/site_init.py will get loaded if it exists, and
708 dir/site_tools will get added to the default toolpath.
709
710 The default set of site_scons dirs used when --site-dir is not
711 specified depends on the system platform, as follows. Note that
712 the directories are examined in the order given, from most
713 generic to most specific, so the last-executed site_init.py file
714 is the most specific one (which gives it the chance to override
715 everything else), and the dirs are prepended to the paths, again
716 so the last dir examined comes first in the resulting path.
717
718
719 Windows:
720 %ALLUSERSPROFILE/Application Data/scons/site_scons
721 %USERPROFILE%/Local Settings/Application Data/scons/site_scons
722 %APPDATA%/scons/site_scons
723 %HOME%/.scons/site_scons
724 ./site_scons
725
726 Mac OS X:
727 /Library/Application Support/SCons/site_scons
728 /opt/local/share/scons/site_scons (for MacPorts)
729 /sw/share/scons/site_scons (for Fink)
730 $HOME/Library/Application Support/SCons/site_scons
731 $HOME/.scons/site_scons
732 ./site_scons
733
734 Solaris:
735 /opt/sfw/scons/site_scons
736 /usr/share/scons/site_scons
737 $HOME/.scons/site_scons
738 ./site_scons
739
740 Linux, HPUX, and other Posix-like systems:
741 /usr/share/scons/site_scons
742 $HOME/.scons/site_scons
743 ./site_scons
744
745
746 --stack-size=KILOBYTES
747 Set the size stack used to run threads to KILOBYTES. This value
748 determines the stack size of the threads used to run jobs.
749 These are the threads that execute the actions of the builders
750 for the nodes that are out-of-date. Note that this option has
751 no effect unless the num_jobs option, which corresponds to -j
752 and --jobs, is larger than one. Using a stack size that is too
753 small may cause stack overflow errors. This usually shows up as
754 segmentation faults that cause scons to abort before building
755 anything. Using a stack size that is too large will cause scons
756 to use more memory than required and may slow down the entire
757 build process.
758
759 The default value is to use a stack size of 256 kilobytes, which
760 should be appropriate for most uses. You should not need to
761 increase this value unless you encounter stack overflow errors.
762
763
764 -t, --touch
765 Ignored for compatibility with GNU make. (Touching a file to
766 make it appear up-to-date is unnecessary when using scons.)
767
768
769 --taskmastertrace=file
770 Prints trace information to the specified file about how the
771 internal Taskmaster object evaluates and controls the order in
772 which Nodes are built. A file name of - may be used to specify
773 the standard output.
774
775
776 -tree=options
777 Prints a tree of the dependencies after each top-level target is
778 built. This prints out some or all of the tree, in various for‐
779 mats, depending on the options specified:
780
781
782 --tree=all
783 Print the entire dependency tree after each top-level target is
784 built. This prints out the complete dependency tree, including
785 implicit dependencies and ignored dependencies.
786
787
788 --tree=derived
789 Restricts the tree output to only derived (target) files, not
790 source files.
791
792
793 --tree=status
794 Prints status information for each displayed node.
795
796
797 --tree=prune
798 Prunes the tree to avoid repeating dependency information for
799 nodes that have already been displayed. Any node that has
800 already been displayed will have its name printed in [square
801 brackets], as an indication that the dependencies for that node
802 can be found by searching for the relevant output higher up in
803 the tree.
804
805
806 Multiple options may be specified, separated by commas:
807
808 # Prints only derived files, with status information:
809 scons --tree=derived,status
810
811 # Prints all dependencies of target, with status information
812 # and pruning dependencies of already-visited Nodes:
813 scons --tree=all,prune,status target
814
815
816 -u, --up, --search-up
817 Walks up the directory structure until an SConstruct , Scon‐
818 struct or sconstruct file is found, and uses that as the top of
819 the directory tree. If no targets are specified on the command
820 line, only targets at or below the current directory will be
821 built.
822
823
824 -U Works exactly the same way as the -u option except for the way
825 default targets are handled. When this option is used and no
826 targets are specified on the command line, all default targets
827 that are defined in the SConscript(s) in the current directory
828 are built, regardless of what directory the resultant targets
829 end up in.
830
831
832 -v, --version
833 Print the scons version, copyright information, list of authors,
834 and any other relevant information. Then exit.
835
836
837 -w, --print-directory
838 Print a message containing the working directory before and
839 after other processing.
840
841
842 --no-print-directory
843 Turn off -w, even if it was turned on implicitly.
844
845
846 --warn=type, --warn=no-type
847 Enable or disable warnings. type specifies the type of warnings
848 to be enabled or disabled:
849
850
851 --warn=all, --warn=no-all
852 Enables or disables all warnings.
853
854
855 --warn=cache-write-error, --warn=no-cache-write-error
856 Enables or disables warnings about errors trying to write a copy
857 of a built file to a specified CacheDir(). These warnings are
858 disabled by default.
859
860
861 --warn=corrupt-sconsign, --warn=no-corrupt-sconsign
862 Enables or disables warnings about unfamiliar signature data in
863 .sconsign files. These warnings are enabled by default.
864
865
866 --warn=dependency, --warn=no-dependency
867 Enables or disables warnings about dependencies. These warnings
868 are disabled by default.
869
870
871 --warn=deprecated, --warn=no-deprecated
872 Enables or disables all warnings about use of currently depre‐
873 cated features. These warnings are enabled by default. Note
874 that the --warn=no-deprecated option does not disable warnings
875 about absolutely all deprecated features. Warnings for some
876 deprecated features that have already been through several
877 releases with deprecation warnings may be mandatory for a
878 release or two before they are officially no longer supported by
879 SCons. Warnings for some specific deprecated features may be
880 enabled or disabled individually; see below.
881
882
883 --warn=deprecated-copy, --warn=no-deprecated-copy
884 Enables or disables warnings about use of the deprecated
885 env.Copy() method.
886
887
888 --warn=deprecated-source-signatures, --warn=no-deprecated-
889 source-signatures
890 Enables or disables warnings about use of the deprecated
891 SourceSignatures() function or env.SourceSignatures()
892 method.
893
894
895 --warn=deprecated-target-signatures, --warn=no-deprecated-tar‐
896 get-signatures
897 Enables or disables warnings about use of the deprecated
898 TargetSignatures() function or env.TargetSignatures()
899 method.
900
901
902 --warn=duplicate-environment, --warn=no-duplicate-environment
903 Enables or disables warnings about attempts to specify a build
904 of a target with two different construction environments that
905 use the same action. These warnings are enabled by default.
906
907
908 --warn=fortran-cxx-mix, --warn=no-fortran-cxx-mix
909 Enables or disables the specific warning about linking Fortran
910 and C++ object files in a single executable, which can yield
911 unpredictable behavior with some compilers.
912
913
914 --warn=future-deprecated, --warn=no-future-deprecated
915 Enables or disables warnings about features that will be depre‐
916 cated in the future. These warnings are disabled by default.
917 Enabling this warning is especially recommended for projects
918 that redistribute SCons configurations for other users to build,
919 so that the project can be warned as soon as possible about to-
920 be-deprecated features that may require changes to the configu‐
921 ration.
922
923
924 --warn=link, --warn=no-link
925 Enables or disables warnings about link steps.
926
927
928 --warn=misleading-keywords, --warn=no-misleading-keywords
929 Enables or disables warnings about use of the misspelled key‐
930 words targets and sources when calling Builders. (Note the last
931 s characters, the correct spellings are target and source.)
932 These warnings are enabled by default.
933
934
935 --warn=missing-sconscript, --warn=no-missing-sconscript
936 Enables or disables warnings about missing SConscript files.
937 These warnings are enabled by default.
938
939
940 --warn=no-md5-module, --warn=no-no-md5-module
941 Enables or disables warnings about the version of Python not
942 having an MD5 checksum module available. These warnings are
943 enabled by default.
944
945
946 --warn=no-metaclass-support, --warn=no-no-metaclass-support
947 Enables or disables warnings about the version of Python not
948 supporting metaclasses when the --debug=memoizer option is used.
949 These warnings are enabled by default.
950
951
952 --warn=no-object-count, --warn=no-no-object-count
953 Enables or disables warnings about the --debug=object feature
954 not working when scons is run with the python -O option or from
955 optimized Python (.pyo) modules.
956
957
958 --warn=no-parallel-support, --warn=no-no-parallel-support
959 Enables or disables warnings about the version of Python not
960 being able to support parallel builds when the -j option is
961 used. These warnings are enabled by default.
962
963
964 --warn=python-version, --warn=no-python-version
965 Enables or disables the warning about running SCons with a dep‐
966 recated version of Python. These warnings are enabled by
967 default.
968
969
970 --warn=reserved-variable, --warn=no-reserved-variable
971 Enables or disables warnings about attempts to set the reserved
972 construction variable names CHANGED_SOURCES, CHANGED_TARGETS,
973 TARGET, TARGETS, SOURCE, SOURCES, UNCHANGED_SOURCES or
974 UNCHANGED_TARGETS. These warnings are disabled by default.
975
976
977 --warn=stack-size, --warn=no-stack-size
978 Enables or disables warnings about requests to set the stack
979 size that could not be honored. These warnings are enabled by
980 default.
981
982
983
984 -Y repository, --repository=repository, --srcdir=repository
985 Search the specified repository for any input and target files
986 not found in the local directory hierarchy. Multiple -Y options
987 may be specified, in which case the repositories are searched in
988 the order specified.
989
990
992 Construction Environments
993 A construction environment is the basic means by which the SConscript
994 files communicate build information to scons. A new construction envi‐
995 ronment is created using the Environment function:
996
997 env = Environment()
998
999 Variables, called construction variables, may be set in a construction
1000 environment either by specifying them as keywords when the object is
1001 created or by assigning them a value after the object is created:
1002
1003 env = Environment(FOO = 'foo')
1004 env['BAR'] = 'bar'
1005
1006 As a convenience, construction variables may also be set or modified by
1007 the parse_flags keyword argument, which applies the ParseFlags method
1008 (described below) to the argument value after all other processing is
1009 completed. This is useful either if the exact content of the flags is
1010 unknown (for example, read from a control file) or if the flags are
1011 distributed to a number of construction variables.
1012
1013 env = Environment(parse_flags = '-Iinclude -DEBUG -lm')
1014
1015 This example adds 'include' to CPPPATH, 'EBUG' to CPPDEFINES, and 'm'
1016 to LIBS.
1017
1018 By default, a new construction environment is initialized with a set of
1019 builder methods and construction variables that are appropriate for the
1020 current platform. An optional platform keyword argument may be used to
1021 specify that an environment should be initialized for a different plat‐
1022 form:
1023
1024 env = Environment(platform = 'cygwin')
1025 env = Environment(platform = 'os2')
1026 env = Environment(platform = 'posix')
1027 env = Environment(platform = 'win32')
1028
1029 Specifying a platform initializes the appropriate construction vari‐
1030 ables in the environment to use and generate file names with prefixes
1031 and suffixes appropriate for the platform.
1032
1033 Note that the win32 platform adds the SystemDrive and SystemRoot vari‐
1034 ables from the user's external environment to the construction environ‐
1035 ment's ENV dictionary. This is so that any executed commands that use
1036 sockets to connect with other systems (such as fetching source files
1037 from external CVS repository specifications like :pserver:anony‐
1038 mous@cvs.sourceforge.net:/cvsroot/scons) will work on Windows systems.
1039
1040 The platform argument may be function or callable object, in which case
1041 the Environment() method will call the specified argument to update the
1042 new construction environment:
1043
1044 def my_platform(env):
1045 env['VAR'] = 'xyzzy'
1046
1047 env = Environment(platform = my_platform)
1048
1049 Additionally, a specific set of tools with which to initialize the
1050 environment may be specified as an optional keyword argument:
1051
1052 env = Environment(tools = ['msvc', 'lex'])
1053
1054 Non-built-in tools may be specified using the toolpath argument:
1055
1056 env = Environment(tools = ['default', 'foo'], toolpath = ['tools'])
1057
1058 This looks for a tool specification in tools/foo.py (as well as using
1059 the ordinary default tools for the platform). foo.py should have two
1060 functions: generate(env, **kw) and exists(env). The generate() func‐
1061 tion modifies the passed-in environment to set up variables so that the
1062 tool can be executed; it may use any keyword arguments that the user
1063 supplies (see below) to vary its initialization. The exists() function
1064 should return a true value if the tool is available. Tools in the
1065 toolpath are used before any of the built-in ones. For example, adding
1066 gcc.py to the toolpath would override the built-in gcc tool. Also note
1067 that the toolpath is stored in the environment for use by later calls
1068 to Clone() and Tool() methods:
1069
1070 base = Environment(toolpath=['custom_path'])
1071 derived = base.Clone(tools=['custom_tool'])
1072 derived.CustomBuilder()
1073
1074 The elements of the tools list may also be functions or callable
1075 objects, in which case the Environment() method will call the specified
1076 elements to update the new construction environment:
1077
1078 def my_tool(env):
1079 env['XYZZY'] = 'xyzzy'
1080
1081 env = Environment(tools = [my_tool])
1082
1083 The individual elements of the tools list may also themselves be two-
1084 element lists of the form (toolname, kw_dict). SCons searches for the
1085 toolname specification file as described above, and passes kw_dict,
1086 which must be a dictionary, as keyword arguments to the tool's generate
1087 function. The generate function can use the arguments to modify the
1088 tool's behavior by setting up the environment in different ways or oth‐
1089 erwise changing its initialization.
1090
1091 # in tools/my_tool.py:
1092 def generate(env, **kw):
1093 # Sets MY_TOOL to the value of keyword argument 'arg1' or 1.
1094 env['MY_TOOL'] = kw.get('arg1', '1')
1095 def exists(env):
1096 return 1
1097
1098 # in SConstruct:
1099 env = Environment(tools = ['default', ('my_tool', {'arg1': 'abc'})],
1100 toolpath=['tools'])
1101
1102 The tool definition (i.e. my_tool()) can use the PLATFORM variable from
1103 the environment it receives to customize the tool for different plat‐
1104 forms.
1105
1106 If no tool list is specified, then SCons will auto-detect the installed
1107 tools using the PATH variable in the ENV construction variable and the
1108 platform name when the Environment is constructed. Changing the PATH
1109 variable after the Environment is constructed will not cause the tools
1110 to be redetected.
1111
1112 SCons supports the following tool specifications out of the box:
1113
1114 386asm
1115 aixc++
1116 aixcc
1117 aixf77
1118 aixlink
1119 ar
1120 as
1121 bcc32
1122 c++
1123 cc
1124 cvf
1125 dmd
1126 dvipdf
1127 dvips
1128 f77
1129 f90
1130 f95
1131 fortran
1132 g++
1133 g77
1134 gas
1135 gcc
1136 gfortran
1137 gnulink
1138 gs
1139 hpc++
1140 hpcc
1141 hplink
1142 icc
1143 icl
1144 ifl
1145 ifort
1146 ilink
1147 ilink32
1148 intelc
1149 jar
1150 javac
1151 javah
1152 latex
1153 lex
1154 link
1155 linkloc
1156 m4
1157 masm
1158 midl
1159 mingw
1160 mslib
1161 mslink
1162 mssdk
1163 msvc
1164 msvs
1165 mwcc
1166 mwld
1167 nasm
1168 pdflatex
1169 pdftex
1170 qt
1171 rmic
1172 rpcgen
1173 sgiar
1174 sgic++
1175 sgicc
1176 sgilink
1177 sunar
1178 sunc++
1179 suncc
1180 sunf77
1181 sunf90
1182 sunf95
1183 sunlink
1184 swig
1185 tar
1186 tex
1187 textfile
1188 tlib
1189 yacc
1190 zip
1191
1192 Additionally, there is a "tool" named default which configures the
1193 environment with a default set of tools for the current platform.
1194
1195 On posix and cygwin platforms the GNU tools (e.g. gcc) are preferred by
1196 SCons, on Windows the Microsoft tools (e.g. msvc) followed by MinGW are
1197 preferred by SCons, and in OS/2 the IBM tools (e.g. icc) are preferred
1198 by SCons.
1199
1200
1201 Builder Methods
1202 Build rules are specified by calling a construction environment's
1203 builder methods. The arguments to the builder methods are target (a
1204 list of targets to be built, usually file names) and source (a list of
1205 sources to be built, usually file names).
1206
1207 Because long lists of file names can lead to a lot of quoting, scons
1208 supplies a Split() global function and a same-named environment method
1209 that split a single string into a list, separated on strings of white-
1210 space characters. (These are similar to the split() member function of
1211 Python strings but work even if the input isn't a string.)
1212
1213 Like all Python arguments, the target and source arguments to a builder
1214 method can be specified either with or without the "target" and
1215 "source" keywords. When the keywords are omitted, the target is first,
1216 followed by the source. The following are equivalent examples of call‐
1217 ing the Program builder method:
1218
1219 env.Program('bar', ['bar.c', 'foo.c'])
1220 env.Program('bar', Split('bar.c foo.c'))
1221 env.Program('bar', env.Split('bar.c foo.c'))
1222 env.Program(source = ['bar.c', 'foo.c'], target = 'bar')
1223 env.Program(target = 'bar', Split('bar.c foo.c'))
1224 env.Program(target = 'bar', env.Split('bar.c foo.c'))
1225 env.Program('bar', source = 'bar.c foo.c'.split())
1226
1227 Target and source file names that are not absolute path names (that is,
1228 do not begin with / on POSIX systems or on Windows systems, with or
1229 without an optional drive letter) are interpreted relative to the
1230 directory containing the SConscript file being read. An initial #
1231 (hash mark) on a path name means that the rest of the file name is
1232 interpreted relative to the directory containing the top-level SCon‐
1233 struct file, even if the # is followed by a directory separator charac‐
1234 ter (slash or backslash).
1235
1236 Examples:
1237
1238 # The comments describing the targets that will be built
1239 # assume these calls are in a SConscript file in the
1240 # a subdirectory named "subdir".
1241
1242 # Builds the program "subdir/foo" from "subdir/foo.c":
1243 env.Program('foo', 'foo.c')
1244
1245 # Builds the program "/tmp/bar" from "subdir/bar.c":
1246 env.Program('/tmp/bar', 'bar.c')
1247
1248 # An initial '#' or '#/' are equivalent; the following
1249 # calls build the programs "foo" and "bar" (in the
1250 # top-level SConstruct directory) from "subdir/foo.c" and
1251 # "subdir/bar.c", respectively:
1252 env.Program('#foo', 'foo.c')
1253 env.Program('#/bar', 'bar.c')
1254
1255 # Builds the program "other/foo" (relative to the top-level
1256 # SConstruct directory) from "subdir/foo.c":
1257 env.Program('#other/foo', 'foo.c')
1258
1259 When the target shares the same base name as the source and only the
1260 suffix varies, and if the builder method has a suffix defined for the
1261 target file type, then the target argument may be omitted completely,
1262 and scons will deduce the target file name from the source file name.
1263 The following examples all build the executable program bar (on POSIX
1264 systems) or bar.exe (on Windows systems) from the bar.c source file:
1265
1266 env.Program(target = 'bar', source = 'bar.c')
1267 env.Program('bar', source = 'bar.c')
1268 env.Program(source = 'bar.c')
1269 env.Program('bar.c')
1270
1271 As a convenience, a srcdir keyword argument may be specified when call‐
1272 ing a Builder. When specified, all source file strings that are not
1273 absolute paths will be interpreted relative to the specified srcdir.
1274 The following example will build the build/prog (or build/prog.exe on
1275 Windows) program from the files src/f1.c and src/f2.c:
1276
1277 env.Program('build/prog', ['f1.c', 'f2.c'], srcdir='src')
1278
1279 It is possible to override or add construction variables when calling a
1280 builder method by passing additional keyword arguments. These overrid‐
1281 den or added variables will only be in effect when building the target,
1282 so they will not affect other parts of the build. For example, if you
1283 want to add additional libraries for just one program:
1284
1285 env.Program('hello', 'hello.c', LIBS=['gl', 'glut'])
1286
1287 or generate a shared library with a non-standard suffix:
1288
1289 env.SharedLibrary('word', 'word.cpp',
1290 SHLIBSUFFIX='.ocx',
1291 LIBSUFFIXES=['.ocx'])
1292
1293 (Note that both the $SHLIBSUFFIX and $LIBSUFFIXES variables must be set
1294 if you want SCons to search automatically for dependencies on the non-
1295 standard library names; see the descriptions of these variables, below,
1296 for more information.)
1297
1298 It is also possible to use the parse_flags keyword argument in an over‐
1299 ride:
1300
1301 env = Program('hello', 'hello.c', parse_flags = '-Iinclude -DEBUG -lm')
1302
1303 This example adds 'include' to CPPPATH, 'EBUG' to CPPDEFINES, and 'm'
1304 to LIBS.
1305
1306 Although the builder methods defined by scons are, in fact, methods of
1307 a construction environment object, they may also be called without an
1308 explicit environment:
1309
1310 Program('hello', 'hello.c')
1311 SharedLibrary('word', 'word.cpp')
1312
1313 In this case, the methods are called internally using a default con‐
1314 struction environment that consists of the tools and values that scons
1315 has determined are appropriate for the local system.
1316
1317 Builder methods that can be called without an explicit environment may
1318 be called from custom Python modules that you import into an SConscript
1319 file by adding the following to the Python module:
1320
1321 from SCons.Script import *
1322
1323 All builder methods return a list-like object containing Nodes that
1324 represent the target or targets that will be built. A Node is an
1325 internal SCons object which represents build targets or sources.
1326
1327 The returned Node-list object can be passed to other builder methods as
1328 source(s) or passed to any SCons function or method where a filename
1329 would normally be accepted. For example, if it were necessary to add a
1330 specific -D flag when compiling one specific object file:
1331
1332 bar_obj_list = env.StaticObject('bar.c', CPPDEFINES='-DBAR')
1333 env.Program(source = ['foo.c', bar_obj_list, 'main.c'])
1334
1335 Using a Node in this way makes for a more portable build by avoiding
1336 having to specify a platform-specific object suffix when calling the
1337 Program() builder method.
1338
1339 Note that Builder calls will automatically "flatten" the source and
1340 target file lists, so it's all right to have the bar_obj list return by
1341 the StaticObject() call in the middle of the source file list. If you
1342 need to manipulate a list of lists returned by Builders directly using
1343 Python, you can either build the list by hand:
1344
1345 foo = Object('foo.c')
1346 bar = Object('bar.c')
1347 objects = ['begin.o'] + foo + ['middle.o'] + bar + ['end.o']
1348 for object in objects:
1349 print str(object)
1350
1351 Or you can use the Flatten() function supplied by scons to create a
1352 list containing just the Nodes, which may be more convenient:
1353
1354 foo = Object('foo.c')
1355 bar = Object('bar.c')
1356 objects = Flatten(['begin.o', foo, 'middle.o', bar, 'end.o'])
1357 for object in objects:
1358 print str(object)
1359
1360 Note also that because Builder calls return a list-like object, not an
1361 actual Python list, you should not use the Python += operator to append
1362 Builder results to a Python list. Because the list and the object are
1363 different types, Python will not update the original list in place, but
1364 will instead create a new Node-list object containing the concatenation
1365 of the list elements and the Builder results. This will cause problems
1366 for any other Python variables in your SCons configuration that still
1367 hold on to a reference to the original list. Instead, use the Python
1368 .extend() method to make sure the list is updated in-place. Example:
1369
1370 object_files = []
1371
1372 # Do NOT use += as follows:
1373 #
1374 # object_files += Object('bar.c')
1375 #
1376 # It will not update the object_files list in place.
1377 #
1378 # Instead, use the .extend() method:
1379 object_files.extend(Object('bar.c'))
1380
1381
1382 The path name for a Node's file may be used by passing the Node to the
1383 Python-builtin str() function:
1384
1385 bar_obj_list = env.StaticObject('bar.c', CPPDEFINES='-DBAR')
1386 print "The path to bar_obj is:", str(bar_obj_list[0])
1387
1388 Note again that because the Builder call returns a list, we have to
1389 access the first element in the list (bar_obj_list[0]) to get at the
1390 Node that actually represents the object file.
1391
1392 Builder calls support a chdir keyword argument that specifies that the
1393 Builder's action(s) should be executed after changing directory. If
1394 the chdir argument is a string or a directory Node, scons will change
1395 to the specified directory. If the chdir is not a string or Node and
1396 is non-zero, then scons will change to the target file's directory.
1397
1398 # scons will change to the "sub" subdirectory
1399 # before executing the "cp" command.
1400 env.Command('sub/dir/foo.out', 'sub/dir/foo.in',
1401 "cp dir/foo.in dir/foo.out",
1402 chdir='sub')
1403
1404 # Because chdir is not a string, scons will change to the
1405 # target's directory ("sub/dir") before executing the
1406 # "cp" command.
1407 env.Command('sub/dir/foo.out', 'sub/dir/foo.in',
1408 "cp foo.in foo.out",
1409 chdir=1)
1410
1411 Note that scons will not automatically modify its expansion of con‐
1412 struction variables like $TARGET and $SOURCE when using the chdir key‐
1413 word argument--that is, the expanded file names will still be relative
1414 to the top-level SConstruct directory, and consequently incorrect rela‐
1415 tive to the chdir directory. If you use the chdir keyword argument,
1416 you will typically need to supply a different command line using expan‐
1417 sions like ${TARGET.file} and ${SOURCE.file} to use just the filename
1418 portion of the targets and source.
1419
1420 scons provides the following builder methods:
1421
1422
1423
1424 CFile()
1425
1426 env.CFile()
1427 Builds a C source file given a lex (.l) or yacc (.y) input file.
1428 The suffix specified by the $CFILESUFFIX construction variable
1429 (.c by default) is automatically added to the target if it is
1430 not already present. Example:
1431
1432 # builds foo.c
1433 env.CFile(target = 'foo.c', source = 'foo.l')
1434 # builds bar.c
1435 env.CFile(target = 'bar', source = 'bar.y')
1436
1437
1438 Command()
1439
1440 env.Command()
1441 The Command() "Builder" is actually implemented as a function
1442 that looks like a Builder, but actually takes an additional
1443 argument of the action from which the Builder should be made.
1444 See the Command() function description for the calling syntax
1445 and details.
1446
1447
1448 CXXFile()
1449
1450 env.CXXFile()
1451 Builds a C++ source file given a lex (.ll) or yacc (.yy) input
1452 file. The suffix specified by the $CXXFILESUFFIX construction
1453 variable (.cc by default) is automatically added to the target
1454 if it is not already present. Example:
1455
1456 # builds foo.cc
1457 env.CXXFile(target = 'foo.cc', source = 'foo.ll')
1458 # builds bar.cc
1459 env.CXXFile(target = 'bar', source = 'bar.yy')
1460
1461
1462 DVI()
1463
1464 env.DVI()
1465 Builds a .dvi file from a .tex, .ltx or .latex input file. If
1466 the source file suffix is .tex, scons will examine the contents
1467 of the file; if the string ocumentclass or ocumentstyle is
1468 found, the file is assumed to be a LaTeX file and the target is
1469 built by invoking the $LATEXCOM command line; otherwise, the
1470 $TEXCOM command line is used. If the file is a LaTeX file, the
1471 DVI() builder method will also examine the contents of the .aux
1472 file and invoke the $BIBTEX command line if the string bibdata
1473 is found, start $MAKEINDEX to generate an index if a .ind file
1474 is found and will examine the contents .log file and re-run the
1475 $LATEXCOM command if the log file says it is necessary.
1476
1477 The suffix .dvi (hard-coded within TeX itself) is automatically
1478 added to the target if it is not already present. Examples:
1479
1480 # builds from aaa.tex
1481 env.DVI(target = 'aaa.dvi', source = 'aaa.tex')
1482 # builds bbb.dvi
1483 env.DVI(target = 'bbb', source = 'bbb.ltx')
1484 # builds from ccc.latex
1485 env.DVI(target = 'ccc.dvi', source = 'ccc.latex')
1486
1487
1488 Install()
1489
1490 env.Install()
1491 Installs one or more source files or directories in the speci‐
1492 fied target, which must be a directory. The names of the speci‐
1493 fied source files or directories remain the same within the des‐
1494 tination directory.
1495
1496 env.Install('/usr/local/bin', source = ['foo', 'bar'])
1497
1498
1499 InstallAs()
1500
1501 env.InstallAs()
1502 Installs one or more source files or directories to specific
1503 names, allowing changing a file or directory name as part of the
1504 installation. It is an error if the target and source arguments
1505 list different numbers of files or directories.
1506
1507 env.InstallAs(target = '/usr/local/bin/foo',
1508 source = 'foo_debug')
1509 env.InstallAs(target = ['../lib/libfoo.a', '../lib/libbar.a'],
1510 source = ['libFOO.a', 'libBAR.a'])
1511
1512
1513 Jar()
1514
1515 env.Jar()
1516 Builds a Java archive (.jar) file from the specified list of
1517 sources. Any directories in the source list will be searched
1518 for .class files). Any .java files in the source list will be
1519 compiled to .class files by calling the Java() Builder.
1520
1521 If the $JARCHDIR value is set, the jar command will change to
1522 the specified directory using the -C option. If $JARCHDIR is
1523 not set explicitly, &SCons; will use the top of any subdirectory
1524 tree in which Java .class were built by the Java() Builder.
1525
1526 If the contents any of the source files begin with the string
1527 Manifest-Version, the file is assumed to be a manifest and is
1528 passed to the jar command with the m option set.
1529
1530 env.Jar(target = 'foo.jar', source = 'classes')
1531
1532 env.Jar(target = 'bar.jar',
1533 source = ['bar1.java', 'bar2.java'])
1534
1535
1536 Java()
1537
1538 env.Java()
1539 Builds one or more Java class files. The sources may be any
1540 combination of explicit .java files, or directory trees which
1541 will be scanned for .java files.
1542
1543 SCons will parse each source .java file to find the classes
1544 (including inner classes) defined within that file, and from
1545 that figure out the target .class files that will be created.
1546 The class files will be placed underneath the specified target
1547 directory.
1548
1549 SCons will also search each Java file for the Java package name,
1550 which it assumes can be found on a line beginning with the
1551 string package in the first column; the resulting .class files
1552 will be placed in a directory reflecting the specified package
1553 name. For example, the file Foo.java defining a single public
1554 Foo class and containing a package name of sub.dir will generate
1555 a corresponding sub/dir/Foo.class class file.
1556
1557 Examples:
1558
1559 env.Java(target = 'classes', source = 'src')
1560 env.Java(target = 'classes', source = ['src1', 'src2'])
1561 env.Java(target = 'classes', source = ['File1.java', 'File2.java'])
1562
1563 Java source files can use the native encoding for the underlying
1564 OS. Since SCons compiles in simple ASCII mode by default, the
1565 compiler will generate warnings about unmappable characters,
1566 which may lead to errors as the file is processed further. In
1567 this case, the user must specify the LANG environment variable
1568 to tell the compiler what encoding is used. For portibility,
1569 it's best if the encoding is hard-coded so that the compile will
1570 work if it is done on a system with a different encoding.
1571
1572 env = Environment()
1573 env['ENV']['LANG'] = 'en_GB.UTF-8'
1574
1575
1576 JavaH()
1577
1578 env.JavaH()
1579 Builds C header and source files for implementing Java native
1580 methods. The target can be either a directory in which the
1581 header files will be written, or a header file name which will
1582 contain all of the definitions. The source can be the names of
1583 .class files, the names of .java files to be compiled into
1584 .class files by calling the Java() builder method, or the
1585 objects returned from the Java() builder method.
1586
1587 If the construction variable $JAVACLASSDIR is set, either in the
1588 environment or in the call to the JavaH() builder method itself,
1589 then the value of the variable will be stripped from the begin‐
1590 ning of any .class file names.
1591
1592 Examples:
1593
1594 # builds java_native.h
1595 classes = env.Java(target = 'classdir', source = 'src')
1596 env.JavaH(target = 'java_native.h', source = classes)
1597
1598 # builds include/package_foo.h and include/package_bar.h
1599 env.JavaH(target = 'include',
1600 source = ['package/foo.class', 'package/bar.class'])
1601
1602 # builds export/foo.h and export/bar.h
1603 env.JavaH(target = 'export',
1604 source = ['classes/foo.class', 'classes/bar.class'],
1605 JAVACLASSDIR = 'classes')
1606
1607
1608 Library()
1609
1610 env.Library()
1611 A synonym for the StaticLibrary() builder method.
1612
1613
1614 LoadableModule()
1615
1616 env.LoadableModule()
1617 On most systems, this is the same as SharedLibrary(). On Mac OS
1618 X (Darwin) platforms, this creates a loadable module bundle.
1619
1620
1621 M4()
1622
1623 env.M4()
1624 Builds an output file from an M4 input file. This uses a
1625 default $M4FLAGS value of -E, which considers all warnings to be
1626 fatal and stops on the first warning when using the GNU version
1627 of m4. Example:
1628
1629 env.M4(target = 'foo.c', source = 'foo.c.m4')
1630
1631
1632 Moc()
1633
1634 env.Moc()
1635 Builds an output file from a moc input file. Moc input files are
1636 either header files or cxx files. This builder is only available
1637 after using the tool 'qt'. See the $QTDIR variable for more
1638 information. Example:
1639
1640 env.Moc('foo.h') # generates moc_foo.cc
1641 env.Moc('foo.cpp') # generates foo.moc
1642
1643
1644 MSVSProject()
1645
1646 env.MSVSProject()
1647 Builds a Microsoft Visual Studio project file, and by default
1648 builds a solution file as well.
1649
1650 This builds a Visual Studio project file, based on the version
1651 of Visual Studio that is configured (either the latest installed
1652 version, or the version specified by $MSVS_VERSION in the Envi‐
1653 ronment constructor). For Visual Studio 6, it will generate a
1654 .dsp file. For Visual Studio 7 (.NET) and later versions, it
1655 will generate a .vcproj file.
1656
1657 By default, this also generates a solution file for the speci‐
1658 fied project, a .dsw file for Visual Studio 6 or a .sln file for
1659 Visual Studio 7 (.NET). This behavior may be disabled by speci‐
1660 fying auto_build_solution=0 when you call MSVSProject(), in
1661 which case you presumably want to build the solution file(s) by
1662 calling the MSVSSolution() Builder (see below).
1663
1664 The MSVSProject() builder takes several lists of filenames to be
1665 placed into the project file. These are currently limited to
1666 srcs, incs, localincs, resources, and misc. These are pretty
1667 self-explanatory, but it should be noted that these lists are
1668 added to the $SOURCES construction variable as strings, NOT as
1669 SCons File Nodes. This is because they represent file names to
1670 be added to the project file, not the source files used to build
1671 the project file.
1672
1673 The above filename lists are all optional, although at least one
1674 must be specified for the resulting project file to be non-
1675 empty.
1676
1677 In addition to the above lists of values, the following values
1678 may be specified:
1679
1680 target: The name of the target .dsp or .vcproj file. The cor‐
1681 rect suffix for the version of Visual Studio must be used, but
1682 the $MSVSPROJECTSUFFIX construction variable will be defined to
1683 the correct value (see example below).
1684
1685 variant: The name of this particular variant. For Visual Studio
1686 7 projects, this can also be a list of variant names. These are
1687 typically things like "Debug" or "Release", but really can be
1688 anything you want. For Visual Studio 7 projects, they may also
1689 specify a target platform separated from the variant name by a |
1690 (vertical pipe) character: Debug|Xbox. The default target plat‐
1691 form is Win32. Multiple calls to MSVSProject() with different
1692 variants are allowed; all variants will be added to the project
1693 file with their appropriate build targets and sources.
1694
1695 buildtarget: An optional string, node, or list of strings or
1696 nodes (one per build variant), to tell the Visual Studio debug‐
1697 ger what output target to use in what build variant. The number
1698 of buildtarget entries must match the number of variant entries.
1699
1700 runfile: The name of the file that Visual Studio 7 and later
1701 will run and debug. This appears as the value of the Output
1702 field in the resutling Visual Studio project file. If this is
1703 not specified, the default is the same as the specified build‐
1704 target value.
1705
1706 Note that because &SCons; always executes its build commands
1707 from the directory in which the SConstruct file is located, if
1708 you generate a project file in a different directory than the
1709 SConstruct directory, users will not be able to double-click on
1710 the file name in compilation error messages displayed in the
1711 Visual Studio console output window. This can be remedied by
1712 adding the Visual C/C++ /FC compiler option to the $CCFLAGS
1713 variable so that the compiler will print the full path name of
1714 any files that cause compilation errors.
1715
1716 Example usage:
1717
1718 barsrcs = ['bar.cpp'],
1719 barincs = ['bar.h'],
1720 barlocalincs = ['StdAfx.h']
1721 barresources = ['bar.rc','resource.h']
1722 barmisc = ['bar_readme.txt']
1723
1724 dll = env.SharedLibrary(target = 'bar.dll',
1725 source = barsrcs)
1726
1727 env.MSVSProject(target = 'Bar' + env['MSVSPROJECTSUFFIX'],
1728 srcs = barsrcs,
1729 incs = barincs,
1730 localincs = barlocalincs,
1731 resources = barresources,
1732 misc = barmisc,
1733 buildtarget = dll,
1734 variant = 'Release')
1735
1736
1737 MSVSSolution()
1738
1739 env.MSVSSolution()
1740 Builds a Microsoft Visual Studio solution file.
1741
1742 This builds a Visual Studio solution file, based on the version
1743 of Visual Studio that is configured (either the latest installed
1744 version, or the version specified by $MSVS_VERSION in the con‐
1745 struction environment). For Visual Studio 6, it will generate a
1746 .dsw file. For Visual Studio 7 (.NET), it will generate a .sln
1747 file.
1748
1749 The following values must be specified:
1750
1751 target: The name of the target .dsw or .sln file. The correct
1752 suffix for the version of Visual Studio must be used, but the
1753 value $MSVSSOLUTIONSUFFIX will be defined to the correct value
1754 (see example below).
1755
1756 variant: The name of this particular variant, or a list of vari‐
1757 ant names (the latter is only supported for MSVS 7 solutions).
1758 These are typically things like "Debug" or "Release", but really
1759 can be anything you want. For MSVS 7 they may also specify tar‐
1760 get platform, like this "Debug|Xbox". Default platform is Win32.
1761
1762 projects: A list of project file names, or Project nodes
1763 returned by calls to the MSVSProject() Builder, to be placed
1764 into the solution file. It should be noted that these file
1765 names are NOT added to the $SOURCES environment variable in form
1766 of files, but rather as strings. This is because they repre‐
1767 sent file names to be added to the solution file, not the source
1768 files used to build the solution file.
1769
1770 Example Usage:
1771
1772 env.MSVSSolution(target = 'Bar' + env['MSVSSOLUTIONSUFFIX'],
1773 projects = ['bar' + env['MSVSPROJECTSUFFIX']],
1774 variant = 'Release')
1775
1776
1777 Object()
1778
1779 env.Object()
1780 A synonym for the StaticObject() builder method.
1781
1782
1783 Package()
1784
1785 env.Package()
1786 Builds software distribution packages. Packages consist of
1787 files to install and packaging information. The former may be
1788 specified with the source parameter and may be left out, in
1789 which case the &FindInstalledFiles; function will collect all
1790 files that have an Install() or InstallAs() Builder attached.
1791 If the target is not specified it will be deduced from addi‐
1792 tional information given to this Builder.
1793
1794 The packaging information is specified with the help of con‐
1795 struction variables documented below. This information is
1796 called a tag to stress that some of them can also be attached to
1797 files with the &Tag; function. The mandatory ones will complain
1798 if they were not specified. They vary depending on chosen tar‐
1799 get packager.
1800
1801 The target packager may be selected with the "PACKAGETYPE" com‐
1802 mand line option or with the $PACKAGETYPE construction variable.
1803 Currently the following packagers available:
1804
1805 * msi - Microsoft Installer
1806 * rpm - Redhat Package Manger
1807 * ipkg - Itsy Package Management System
1808 * tarbz2 - compressed tar
1809 * targz - compressed tar
1810 * zip - zip file
1811 * src_tarbz2 - compressed tar source
1812 * src_targz - compressed tar source
1813 * src_zip - zip file source
1814
1815 An updated list is always available under the "package_type"
1816 option when running "scons --help" on a project that has packag‐
1817 ing activated.
1818 env = Environment(tools=['default', 'packaging'])
1819 env.Install('/bin/', 'my_program')
1820 env.Package( NAME = 'foo',
1821 VERSION = '1.2.3',
1822 PACKAGEVERSION = 0,
1823 PACKAGETYPE = 'rpm',
1824 LICENSE = 'gpl',
1825 SUMMARY = 'balalalalal',
1826 DESCRIPTION = 'this should be really really long',
1827 X_RPM_GROUP = 'Application/fu',
1828 SOURCE_URL = 'http://foo.org/foo-1.2.3.tar.gz'
1829 )
1830
1831
1832 PCH()
1833
1834 env.PCH()
1835 Builds a Microsoft Visual C++ precompiled header. Calling this
1836 builder method returns a list of two targets: the PCH as the
1837 first element, and the object file as the second element. Nor‐
1838 mally the object file is ignored. This builder method is only
1839 provided when Microsoft Visual C++ is being used as the com‐
1840 piler. The PCH builder method is generally used in conjuction
1841 with the PCH construction variable to force object files to use
1842 the precompiled header:
1843
1844 env['PCH'] = env.PCH('StdAfx.cpp')[0]
1845
1846
1847 PDF()
1848
1849 env.PDF()
1850 Builds a .pdf file from a .dvi input file (or, by extension, a
1851 .tex, .ltx, or .latex input file). The suffix specified by the
1852 $PDFSUFFIX construction variable (.pdf by default) is added
1853 automatically to the target if it is not already present. Exam‐
1854 ple:
1855
1856 # builds from aaa.tex
1857 env.PDF(target = 'aaa.pdf', source = 'aaa.tex')
1858 # builds bbb.pdf from bbb.dvi
1859 env.PDF(target = 'bbb', source = 'bbb.dvi')
1860
1861
1862 PostScript()
1863
1864 env.PostScript()
1865 Builds a .ps file from a .dvi input file (or, by extension, a
1866 .tex, .ltx, or .latex input file). The suffix specified by the
1867 $PSSUFFIX construction variable (.ps by default) is added auto‐
1868 matically to the target if it is not already present. Example:
1869
1870 # builds from aaa.tex
1871 env.PostScript(target = 'aaa.ps', source = 'aaa.tex')
1872 # builds bbb.ps from bbb.dvi
1873 env.PostScript(target = 'bbb', source = 'bbb.dvi')
1874
1875
1876 Program()
1877
1878 env.Program()
1879 Builds an executable given one or more object files or C, C++,
1880 D, or Fortran source files. If any C, C++, D or Fortran source
1881 files are specified, then they will be automatically compiled to
1882 object files using the Object() builder method; see that builder
1883 method's description for a list of legal source file suffixes
1884 and how they are interpreted. The target executable file prefix
1885 (specified by the $PROGPREFIX construction variable; nothing by
1886 default) and suffix (specified by the $PROGSUFFIX construction
1887 variable; by default, .exe on Windows systems, nothing on POSIX
1888 systems) are automatically added to the target if not already
1889 present. Example:
1890
1891 env.Program(target = 'foo', source = ['foo.o', 'bar.c', 'baz.f'])
1892
1893
1894 RES()
1895
1896 env.RES()
1897 Builds a Microsoft Visual C++ resource file. This builder
1898 method is only provided when Microsoft Visual C++ or MinGW is
1899 being used as the compiler. The .res (or .o for MinGW) suffix is
1900 added to the target name if no other suffix is given. The
1901 source file is scanned for implicit dependencies as though it
1902 were a C file. Example:
1903
1904 env.RES('resource.rc')
1905
1906
1907 RMIC()
1908
1909 env.RMIC()
1910 Builds stub and skeleton class files for remote objects from
1911 Java .class files. The target is a directory relative to which
1912 the stub and skeleton class files will be written. The source
1913 can be the names of .class files, or the objects return from the
1914 Java() builder method.
1915
1916 If the construction variable $JAVACLASSDIR is set, either in the
1917 environment or in the call to the RMIC() builder method itself,
1918 then the value of the variable will be stripped from the begin‐
1919 ning of any .class file names.
1920
1921 classes = env.Java(target = 'classdir', source = 'src')
1922 env.RMIC(target = 'outdir1', source = classes)
1923
1924 env.RMIC(target = 'outdir2',
1925 source = ['package/foo.class', 'package/bar.class'])
1926
1927 env.RMIC(target = 'outdir3',
1928 source = ['classes/foo.class', 'classes/bar.class'],
1929 JAVACLASSDIR = 'classes')
1930
1931
1932 RPCGenClient()
1933
1934 env.RPCGenClient()
1935 Generates an RPC client stub (_clnt.c) file from a specified RPC
1936 (.x) source file. Because rpcgen only builds output files in
1937 the local directory, the command will be executed in the source
1938 file's directory by default.
1939
1940 # Builds src/rpcif_clnt.c
1941 env.RPCGenClient('src/rpcif.x')
1942
1943
1944 RPCGenHeader()
1945
1946 env.RPCGenHeader()
1947 Generates an RPC header (.h) file from a specified RPC (.x)
1948 source file. Because rpcgen only builds output files in the
1949 local directory, the command will be executed in the source
1950 file's directory by default.
1951
1952 # Builds src/rpcif.h
1953 env.RPCGenHeader('src/rpcif.x')
1954
1955
1956 RPCGenService()
1957
1958 env.RPCGenService()
1959 Generates an RPC server-skeleton (_svc.c) file from a specified
1960 RPC (.x) source file. Because rpcgen only builds output files
1961 in the local directory, the command will be executed in the
1962 source file's directory by default.
1963
1964 # Builds src/rpcif_svc.c
1965 env.RPCGenClient('src/rpcif.x')
1966
1967
1968 RPCGenXDR()
1969
1970 env.RPCGenXDR()
1971 Generates an RPC XDR routine (_xdr.c) file from a specified RPC
1972 (.x) source file. Because rpcgen only builds output files in
1973 the local directory, the command will be executed in the source
1974 file's directory by default.
1975
1976 # Builds src/rpcif_xdr.c
1977 env.RPCGenClient('src/rpcif.x')
1978
1979
1980 SharedLibrary()
1981
1982 env.SharedLibrary()
1983 Builds a shared library (.so on a POSIX system, .dll on Windows)
1984 given one or more object files or C, C++, D or Fortran source
1985 files. If any source files are given, then they will be auto‐
1986 matically compiled to object files. The static library prefix
1987 and suffix (if any) are automatically added to the target. The
1988 target library file prefix (specified by the $SHLIBPREFIX con‐
1989 struction variable; by default, lib on POSIX systems, nothing on
1990 Windows systems) and suffix (specified by the $SHLIBSUFFIX con‐
1991 struction variable; by default, .dll on Windows systems, .so on
1992 POSIX systems) are automatically added to the target if not
1993 already present. Example:
1994
1995 env.SharedLibrary(target = 'bar', source = ['bar.c', 'foo.o'])
1996
1997 On Windows systems, the SharedLibrary() builder method will
1998 always build an import (.lib) library in addition to the shared
1999 (.dll) library, adding a .lib library with the same basename if
2000 there is not already a .lib file explicitly listed in the tar‐
2001 gets.
2002
2003 Any object files listed in the source must have been built for a
2004 shared library (that is, using the SharedObject() builder
2005 method). scons will raise an error if there is any mismatch.
2006
2007 On some platforms, there is a distinction between a shared
2008 library (loaded automatically by the system to resolve external
2009 references) and a loadable module (explicitly loaded by user
2010 action). For maximum portability, use the LoadableModule()
2011 builder for the latter.
2012
2013 On Windows systems, specifying register=1 will cause the .dll to
2014 be registered after it is built using REGSVR32. The command
2015 that is run ("regsvr32" by default) is determined by $REGSVR
2016 construction variable, and the flags passed are determined by
2017 $REGSVRFLAGS. By default, $REGSVRFLAGS includes the /s option,
2018 to prevent dialogs from popping up and requiring user attention
2019 when it is run. If you change $REGSVRFLAGS, be sure to include
2020 the /s option. For example,
2021
2022 env.SharedLibrary(target = 'bar',
2023 source = ['bar.cxx', 'foo.obj'],
2024 register=1)
2025
2026 will register bar.dll as a COM object when it is done linking
2027 it.
2028
2029
2030 SharedObject()
2031
2032 env.SharedObject()
2033 Builds an object file for inclusion in a shared library. Source
2034 files must have one of the same set of extensions specified
2035 above for the StaticObject() builder method. On some platforms
2036 building a shared object requires additional compiler option
2037 (e.g. -fPIC for gcc) in addition to those needed to build a nor‐
2038 mal (static) object, but on some platforms there is no differ‐
2039 ence between a shared object and a normal (static) one. When
2040 there is a difference, SCons will only allow shared objects to
2041 be linked into a shared library, and will use a different suffix
2042 for shared objects. On platforms where there is no difference,
2043 SCons will allow both normal (static) and shared objects to be
2044 linked into a shared library, and will use the same suffix for
2045 shared and normal (static) objects. The target object file pre‐
2046 fix (specified by the $SHOBJPREFIX construction variable; by
2047 default, the same as $OBJPREFIX) and suffix (specified by the
2048 $SHOBJSUFFIX construction variable) are automatically added to
2049 the target if not already present. Examples:
2050
2051 env.SharedObject(target = 'ddd', source = 'ddd.c')
2052 env.SharedObject(target = 'eee.o', source = 'eee.cpp')
2053 env.SharedObject(target = 'fff.obj', source = 'fff.for')
2054
2055 Note that the source files will be scanned according to the suf‐
2056 fix mappings in the SourceFileScanner object. See the section
2057 "Scanner Objects," below, for more information.
2058
2059
2060 StaticLibrary()
2061
2062 env.StaticLibrary()
2063 Builds a static library given one or more object files or C,
2064 C++, D or Fortran source files. If any source files are given,
2065 then they will be automatically compiled to object files. The
2066 static library prefix and suffix (if any) are automatically
2067 added to the target. The target library file prefix (specified
2068 by the $LIBPREFIX construction variable; by default, lib on
2069 POSIX systems, nothing on Windows systems) and suffix (specified
2070 by the $LIBSUFFIX construction variable; by default, .lib on
2071 Windows systems, .a on POSIX systems) are automatically added to
2072 the target if not already present. Example:
2073
2074 env.StaticLibrary(target = 'bar', source = ['bar.c', 'foo.o'])
2075
2076 Any object files listed in the source must have been built for a
2077 static library (that is, using the StaticObject() builder
2078 method). scons will raise an error if there is any mismatch.
2079
2080
2081 StaticObject()
2082
2083 env.StaticObject()
2084 Builds a static object file from one or more C, C++, D, or For‐
2085 tran source files. Source files must have one of the following
2086 extensions:
2087
2088 .asm assembly language file
2089 .ASM assembly language file
2090 .c C file
2091 .C Windows: C file
2092 POSIX: C++ file
2093 .cc C++ file
2094 .cpp C++ file
2095 .cxx C++ file
2096 .cxx C++ file
2097 .c++ C++ file
2098 .C++ C++ file
2099 .d D file
2100 .f Fortran file
2101 .F Windows: Fortran file
2102 POSIX: Fortran file + C pre-processor
2103 .for Fortran file
2104 .FOR Fortran file
2105 .fpp Fortran file + C pre-processor
2106 .FPP Fortran file + C pre-processor
2107 .m Object C file
2108 .mm Object C++ file
2109 .s assembly language file
2110 .S Windows: assembly language file
2111 ARM: CodeSourcery Sourcery Lite
2112 .sx assembly language file + C pre-processor
2113 POSIX: assembly language file + C pre-processor
2114 .spp assembly language file + C pre-processor
2115 .SPP assembly language file + C pre-processor
2116
2117 The target object file prefix (specified by the $OBJPREFIX con‐
2118 struction variable; nothing by default) and suffix (specified by
2119 the $OBJSUFFIX construction variable; .obj on Windows systems,
2120 .o on POSIX systems) are automatically added to the target if
2121 not already present. Examples:
2122
2123 env.StaticObject(target = 'aaa', source = 'aaa.c')
2124 env.StaticObject(target = 'bbb.o', source = 'bbb.c++')
2125 env.StaticObject(target = 'ccc.obj', source = 'ccc.f')
2126
2127 Note that the source files will be scanned according to the suf‐
2128 fix mappings in SourceFileScanner object. See the section
2129 "Scanner Objects," below, for more information.
2130
2131
2132 Substfile()
2133
2134 env.Substfile()
2135 The Substfile() builder generates a single text file by concate‐
2136 nating the source files. Nested lists of sources are flattened.
2137 $LINESEPARATOR is used to separate the source files; see the
2138 description of Textfile() for details.
2139
2140 If a single source file is present with an .in suffix, the suf‐
2141 fix is stripped and the remainder is used as the default target
2142 name.
2143
2144 The prefix and suffix specified by the $SUBSTFILEPREFIX and
2145 $SUBSTFILESUFFIX construction variables (the null string by
2146 default in both cases) are automatically added to the target if
2147 they are not already present.
2148
2149 If a construction variable named $SUBST_DICT is present, it may
2150 be either a Python dictionary or a sequence of (key,value)
2151 tuples. If the former, the dictionary is converted into a list
2152 of tuples in an arbitrary order, so if one key is a prefix of
2153 another key or if one substitution could be further expanded by
2154 another subsitition, it is unpredictible whether the expansion
2155 will occur.
2156
2157 Any occurences in the source of a key are replaced by the corre‐
2158 sponding value, which may be a Python callable function or a
2159 string. If a value is a function, it is first called (with no
2160 arguments) to produce a string. The string is subst-expanded
2161 and the result replaces the key.
2162
2163 env = Environment(tools = ['default', 'textfile'])
2164
2165 env['prefix'] = '/usr/bin'
2166 script_dict = {'@prefix@': '/bin', @exec_prefix@: '$prefix'}
2167 env.Substfile('script.in', SUBST_DICT = script_dict)
2168
2169 conf_dict = {'%VERSION%': '1.2.3', '%BASE%': 'MyProg'}
2170 env.Substfile('config.h.in', conf_dict, SUBST_DICT = conf_dict)
2171
2172 # UNPREDICTABLE - one key is a prefix of another
2173 bad_foo = {'$foo': '$foo', '$foobar': '$foobar'}
2174 env.Substfile('foo.in', SUBST_DICT = bad_foo)
2175
2176 # PREDICTABLE - keys are applied longest first
2177 good_foo = [('$foobar', '$foobar'), ('$foo', '$foo')]
2178 env.Substfile('foo.in', SUBST_DICT = good_foo)
2179
2180 # UNPREDICTABLE - one substitution could be futher expanded
2181 bad_bar = {'@bar@': '@soap@', '@soap@': 'lye'}
2182 env.Substfile('bar.in', SUBST_DICT = bad_bar)
2183
2184 # PREDICTABLE - substitutions are expanded in order
2185 good_bar = (('@bar@', '@soap@'), ('@soap@', 'lye'))
2186 env.Substfile('bar.in', SUBST_DICT = good_bar)
2187
2188 # the SUBST_DICT may be in common (and not an override)
2189 substutions = {}
2190 subst = Environment(tools = ['textfile', SUBST_DICT = substitutions)
2191 substitutions['@foo@'] = 'foo'
2192 subst['SUBST_DICT']['@bar@'] = 'bar'
2193 subst.Substfile('pgm1.c', [Value('#include "@foo@.h"'),
2194 Value('#include "@bar@.h"'),
2195 "common.in",
2196 "pgm1.in"
2197 ])
2198 subst.Substfile('pgm2.c', [Value('#include "@foo@.h"'),
2199 Value('#include "@bar@.h"'),
2200 "common.in",
2201 "pgm2.in"
2202 ])
2203
2204
2205
2206 Tar()
2207
2208 env.Tar()
2209 Builds a tar archive of the specified files and/or directories.
2210 Unlike most builder methods, the Tar() builder method may be
2211 called multiple times for a given target; each additional call
2212 adds to the list of entries that will be built into the archive.
2213 Any source directories will be scanned for changes to any on-
2214 disk files, regardless of whether or not scons knows about them
2215 from other Builder or function calls.
2216
2217 env.Tar('src.tar', 'src')
2218
2219 # Create the stuff.tar file.
2220 env.Tar('stuff', ['subdir1', 'subdir2'])
2221 # Also add "another" to the stuff.tar file.
2222 env.Tar('stuff', 'another')
2223
2224 # Set TARFLAGS to create a gzip-filtered archive.
2225 env = Environment(TARFLAGS = '-c -z')
2226 env.Tar('foo.tar.gz', 'foo')
2227
2228 # Also set the suffix to .tgz.
2229 env = Environment(TARFLAGS = '-c -z',
2230 TARSUFFIX = '.tgz')
2231 env.Tar('foo')
2232
2233
2234 Textfile()
2235
2236 env.Textfile()
2237 The Textfile() builder generates a single text file. The source
2238 strings constitute the lines; nested lists of sources are flat‐
2239 tened. $LINESEPARATOR is used to separate the strings.
2240
2241 If present, the $SUBST_DICT construction variable is used to
2242 modify the strings before they are written; see the Substfile()
2243 description for details.
2244
2245 The prefix and suffix specified by the $TEXTFILEPREFIX and
2246 $TEXTFILESUFFIX construction variables (the null string and .txt
2247 by default, respectively) are automatically added to the target
2248 if they are not already present. Examples:
2249
2250 # builds/writes foo.txt
2251 env.Textfile(target = 'foo.txt', source = ['Goethe', 42, 'Schiller'])
2252
2253 # builds/writes bar.txt
2254 env.Textfile(target = 'bar',
2255 source = ['lalala', 'tanteratei'],
2256 LINESEPARATOR='|*')
2257
2258 # nested lists are flattened automatically
2259 env.Textfile(target = 'blob',
2260 source = ['lalala', ['Goethe', 42 'Schiller'], 'tanteratei'])
2261
2262 # files may be used as input by wraping them in File()
2263 env.Textfile(target = 'concat', # concatenate files with a marker between
2264 source = [File('concat1'), File('concat2')],
2265 LINESEPARATOR = '====================\n')
2266
2267 Results are:
2268 foo.txt
2269 ....8<----
2270 Goethe
2271 42
2272 Schiller
2273 ....8<---- (no linefeed at the end)
2274
2275 bar.txt:
2276 ....8<----
2277 lalala|*tanteratei
2278 ....8<---- (no linefeed at the end)
2279
2280 blob.txt
2281 ....8<----
2282 lalala
2283 Goethe
2284 42
2285 Schiller
2286 tanteratei
2287 ....8<---- (no linefeed at the end)
2288
2289
2290 TypeLibrary()
2291
2292 env.TypeLibrary()
2293 Builds a Windows type library (.tlb) file from an input IDL file
2294 (.idl). In addition, it will build the associated inteface stub
2295 and proxy source files, naming them according to the base name
2296 of the .idl file. For example,
2297
2298 env.TypeLibrary(source="foo.idl")
2299
2300 Will create foo.tlb, foo.h, foo_i.c, foo_p.c and foo_data.c
2301 files.
2302
2303
2304 Uic()
2305
2306 env.Uic()
2307 Builds a header file, an implementation file and a moc file from
2308 an ui file. and returns the corresponding nodes in the above
2309 order. This builder is only available after using the tool
2310 'qt'. Note: you can specify .ui files directly as source files
2311 to the Program(), Library() and SharedLibrary() builders without
2312 using this builder. Using this builder lets you override the
2313 standard naming conventions (be careful: prefixes are always
2314 prepended to names of built files; if you don't want prefixes,
2315 you may set them to ``). See the $QTDIR variable for more
2316 information. Example:
2317
2318 env.Uic('foo.ui') # -> ['foo.h', 'uic_foo.cc', 'moc_foo.cc']
2319 env.Uic(target = Split('include/foo.h gen/uicfoo.cc gen/mocfoo.cc'),
2320 source = 'foo.ui') # -> ['include/foo.h', 'gen/uicfoo.cc', 'gen/mocfoo.cc']
2321
2322
2323 Zip()
2324
2325 env.Zip()
2326 Builds a zip archive of the specified files and/or directories.
2327 Unlike most builder methods, the Zip() builder method may be
2328 called multiple times for a given target; each additional call
2329 adds to the list of entries that will be built into the archive.
2330 Any source directories will be scanned for changes to any on-
2331 disk files, regardless of whether or not scons knows about them
2332 from other Builder or function calls.
2333
2334 env.Zip('src.zip', 'src')
2335
2336 # Create the stuff.zip file.
2337 env.Zip('stuff', ['subdir1', 'subdir2'])
2338 # Also add "another" to the stuff.tar file.
2339 env.Zip('stuff', 'another')
2340
2341
2342 All targets of builder methods automatically depend on their sources.
2343 An explicit dependency can be specified using the Depends method of a
2344 construction environment (see below).
2345
2346 In addition, scons automatically scans source files for various pro‐
2347 gramming languages, so the dependencies do not need to be specified
2348 explicitly. By default, SCons can C source files, C++ source files,
2349 Fortran source files with .F (POSIX systems only), .fpp, or .FPP file
2350 extensions, and assembly language files with .S (POSIX systems only),
2351 .spp, or .SPP files extensions for C preprocessor dependencies. SCons
2352 also has default support for scanning D source files, You can also
2353 write your own Scanners to add support for additional source file
2354 types. These can be added to the default Scanner object used by the
2355 Object(), StaticObject(), and SharedObject() Builders by adding them to
2356 the SourceFileScanner object. See the section "Scanner Objects" below,
2357 for more information about defining your own Scanner objects and using
2358 the SourceFileScanner object.
2359
2360
2361 Methods and Functions to Do Things
2362 In addition to Builder methods, scons provides a number of other con‐
2363 struction environment methods and global functions to manipulate the
2364 build configuration.
2365
2366 Usually, a construction environment method and global function with the
2367 same name both exist so that you don't have to remember whether to a
2368 specific bit of functionality must be called with or without a con‐
2369 struction environment. In the following list, if you call something as
2370 a global function it looks like:
2371 Function(arguments)
2372 and if you call something through a construction environment it looks
2373 like:
2374 env.Function(arguments)
2375 If you can call the functionality in both ways, then both forms are
2376 listed.
2377
2378 Global functions may be called from custom Python modules that you
2379 import into an SConscript file by adding the following to the Python
2380 module:
2381
2382 from SCons.Script import *
2383
2384 Except where otherwise noted, the same-named construction environment
2385 method and global function provide the exact same functionality. The
2386 only difference is that, where appropriate, calling the functionality
2387 through a construction environment will substitute construction vari‐
2388 ables into any supplied strings. For example:
2389
2390 env = Environment(FOO = 'foo')
2391 Default('$FOO')
2392 env.Default('$FOO')
2393
2394 In the above example, the first call to the global Default() function
2395 will actually add a target named $FOO to the list of default targets,
2396 while the second call to the env.Default() construction environment
2397 method will expand the value and add a target named foo to the list of
2398 default targets. For more on construction variable expansion, see the
2399 next section on construction variables.
2400
2401 Construction environment methods and global functions supported by
2402 scons include:
2403
2404
2405
2406 Action(action, [cmd/str/fun, [var, ...]] [option=value, ...])
2407
2408 env.Action(action, [cmd/str/fun, [var, ...]] [option=value, ...])
2409 Creates an Action object for the specified action. See the sec‐
2410 tion "Action Objects," below, for a complete explanation of the
2411 arguments and behavior.
2412
2413 Note that the env.Action() form of the invocation will expand
2414 construction variables in any argument strings, including the
2415 action argument, at the time it is called using the construction
2416 variables in the env construction environment through which
2417 env.Action() was called. The Action() form delays all variable
2418 expansion until the Action object is actually used.
2419
2420
2421 AddMethod(object, function, [name])
2422
2423 env.AddMethod(function, [name])
2424 When called with the AddMethod() form, adds the specified func‐
2425 tion to the specified object as the specified method name. When
2426 called with the env.AddMethod() form, adds the specified func‐
2427 tion to the construction environment env as the specified method
2428 name. In both cases, if name is omitted or None, the name of
2429 the specified function itself is used for the method name.
2430
2431 Examples:
2432
2433 # Note that the first argument to the function to
2434 # be attached as a method must be the object through
2435 # which the method will be called; the Python
2436 # convention is to call it 'self'.
2437 def my_method(self, arg):
2438 print "my_method() got", arg
2439
2440 # Use the global AddMethod() function to add a method
2441 # to the Environment class. This
2442 AddMethod(Environment, my_method)
2443 env = Environment()
2444 env.my_method('arg')
2445
2446 # Add the function as a method, using the function
2447 # name for the method call.
2448 env = Environment()
2449 env.AddMethod(my_method, 'other_method_name')
2450 env.other_method_name('another arg')
2451
2452
2453 AddOption(arguments)
2454 This function adds a new command-line option to be recognized.
2455 The specified arguments are the same as supported by the stan‐
2456 dard Python optparse.add_option() method (with a few additional
2457 capabilities noted below); see the documentation for optparse
2458 for a thorough discussion of its option-processing capabities.
2459
2460 In addition to the arguments and values supported by the opt‐
2461 parse.add_option() method, the SCons AddOption() function allows
2462 you to set the nargs keyword value to '?' (a string with just
2463 the question mark) to indicate that the specified long option(s)
2464 take(s) an optional argument. When nargs = '?' is passed to
2465 the AddOption() function, the const keyword argument may be used
2466 to supply the "default" value that should be used when the
2467 option is specified on the command line without an explicit
2468 argument.
2469
2470 If no default= keyword argument is supplied when calling AddOp‐
2471 tion(), the option will have a default value of None.
2472
2473 Once a new command-line option has been added with AddOption(),
2474 the option value may be accessed using GetOption() or env.GetOp‐
2475 tion(). The value may also be set, using SetOption() or
2476 env.SetOption(), if conditions in a SConscript require overrid‐
2477 ing any default value. Note, however, that a value specified on
2478 the command line will always override a value set by any SCon‐
2479 script file.
2480
2481 Any specified help= strings for the new option(s) will be dis‐
2482 played by the -H or -h options (the latter only if no other help
2483 text is specified in the SConscript files). The help text for
2484 the local options specified by AddOption() will appear below the
2485 SCons options themselves, under a separate Local Options head‐
2486 ing. The options will appear in the help text in the order in
2487 which the AddOption() calls occur.
2488
2489 Example:
2490
2491 AddOption('--prefix',
2492 dest='prefix',
2493 nargs=1, type='string',
2494 action='store',
2495 metavar='DIR',
2496 help='installation prefix')
2497 env = Environment(PREFIX = GetOption('prefix'))
2498
2499
2500 AddPostAction(target, action)
2501
2502 env.AddPostAction(target, action)
2503 Arranges for the specified action to be performed after the
2504 specified target has been built. The specified action(s) may be
2505 an Action object, or anything that can be converted into an
2506 Action object (see below).
2507
2508 When multiple targets are supplied, the action may be called
2509 multiple times, once after each action that generates one or
2510 more targets in the list.
2511
2512
2513 AddPreAction(target, action)
2514
2515 env.AddPreAction(target, action)
2516 Arranges for the specified action to be performed before the
2517 specified target is built. The specified action(s) may be an
2518 Action object, or anything that can be converted into an Action
2519 object (see below).
2520
2521 When multiple targets are specified, the action(s) may be called
2522 multiple times, once before each action that generates one or
2523 more targets in the list.
2524
2525 Note that if any of the targets are built in multiple steps, the
2526 action will be invoked just before the "final" action that
2527 specifically generates the specified target(s). For example,
2528 when building an executable program from a specified source .c
2529 file via an intermediate object file:
2530
2531 foo = Program('foo.c')
2532 AddPreAction(foo, 'pre_action')
2533
2534 The specified pre_action would be executed before scons calls
2535 the link command that actually generates the executable program
2536 binary foo, not before compiling the foo.c file into an object
2537 file.
2538
2539
2540 Alias(alias, [targets, [action]])
2541
2542 env.Alias(alias, [targets, [action]])
2543 Creates one or more phony targets that expand to one or more
2544 other targets. An optional action (command) or list of actions
2545 can be specified that will be executed whenever the any of the
2546 alias targets are out-of-date. Returns the Node object repre‐
2547 senting the alias, which exists outside of any file system.
2548 This Node object, or the alias name, may be used as a dependency
2549 of any other target, including another alias. Alias() can be
2550 called multiple times for the same alias to add additional tar‐
2551 gets to the alias, or additional actions to the list for this
2552 alias.
2553
2554 Examples:
2555
2556 Alias('install')
2557 Alias('install', '/usr/bin')
2558 Alias(['install', 'install-lib'], '/usr/local/lib')
2559
2560 env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
2561 env.Alias('install', ['/usr/local/man'])
2562
2563 env.Alias('update', ['file1', 'file2'], "update_database $SOURCES")
2564
2565
2566 AllowSubstExceptions([exception, ...])
2567 Specifies the exceptions that will be allowed when expanding
2568 construction variables. By default, any construction variable
2569 expansions that generate a NameError or IndexError exception
2570 will expand to a '' (a null string) and not cause scons to fail.
2571 All exceptions not in the specified list will generate an error
2572 message and terminate processing.
2573
2574 If AllowSubstExceptions() is called multiple times, each call
2575 completely overwrites the previous list of allowed exceptions.
2576
2577 Example:
2578
2579 # Requires that all construction variable names exist.
2580 # (You may wish to do this if you want to enforce strictly
2581 # that all construction variables must be defined before use.)
2582 AllowSubstExceptions()
2583
2584 # Also allow a string containing a zero-division expansion
2585 # like '${1 / 0}' to evalute to ''.
2586 AllowSubstExceptions(IndexError, NameError, ZeroDivisionError)
2587
2588
2589 AlwaysBuild(target, ...)
2590
2591 env.AlwaysBuild(target, ...)
2592 Marks each given target so that it is always assumed to be out
2593 of date, and will always be rebuilt if needed. Note, however,
2594 that AlwaysBuild() does not add its target(s) to the default
2595 target list, so the targets will only be built if they are spec‐
2596 ified on the command line, or are a dependent of a target speci‐
2597 fied on the command line--but they will always be built if so
2598 specified. Multiple targets can be passed in to a single call
2599 to AlwaysBuild().
2600
2601
2602 env.Append(key=val, [...])
2603 Appends the specified keyword arguments to the end of construc‐
2604 tion variables in the environment. If the Environment does not
2605 have the specified construction variable, it is simply added to
2606 the environment. If the values of the construction variable and
2607 the keyword argument are the same type, then the two values will
2608 be simply added together. Otherwise, the construction variable
2609 and the value of the keyword argument are both coerced to lists,
2610 and the lists are added together. (See also the Prepend method,
2611 below.)
2612
2613 Example:
2614
2615 env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
2616
2617
2618 env.AppendENVPath(name, newpath, [envname, sep, delete_existing])
2619 This appends new path elements to the given path in the speci‐
2620 fied external environment (ENV by default). This will only add
2621 any particular path once (leaving the last one it encounters and
2622 ignoring the rest, to preserve path order), and to help assure
2623 this, will normalize all paths (using os.path.normpath and
2624 os.path.normcase). This can also handle the case where the
2625 given old path variable is a list instead of a string, in which
2626 case a list will be returned instead of a string.
2627
2628 If delete_existing is 0, then adding a path that already exists
2629 will not move it to the end; it will stay where it is in the
2630 list.
2631
2632 Example:
2633
2634 print 'before:',env['ENV']['INCLUDE']
2635 include_path = '/foo/bar:/foo'
2636 env.AppendENVPath('INCLUDE', include_path)
2637 print 'after:',env['ENV']['INCLUDE']
2638
2639 yields:
2640 before: /foo:/biz
2641 after: /biz:/foo/bar:/foo
2642
2643
2644 env.AppendUnique(key=val, [...], delete_existing=0)
2645 Appends the specified keyword arguments to the end of construc‐
2646 tion variables in the environment. If the Environment does not
2647 have the specified construction variable, it is simply added to
2648 the environment. If the construction variable being appended to
2649 is a list, then any value(s) that already exist in the construc‐
2650 tion variable will not be added again to the list. However, if
2651 delete_existing is 1, existing matching values are removed
2652 first, so existing values in the arg list move to the end of the
2653 list.
2654
2655 Example:
2656
2657 env.AppendUnique(CCFLAGS = '-g', FOO = ['foo.yyy'])
2658
2659
2660 env.BitKeeper()
2661 A factory function that returns a Builder object to be used to
2662 fetch source files using BitKeeper. The returned Builder is
2663 intended to be passed to the SourceCode() function.
2664
2665 This function is deprecated. For details, see the entry for the
2666 SourceCode() function.
2667
2668 Example:
2669
2670 env.SourceCode('.', env.BitKeeper())
2671
2672
2673 BuildDir(build_dir, src_dir, [duplicate])
2674
2675 env.BuildDir(build_dir, src_dir, [duplicate])
2676 Deprecated synonyms for VariantDir() and env.VariantDir(). The
2677 build_dir argument becomes the variant_dir argument of Variant‐
2678 Dir() or env.VariantDir().
2679
2680
2681 Builder(action, [arguments])
2682
2683 env.Builder(action, [arguments])
2684 Creates a Builder object for the specified action. See the sec‐
2685 tion "Builder Objects," below, for a complete explanation of the
2686 arguments and behavior.
2687
2688 Note that the env.Builder() form of the invocation will expand
2689 construction variables in any arguments strings, including the
2690 action argument, at the time it is called using the construction
2691 variables in the env construction environment through which
2692 env.Builder() was called. The Builder() form delays all vari‐
2693 able expansion until after the Builder object is actually
2694 called.
2695
2696
2697 CacheDir(cache_dir)
2698
2699 env.CacheDir(cache_dir)
2700 Specifies that scons will maintain a cache of derived files in
2701 cache_dir. The derived files in the cache will be shared among
2702 all the builds using the same CacheDir() call. Specifying a
2703 cache_dir of None disables derived file caching.
2704
2705 Calling env.CacheDir() will only affect targets built through
2706 the specified construction environment. Calling CacheDir() sets
2707 a global default that will be used by all targets built through
2708 construction environments that do not have an env.CacheDir()
2709 specified.
2710
2711 When a CacheDir() is being used and scons finds a derived file
2712 that needs to be rebuilt, it will first look in the cache to see
2713 if a derived file has already been built from identical input
2714 files and an identical build action (as incorporated into the
2715 MD5 build signature). If so, scons will retrieve the file from
2716 the cache. If the derived file is not present in the cache,
2717 scons will rebuild it and then place a copy of the built file in
2718 the cache (identified by its MD5 build signature), so that it
2719 may be retrieved by other builds that need to build the same
2720 derived file from identical inputs.
2721
2722 Use of a specified CacheDir() may be disabled for any invocation
2723 by using the --cache-disable option.
2724
2725 If the --cache-force option is used, scons will place a copy of
2726 all derived files in the cache, even if they already existed and
2727 were not built by this invocation. This is useful to populate a
2728 cache the first time CacheDir() is added to a build, or after
2729 using the --cache-disable option.
2730
2731 When using CacheDir(), scons will report, "Retrieved `file' from
2732 cache," unless the --cache-show option is being used. When the
2733 --cache-show option is used, scons will print the action that
2734 would have been used to build the file, without any indication
2735 that the file was actually retrieved from the cache. This is
2736 useful to generate build logs that are equivalent regardless of
2737 whether a given derived file has been built in-place or
2738 retrieved from the cache.
2739
2740 The NoCache() method can be used to disable caching of specific
2741 files. This can be useful if inputs and/or outputs of some tool
2742 are impossible to predict or prohibitively large.
2743
2744
2745 Clean(targets, files_or_dirs)
2746
2747 env.Clean(targets, files_or_dirs)
2748 This specifies a list of files or directories which should be
2749 removed whenever the targets are specified with the -c command
2750 line option. The specified targets may be a list or an individ‐
2751 ual target. Multiple calls to Clean() are legal, and create new
2752 targets or add files and directories to the clean list for the
2753 specified targets.
2754
2755 Multiple files or directories should be specified either as sep‐
2756 arate arguments to the Clean() method, or as a list. Clean()
2757 will also accept the return value of any of the construction
2758 environment Builder methods. Examples:
2759
2760 The related NoClean() function overrides calling Clean() for the
2761 same target, and any targets passed to both functions will not
2762 be removed by the -c option.
2763
2764 Examples:
2765
2766 Clean('foo', ['bar', 'baz'])
2767 Clean('dist', env.Program('hello', 'hello.c'))
2768 Clean(['foo', 'bar'], 'something_else_to_clean')
2769
2770 In this example, installing the project creates a subdirectory
2771 for the documentation. This statement causes the subdirectory
2772 to be removed if the project is deinstalled.
2773 Clean(docdir, os.path.join(docdir, projectname))
2774
2775
2776 env.Clone([key=val, ...])
2777 Returns a separate copy of a construction environment. If there
2778 are any keyword arguments specified, they are added to the
2779 returned copy, overwriting any existing values for the keywords.
2780
2781 Example:
2782
2783 env2 = env.Clone()
2784 env3 = env.Clone(CCFLAGS = '-g')
2785
2786 Additionally, a list of tools and a toolpath may be specified,
2787 as in the Environment constructor:
2788
2789 def MyTool(env): env['FOO'] = 'bar'
2790 env4 = env.Clone(tools = ['msvc', MyTool])
2791
2792 The parse_flags keyword argument is also recognized:
2793
2794 # create an environment for compiling programs that use wxWidgets
2795 wx_env = env.Clone(parse_flags = '!wx-config --cflags --cxxflags')
2796
2797
2798 Command(target, source, action, [key=val, ...])
2799
2800 env.Command(target, source, action, [key=val, ...])
2801 Executes a specific action (or list of actions) to build a tar‐
2802 get file or files. This is more convenient than defining a sep‐
2803 arate Builder object for a single special-case build.
2804
2805 As a special case, the source_scanner keyword argument can be
2806 used to specify a Scanner object that will be used to scan the
2807 sources. (The global DirScanner object can be used if any of
2808 the sources will be directories that must be scanned on-disk for
2809 changes to files that aren't already specified in other Builder
2810 of function calls.)
2811
2812 Any other keyword arguments specified override any same-named
2813 existing construction variables.
2814
2815 An action can be an external command, specified as a string, or
2816 a callable Python object; see "Action Objects," below, for more
2817 complete information. Also note that a string specifying an
2818 external command may be preceded by an @ (at-sign) to suppress
2819 printing the command in question, or by a - (hyphen) to ignore
2820 the exit status of the external command.
2821
2822 Examples:
2823
2824 env.Command('foo.out', 'foo.in',
2825 "$FOO_BUILD < $SOURCES > $TARGET")
2826
2827 env.Command('bar.out', 'bar.in',
2828 ["rm -f $TARGET",
2829 "$BAR_BUILD < $SOURCES > $TARGET"],
2830 ENV = {'PATH' : '/usr/local/bin/'})
2831
2832 def rename(env, target, source):
2833 import os
2834 os.rename('.tmp', str(target[0]))
2835
2836 env.Command('baz.out', 'baz.in',
2837 ["$BAZ_BUILD < $SOURCES > .tmp",
2838 rename ])
2839
2840 Note that the Command() function will usually assume, by
2841 default, that the specified targets and/or sources are Files, if
2842 no other part of the configuration identifies what type of entry
2843 it is. If necessary, you can explicitly specify that targets or
2844 source nodes should be treated as directoriese by using the
2845 Dir() or env.Dir() functions.
2846
2847 Examples:
2848
2849 env.Command('ddd.list', Dir('ddd'), 'ls -l $SOURCE > $TARGET')
2850
2851 env['DISTDIR'] = 'destination/directory'
2852 env.Command(env.Dir('$DISTDIR')), None, make_distdir)
2853
2854 (Also note that SCons will usually automatically create any
2855 directory necessary to hold a target file, so you normally don't
2856 need to create directories by hand.)
2857
2858
2859 Configure(env, [custom_tests, conf_dir, log_file, config_h])
2860
2861 env.Configure([custom_tests, conf_dir, log_file, config_h])
2862 Creates a Configure object for integrated functionality similar
2863 to GNU autoconf. See the section "Configure Contexts," below,
2864 for a complete explanation of the arguments and behavior.
2865
2866
2867 env.Copy([key=val, ...])
2868 A now-deprecated synonym for env.Clone().
2869
2870
2871 env.CVS(repository, module)
2872 A factory function that returns a Builder object to be used to
2873 fetch source files from the specified CVS repository. The
2874 returned Builder is intended to be passed to the SourceCode()
2875 function.
2876
2877 This function is deprecated. For details, see the entry for the
2878 SourceCode() function.
2879
2880 The optional specified module will be added to the beginning of
2881 all repository path names; this can be used, in essence, to
2882 strip initial directory names from the repository path names, so
2883 that you only have to replicate part of the repository directory
2884 hierarchy in your local build directory.
2885
2886 Examples:
2887
2888 # Will fetch foo/bar/src.c
2889 # from /usr/local/CVSROOT/foo/bar/src.c.
2890 env.SourceCode('.', env.CVS('/usr/local/CVSROOT'))
2891
2892 # Will fetch bar/src.c
2893 # from /usr/local/CVSROOT/foo/bar/src.c.
2894 env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo'))
2895
2896 # Will fetch src.c
2897 # from /usr/local/CVSROOT/foo/bar/src.c.
2898 env.SourceCode('.', env.CVS('/usr/local/CVSROOT', 'foo/bar'))
2899
2900
2901 Decider(function)
2902
2903 env.Decider(function)
2904 Specifies that all up-to-date decisions for targets built
2905 through this construction environment will be handled by the
2906 specified function. The function can be one of the following
2907 strings that specify the type of decision function to be per‐
2908 formed:
2909
2910
2911 timestamp-newer
2912 Specifies that a target shall be considered out of date
2913 and rebuilt if the dependency's timestamp is newer than
2914 the target file's timestamp. This is the behavior of
2915 the classic Make utility, and make can be used a syn‐
2916 onym for timestamp-newer.
2917
2918 timestamp-match
2919 Specifies that a target shall be considered out of date
2920 and rebuilt if the dependency's timestamp is different
2921 than the timestamp recorded the last time the target
2922 was built. This provides behavior very similar to the
2923 classic Make utility (in particular, files are not
2924 opened up so that their contents can be checksummed)
2925 except that the target will also be rebuilt if a depen‐
2926 dency file has been restored to a version with an ear‐
2927 lier timestamp, such as can happen when restoring files
2928 from backup archives.
2929
2930 MD5 Specifies that a target shall be considered out of date
2931 and rebuilt if the dependency's content has changed
2932 sine the last time the target was built, as determined
2933 be performing an MD5 checksum on the dependency's con‐
2934 tents and comparing it to the checksum recorded the
2935 last time the target was built. content can be used as
2936 a synonym for MD5.
2937
2938 MD5-timestamp
2939 Specifies that a target shall be considered out of date
2940 and rebuilt if the dependency's content has changed
2941 sine the last time the target was built, except that
2942 dependencies with a timestamp that matches the last
2943 time the target was rebuilt will be assumed to be up-
2944 to-date and not rebuilt. This provides behavior very
2945 similar to the MD5 behavior of always checksumming file
2946 contents, with an optimization of not checking the con‐
2947 tents of files whose timestamps haven't changed. The
2948 drawback is that SCons will not detect if a file's con‐
2949 tent has changed but its timestamp is the same, as
2950 might happen in an automated script that runs a build,
2951 updates a file, and runs the build again, all within a
2952 single second.
2953
2954 Examples:
2955
2956 # Use exact timestamp matches by default.
2957 Decider('timestamp-match')
2958
2959 # Use MD5 content signatures for any targets built
2960 # with the attached construction environment.
2961 env.Decider('content')
2962
2963 In addition to the above already-available functions, the func‐
2964 tion argument may be an actual Python function that takes the
2965 following three arguments:
2966
2967
2968 dependency
2969 The Node (file) which should cause the target to be
2970 rebuilt if it has "changed" since the last tme target
2971 was built.
2972
2973 target The Node (file) being built. In the normal case, this
2974 is what should get rebuilt if the dependency has
2975 "changed."
2976
2977 prev_ni
2978 Stored information about the state of the dependency
2979 the last time the target was built. This can be con‐
2980 sulted to match various file characteristics such as
2981 the timestamp, size, or content signature.
2982
2983 The function should return a True (non-zero) value if the dependency
2984 has "changed" since the last time the target was built (indicating that
2985 the target should be rebuilt), and False (zero) otherwise (indicating
2986 that the target should not be rebuilt). Note that the decision can be
2987 made using whatever criteria are appopriate. Ignoring some or all of
2988 the function arguments is perfectly normal.
2989
2990 Example:
2991
2992 def my_decider(dependency, target, prev_ni):
2993 return not os.path.exists(str(target))
2994
2995 env.Decider(my_decider)
2996
2997
2998 Default(targets)
2999
3000 env.Default(targets)
3001 This specifies a list of default targets, which will be built by
3002 scons if no explicit targets are given on the command line.
3003 Multiple calls to Default() are legal, and add to the list of
3004 default targets.
3005
3006 Multiple targets should be specified as separate arguments to
3007 the Default() method, or as a list. Default() will also accept
3008 the Node returned by any of a construction environment's builder
3009 methods.
3010
3011 Examples:
3012
3013 Default('foo', 'bar', 'baz')
3014 env.Default(['a', 'b', 'c'])
3015 hello = env.Program('hello', 'hello.c')
3016 env.Default(hello)
3017
3018 An argument to Default() of None will clear all default targets.
3019 Later calls to Default() will add to the (now empty) default-
3020 target list like normal.
3021
3022 The current list of targets added using the Default() function
3023 or method is available in the DEFAULT_TARGETS list; see below.
3024
3025
3026 DefaultEnvironment([args])
3027 Creates and returns a default construction environment object.
3028 This construction environment is used internally by SCons in
3029 order to execute many of the global functions in this list, and
3030 to fetch source files transparently from source code management
3031 systems.
3032
3033
3034 Depends(target, dependency)
3035
3036 env.Depends(target, dependency)
3037 Specifies an explicit dependency; the target will be rebuilt
3038 whenever the dependency has changed. Both the specified target
3039 and dependency can be a string (usually the path name of a file
3040 or directory) or Node objects, or a list of strings or Node
3041 objects (such as returned by a Builder call). This should only
3042 be necessary for cases where the dependency is not caught by a
3043 Scanner for the file.
3044
3045 Example:
3046
3047 env.Depends('foo', 'other-input-file-for-foo')
3048
3049 mylib = env.Library('mylib.c')
3050 installed_lib = env.Install('lib', mylib)
3051 bar = env.Program('bar.c')
3052
3053 # Arrange for the library to be copied into the installation
3054 # directory before trying to build the "bar" program.
3055 # (Note that this is for example only. A "real" library
3056 # dependency would normally be configured through the $LIBS
3057 # and $LIBPATH variables, not using an env.Depends() call.)
3058
3059 env.Depends(bar, installed_lib)
3060
3061
3062 env.Dictionary([vars])
3063 Returns a dictionary object containing copies of all of the con‐
3064 struction variables in the environment. If there are any vari‐
3065 able names specified, only the specified construction variables
3066 are returned in the dictionary.
3067
3068 Example:
3069
3070 dict = env.Dictionary()
3071 cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
3072
3073
3074 Dir(name, [directory])
3075
3076 env.Dir(name, [directory])
3077 This returns a Directory Node, an object that represents the
3078 specified directory name. name can be a relative or absolute
3079 path. directory is an optional directory that will be used as
3080 the parent directory. If no directory is specified, the current
3081 script's directory is used as the parent.
3082
3083 If name is a list, SCons returns a list of Dir nodes. Construc‐
3084 tion variables are expanded in name.
3085
3086 Directory Nodes can be used anywhere you would supply a string
3087 as a directory name to a Builder method or function. Directory
3088 Nodes have attributes and methods that are useful in many situa‐
3089 tions; see "File and Directory Nodes," below.
3090
3091
3092 env.Dump([key])
3093 Returns a pretty printable representation of the environment.
3094 key, if not None, should be a string containing the name of the
3095 variable of interest.
3096
3097 This SConstruct:
3098
3099 env=Environment()
3100 print env.Dump('CCCOM')
3101
3102 will print:
3103
3104
3105 While this SConstruct:
3106
3107 env=Environment()
3108 print env.Dump()
3109
3110 will print:
3111 { 'AR': 'ar',
3112 'ARCOM': '$AR $ARFLAGS $TARGET $SOURCES\n$RANLIB $RANLIBFLAGS $TARGET',
3113 'ARFLAGS': ['r'],
3114 'AS': 'as',
3115 'ASCOM': '$AS $ASFLAGS -o $TARGET $SOURCES',
3116 'ASFLAGS': [],
3117 ...
3118
3119
3120 EnsurePythonVersion(major, minor)
3121
3122 env.EnsurePythonVersion(major, minor)
3123 Ensure that the Python version is at least major.minor. This
3124 function will print out an error message and exit SCons with a
3125 non-zero exit code if the actual Python version is not late
3126 enough.
3127
3128 Example:
3129
3130 EnsurePythonVersion(2,2)
3131
3132
3133 EnsureSConsVersion(major, minor, [revision])
3134
3135 env.EnsureSConsVersion(major, minor, [revision])
3136 Ensure that the SCons version is at least major.minor, or
3137 major.minor.revision. if revision is specified. This function
3138 will print out an error message and exit SCons with a non-zero
3139 exit code if the actual SCons version is not late enough.
3140
3141 Examples:
3142
3143 EnsureSConsVersion(0,14)
3144
3145 EnsureSConsVersion(0,96,90)
3146
3147
3148 Environment([key=value, ...])
3149
3150 env.Environment([key=value, ...])
3151 Return a new construction environment initialized with the spec‐
3152 ified key=value pairs.
3153
3154
3155 Execute(action, [strfunction, varlist])
3156
3157 env.Execute(action, [strfunction, varlist])
3158 Executes an Action object. The specified action may be an
3159 Action object (see the section "Action Objects," below, for a
3160 complete explanation of the arguments and behavior), or it may
3161 be a command-line string, list of commands, or executable Python
3162 function, each of which will be converted into an Action object
3163 and then executed. The exit value of the command or return
3164 value of the Python function will be returned.
3165
3166 Note that scons will print an error message if the executed
3167 action fails--that is, exits with or returns a non-zero value.
3168 scons will not, however, automatically terminate the build if
3169 the specified action fails. If you want the build to stop in
3170 response to a failed Execute() call, you must explicitly check
3171 for a non-zero return value:
3172
3173 Execute(Copy('file.out', 'file.in'))
3174
3175 if Execute("mkdir sub/dir/ectory"):
3176 # The mkdir failed, don't try to build.
3177 Exit(1)
3178
3179
3180 Exit([value])
3181
3182 env.Exit([value])
3183 This tells scons to exit immediately with the specified value.
3184 A default exit value of 0 (zero) is used if no value is speci‐
3185 fied.
3186
3187
3188 Export(vars)
3189
3190 env.Export(vars)
3191 This tells scons to export a list of variables from the current
3192 SConscript file to all other SConscript files. The exported
3193 variables are kept in a global collection, so subsequent calls
3194 to Export() will over-write previous exports that have the same
3195 name. Multiple variable names can be passed to Export() as sep‐
3196 arate arguments or as a list. Keyword arguments can be used to
3197 provide names and their values. A dictionary can be used to map
3198 variables to a different name when exported. Both local vari‐
3199 ables and global variables can be exported.
3200
3201 Examples:
3202
3203 env = Environment()
3204 # Make env available for all SConscript files to Import().
3205 Export("env")
3206
3207 package = 'my_name'
3208 # Make env and package available for all SConscript files:.
3209 Export("env", "package")
3210
3211 # Make env and package available for all SConscript files:
3212 Export(["env", "package"])
3213
3214 # Make env available using the name debug:
3215 Export(debug = env)
3216
3217 # Make env available using the name debug:
3218 Export({"debug":env})
3219
3220 Note that the SConscript() function supports an exports argument
3221 that makes it easier to to export a variable or set of variables
3222 to a single SConscript file. See the description of the SCon‐
3223 script() function, below.
3224
3225
3226 File(name, [directory])
3227
3228 env.File(name, [directory])
3229 This returns a File Node, an object that represents the speci‐
3230 fied file name. name can be a relative or absolute path.
3231 directory is an optional directory that will be used as the par‐
3232 ent directory.
3233
3234 If name is a list, SCons returns a list of File nodes. Con‐
3235 struction variables are expanded in name.
3236
3237 File Nodes can be used anywhere you would supply a string as a
3238 file name to a Builder method or function. File Nodes have
3239 attributes and methods that are useful in many situations; see
3240 "File and Directory Nodes," below.
3241
3242
3243 FindFile(file, dirs)
3244
3245 env.FindFile(file, dirs)
3246 Search for file in the path specified by dirs. dirs may be a
3247 list of directory names or a single directory name. In addition
3248 to searching for files that exist in the filesystem, this func‐
3249 tion also searches for derived files that have not yet been
3250 built.
3251
3252 Example:
3253
3254 foo = env.FindFile('foo', ['dir1', 'dir2'])
3255
3256
3257 FindInstalledFiles()
3258
3259 env.FindInstalledFiles()
3260 Returns the list of targets set up by the Install() or Instal‐
3261 lAs() builders.
3262
3263 This function serves as a convenient method to select the con‐
3264 tents of a binary package.
3265
3266 Example:
3267
3268 Install( '/bin', [ 'executable_a', 'executable_b' ] )
3269
3270 # will return the file node list
3271 # [ '/bin/executable_a', '/bin/executable_b' ]
3272 FindInstalledFiles()
3273
3274 Install( '/lib', [ 'some_library' ] )
3275
3276 # will return the file node list
3277 # [ '/bin/executable_a', '/bin/executable_b', '/lib/some_library' ]
3278 FindInstalledFiles()
3279
3280
3281 FindPathDirs(variable)
3282 Returns a function (actually a callable Python object) intended
3283 to be used as the path_function of a Scanner object. The
3284 returned object will look up the specified variable in a con‐
3285 struction environment and treat the construction variable's
3286 value as a list of directory paths that should be searched (like
3287 $CPPPATH, $LIBPATH, etc.).
3288
3289 Note that use of FindPathDirs() is generally preferable to writ‐
3290 ing your own path_function for the following reasons: 1) The
3291 returned list will contain all appropriate directories found in
3292 source trees (when VariantDir() is used) or in code repositories
3293 (when Repository() or the -Y option are used). 2) scons will
3294 identify expansions of variable that evaluate to the same list
3295 of directories as, in fact, the same list, and avoid re-scanning
3296 the directories for files, when possible.
3297
3298 Example:
3299
3300 def my_scan(node, env, path, arg):
3301 # Code to scan file contents goes here...
3302 return include_files
3303
3304 scanner = Scanner(name = 'myscanner',
3305 function = my_scan,
3306 path_function = FindPathDirs('MYPATH'))
3307
3308
3309 FindSourceFiles(node='"."')
3310
3311 env.FindSourceFiles(node='"."')
3312 Returns the list of nodes which serve as the source of the built
3313 files. It does so by inspecting the dependency tree starting at
3314 the optional argument node which defaults to the '"."'-node. It
3315 will then return all leaves of node. These are all children
3316 which have no further children.
3317
3318 This function is a convenient method to select the contents of a
3319 Source Package.
3320
3321 Example:
3322
3323 Program( 'src/main_a.c' )
3324 Program( 'src/main_b.c' )
3325 Program( 'main_c.c' )
3326
3327 # returns ['main_c.c', 'src/main_a.c', 'SConstruct', 'src/main_b.c']
3328 FindSourceFiles()
3329
3330 # returns ['src/main_b.c', 'src/main_a.c' ]
3331 FindSourceFiles( 'src' )
3332
3333 As you can see build support files (SConstruct in the above
3334 example) will also be returned by this function.
3335
3336
3337 Flatten(sequence)
3338
3339 env.Flatten(sequence)
3340 Takes a sequence (that is, a Python list or tuple) that may con‐
3341 tain nested sequences and returns a flattened list containing
3342 all of the individual elements in any sequence. This can be
3343 helpful for collecting the lists returned by calls to Builders;
3344 other Builders will automatically flatten lists specified as
3345 input, but direct Python manipulation of these lists does not.
3346
3347 Examples:
3348
3349 foo = Object('foo.c')
3350 bar = Object('bar.c')
3351
3352 # Because `foo' and `bar' are lists returned by the Object() Builder,
3353 # `objects' will be a list containing nested lists:
3354 objects = ['f1.o', foo, 'f2.o', bar, 'f3.o']
3355
3356 # Passing such a list to another Builder is all right because
3357 # the Builder will flatten the list automatically:
3358 Program(source = objects)
3359
3360 # If you need to manipulate the list directly using Python, you need to
3361 # call Flatten() yourself, or otherwise handle nested lists:
3362 for object in Flatten(objects):
3363 print str(object)
3364
3365
3366 GetBuildFailures()
3367 Returns a list of exceptions for the actions that failed while
3368 attempting to build targets. Each element in the returned list
3369 is a BuildError object with the following attributes that record
3370 various aspects of the build failure:
3371
3372 .node The node that was being built when the build failure
3373 occurred.
3374
3375 .status The numeric exit status returned by the command or
3376 Python function that failed when trying to build the specified
3377 Node.
3378
3379 .errstr The SCons error string describing the build failure.
3380 (This is often a generic message like "Error 2" to indicate that
3381 an executed command exited with a status of 2.)
3382
3383 .filename The name of the file or directory that actually caused
3384 the failure. This may be different from the .node attribute.
3385 For example, if an attempt to build a target named sub/dir/tar‐
3386 get fails because the sub/dir directory could not be created,
3387 then the .node attribute will be sub/dir/target but the .file‐
3388 name attribute will be sub/dir.
3389
3390 .executor The SCons Executor object for the target Node being
3391 built. This can be used to retrieve the construction environ‐
3392 ment used for the failed action.
3393
3394 .action The actual SCons Action object that failed. This will
3395 be one specific action out of the possible list of actions that
3396 would have been executed to build the target.
3397
3398 .command The actual expanded command that was executed and
3399 failed, after expansion of $TARGET, $SOURCE, and other construc‐
3400 tion variables.
3401
3402 Note that the GetBuildFailures() function will always return an
3403 empty list until any build failure has occurred, which means
3404 that GetBuildFailures() will always return an empty list while
3405 the SConscript files are being read. Its primary intended use
3406 is for functions that will be executed before SCons exits by
3407 passing them to the standard Python atexit.register() function.
3408 Example:
3409
3410 import atexit
3411
3412 def print_build_failures():
3413 from SCons.Script import GetBuildFailures
3414 for bf in GetBuildFailures():
3415 print "%s failed: %s" % (bf.node, bf.errstr)
3416
3417 atexit.register(print_build_failures)
3418
3419
3420 GetBuildPath(file, [...])
3421
3422 env.GetBuildPath(file, [...])
3423 Returns the scons path name (or names) for the specified file
3424 (or files). The specified file or files may be scons Nodes or
3425 strings representing path names.
3426
3427
3428 GetLaunchDir()
3429
3430 env.GetLaunchDir()
3431 Returns the absolute path name of the directory from which scons
3432 was initially invoked. This can be useful when using the -u, -U
3433 or -D options, which internally change to the directory in which
3434 the SConstruct file is found.
3435
3436
3437 GetOption(name)
3438
3439 env.GetOption(name)
3440 This function provides a way to query the value of SCons options
3441 set on scons command line (or set using the SetOption() func‐
3442 tion). The options supported are:
3443
3444
3445 cache_debug
3446 which corresponds to --cache-debug;
3447
3448 cache_disable
3449 which corresponds to --cache-disable;
3450
3451 cache_force
3452 which corresponds to --cache-force;
3453
3454 cache_show
3455 which corresponds to --cache-show;
3456
3457 clean which corresponds to -c, --clean and --remove;
3458
3459 config
3460 which corresponds to --config;
3461
3462 directory
3463 which corresponds to -C and --directory;
3464
3465 diskcheck
3466 which corresponds to --diskcheck
3467
3468 duplicate
3469 which corresponds to --duplicate;
3470
3471 file which corresponds to -f, --file, --makefile and --scon‐
3472 struct;
3473
3474 help which corresponds to -h and --help;
3475
3476 ignore_errors
3477 which corresponds to --ignore-errors;
3478
3479 implicit_cache
3480 which corresponds to --implicit-cache;
3481
3482 implicit_deps_changed
3483 which corresponds to --implicit-deps-changed;
3484
3485 implicit_deps_unchanged
3486 which corresponds to --implicit-deps-unchanged;
3487
3488 interactive
3489 which corresponds to --interact and --interactive;
3490
3491 keep_going
3492 which corresponds to -k and --keep-going;
3493
3494 max_drift
3495 which corresponds to --max-drift;
3496
3497 no_exec
3498 which corresponds to -n, --no-exec, --just-print,
3499 --dry-run and --recon;
3500
3501 no_site_dir
3502 which corresponds to --no-site-dir;
3503
3504 num_jobs
3505 which corresponds to -j and --jobs;
3506
3507 profile_file
3508 which corresponds to --profile;
3509
3510 question
3511 which corresponds to -q and --question;
3512
3513 random
3514 which corresponds to --random;
3515
3516 repository
3517 which corresponds to -Y, --repository and --srcdir;
3518
3519 silent
3520 which corresponds to -s, --silent and --quiet;
3521
3522 site_dir
3523 which corresponds to --site-dir;
3524
3525 stack_size
3526 which corresponds to --stack-size;
3527
3528 taskmastertrace_file
3529 which corresponds to --taskmastertrace; and
3530
3531 warn which corresponds to --warn and --warning.
3532
3533 See the documentation for the corresponding command line object for
3534 information about each specific option.
3535
3536
3537 Glob(pattern, [ondisk, source, strings])
3538
3539 env.Glob(pattern, [ondisk, source, strings])
3540 Returns Nodes (or strings) that match the specified pattern,
3541 relative to the directory of the current SConscript file. The
3542 env.Glob() form performs string substition on pattern and
3543 returns whatever matches the resulting expanded pattern.
3544
3545 The specified pattern uses Unix shell style metacharacters for
3546 matching:
3547
3548 * matches everything
3549 ? matches any single character
3550 [seq] matches any character in seq
3551 [!seq] matches any char not in seq
3552
3553 If the first character of a filename is a dot, it must be
3554 matched explicitly. Character matches do not span directory
3555 separators.
3556
3557 The Glob() knows about repositories (see the Repository() func‐
3558 tion) and source directories (see the VariantDir() function) and
3559 returns a Node (or string, if so configured) in the local (SCon‐
3560 script) directory if matching Node is found anywhere in a corre‐
3561 sponding repository or source directory.
3562
3563 The ondisk argument may be set to False (or any other non-true
3564 value) to disable the search for matches on disk, thereby only
3565 returning matches among already-configured File or Dir Nodes.
3566 The default behavior is to return corresponding Nodes for any
3567 on-disk matches found.
3568
3569 The source argument may be set to True (or any equivalent value)
3570 to specify that, when the local directory is a VariantDir(), the
3571 returned Nodes should be from the corresponding source direc‐
3572 tory, not the local directory.
3573
3574 The strings argument may be set to True (or any equivalent
3575 value) to have the Glob() function return strings, not Nodes,
3576 that represent the matched files or directories. The returned
3577 strings will be relative to the local (SConscript) directory.
3578 (Note that This may make it easier to perform arbitrary manipu‐
3579 lation of file names, but if the returned strings are passed to
3580 a different SConscript file, any Node translation will be rela‐
3581 tive to the other SConscript directory, not the original SCon‐
3582 script directory.)
3583
3584 Examples:
3585
3586 Program('foo', Glob('*.c'))
3587 Zip('/tmp/everything', Glob('.??*') + Glob('*'))
3588
3589
3590 Help(text)
3591
3592 env.Help(text)
3593 This specifies help text to be printed if the -h argument is
3594 given to scons. If Help() is called multiple times, the text is
3595 appended together in the order that Help() is called.
3596
3597
3598 Ignore(target, dependency)
3599
3600 env.Ignore(target, dependency)
3601 The specified dependency file(s) will be ignored when deciding
3602 if the target file(s) need to be rebuilt.
3603
3604 You can also use Ignore() to remove a target from the default
3605 build. In order to do this you must specify the directory the
3606 target will be built in as the target, and the file you want to
3607 skip building as the dependency.
3608
3609 Note that this will only remove the dependencies listed from the
3610 files built by default. It will still be built if that depen‐
3611 dency is needed by another object being built. See the third
3612 and forth examples below.
3613
3614 Examples:
3615
3616 env.Ignore('foo', 'foo.c')
3617 env.Ignore('bar', ['bar1.h', 'bar2.h'])
3618 env.Ignore('.','foobar.obj')
3619 env.Ignore('bar','bar/foobar.obj')
3620
3621
3622 Import(vars)
3623
3624 env.Import(vars)
3625 This tells scons to import a list of variables into the current
3626 SConscript file. This will import variables that were exported
3627 with Export() or in the exports argument to SConscript(). Vari‐
3628 ables exported by SConscript() have precedence. Multiple vari‐
3629 able names can be passed to Import() as separate arguments or as
3630 a list. The variable "*" can be used to import all variables.
3631
3632 Examples:
3633
3634 Import("env")
3635 Import("env", "variable")
3636 Import(["env", "variable"])
3637 Import("*")
3638
3639
3640 Literal(string)
3641
3642 env.Literal(string)
3643 The specified string will be preserved as-is and not have con‐
3644 struction variables expanded.
3645
3646
3647 Local(targets)
3648
3649 env.Local(targets)
3650 The specified targets will have copies made in the local tree,
3651 even if an already up-to-date copy exists in a repository.
3652 Returns a list of the target Node or Nodes.
3653
3654
3655 env.MergeFlags(arg, [unique])
3656 Merges the specified arg values to the construction environ‐
3657 ment's construction variables. If the arg argument is not a
3658 dictionary, it is converted to one by calling env.ParseFlags()
3659 on the argument before the values are merged. Note that arg
3660 must be a single value, so multiple strings must be passed in as
3661 a list, not as separate arguments to env.MergeFlags().
3662
3663 By default, duplicate values are eliminated; you can, however,
3664 specify unique=0 to allow duplicate values to be added. When
3665 eliminating duplicate values, any construction variables that
3666 end with the string PATH keep the left-most unique value. All
3667 other construction variables keep the right-most unique value.
3668
3669 Examples:
3670
3671 # Add an optimization flag to $CCFLAGS.
3672 env.MergeFlags('-O3')
3673
3674 # Combine the flags returned from running pkg-config with an optimization
3675 # flag and merge the result into the construction variables.
3676 env.MergeFlags(['!pkg-config gtk+-2.0 --cflags', '-O3'])
3677
3678 # Combine an optimization flag with the flags returned from running pkg-config
3679 # twice and merge the result into the construction variables.
3680 env.MergeFlags(['-O3',
3681 '!pkg-config gtk+-2.0 --cflags --libs',
3682 '!pkg-config libpng12 --cflags --libs'])
3683
3684
3685 NoCache(target, ...)
3686
3687 env.NoCache(target, ...)
3688 Specifies a list of files which should not be cached whenever
3689 the CacheDir() method has been activated. The specified targets
3690 may be a list or an individual target.
3691
3692 Multiple files should be specified either as separate arguments
3693 to the NoCache() method, or as a list. NoCache() will also
3694 accept the return value of any of the construction environment
3695 Builder methods.
3696
3697 Calling NoCache() on directories and other non-File Node types
3698 has no effect because only File Nodes are cached.
3699
3700 Examples:
3701
3702 NoCache('foo.elf')
3703 NoCache(env.Program('hello', 'hello.c'))
3704
3705
3706 NoClean(target, ...)
3707
3708 env.NoClean(target, ...)
3709 Specifies a list of files or directories which should not be
3710 removed whenever the targets (or their dependencies) are speci‐
3711 fied with the -c command line option. The specified targets may
3712 be a list or an individual target. Multiple calls to NoClean()
3713 are legal, and prevent each specified target from being removed
3714 by calls to the -c option.
3715
3716 Multiple files or directories should be specified either as sep‐
3717 arate arguments to the NoClean() method, or as a list.
3718 NoClean() will also accept the return value of any of the con‐
3719 struction environment Builder methods.
3720
3721 Calling NoClean() for a target overrides calling Clean() for the
3722 same target, and any targets passed to both functions will not
3723 be removed by the -c option.
3724
3725 Examples:
3726
3727 NoClean('foo.elf')
3728 NoClean(env.Program('hello', 'hello.c'))
3729
3730
3731 env.ParseConfig(command, [function, unique])
3732 Calls the specified function to modify the environment as speci‐
3733 fied by the output of command. The default function is
3734 env.MergeFlags(), which expects the output of a typical *-config
3735 command (for example, gtk-config) and adds the options to the
3736 appropriate construction variables. By default, duplicate val‐
3737 ues are not added to any construction variables; you can specify
3738 unique=0 to allow duplicate values to be added.
3739
3740 Interpreted options and the construction variables they affect
3741 are as specified for the env.ParseFlags() method (which this
3742 method calls). See that method's description, below, for a ta‐
3743 ble of options and construction variables.
3744
3745
3746 ParseDepends(filename, [must_exist, only_one])
3747
3748 env.ParseDepends(filename, [must_exist, only_one])
3749 Parses the contents of the specified filename as a list of
3750 dependencies in the style of Make or mkdep, and explicitly
3751 establishes all of the listed dependencies.
3752
3753 By default, it is not an error if the specified filename does
3754 not exist. The optional must_exist argument may be set to a
3755 non-zero value to have scons throw an exception and generate an
3756 error if the file does not exist, or is otherwise inaccessible.
3757
3758 The optional only_one argument may be set to a non-zero value to
3759 have scons thrown an exception and generate an error if the file
3760 contains dependency information for more than one target. This
3761 can provide a small sanity check for files intended to be gener‐
3762 ated by, for example, the gcc -M flag, which should typically
3763 only write dependency information for one output file into a
3764 corresponding .d file.
3765
3766 The filename and all of the files listed therein will be inter‐
3767 preted relative to the directory of the SConscript file which
3768 calls the ParseDepends() function.
3769
3770
3771 env.ParseFlags(flags, ...)
3772 Parses one or more strings containing typical command-line flags
3773 for GCC tool chains and returns a dictionary with the flag val‐
3774 ues separated into the appropriate SCons construction variables.
3775 This is intended as a companion to the env.MergeFlags() method,
3776 but allows for the values in the returned dictionary to be modi‐
3777 fied, if necessary, before merging them into the construction
3778 environment. (Note that env.MergeFlags() will call this method
3779 if its argument is not a dictionary, so it is usually not neces‐
3780 sary to call env.ParseFlags() directly unless you want to manip‐
3781 ulate the values.)
3782
3783 If the first character in any string is an exclamation mark (!),
3784 the rest of the string is executed as a command, and the output
3785 from the command is parsed as GCC tool chain command-line flags
3786 and added to the resulting dictionary.
3787
3788 Flag values are translated accordig to the prefix found, and
3789 added to the following construction variables:
3790
3791 -arch CCFLAGS, LINKFLAGS
3792 -D CPPDEFINES
3793 -framework FRAMEWORKS
3794 -frameworkdir= FRAMEWORKPATH
3795 -include CCFLAGS
3796 -isysroot CCFLAGS, LINKFLAGS
3797 -I CPPPATH
3798 -l LIBS
3799 -L LIBPATH
3800 -mno-cygwin CCFLAGS, LINKFLAGS
3801 -mwindows LINKFLAGS
3802 -pthread CCFLAGS, LINKFLAGS
3803 -std= CFLAGS
3804 -Wa, ASFLAGS, CCFLAGS
3805 -Wl,-rpath= RPATH
3806 -Wl,-R, RPATH
3807 -Wl,-R RPATH
3808 -Wl, LINKFLAGS
3809 -Wp, CPPFLAGS
3810 - CCFLAGS
3811 + CCFLAGS, LINKFLAGS
3812
3813 Any other strings not associated with options are assumed to be
3814 the names of libraries and added to the $LIBS construction vari‐
3815 able.
3816
3817 Examples (all of which produce the same result):
3818
3819 dict = env.ParseFlags('-O2 -Dfoo -Dbar=1')
3820 dict = env.ParseFlags('-O2', '-Dfoo', '-Dbar=1')
3821 dict = env.ParseFlags(['-O2', '-Dfoo -Dbar=1'])
3822 dict = env.ParseFlags('-O2', '!echo -Dfoo -Dbar=1')
3823
3824
3825 env.Perforce()
3826 A factory function that returns a Builder object to be used to
3827 fetch source files from the Perforce source code management sys‐
3828 tem. The returned Builder is intended to be passed to the
3829 SourceCode() function.
3830
3831 This function is deprecated. For details, see the entry for the
3832 SourceCode() function.
3833
3834 Example:
3835
3836 env.SourceCode('.', env.Perforce())
3837
3838 Perforce uses a number of external environment variables for its
3839 operation. Consequently, this function adds the following vari‐
3840 ables from the user's external environment to the construction
3841 environment's ENV dictionary: P4CHARSET, P4CLIENT, P4LANGUAGE,
3842 P4PASSWD, P4PORT, P4USER, SystemRoot, USER, and USERNAME.
3843
3844
3845 Platform(string)
3846 The Platform() form returns a callable object that can be used
3847 to initialize a construction environment using the platform key‐
3848 word of the Environment() function.
3849
3850 Example:
3851
3852 env = Environment(platform = Platform('win32'))
3853
3854 The env.Platform() form applies the callable object for the
3855 specified platform string to the environment through which the
3856 method was called.
3857
3858 env.Platform('posix')
3859
3860 Note that the win32 platform adds the SystemDrive and SystemRoot
3861 variables from the user's external environment to the construc‐
3862 tion environment's $ENV dictionary. This is so that any exe‐
3863 cuted commands that use sockets to connect with other systems
3864 (such as fetching source files from external CVS repository
3865 specifications like :pserver:anonymous@cvs.sourceforge.net:/cvs‐
3866 root/scons) will work on Windows systems.
3867
3868
3869 Precious(target, ...)
3870
3871 env.Precious(target, ...)
3872 Marks each given target as precious so it is not deleted before
3873 it is rebuilt. Normally scons deletes a target before building
3874 it. Multiple targets can be passed in to a single call to Pre‐
3875 cious().
3876
3877
3878 env.Prepend(key=val, [...])
3879 Appends the specified keyword arguments to the beginning of con‐
3880 struction variables in the environment. If the Environment does
3881 not have the specified construction variable, it is simply added
3882 to the environment. If the values of the construction variable
3883 and the keyword argument are the same type, then the two values
3884 will be simply added together. Otherwise, the construction
3885 variable and the value of the keyword argument are both coerced
3886 to lists, and the lists are added together. (See also the
3887 Append method, above.)
3888
3889 Example:
3890
3891 env.Prepend(CCFLAGS = '-g ', FOO = ['foo.yyy'])
3892
3893
3894 env.PrependENVPath(name, newpath, [envname, sep, delete_existing])
3895 This appends new path elements to the given path in the speci‐
3896 fied external environment ($ENV by default). This will only add
3897 any particular path once (leaving the first one it encounters
3898 and ignoring the rest, to preserve path order), and to help
3899 assure this, will normalize all paths (using os.path.normpath
3900 and os.path.normcase). This can also handle the case where the
3901 given old path variable is a list instead of a string, in which
3902 case a list will be returned instead of a string.
3903
3904 If delete_existing is 0, then adding a path that already exists
3905 will not move it to the beginning; it will stay where it is in
3906 the list.
3907
3908 Example:
3909
3910 print 'before:',env['ENV']['INCLUDE']
3911 include_path = '/foo/bar:/foo'
3912 env.PrependENVPath('INCLUDE', include_path)
3913 print 'after:',env['ENV']['INCLUDE']
3914
3915 The above example will print:
3916
3917 before: /biz:/foo
3918 after: /foo/bar:/foo:/biz
3919
3920
3921 env.PrependUnique(key=val, delete_existing=0, [...])
3922 Appends the specified keyword arguments to the beginning of con‐
3923 struction variables in the environment. If the Environment does
3924 not have the specified construction variable, it is simply added
3925 to the environment. If the construction variable being appended
3926 to is a list, then any value(s) that already exist in the con‐
3927 struction variable will not be added again to the list. How‐
3928 ever, if delete_existing is 1, existing matching values are
3929 removed first, so existing values in the arg list move to the
3930 front of the list.
3931
3932 Example:
3933
3934 env.PrependUnique(CCFLAGS = '-g', FOO = ['foo.yyy'])
3935
3936
3937 Progress(callable, [interval])
3938
3939 Progress(string, [interval, file, overwrite])
3940
3941 Progress(list_of_strings, [interval, file, overwrite])
3942 Allows SCons to show progress made during the build by display‐
3943 ing a string or calling a function while evaluating Nodes (e.g.
3944 files).
3945
3946 If the first specified argument is a Python callable (a function
3947 or an object that has a __call__() method), the function will be
3948 called once every interval times a Node is evaluated. The
3949 callable will be passed the evaluated Node as its only argument.
3950 (For future compatibility, it's a good idea to also add *args
3951 and **kw as arguments to your function or method. This will
3952 prevent the code from breaking if SCons ever changes the inter‐
3953 face to call the function with additional arguments in the
3954 future.)
3955
3956 An example of a simple custom progress function that prints a
3957 string containing the Node name every 10 Nodes:
3958
3959 def my_progress_function(node, *args, **kw):
3960 print 'Evaluating node %s!' % node
3961 Progress(my_progress_function, interval=10)
3962
3963 A more complicated example of a custom progress display object
3964 that prints a string contai(naincgarraiagceournetturenv)erayt t1h0e0enedvaslouattheadt
3965 Nodes. Note the use of
3966 the string will overwrite itself on a display:
3967
3968 import sys
3969 class ProgressCounter(object):
3970 count = 0
3971 def __call__(self, node, *args, **kw):
3972 self.count += 100
3973 sys.stderr.write('Evaluated %s nodes\r' % self.count)
3974 Progress(ProgressCounter(), interval=100)
3975
3976 If the first argument Progress() is a string, the string will be
3977 displayed every interval evaluated Nodes. The default is to
3978 print the string on standard output; an alternate output stream
3979 may be specified with the file= argument. The following will
3980 print a series of dots on the error output, one dot for every
3981 100 evaluated Nodes:
3982
3983 import sys
3984 Progress('.', interval=100, file=sys.stderr)
3985
3986 If the string contains the verbatim substring $TARGET, it will
3987 be replaced with the Node. Note that, for performance reasons,
3988 this is not a regular SCons variable substition, so you can not
3989 use other variables or use curly braces. The following(ceaxrarmipalgee
3990 will print the name of every evaluated Node, using a
3991 return) to cause each line to overwritten by the next line, and
3992 the overwrite= keyword argument to make sure the previously-
3993 printed file name is overwritten with blank spaces:
3994
3995 import sys
3996 Progress('$TARGET\r', overwrite=True)
3997
3998 If the first argument to Progress() is a list of strings, then
3999 each string in the list will be displayed in rotating fashion
4000 every interval evaluated Nodes. This can be used to implement a
4001 "spinner" on the user's screen as follows:
4002
4003 Progress(['-\r', '\\\r', '|\r', '/\r'], interval=5)
4004
4005
4006 env.RCS()
4007 A factory function that returns a Builder object to be used to
4008 fetch source files from RCS. The returned Builder is intended
4009 to be passed to the SourceCode() function:
4010
4011 This function is deprecated. For details, see the entry for the
4012 SourceCode() function.
4013
4014 Examples:
4015
4016 env.SourceCode('.', env.RCS())
4017
4018 Note that scons will fetch source files from RCS subdirectories
4019 automatically, so configuring RCS as demonstrated in the above
4020 example should only be necessary if you are fetching from RCS,v
4021 files in the same directory as the source files, or if you need
4022 to explicitly specify RCS for a specific subdirectory.
4023
4024
4025 env.Replace(key=val, [...])
4026 Replaces construction variables in the Environment with the
4027 specified keyword arguments.
4028
4029 Example:
4030
4031 env.Replace(CCFLAGS = '-g', FOO = 'foo.xxx')
4032
4033
4034 Repository(directory)
4035
4036 env.Repository(directory)
4037 Specifies that directory is a repository to be searched for
4038 files. Multiple calls to Repository() are legal, and each one
4039 adds to the list of repositories that will be searched.
4040
4041 To scons, a repository is a copy of the source tree, from the
4042 top-level directory on down, which may contain both source files
4043 and derived files that can be used to build targets in the local
4044 source tree. The canonical example would be an official source
4045 tree maintained by an integrator. If the repository contains
4046 derived files, then the derived files should have been built
4047 using scons, so that the repository contains the necessary sig‐
4048 nature information to allow scons to figure out when it is
4049 appropriate to use the repository copy of a derived file,
4050 instead of building one locally.
4051
4052 Note that if an up-to-date derived file already exists in a
4053 repository, scons will not make a copy in the local directory
4054 tree. In order to guarantee that a local copy will be made, use
4055 the Local() method.
4056
4057
4058 Requires(target, prerequisite)
4059
4060 env.Requires(target, prerequisite)
4061 Specifies an order-only relationship between the specified tar‐
4062 get file(s) and the specified prerequisite file(s). The prereq‐
4063 uisite file(s) will be (re)built, if necessary, before the tar‐
4064 get file(s), but the target file(s) do not actually depend on
4065 the prerequisites and will not be rebuilt simply because the
4066 prerequisite file(s) change.
4067
4068 Example:
4069
4070 env.Requires('foo', 'file-that-must-be-built-before-foo')
4071
4072
4073 Return([vars..., stop=])
4074 By default, this stops processing the current SConscript file
4075 and returns to the calling SConscript file the values of the
4076 variables named in the vars string arguments. Multiple strings
4077 contaning variable names may be passed to Return(). Any strings
4078 that contain white space
4079
4080 The optional stop= keyword argument may be set to a false value
4081 to continue processing the rest of the SConscript file after the
4082 Return() call. This was the default behavior prior to SCons
4083 0.98. However, the values returned are still the values of the
4084 variables in the named vars at the point Return() is called.
4085
4086 Examples:
4087
4088 # Returns without returning a value.
4089 Return()
4090
4091 # Returns the value of the 'foo' Python variable.
4092 Return("foo")
4093
4094 # Returns the values of the Python variables 'foo' and 'bar'.
4095 Return("foo", "bar")
4096
4097 # Returns the values of Python variables 'val1' and 'val2'.
4098 Return('val1 val2')
4099
4100
4101 Scanner(function, [argument, keys, path_function, node_class, node_fac‐
4102 tory, scan_check, recursive])
4103
4104 env.Scanner(function, [argument, keys, path_function, node_class,
4105 node_factory, scan_check, recursive])
4106 Creates a Scanner object for the specified function. See the
4107 section "Scanner Objects," below, for a complete explanation of
4108 the arguments and behavior.
4109
4110
4111 env.SCCS()
4112 A factory function that returns a Builder object to be used to
4113 fetch source files from SCCS. The returned Builder is intended
4114 to be passed to the SourceCode() function.
4115
4116 Example:
4117
4118 env.SourceCode('.', env.SCCS())
4119
4120 Note that scons will fetch source files from SCCS subdirectories
4121 automatically, so configuring SCCS as demonstrated in the above
4122 example should only be necessary if you are fetching from s.SCCS
4123 files in the same directory as the source files, or if you need
4124 to explicitly specify SCCS for a specific subdirectory.
4125
4126
4127 SConscript(scripts, [exports, variant_dir, duplicate])
4128
4129 env.SConscript(scripts, [exports, variant_dir, duplicate])
4130
4131 SConscript(dirs=subdirs, [name=script, exports, variant_dir, dupli‐
4132 cate])
4133
4134 env.SConscript(dirs=subdirs, [name=script, exports, variant_dir, dupli‐
4135 cate])
4136 This tells scons to execute one or more subsidiary SConscript
4137 (configuration) files. Any variables returned by a called
4138 script using Return() will be returned by the call to SCon‐
4139 script(). There are two ways to call the SConscript() function.
4140
4141 The first way you can call SConscript() is to explicitly specify
4142 one or more scripts as the first argument. A single script may
4143 be specified as a string; multiple scripts must be specified as
4144 a list (either explicitly or as created by a function like
4145 Split()). Examples:
4146 SConscript('SConscript') # run SConscript in the current directory
4147 SConscript('src/SConscript') # run SConscript in the src directory
4148 SConscript(['src/SConscript', 'doc/SConscript'])
4149 config = SConscript('MyConfig.py')
4150
4151 The second way you can call SConscript() is to specify a list of
4152 (sub)directory names as a dirs=subdirs keyword argument. In
4153 this case, scons will, by default, execute a subsidiary configu‐
4154 ration file named SConscript in each of the specified directo‐
4155 ries. You may specify a name other than SConscript by supplying
4156 an optional name=script keyword argument. The first three exam‐
4157 ples below have the same effect as the first three examples
4158 above:
4159 SConscript(dirs='.') # run SConscript in the current directory
4160 SConscript(dirs='src') # run SConscript in the src directory
4161 SConscript(dirs=['src', 'doc'])
4162 SConscript(dirs=['sub1', 'sub2'], name='MySConscript')
4163
4164 The optional exports argument provides a list of variable names
4165 or a dictionary of named values to export to the script(s).
4166 These variables are locally exported only to the specified
4167 script(s), and do not affect the global pool of variables used
4168 by the Export() function. The subsidiary script(s) must use the
4169 Import() function to import the variables. Examples:
4170 foo = SConscript('sub/SConscript', exports='env')
4171 SConscript('dir/SConscript', exports=['env', 'variable'])
4172 SConscript(dirs='subdir', exports='env variable')
4173 SConscript(dirs=['one', 'two', 'three'], exports='shared_info')
4174
4175 If the optional variant_dir argument is present, it causes an
4176 effect equivalent to the VariantDir() method described below.
4177 (If variant_dir is not present, the duplicate argument is
4178 ignored.) The variant_dir argument is interpreted relative to
4179 the directory of the calling SConscript file. See the descrip‐
4180 tion of the VariantDir() function below for additional details
4181 and restrictions.
4182
4183 If variant_dir is present, the source directory is the directory
4184 in which the SConscript file resides and the SConscript file is
4185 evaluated as if it were in the variant_dir directory:
4186 SConscript('src/SConscript', variant_dir = 'build')
4187
4188 is equivalent to
4189
4190 VariantDir('build', 'src')
4191 SConscript('build/SConscript')
4192
4193 This later paradigm is often used when the sources are in the
4194 same directory as the SConstruct:
4195
4196 SConscript('SConscript', variant_dir = 'build')
4197
4198 is equivalent to
4199
4200 VariantDir('build', '.')
4201 SConscript('build/SConscript')
4202
4203 Here are some composite examples:
4204
4205 # collect the configuration information and use it to build src and doc
4206 shared_info = SConscript('MyConfig.py')
4207 SConscript('src/SConscript', exports='shared_info')
4208 SConscript('doc/SConscript', exports='shared_info')
4209
4210 # build debugging and production versions. SConscript
4211 # can use Dir('.').path to determine variant.
4212 SConscript('SConscript', variant_dir='debug', duplicate=0)
4213 SConscript('SConscript', variant_dir='prod', duplicate=0)
4214
4215 # build debugging and production versions. SConscript
4216 # is passed flags to use.
4217 opts = { 'CPPDEFINES' : ['DEBUG'], 'CCFLAGS' : '-pgdb' }
4218 SConscript('SConscript', variant_dir='debug', duplicate=0, exports=opts)
4219 opts = { 'CPPDEFINES' : ['NODEBUG'], 'CCFLAGS' : '-O' }
4220 SConscript('SConscript', variant_dir='prod', duplicate=0, exports=opts)
4221
4222 # build common documentation and compile for different architectures
4223 SConscript('doc/SConscript', variant_dir='build/doc', duplicate=0)
4224 SConscript('src/SConscript', variant_dir='build/x86', duplicate=0)
4225 SConscript('src/SConscript', variant_dir='build/ppc', duplicate=0)
4226
4227
4228 SConscriptChdir(value)
4229
4230 env.SConscriptChdir(value)
4231 By default, scons changes its working directory to the directory
4232 in which each subsidiary SConscript file lives. This behavior
4233 may be disabled by specifying either:
4234
4235 SConscriptChdir(0)
4236 env.SConscriptChdir(0)
4237
4238 in which case scons will stay in the top-level directory while
4239 reading all SConscript files. (This may be necessary when
4240 building from repositories, when all the directories in which
4241 SConscript files may be found don't necessarily exist locally.)
4242 You may enable and disable this ability by calling SCon‐
4243 scriptChdir() multiple times.
4244
4245 Example:
4246
4247 env = Environment()
4248 SConscriptChdir(0)
4249 SConscript('foo/SConscript') # will not chdir to foo
4250 env.SConscriptChdir(1)
4251 SConscript('bar/SConscript') # will chdir to bar
4252
4253
4254 SConsignFile([file, dbm_module])
4255
4256 env.SConsignFile([file, dbm_module])
4257 This tells scons to store all file signatures in the specified
4258 database file. If the file name is omitted, .sconsign is used
4259 by default. (The actual file name(s) stored on disk may have an
4260 appropriated suffix appended by the dbm_module.) If file is not
4261 an absolute path name, the file is placed in the same directory
4262 as the top-level SConstruct file.
4263
4264 If file is None, then scons will store file signatures in a sep‐
4265 arate .sconsign file in each directory, not in one global data‐
4266 base file. (This was the default behavior prior to SCons
4267 0.96.91 and 0.97.)
4268
4269 The optional dbm_module argument can be used to specify which
4270 Python database module The default is to use a custom
4271 SCons.dblite module that uses pickled Python data structures,
4272 and which works on all Python versions.
4273
4274 Examples:
4275
4276 # Explicitly stores signatures in ".sconsign.dblite"
4277 # in the top-level SConstruct directory (the
4278 # default behavior).
4279 SConsignFile()
4280
4281 # Stores signatures in the file "etc/scons-signatures"
4282 # relative to the top-level SConstruct directory.
4283 SConsignFile("etc/scons-signatures")
4284
4285 # Stores signatures in the specified absolute file name.
4286 SConsignFile("/home/me/SCons/signatures")
4287
4288 # Stores signatures in a separate .sconsign file
4289 # in each directory.
4290 SConsignFile(None)
4291
4292
4293 env.SetDefault(key=val, [...])
4294 Sets construction variables to default values specified with the
4295 keyword arguments if (and only if) the variables are not already
4296 set. The following statements are equivalent:
4297
4298 env.SetDefault(FOO = 'foo')
4299
4300 if 'FOO' not in env: env['FOO'] = 'foo'
4301
4302
4303 SetOption(name, value)
4304
4305 env.SetOption(name, value)
4306 This function provides a way to set a select subset of the scons
4307 command line options from a SConscript file. The options sup‐
4308 ported are:
4309
4310
4311 clean which corresponds to -c, --clean and --remove;
4312
4313 duplicate
4314 which corresponds to --duplicate;
4315
4316 help which corresponds to -h and --help;
4317
4318 implicit_cache
4319 which corresponds to --implicit-cache;
4320
4321 max_drift
4322 which corresponds to --max-drift;
4323
4324 no_exec
4325 which corresponds to -n, --no-exec, --just-print,
4326 --dry-run and --recon;
4327
4328 num_jobs
4329 which corresponds to -j and --jobs;
4330
4331 random
4332 which corresponds to --random; and
4333
4334 stack_size
4335 which corresponds to --stack-size.
4336
4337 See the documentation for the corresponding command line object for
4338 information about each specific option.
4339
4340 Example:
4341
4342 SetOption('max_drift', 1)
4343
4344
4345 SideEffect(side_effect, target)
4346
4347 env.SideEffect(side_effect, target)
4348 Declares side_effect as a side effect of building target. Both
4349 side_effect and target can be a list, a file name, or a node. A
4350 side effect is a target file that is created or updated as a
4351 side effect of building other targets. For example, a Windows
4352 PDB file is created as a side effect of building the .obj files
4353 for a static library, and various log files are created updated
4354 as side effects of various TeX commands. If a target is a side
4355 effect of multiple build commands, scons will ensure that only
4356 one set of commands is executed at a time. Consequently, you
4357 only need to use this method for side-effect targets that are
4358 built as a result of multiple build commands.
4359
4360 Because multiple build commands may update the same side effect
4361 file, by default the side_effect target is not automatically
4362 removed when the target is removed by the -c option. (Note,
4363 however, that the side_effect might be removed as part of clean‐
4364 ing the directory in which it lives.) If you want to make sure
4365 the side_effect is cleaned whenever a specific target is
4366 cleaned, you must specify this explicitly with the Clean() or
4367 env.Clean() function.
4368
4369
4370 SourceCode(entries, builder)
4371
4372 env.SourceCode(entries, builder)
4373 This function and its associate factory functions are depre‐
4374 cated. There is no replacement. The intended use was to keep a
4375 local tree in sync with an archive, but in actuality the func‐
4376 tion only causes the archive to be fetched on the first run.
4377 Synchronizing with the archive is best done external to &SCons;.
4378
4379 Arrange for non-existent source files to be fetched from a
4380 source code management system using the specified builder. The
4381 specified entries may be a Node, string or list of both, and may
4382 represent either individual source files or directories in which
4383 source files can be found.
4384
4385 For any non-existent source files, scons will search up the
4386 directory tree and use the first SourceCode() builder it finds.
4387 The specified builder may be None, in which case scons will not
4388 use a builder to fetch source files for the specified entries,
4389 even if a SourceCode() builder has been specified for a direc‐
4390 tory higher up the tree.
4391
4392 scons will, by default, fetch files from SCCS or RCS subdirecto‐
4393 ries without explicit configuration. This takes some extra pro‐
4394 cessing time to search for the necessary source code management
4395 files on disk. You can avoid these extra searches and speed up
4396 your build a little by disabling these searches as follows:
4397
4398 env.SourceCode('.', None)
4399
4400 Note that if the specified builder is one you create by hand, it
4401 must have an associated construction environment to use when
4402 fetching a source file.
4403
4404 scons provides a set of canned factory functions that return
4405 appropriate Builders for various popular source code management
4406 systems. Canonical examples of invocation include:
4407
4408 env.SourceCode('.', env.BitKeeper('/usr/local/BKsources'))
4409 env.SourceCode('src', env.CVS('/usr/local/CVSROOT'))
4410 env.SourceCode('/', env.RCS())
4411 env.SourceCode(['f1.c', 'f2.c'], env.SCCS())
4412 env.SourceCode('no_source.c', None)
4413
4414
4415 SourceSignatures(type)
4416
4417 env.SourceSignatures(type)
4418 Note: Although it is not yet officially deprecated, use of this
4419 function is discouraged. See the Decider() function for a more
4420 flexible and straightforward way to configure SCons' decision-
4421 making.
4422
4423 The SourceSignatures() function tells scons how to decide if a
4424 source file (a file that is not built from any other files) has
4425 changed since the last time it was used to build a particular
4426 target file. Legal values are MD5 or timestamp.
4427
4428 If the environment method is used, the specified type of source
4429 signature is only used when deciding whether targets built with
4430 that environment are up-to-date or must be rebuilt. If the
4431 global function is used, the specified type of source signature
4432 becomes the default used for all decisions about whether targets
4433 are up-to-date.
4434
4435 MD5 means scons decides that a source file has changed if the
4436 MD5 checksum of its contents has changed since the last time it
4437 was used to rebuild a particular target file.
4438
4439 timestamp means scons decides that a source file has changed if
4440 its timestamp (modification time) has changed since the last
4441 time it was used to rebuild a particular target file. (Note
4442 that although this is similar to the behavior of Make, by
4443 default it will also rebuild if the dependency is older than the
4444 last time it was used to rebuild the target file.)
4445
4446 There is no different between the two behaviors for Python
4447 Value() node objects.
4448
4449 MD5 signatures take longer to compute, but are more accurate
4450 than timestamp signatures. The default value is MD5.
4451
4452 Note that the default TargetSignatures() setting (see below) is
4453 to use this SourceSignatures() setting for any target files that
4454 are used to build other target files. Consequently, changing
4455 the value of SourceSignatures() will, by default, affect the up-
4456 to-date decision for all files in the build (or all files built
4457 with a specific construction environment when env.SourceSigna‐
4458 tures() is used).
4459
4460
4461 Split(arg)
4462
4463 env.Split(arg)
4464 Returns a list of file names or other objects. If arg is a
4465 string, it will be split on strings of white-space characters
4466 within the string, making it easier to write long lists of file
4467 names. If arg is already a list, the list will be returned
4468 untouched. If arg is any other type of object, it will be
4469 returned as a list containing just the object.
4470
4471 Example:
4472
4473 files = Split("f1.c f2.c f3.c")
4474 files = env.Split("f4.c f5.c f6.c")
4475 files = Split("""
4476 f7.c
4477 f8.c
4478 f9.c
4479 """)
4480
4481
4482 env.subst(input, [raw, target, source, conv])
4483 Performs construction variable interpolation on the specified
4484 string or sequence argument input.
4485
4486 By default, leading or trailing white space will be removed from
4487 the result. and all sequences of white space will be compressed
4488 to a single space character. Additionally, any $( and $) char‐
4489 acter sequences will be stripped from the returned string, The
4490 optional raw argument may be set to 1 if you want to preserve
4491 white space and $(-$) sequences. The raw argument may be set to
4492 2 if you want to strip all characters between any $( and $)
4493 pairs (as is done for signature calculation).
4494
4495 If the input is a sequence (list or tuple), the individual ele‐
4496 ments of the sequence will be expanded, and the results will be
4497 returned as a list.
4498
4499 The optional target and source keyword arguments must be set to
4500 lists of target and source nodes, respectively, if you want the
4501 $TARGET, $TARGETS, $SOURCE and $SOURCES to be available for
4502 expansion. This is usually necessary if you are calling
4503 env.subst() from within a Python function used as an SCons
4504 action.
4505
4506 Returned string values or sequence elements are converted to
4507 their string representation by default. The optional conv argu‐
4508 ment may specify a conversion function that will be used in
4509 place of the default. For example, if you want Python objects
4510 (including SCons Nodes) to be returned as Python objects, you
4511 can use the Python lambda idiom to pass in an unnamed function
4512 that simply returns its unconverted argument.
4513
4514 Example:
4515
4516 print env.subst("The C compiler is: $CC")
4517
4518 def compile(target, source, env):
4519 sourceDir = env.subst("${SOURCE.srcdir}",
4520 target=target,
4521 source=source)
4522
4523 source_nodes = env.subst('$EXPAND_TO_NODELIST',
4524 conv=lambda x: x)
4525
4526
4527 Tag(node, tags)
4528 Annotates file or directory Nodes with information about how the
4529 Package() Builder should package those files or directories.
4530 All tags are optional.
4531
4532 Examples:
4533
4534 # makes sure the built library will be installed with 0644 file
4535 # access mode
4536 Tag( Library( 'lib.c' ), UNIX_ATTR="0644" )
4537
4538 # marks file2.txt to be a documentation file
4539 Tag( 'file2.txt', DOC )
4540
4541
4542 TargetSignatures(type)
4543
4544 env.TargetSignatures(type)
4545 Note: Although it is not yet officially deprecated, use of this
4546 function is discouraged. See the Decider() function for a more
4547 flexible and straightforward way to configure SCons' decision-
4548 making.
4549
4550 The TargetSignatures() function tells scons how to decide if a
4551 target file (a file that is built from any other files) has
4552 changed since the last time it was used to build some other tar‐
4553 get file. Legal values are build; content (or its synonym MD5);
4554 timestamp; or source.
4555
4556 If the environment method is used, the specified type of target
4557 signature is only used for targets built with that environment.
4558 If the global function is used, the specified type of signature
4559 becomes the default used for all target files that don't have an
4560 explicit target signature type specified for their environments.
4561
4562 content (or its synonym MD5) means scons decides that a target
4563 file has changed if the MD5 checksum of its contents has changed
4564 since the last time it was used to rebuild some other target
4565 file. This means scons will open up MD5 sum the contents of
4566 target files after they're built, and may decide that it does
4567 not need to rebuild "downstream" target files if a file was
4568 rebuilt with exactly the same contents as the last time.
4569
4570 timestamp means scons decides that a target file has changed if
4571 its timestamp (modification time) has changed since the last
4572 time it was used to rebuild some other target file. (Note that
4573 although this is similar to the behavior of Make, by default it
4574 will also rebuild if the dependency is older than the last time
4575 it was used to rebuild the target file.)
4576
4577 source means scons decides that a target file has changed as
4578 specified by the corresponding SourceSignatures() setting (MD5
4579 or timestamp). This means that scons will treat all input files
4580 to a target the same way, regardless of whether they are source
4581 files or have been built from other files.
4582
4583 build means scons decides that a target file has changed if it
4584 has been rebuilt in this invocation or if its content or time‐
4585 stamp have changed as specified by the corresponding SourceSig‐
4586 natures() setting. This "propagates" the status of a rebuilt
4587 file so that other "downstream" target files will always be
4588 rebuilt, even if the contents or the timestamp have not changed.
4589
4590 build signatures are fastest because content (or MD5) signatures
4591 take longer to compute, but are more accurate than timestamp
4592 signatures, and can prevent unnecessary "downstream" rebuilds
4593 when a target file is rebuilt to the exact same contents as the
4594 previous build. The source setting provides the most consistent
4595 behavior when other target files may be rebuilt from both source
4596 and target input files. The default value is source.
4597
4598 Because the default setting is source, using SourceSignatures()
4599 is generally preferable to TargetSignatures(), so that the up-
4600 to-date decision will be consistent for all files (or all files
4601 built with a specific construction environment). Use of Tar‐
4602 getSignatures() provides specific control for how built target
4603 files affect their "downstream" dependencies.
4604
4605
4606 Tool(string, [toolpath, **kw])
4607
4608 env.Tool(string, [toolpath, **kw])
4609 The Tool() form of the function returns a callable object that
4610 can be used to initialize a construction environment using the
4611 tools keyword of the Environment() method. The object may be
4612 called with a construction environment as an argument, in which
4613 case the object will add the necessary variables to the con‐
4614 struction environment and the name of the tool will be added to
4615 the $TOOLS construction variable.
4616
4617 Additional keyword arguments are passed to the tool's generate()
4618 method.
4619
4620 Examples:
4621
4622 env = Environment(tools = [ Tool('msvc') ])
4623
4624 env = Environment()
4625 t = Tool('msvc')
4626 t(env) # adds 'msvc' to the TOOLS variable
4627 u = Tool('opengl', toolpath = ['tools'])
4628 u(env) # adds 'opengl' to the TOOLS variable
4629
4630 The env.Tool() form of the function applies the callable object
4631 for the specified tool string to the environment through which
4632 the method was called.
4633
4634 Additional keyword arguments are passed to the tool's generate()
4635 method.
4636
4637 env.Tool('gcc')
4638 env.Tool('opengl', toolpath = ['build/tools'])
4639
4640
4641 Value(value, [built_value])
4642
4643 env.Value(value, [built_value])
4644 Returns a Node object representing the specified Python value.
4645 Value Nodes can be used as dependencies of targets. If the
4646 result of calling str(value) changes between SCons runs, any
4647 targets depending on Value(value) will be rebuilt. (This is
4648 true even when using timestamps to decide if files are up-to-
4649 date.) When using timestamp source signatures, Value Nodes'
4650 timestamps are equal to the system time when the Node is cre‐
4651 ated.
4652
4653 The returned Value Node object has a write() method that can be
4654 used to "build" a Value Node by setting a new value. The
4655 optional built_value argument can be specified when the Value
4656 Node is created to indicate the Node should already be consid‐
4657 ered "built." There is a corresponding read() method that will
4658 return the built value of the Node.
4659
4660 Examples:
4661
4662 env = Environment()
4663
4664 def create(target, source, env):
4665 # A function that will write a 'prefix=$SOURCE'
4666 # string into the file name specified as the
4667 # $TARGET.
4668 f = open(str(target[0]), 'wb')
4669 f.write('prefix=' + source[0].get_contents())
4670
4671 # Fetch the prefix= argument, if any, from the command
4672 # line, and use /usr/local as the default.
4673 prefix = ARGUMENTS.get('prefix', '/usr/local')
4674
4675 # Attach a .Config() builder for the above function action
4676 # to the construction environment.
4677 env['BUILDERS']['Config'] = Builder(action = create)
4678 env.Config(target = 'package-config', source = Value(prefix))
4679
4680 def build_value(target, source, env):
4681 # A function that "builds" a Python Value by updating
4682 # the the Python value with the contents of the file
4683 # specified as the source of the Builder call ($SOURCE).
4684 target[0].write(source[0].get_contents())
4685
4686 output = env.Value('before')
4687 input = env.Value('after')
4688
4689 # Attach a .UpdateValue() builder for the above function
4690 # action to the construction environment.
4691 env['BUILDERS']['UpdateValue'] = Builder(action = build_value)
4692 env.UpdateValue(target = Value(output), source = Value(input))
4693
4694
4695 VariantDir(variant_dir, src_dir, [duplicate])
4696
4697 env.VariantDir(variant_dir, src_dir, [duplicate])
4698 Use the VariantDir() function to create a copy of your sources
4699 in another location: if a name under variant_dir is not found
4700 but exists under src_dir, the file or directory is copied to
4701 variant_dir. Target files can be built in a different directory
4702 than the original sources by simply refering to the sources (and
4703 targets) within the variant tree.
4704
4705 VariantDir() can be called multiple times with the same src_dir
4706 to set up multiple builds with different options (variants).
4707 The src_dir location must be in or underneath the SConstruct
4708 file's directory, and variant_dir may not be underneath src_dir.
4709
4710 The default behavior is for scons to physically duplicate the
4711 source files in the variant tree. Thus, a build performed in
4712 the variant tree is guaranteed to be identical to a build per‐
4713 formed in the source tree even if intermediate source files are
4714 generated during the build, or preprocessors or other scanners
4715 search for included files relative to the source file, or indi‐
4716 vidual compilers or other invoked tools are hard-coded to put
4717 derived files in the same directory as source files.
4718
4719 If possible on the platform, the duplication is performed by
4720 linking rather than copying; see also the --duplicate command-
4721 line option. Moreover, only the files needed for the build are
4722 duplicated; files and directories that are not used are not
4723 present in variant_dir.
4724
4725 Duplicating the source tree may be disabled by setting the
4726 duplicate argument to 0 (zero). This will cause scons to invoke
4727 Builders using the path names of source files in src_dir and the
4728 path names of derived files within variant_dir. This is always
4729 more efficient than duplicate=1, and is usually safe for most
4730 builds (but see above for cases that may cause problems).
4731
4732 Note that VariantDir() works most naturally with a subsidiary
4733 SConscript file. However, you would then call the subsidiary
4734 SConscript file not in the source directory, but in the vari‐
4735 ant_dir, regardless of the value of duplicate. This is how you
4736 tell scons which variant of a source tree to build:
4737
4738 # run src/SConscript in two variant directories
4739 VariantDir('build/variant1', 'src')
4740 SConscript('build/variant1/SConscript')
4741 VariantDir('build/variant2', 'src')
4742 SConscript('build/variant2/SConscript')
4743
4744 See also the SConscript() function, described above, for another
4745 way to specify a variant directory in conjunction with calling a
4746 subsidiary SConscript file.
4747
4748 Examples:
4749
4750 # use names in the build directory, not the source directory
4751 VariantDir('build', 'src', duplicate=0)
4752 Program('build/prog', 'build/source.c')
4753
4754 # this builds both the source and docs in a separate subtree
4755 VariantDir('build', '.', duplicate=0)
4756 SConscript(dirs=['build/src','build/doc'])
4757
4758 # same as previous example, but only uses SConscript
4759 SConscript(dirs='src', variant_dir='build/src', duplicate=0)
4760 SConscript(dirs='doc', variant_dir='build/doc', duplicate=0)
4761
4762
4763 WhereIs(program, [path, pathext, reject])
4764
4765 env.WhereIs(program, [path, pathext, reject])
4766 Searches for the specified executable program, returning the
4767 full path name to the program if it is found, and returning None
4768 if not. Searches the specified path, the value of the calling
4769 environment's PATH (env['ENV']['PATH']), or the user's current
4770 external PATH (os.environ['PATH']) by default. On Windows sys‐
4771 tems, searches for executable programs with any of the file
4772 extensions listed in the specified pathext, the calling environ‐
4773 ment's PATHEXT (env['ENV']['PATHEXT']) or the user's current
4774 PATHEXT (os.environ['PATHEXT']) by default. Will not select any
4775 path name or names in the specified reject list, if any.
4776
4777
4778 SConscript Variables
4779 In addition to the global functions and methods, scons supports a num‐
4780 ber of Python variables that can be used in SConscript files to affect
4781 how you want the build to be performed. These variables may be
4782 accessed from custom Python modules that you import into an SConscript
4783 file by adding the following to the Python module:
4784
4785 from SCons.Script import *
4786
4787
4788 ARGLIST
4789 A list keyword=value arguments specified on the command line.
4790 Each element in the list is a tuple containing the (key‐
4791 word,value) of the argument. The separate keyword and value
4792 elements of the tuple can be accessed by subscripting for ele‐
4793 ment [0] and [1] of the tuple, respectively.
4794
4795 Example:
4796
4797 print "first keyword, value =", ARGLIST[0][0], ARGLIST[0][1]
4798 print "second keyword, value =", ARGLIST[1][0], ARGLIST[1][1]
4799 third_tuple = ARGLIST[2]
4800 print "third keyword, value =", third_tuple[0], third_tuple[1]
4801 for key, value in ARGLIST:
4802 # process key and value
4803
4804
4805 ARGUMENTS
4806 A dictionary of all the keyword=value arguments specified on the
4807 command line. The dictionary is not in order, and if a given
4808 keyword has more than one value assigned to it on the command
4809 line, the last (right-most) value is the one in the ARGUMENTS
4810 dictionary.
4811
4812 Example:
4813
4814 if ARGUMENTS.get('debug', 0):
4815 env = Environment(CCFLAGS = '-g')
4816 else:
4817 env = Environment()
4818
4819
4820 BUILD_TARGETS
4821 A list of the targets which scons will actually try to build,
4822 regardless of whether they were specified on the command line or
4823 via the Default() function or method. The elements of this list
4824 may be strings or nodes, so you should run the list through the
4825 Python str function to make sure any Node path names are con‐
4826 verted to strings.
4827
4828 Because this list may be taken from the list of targets speci‐
4829 fied using the Default() function or method, the contents of the
4830 list may change on each successive call to Default(). See the
4831 DEFAULT_TARGETS list, below, for additional information.
4832
4833 Example:
4834
4835 if 'foo' in BUILD_TARGETS:
4836 print "Don't forget to test the `foo' program!"
4837 if 'special/program' in BUILD_TARGETS:
4838 SConscript('special')
4839
4840 Note that the BUILD_TARGETS list only contains targets expected
4841 listed on the command line or via calls to the Default() func‐
4842 tion or method. It does not contain all dependent targets that
4843 will be built as a result of making the sure the explicitly-
4844 specified targets are up to date.
4845
4846
4847 COMMAND_LINE_TARGETS
4848 A list of the targets explicitly specified on the command line.
4849 If there are no targets specified on the command line, the list
4850 is empty. This can be used, for example, to take specific
4851 actions only when a certain target or targets is explicitly
4852 being built.
4853
4854 Example:
4855
4856 if 'foo' in COMMAND_LINE_TARGETS:
4857 print "Don't forget to test the `foo' program!"
4858 if 'special/program' in COMMAND_LINE_TARGETS:
4859 SConscript('special')
4860
4861
4862 DEFAULT_TARGETS
4863 A list of the target nodes that have been specified using the
4864 Default() function or method. The elements of the list are
4865 nodes, so you need to run them through the Python str function
4866 to get at the path name for each Node.
4867
4868 Example:
4869
4870 print str(DEFAULT_TARGETS[0])
4871 if 'foo' in map(str, DEFAULT_TARGETS):
4872 print "Don't forget to test the `foo' program!"
4873
4874 The contents of the DEFAULT_TARGETS list change on on each suc‐
4875 cessive call to the Default() function:
4876
4877 print map(str, DEFAULT_TARGETS) # originally []
4878 Default('foo')
4879 print map(str, DEFAULT_TARGETS) # now a node ['foo']
4880 Default('bar')
4881 print map(str, DEFAULT_TARGETS) # now a node ['foo', 'bar']
4882 Default(None)
4883 print map(str, DEFAULT_TARGETS) # back to []
4884
4885 Consequently, be sure to use DEFAULT_TARGETS only after you've
4886 made all of your Default() calls, or else simply be careful of
4887 the order of these statements in your SConscript files so that
4888 you don't look for a specific default target before it's actu‐
4889 ally been added to the list.
4890
4891
4892 Construction Variables
4893 A construction environment has an associated dictionary of construction
4894 variables that are used by built-in or user-supplied build rules. Con‐
4895 struction variables must follow the same rules for Python identifiers:
4896 the initial character must be an underscore or letter, followed by any
4897 number of underscores, letters, or digits.
4898
4899 A number of useful construction variables are automatically defined by
4900 scons for each supported platform, and additional construction vari‐
4901 ables can be defined by the user. The following is a list of the auto‐
4902 matically defined construction variables:
4903
4904
4905
4906 AR The static library archiver.
4907
4908
4909 ARCHITECTURE
4910 Specifies the system architecture for which the package is being
4911 built. The default is the system architecture of the machine on
4912 which SCons is running. This is used to fill in the Architec‐
4913 ture: field in an Ipkg control file, and as part of the name of
4914 a generated RPM file.
4915
4916
4917 ARCOM The command line used to generate a static library from object
4918 files.
4919
4920
4921 ARCOMSTR
4922 The string displayed when an object file is generated from an
4923 assembly-language source file. If this is not set, then $ARCOM
4924 (the command line) is displayed.
4925
4926 env = Environment(ARCOMSTR = "Archiving $TARGET")
4927
4928
4929 ARFLAGS
4930 General options passed to the static library archiver.
4931
4932
4933 AS The assembler.
4934
4935
4936 ASCOM The command line used to generate an object file from an assem‐
4937 bly-language source file.
4938
4939
4940 ASCOMSTR
4941 The string displayed when an object file is generated from an
4942 assembly-language source file. If this is not set, then $ASCOM
4943 (the command line) is displayed.
4944
4945 env = Environment(ASCOMSTR = "Assembling $TARGET")
4946
4947
4948 ASFLAGS
4949 General options passed to the assembler.
4950
4951
4952 ASPPCOM
4953 The command line used to assemble an assembly-language source
4954 file into an object file after first running the file through
4955 the C preprocessor. Any options specified in the $ASFLAGS and
4956 $CPPFLAGS construction variables are included on this command
4957 line.
4958
4959
4960 ASPPCOMSTR
4961 The string displayed when an object file is generated from an
4962 assembly-language source file after first running the file
4963 through the C preprocessor. If this is not set, then $ASPPCOM
4964 (the command line) is displayed.
4965
4966 env = Environment(ASPPCOMSTR = "Assembling $TARGET")
4967
4968
4969 ASPPFLAGS
4970 General options when an assembling an assembly-language source
4971 file into an object file after first running the file through
4972 the C preprocessor. The default is to use the value of
4973 $ASFLAGS.
4974
4975
4976 BIBTEX The bibliography generator for the TeX formatter and typesetter
4977 and the LaTeX structured formatter and typesetter.
4978
4979
4980 BIBTEXCOM
4981 The command line used to call the bibliography generator for the
4982 TeX formatter and typesetter and the LaTeX structured formatter
4983 and typesetter.
4984
4985
4986 BIBTEXCOMSTR
4987 The string displayed when generating a bibliography for TeX or
4988 LaTeX. If this is not set, then $BIBTEXCOM (the command line)
4989 is displayed.
4990
4991 env = Environment(BIBTEXCOMSTR = "Generating bibliography $TARGET")
4992
4993
4994 BIBTEXFLAGS
4995 General options passed to the bibliography generator for the TeX
4996 formatter and typesetter and the LaTeX structured formatter and
4997 typesetter.
4998
4999
5000 BITKEEPER
5001 The BitKeeper executable.
5002
5003
5004 BITKEEPERCOM
5005 The command line for fetching source files using BitKeeper.
5006
5007
5008 BITKEEPERCOMSTR
5009 The string displayed when fetching a source file using Bit‐
5010 Keeper. If this is not set, then $BITKEEPERCOM (the command
5011 line) is displayed.
5012
5013
5014 BITKEEPERGET
5015 The command ($BITKEEPER) and subcommand for fetching source
5016 files using BitKeeper.
5017
5018
5019 BITKEEPERGETFLAGS
5020 Options that are passed to the BitKeeper get subcommand.
5021
5022
5023 BUILDERS
5024 A dictionary mapping the names of the builders available through
5025 this environment to underlying Builder objects. Builders named
5026 Alias, CFile, CXXFile, DVI, Library, Object, PDF, PostScript,
5027 and Program are available by default. If you initialize this
5028 variable when an Environment is created:
5029
5030 env = Environment(BUILDERS = {'NewBuilder' : foo})
5031
5032 the default Builders will no longer be available. To use a new
5033 Builder object in addition to the default Builders, add your new
5034 Builder object like this:
5035
5036 env = Environment()
5037 env.Append(BUILDERS = {'NewBuilder' : foo})
5038
5039 or this:
5040
5041 env = Environment()
5042 env['BUILDERS]['NewBuilder'] = foo
5043
5044
5045 CC The C compiler.
5046
5047
5048 CCCOM The command line used to compile a C source file to a (static)
5049 object file. Any options specified in the $CFLAGS, $CCFLAGS and
5050 $CPPFLAGS construction variables are included on this command
5051 line.
5052
5053
5054 CCCOMSTR
5055 The string displayed when a C source file is compiled to a
5056 (static) object file. If this is not set, then $CCCOM (the com‐
5057 mand line) is displayed.
5058
5059 env = Environment(CCCOMSTR = "Compiling static object $TARGET")
5060
5061
5062 CCFLAGS
5063 General options that are passed to the C and C++ compilers.
5064
5065
5066 CCPCHFLAGS
5067 Options added to the compiler command line to support building
5068 with precompiled headers. The default value expands expands to
5069 the appropriate Microsoft Visual C++ command-line options when
5070 the $PCH construction variable is set.
5071
5072
5073 CCPDBFLAGS
5074 Options added to the compiler command line to support storing
5075 debugging information in a Microsoft Visual C++ PDB file. The
5076 default value expands expands to appropriate Microsoft Visual
5077 C++ command-line options when the $PDB construction variable is
5078 set.
5079
5080 The Visual C++ compiler option that SCons uses by default to
5081 generate PDB information is /Z7. This works correctly with par‐
5082 allel (-j) builds because it embeds the debug information in the
5083 intermediate object files, as opposed to sharing a single PDB
5084 file between multiple object files. This is also the only way
5085 to get debug information embedded into a static library. Using
5086 the /Zi instead may yield improved link-time performance,
5087 although parallel builds will no longer work.
5088
5089 You can generate PDB files with the /Zi switch by overriding the
5090 default $CCPDBFLAGS variable as follows:
5091
5092 env['CCPDBFLAGS'] = ['${(PDB and "/Zi /Fd%s" % File(PDB)) or ""}']
5093
5094 An alternative would be to use the /Zi to put the debugging
5095 information in a separate .pdb file for each object file by
5096 overriding the $CCPDBFLAGS variable as follows:
5097
5098 env['CCPDBFLAGS'] = '/Zi /Fd${TARGET}.pdb'
5099
5100
5101 CCVERSION
5102 The version number of the C compiler. This may or may not be
5103 set, depending on the specific C compiler being used.
5104
5105
5106 CFILESUFFIX
5107 The suffix for C source files. This is used by the internal
5108 CFile builder when generating C files from Lex (.l) or YACC (.y)
5109 input files. The default suffix, of course, is .c (lower case).
5110 On case-insensitive systems (like Windows), SCons also treats .C
5111 (upper case) files as C files.
5112
5113
5114 CFLAGS General options that are passed to the C compiler (C only; not
5115 C++).
5116
5117
5118 CHANGE_SPECFILE
5119 A hook for modifying the file that controls the packaging build
5120 (the .spec for RPM, the control for Ipkg, the .wxs for MSI). If
5121 set, the function will be called after the SCons template for
5122 the file has been written. XXX
5123
5124
5125 CHANGED_SOURCES
5126 A reserved variable name that may not be set or used in a con‐
5127 struction environment. (See "Variable Substitution," below.)
5128
5129
5130 CHANGED_TARGETS
5131 A reserved variable name that may not be set or used in a con‐
5132 struction environment. (See "Variable Substitution," below.)
5133
5134
5135 CHANGELOG
5136 The name of a file containing the change log text to be included
5137 in the package. This is included as the %changelog section of
5138 the RPM .spec file.
5139
5140
5141 _concat
5142 A function used to produce variables like $_CPPINCFLAGS. It
5143 takes four or five arguments: a prefix to concatenate onto each
5144 element, a list of elements, a suffix to concatenate onto each
5145 element, an environment for variable interpolation, and an
5146 optional function that will be called to transform the list
5147 before concatenation.
5148
5149 env['_CPPINCFLAGS'] = '$( ${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs)} $)',
5150
5151
5152 CONFIGUREDIR
5153 The name of the directory in which Configure context test files
5154 are written. The default is .sconf_temp in the top-level direc‐
5155 tory containing the SConstruct file.
5156
5157
5158 CONFIGURELOG
5159 The name of the Configure context log file. The default is con‐
5160 fig.log in the top-level directory containing the SConstruct
5161 file.
5162
5163
5164 _CPPDEFFLAGS
5165 An automatically-generated construction variable containing the
5166 C preprocessor command-line options to define values. The value
5167 of $_CPPDEFFLAGS is created by appending $CPPDEFPREFIX and
5168 $CPPDEFSUFFIX to the beginning and end of each definition in
5169 $CPPDEFINES.
5170
5171
5172 CPPDEFINES
5173 A platform independent specification of C preprocessor defini‐
5174 tions. The definitions will be added to command lines through
5175 the automatically-generated $_CPPDEFFLAGS construction variable
5176 (see above), which is constructed according to the type of value
5177 of $CPPDEFINES:
5178
5179 If $CPPDEFINES is a string, the values of the $CPPDEFPRE‐
5180 FIXand$CPPDEFSUFFIX construction variables will be added to the
5181 beginning and end.
5182
5183 # Will add -Dxyz to POSIX compiler command lines,
5184 # and /Dxyz to Microsoft Visual C++ command lines.
5185 env = Environment(CPPDEFINES='xyz')
5186
5187 If $CPPDEFINES is a list, the values of the $CPPDEFPRE‐
5188 FIXand$CPPDEFSUFFIX construction variables will be appended to
5189 the beginning and end of each element in the list. If any ele‐
5190 ment is a list or tuple, then the first item is the name being
5191 defined and the second item is its value:
5192
5193 # Will add -DB=2 -DA to POSIX compiler command lines,
5194 # and /DB=2 /DA to Microsoft Visual C++ command lines.
5195 env = Environment(CPPDEFINES=[('B', 2), 'A'])
5196
5197 If $CPPDEFINES is a dictionary, the values of the $CPPDEFPRE‐
5198 FIXand$CPPDEFSUFFIX construction variables will be appended to
5199 the beginning and end of each item from the dictionary. The key
5200 of each dictionary item is a name being defined to the dictio‐
5201 nary item's corresponding value; if the value is None, then the
5202 name is defined without an explicit value. Note that the
5203 resulting flags are sorted by keyword to ensure that the order
5204 of the options on the command line is consistent each time scons
5205 is run.
5206
5207 # Will add -DA -DB=2 to POSIX compiler command lines,
5208 # and /DA /DB=2 to Microsoft Visual C++ command lines.
5209 env = Environment(CPPDEFINES={'B':2, 'A':None})
5210
5211
5212 CPPDEFPREFIX
5213 The prefix used to specify preprocessor definitions on the C
5214 compiler command line. This will be appended to the beginning
5215 of each definition in the $CPPDEFINES construction variable when
5216 the $_CPPDEFFLAGS variable is automatically generated.
5217
5218
5219 CPPDEFSUFFIX
5220 The suffix used to specify preprocessor definitions on the C
5221 compiler command line. This will be appended to the end of each
5222 definition in the $CPPDEFINES construction variable when the
5223 $_CPPDEFFLAGS variable is automatically generated.
5224
5225
5226 CPPFLAGS
5227 User-specified C preprocessor options. These will be included
5228 in any command that uses the C preprocessor, including not just
5229 compilation of C and C++ source files via the $CCCOM, $SHCCCOM,
5230 $CXXCOM and $SHCXXCOM command lines, but also the $FORTRANPPCOM,
5231 $SHFORTRANPPCOM, $F77PPCOM and $SHF77PPCOM command lines used to
5232 compile a Fortran source file, and the $ASPPCOM command line
5233 used to assemble an assembly language source file, after first
5234 running each file through the C preprocessor. Note that this
5235 variable does not contain -I (or similar) include search path
5236 options that scons generates automatically from $CPPPATH. See
5237 $_CPPINCFLAGS, below, for the variable that expands to those
5238 options.
5239
5240
5241 _CPPINCFLAGS
5242 An automatically-generated construction variable containing the
5243 C preprocessor command-line options for specifying directories
5244 to be searched for include files. The value of $_CPPINCFLAGS is
5245 created by appending $INCPREFIX and $INCSUFFIX to the beginning
5246 and end of each directory in $CPPPATH.
5247
5248
5249 CPPPATH
5250 The list of directories that the C preprocessor will search for
5251 include directories. The C/C++ implicit dependency scanner will
5252 search these directories for include files. Don't explicitly put
5253 include directory arguments in CCFLAGS or CXXFLAGS because the
5254 result will be non-portable and the directories will not be
5255 searched by the dependency scanner. Note: directory names in
5256 CPPPATH will be looked-up relative to the SConscript directory
5257 when they are used in a command. To force scons to look-up a
5258 directory relative to the root of the source tree use #:
5259
5260 env = Environment(CPPPATH='#/include')
5261
5262 The directory look-up can also be forced using the Dir() func‐
5263 tion:
5264
5265 include = Dir('include')
5266 env = Environment(CPPPATH=include)
5267
5268 The directory list will be added to command lines through the
5269 automatically-generated $_CPPINCFLAGS construction variable,
5270 which is constructed by appending the values of the $INCPRE‐
5271 FIXand$INCSUFFIX construction variables to the beginning and end
5272 of each directory in $CPPPATH. Any command lines you define
5273 that need the CPPPATH directory list should include
5274 $_CPPINCFLAGS:
5275
5276 env = Environment(CCCOM="my_compiler $_CPPINCFLAGS -c -o $TARGET $SOURCE")
5277
5278
5279 CPPSUFFIXES
5280 The list of suffixes of files that will be scanned for C pre‐
5281 processor implicit dependencies (#include lines). The default
5282 list is:
5283
5284 [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
5285 ".h", ".H", ".hxx", ".hpp", ".hh",
5286 ".F", ".fpp", ".FPP",
5287 ".m", ".mm",
5288 ".S", ".spp", ".SPP"]
5289
5290
5291 CVS The CVS executable.
5292
5293
5294 CVSCOFLAGS
5295 Options that are passed to the CVS checkout subcommand.
5296
5297
5298 CVSCOM The command line used to fetch source files from a CVS reposi‐
5299 tory.
5300
5301
5302 CVSCOMSTR
5303 The string displayed when fetching a source file from a CVS
5304 repository. If this is not set, then $CVSCOM (the command line)
5305 is displayed.
5306
5307
5308 CVSFLAGS
5309 General options that are passed to CVS. By default, this is set
5310 to -d $CVSREPOSITORY to specify from where the files must be
5311 fetched.
5312
5313
5314 CVSREPOSITORY
5315 The path to the CVS repository. This is referenced in the
5316 default $CVSFLAGS value.
5317
5318
5319 CXX The C++ compiler.
5320
5321
5322 CXXCOM The command line used to compile a C++ source file to an object
5323 file. Any options specified in the $CXXFLAGS and $CPPFLAGS con‐
5324 struction variables are included on this command line.
5325
5326
5327 CXXCOMSTR
5328 The string displayed when a C++ source file is compiled to a
5329 (static) object file. If this is not set, then $CXXCOM (the
5330 command line) is displayed.
5331
5332 env = Environment(CXXCOMSTR = "Compiling static object $TARGET")
5333
5334
5335 CXXFILESUFFIX
5336 The suffix for C++ source files. This is used by the internal
5337 CXXFile builder when generating C++ files from Lex (.ll) or YACC
5338 (.yy) input files. The default suffix is .cc. SCons also
5339 treats files with the suffixes .cpp, .cxx, .c++, and .C++ as C++
5340 files, and files with .mm suffixes as Objective C++ files. On
5341 case-sensitive systems (Linux, UNIX, and other POSIX-alikes),
5342 SCons also treats .C (upper case) files as C++ files.
5343
5344
5345 CXXFLAGS
5346 General options that are passed to the C++ compiler. By
5347 default, this includes the value of $CCFLAGS, so that setting
5348 $CCFLAGS affects both C and C++ compilation. If you want to add
5349 C++-specific flags, you must set or override the value of
5350 $CXXFLAGS.
5351
5352
5353 CXXVERSION
5354 The version number of the C++ compiler. This may or may not be
5355 set, depending on the specific C++ compiler being used.
5356
5357
5358 DESCRIPTION
5359 A long description of the project being packaged. This is
5360 included in the relevant section of the file that controls the
5361 packaging build.
5362
5363
5364 DESCRIPTION_lang
5365 A language-specific long description for the specified lang.
5366 This is used to populate a %description -l section of an RPM
5367 .spec file.
5368
5369
5370 Dir A function that converts a string into a Dir instance relative
5371 to the target being built.
5372
5373
5374 Dirs A function that converts a list of strings into a list of Dir
5375 instances relative to the target being built.
5376
5377
5378 DSUFFIXES
5379 The list of suffixes of files that will be scanned for imported
5380 D package files. The default list is:
5381
5382 ['.d']
5383
5384
5385 DVIPDF The TeX DVI file to PDF file converter.
5386
5387
5388 DVIPDFCOM
5389 The command line used to convert TeX DVI files into a PDF file.
5390
5391
5392 DVIPDFCOMSTR
5393 The string displayed when a TeX DVI file is converted into a PDF
5394 file. If this is not set, then $DVIPDFCOM (the command line) is
5395 displayed.
5396
5397
5398 DVIPDFFLAGS
5399 General options passed to the TeX DVI file to PDF file con‐
5400 verter.
5401
5402
5403 DVIPS The TeX DVI file to PostScript converter.
5404
5405
5406 DVIPSFLAGS
5407 General options passed to the TeX DVI file to PostScript con‐
5408 verter.
5409
5410
5411 ENV A dictionary of environment variables to use when invoking com‐
5412 mands. When $ENV is used in a command all list values will be
5413 joined using the path separator and any other non-string values
5414 will simply be coerced to a string. Note that, by default,
5415 scons does not propagate the environment in force when you exe‐
5416 cute scons to the commands used to build target files. This is
5417 so that builds will be guaranteed repeatable regardless of the
5418 environment variables set at the time scons is invoked.
5419
5420 If you want to propagate your environment variables to the com‐
5421 mands executed to build target files, you must do so explicitly:
5422
5423 import os
5424 env = Environment(ENV = os.environ)
5425
5426 Note that you can choose only to propagate certain environment
5427 variables. A common example is the system PATH environment
5428 variable, so that scons uses the same utilities as the invoking
5429 shell (or other process):
5430
5431 import os
5432 env = Environment(ENV = {'PATH' : os.environ['PATH']})
5433
5434
5435 ESCAPE A function that will be called to escape shell special charac‐
5436 ters in command lines. The function should take one argument:
5437 the command line string to escape; and should return the escaped
5438 command line.
5439
5440
5441 F77 The Fortran 77 compiler. You should normally set the $FORTRAN
5442 variable, which specifies the default Fortran compiler for all
5443 Fortran versions. You only need to set $F77 if you need to use
5444 a specific compiler or compiler version for Fortran 77 files.
5445
5446
5447 F77COM The command line used to compile a Fortran 77 source file to an
5448 object file. You only need to set $F77COM if you need to use a
5449 specific command line for Fortran 77 files. You should normally
5450 set the $FORTRANCOM variable, which specifies the default com‐
5451 mand line for all Fortran versions.
5452
5453
5454 F77COMSTR
5455 The string displayed when a Fortran 77 source file is compiled
5456 to an object file. If this is not set, then $F77COM or $FOR‐
5457 TRANCOM (the command line) is displayed.
5458
5459
5460 F77FILESUFFIXES
5461 The list of file extensions for which the F77 dialect will be
5462 used. By default, this is ['.f77']
5463
5464
5465 F77FLAGS
5466 General user-specified options that are passed to the Fortran 77
5467 compiler. Note that this variable does not contain -I (or simi‐
5468 lar) include search path options that scons generates automati‐
5469 cally from $F77PATH. See $_F77INCFLAGS below, for the variable
5470 that expands to those options. You only need to set $F77FLAGS
5471 if you need to define specific user options for Fortran 77
5472 files. You should normally set the $FORTRANFLAGS variable,
5473 which specifies the user-specified options passed to the default
5474 Fortran compiler for all Fortran versions.
5475
5476
5477 _F77INCFLAGS
5478 An automatically-generated construction variable containing the
5479 Fortran 77 compiler command-line options for specifying directo‐
5480 ries to be searched for include files. The value of
5481 $_F77INCFLAGS is created by appending $INCPREFIX and $INCSUFFIX
5482 to the beginning and end of each directory in $F77PATH.
5483
5484
5485 F77PATH
5486 The list of directories that the Fortran 77 compiler will search
5487 for include directories. The implicit dependency scanner will
5488 search these directories for include files. Don't explicitly put
5489 include directory arguments in $F77FLAGS because the result will
5490 be non-portable and the directories will not be searched by the
5491 dependency scanner. Note: directory names in $F77PATH will be
5492 looked-up relative to the SConscript directory when they are
5493 used in a command. To force scons to look-up a directory rela‐
5494 tive to the root of the source tree use #: You only need to set
5495 $F77PATH if you need to define a specific include path for For‐
5496 tran 77 files. You should normally set the $FORTRANPATH vari‐
5497 able, which specifies the include path for the default Fortran
5498 compiler for all Fortran versions.
5499
5500 env = Environment(F77PATH='#/include')
5501
5502 The directory look-up can also be forced using the Dir() func‐
5503 tion:
5504
5505 include = Dir('include')
5506 env = Environment(F77PATH=include)
5507
5508 The directory list will be added to command lines through the
5509 automatically-generated $_F77INCFLAGS construction variable,
5510 which is constructed by appending the values of the $INCPRE‐
5511 FIXand$INCSUFFIX construction variables to the beginning and end
5512 of each directory in $F77PATH. Any command lines you define
5513 that need the F77PATH directory list should include
5514 $_F77INCFLAGS:
5515
5516 env = Environment(F77COM="my_compiler $_F77INCFLAGS -c -o $TARGET $SOURCE")
5517
5518
5519 F77PPCOM
5520 The command line used to compile a Fortran 77 source file to an
5521 object file after first running the file through the C pre‐
5522 processor. Any options specified in the $F77FLAGS and $CPPFLAGS
5523 construction variables are included on this command line. You
5524 only need to set $F77PPCOM if you need to use a specific C-pre‐
5525 processor command line for Fortran 77 files. You should nor‐
5526 mally set the $FORTRANPPCOM variable, which specifies the
5527 default C-preprocessor command line for all Fortran versions.
5528
5529
5530 F77PPCOMSTR
5531 The string displayed when a Fortran 77 source file is compiled
5532 to an object file after first running the file through the C
5533 preprocessor. If this is not set, then $F77PPCOM or $FORTRANPP‐
5534 COM (the command line) is displayed.
5535
5536
5537 F77PPFILESUFFIXES
5538 The list of file extensions for which the compilation + pre‐
5539 processor pass for F77 dialect will be used. By default, this is
5540 empty
5541
5542
5543 F90 The Fortran 90 compiler. You should normally set the $FORTRAN
5544 variable, which specifies the default Fortran compiler for all
5545 Fortran versions. You only need to set $F90 if you need to use
5546 a specific compiler or compiler version for Fortran 90 files.
5547
5548
5549 F90COM The command line used to compile a Fortran 90 source file to an
5550 object file. You only need to set $F90COM if you need to use a
5551 specific command line for Fortran 90 files. You should normally
5552 set the $FORTRANCOM variable, which specifies the default com‐
5553 mand line for all Fortran versions.
5554
5555
5556 F90COMSTR
5557 The string displayed when a Fortran 90 source file is compiled
5558 to an object file. If this is not set, then $F90COM or $FOR‐
5559 TRANCOM (the command line) is displayed.
5560
5561
5562 F90FILESUFFIXES
5563 The list of file extensions for which the F90 dialect will be
5564 used. By default, this is ['.f90']
5565
5566
5567 F90FLAGS
5568 General user-specified options that are passed to the Fortran 90
5569 compiler. Note that this variable does not contain -I (or simi‐
5570 lar) include search path options that scons generates automati‐
5571 cally from $F90PATH. See $_F90INCFLAGS below, for the variable
5572 that expands to those options. You only need to set $F90FLAGS
5573 if you need to define specific user options for Fortran 90
5574 files. You should normally set the $FORTRANFLAGS variable,
5575 which specifies the user-specified options passed to the default
5576 Fortran compiler for all Fortran versions.
5577
5578
5579 _F90INCFLAGS
5580 An automatically-generated construction variable containing the
5581 Fortran 90 compiler command-line options for specifying directo‐
5582 ries to be searched for include files. The value of
5583 $_F90INCFLAGS is created by appending $INCPREFIX and $INCSUFFIX
5584 to the beginning and end of each directory in $F90PATH.
5585
5586
5587 F90PATH
5588 The list of directories that the Fortran 90 compiler will search
5589 for include directories. The implicit dependency scanner will
5590 search these directories for include files. Don't explicitly put
5591 include directory arguments in $F90FLAGS because the result will
5592 be non-portable and the directories will not be searched by the
5593 dependency scanner. Note: directory names in $F90PATH will be
5594 looked-up relative to the SConscript directory when they are
5595 used in a command. To force scons to look-up a directory rela‐
5596 tive to the root of the source tree use #: You only need to set
5597 $F90PATH if you need to define a specific include path for For‐
5598 tran 90 files. You should normally set the $FORTRANPATH vari‐
5599 able, which specifies the include path for the default Fortran
5600 compiler for all Fortran versions.
5601
5602 env = Environment(F90PATH='#/include')
5603
5604 The directory look-up can also be forced using the Dir() func‐
5605 tion:
5606
5607 include = Dir('include')
5608 env = Environment(F90PATH=include)
5609
5610 The directory list will be added to command lines through the
5611 automatically-generated $_F90INCFLAGS construction variable,
5612 which is constructed by appending the values of the $INCPRE‐
5613 FIXand$INCSUFFIX construction variables to the beginning and end
5614 of each directory in $F90PATH. Any command lines you define
5615 that need the F90PATH directory list should include
5616 $_F90INCFLAGS:
5617
5618 env = Environment(F90COM="my_compiler $_F90INCFLAGS -c -o $TARGET $SOURCE")
5619
5620
5621 F90PPCOM
5622 The command line used to compile a Fortran 90 source file to an
5623 object file after first running the file through the C pre‐
5624 processor. Any options specified in the $F90FLAGS and $CPPFLAGS
5625 construction variables are included on this command line. You
5626 only need to set $F90PPCOM if you need to use a specific C-pre‐
5627 processor command line for Fortran 90 files. You should nor‐
5628 mally set the $FORTRANPPCOM variable, which specifies the
5629 default C-preprocessor command line for all Fortran versions.
5630
5631
5632 F90PPCOMSTR
5633 The string displayed when a Fortran 90 source file is compiled
5634 after first running the file through the C preprocessor. If
5635 this is not set, then $F90PPCOM or $FORTRANPPCOM (the command
5636 line) is displayed.
5637
5638
5639 F90PPFILESUFFIXES
5640 The list of file extensions for which the compilation + pre‐
5641 processor pass for F90 dialect will be used. By default, this is
5642 empty
5643
5644
5645 F95 The Fortran 95 compiler. You should normally set the $FORTRAN
5646 variable, which specifies the default Fortran compiler for all
5647 Fortran versions. You only need to set $F95 if you need to use
5648 a specific compiler or compiler version for Fortran 95 files.
5649
5650
5651 F95COM The command line used to compile a Fortran 95 source file to an
5652 object file. You only need to set $F95COM if you need to use a
5653 specific command line for Fortran 95 files. You should normally
5654 set the $FORTRANCOM variable, which specifies the default com‐
5655 mand line for all Fortran versions.
5656
5657
5658 F95COMSTR
5659 The string displayed when a Fortran 95 source file is compiled
5660 to an object file. If this is not set, then $F95COM or $FOR‐
5661 TRANCOM (the command line) is displayed.
5662
5663
5664 F95FILESUFFIXES
5665 The list of file extensions for which the F95 dialect will be
5666 used. By default, this is ['.f95']
5667
5668
5669 F95FLAGS
5670 General user-specified options that are passed to the Fortran 95
5671 compiler. Note that this variable does not contain -I (or simi‐
5672 lar) include search path options that scons generates automati‐
5673 cally from $F95PATH. See $_F95INCFLAGS below, for the variable
5674 that expands to those options. You only need to set $F95FLAGS
5675 if you need to define specific user options for Fortran 95
5676 files. You should normally set the $FORTRANFLAGS variable,
5677 which specifies the user-specified options passed to the default
5678 Fortran compiler for all Fortran versions.
5679
5680
5681 _F95INCFLAGS
5682 An automatically-generated construction variable containing the
5683 Fortran 95 compiler command-line options for specifying directo‐
5684 ries to be searched for include files. The value of
5685 $_F95INCFLAGS is created by appending $INCPREFIX and $INCSUFFIX
5686 to the beginning and end of each directory in $F95PATH.
5687
5688
5689 F95PATH
5690 The list of directories that the Fortran 95 compiler will search
5691 for include directories. The implicit dependency scanner will
5692 search these directories for include files. Don't explicitly put
5693 include directory arguments in $F95FLAGS because the result will
5694 be non-portable and the directories will not be searched by the
5695 dependency scanner. Note: directory names in $F95PATH will be
5696 looked-up relative to the SConscript directory when they are
5697 used in a command. To force scons to look-up a directory rela‐
5698 tive to the root of the source tree use #: You only need to set
5699 $F95PATH if you need to define a specific include path for For‐
5700 tran 95 files. You should normally set the $FORTRANPATH vari‐
5701 able, which specifies the include path for the default Fortran
5702 compiler for all Fortran versions.
5703
5704 env = Environment(F95PATH='#/include')
5705
5706 The directory look-up can also be forced using the Dir() func‐
5707 tion:
5708
5709 include = Dir('include')
5710 env = Environment(F95PATH=include)
5711
5712 The directory list will be added to command lines through the
5713 automatically-generated $_F95INCFLAGS construction variable,
5714 which is constructed by appending the values of the $INCPRE‐
5715 FIXand$INCSUFFIX construction variables to the beginning and end
5716 of each directory in $F95PATH. Any command lines you define
5717 that need the F95PATH directory list should include
5718 $_F95INCFLAGS:
5719
5720 env = Environment(F95COM="my_compiler $_F95INCFLAGS -c -o $TARGET $SOURCE")
5721
5722
5723 F95PPCOM
5724 The command line used to compile a Fortran 95 source file to an
5725 object file after first running the file through the C pre‐
5726 processor. Any options specified in the $F95FLAGS and $CPPFLAGS
5727 construction variables are included on this command line. You
5728 only need to set $F95PPCOM if you need to use a specific C-pre‐
5729 processor command line for Fortran 95 files. You should nor‐
5730 mally set the $FORTRANPPCOM variable, which specifies the
5731 default C-preprocessor command line for all Fortran versions.
5732
5733
5734 F95PPCOMSTR
5735 The string displayed when a Fortran 95 source file is compiled
5736 to an object file after first running the file through the C
5737 preprocessor. If this is not set, then $F95PPCOM or $FORTRANPP‐
5738 COM (the command line) is displayed.
5739
5740
5741 F95PPFILESUFFIXES
5742 The list of file extensions for which the compilation + pre‐
5743 processor pass for F95 dialect will be used. By default, this is
5744 empty
5745
5746
5747 File A function that converts a string into a File instance relative
5748 to the target being built.
5749
5750
5751 FORTRAN
5752 The default Fortran compiler for all versions of Fortran.
5753
5754
5755 FORTRANCOM
5756 The command line used to compile a Fortran source file to an
5757 object file. By default, any options specified in the $FORTRAN‐
5758 FLAGS, $CPPFLAGS, $_CPPDEFFLAGS, $_FORTRANMODFLAG, and $_FOR‐
5759 TRANINCFLAGS construction variables are included on this command
5760 line.
5761
5762
5763 FORTRANCOMSTR
5764 The string displayed when a Fortran source file is compiled to
5765 an object file. If this is not set, then $FORTRANCOM (the com‐
5766 mand line) is displayed.
5767
5768
5769 FORTRANFILESUFFIXES
5770 The list of file extensions for which the FORTRAN dialect will
5771 be used. By default, this is ['.f', '.for', '.ftn']
5772
5773
5774 FORTRANFLAGS
5775 General user-specified options that are passed to the Fortran
5776 compiler. Note that this variable does not contain -I (or simi‐
5777 lar) include or module search path options that scons generates
5778 automatically from $FORTRANPATH. See $_FORTRANINCFLAGSand$_FOR‐
5779 TRANMODFLAG, below, for the variables that expand those options.
5780
5781
5782 _FORTRANINCFLAGS
5783 An automatically-generated construction variable containing the
5784 Fortran compiler command-line options for specifying directories
5785 to be searched for include files and module files. The value of
5786 $_FORTRANINCFLAGS is created by prepending/appending $INCPREFIX
5787 and $INCSUFFIX to the beginning and end of each directory in
5788 $FORTRANPATH.
5789
5790
5791 FORTRANMODDIR
5792 Directory location where the Fortran compiler should place any
5793 module files it generates. This variable is empty, by default.
5794 Some Fortran compilers will internally append this directory in
5795 the search path for module files, as well.
5796
5797
5798 FORTRANMODDIRPREFIX
5799 The prefix used to specify a module directory on the Fortran
5800 compiler command line. This will be appended to the beginning
5801 of the directory in the $FORTRANMODDIR construction variables
5802 when the $_FORTRANMODFLAG variables is automatically generated.
5803
5804
5805 FORTRANMODDIRSUFFIX
5806 The suffix used to specify a module directory on the Fortran
5807 compiler command line. This will be appended to the beginning
5808 of the directory in the $FORTRANMODDIR construction variables
5809 when the $_FORTRANMODFLAG variables is automatically generated.
5810
5811
5812 _FORTRANMODFLAG
5813 An automatically-generated construction variable containing the
5814 Fortran compiler command-line option for specifying the direc‐
5815 tory location where the Fortran compiler should place any module
5816 files that happen to get generated during compilation. The
5817 value of $_FORTRANMODFLAG is created by prepending/appending
5818 $FORTRANMODDIRPREFIX and $FORTRANMODDIRSUFFIX to the beginning
5819 and end of the directory in $FORTRANMODDIR.
5820
5821
5822 FORTRANMODPREFIX
5823 The module file prefix used by the Fortran compiler. SCons
5824 assumes that the Fortran compiler follows the quasi-standard
5825 naming convention for module files of module_name.mod. As a
5826 result, this variable is left empty, by default. For situations
5827 in which the compiler does not necessarily follow the normal
5828 convention, the user may use this variable. Its value will be
5829 appended to every module file name as scons attempts to resolve
5830 dependencies.
5831
5832
5833 FORTRANMODSUFFIX
5834 The module file suffix used by the Fortran compiler. SCons
5835 assumes that the Fortran compiler follows the quasi-standard
5836 naming convention for module files of module_name.mod. As a
5837 result, this variable is set to ".mod", by default. For situa‐
5838 tions in which the compiler does not necessarily follow the nor‐
5839 mal convention, the user may use this variable. Its value will
5840 be appended to every module file name as scons attempts to
5841 resolve dependencies.
5842
5843
5844 FORTRANPATH
5845 The list of directories that the Fortran compiler will search
5846 for include files and (for some compilers) module files. The
5847 Fortran implicit dependency scanner will search these directo‐
5848 ries for include files (but not module files since they are
5849 autogenerated and, as such, may not actually exist at the time
5850 the scan takes place). Don't explicitly put include directory
5851 arguments in FORTRANFLAGS because the result will be non-porta‐
5852 ble and the directories will not be searched by the dependency
5853 scanner. Note: directory names in FORTRANPATH will be looked-up
5854 relative to the SConscript directory when they are used in a
5855 command. To force scons to look-up a directory relative to the
5856 root of the source tree use #:
5857
5858 env = Environment(FORTRANPATH='#/include')
5859
5860 The directory look-up can also be forced using the Dir() func‐
5861 tion:
5862
5863 include = Dir('include')
5864 env = Environment(FORTRANPATH=include)
5865
5866 The directory list will be added to command lines through the
5867 automatically-generated $_FORTRANINCFLAGS construction variable,
5868 which is constructed by appending the values of the $INCPRE‐
5869 FIXand$INCSUFFIX construction variables to the beginning and end
5870 of each directory in $FORTRANPATH. Any command lines you define
5871 that need the FORTRANPATH directory list should include $_FOR‐
5872 TRANINCFLAGS:
5873
5874 env = Environment(FORTRANCOM="my_compiler $_FORTRANINCFLAGS -c -o $TARGET $SOURCE")
5875
5876
5877 FORTRANPPCOM
5878 The command line used to compile a Fortran source file to an
5879 object file after first running the file through the C pre‐
5880 processor. By default, any options specified in the $FORTRAN‐
5881 FLAGS, $CPPFLAGS, $_CPPDEFFLAGS, $_FORTRANMODFLAG, and $_FOR‐
5882 TRANINCFLAGS construction variables are included on this command
5883 line.
5884
5885
5886 FORTRANPPCOMSTR
5887 The string displayed when a Fortran source file is compiled to
5888 an object file after first running the file through the C pre‐
5889 processor. If this is not set, then $FORTRANPPCOM (the command
5890 line) is displayed.
5891
5892
5893 FORTRANPPFILESUFFIXES
5894 The list of file extensions for which the compilation + pre‐
5895 processor pass for FORTRAN dialect will be used. By default,
5896 this is ['.fpp', '.FPP']
5897
5898
5899 FORTRANSUFFIXES
5900 The list of suffixes of files that will be scanned for Fortran
5901 implicit dependencies (INCLUDE lines and USE statements). The
5902 default list is:
5903
5904 [".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
5905 ".f77", ".F77", ".f90", ".F90", ".f95", ".F95"]
5906
5907
5908 FRAMEWORKPATH
5909 On Mac OS X with gcc, a list containing the paths to search for
5910 frameworks. Used by the compiler to find framework-style
5911 includes like #include <Fmwk/Header.h>. Used by the linker to
5912 find user-specified frameworks when linking (see $FRAMEWORKS).
5913 For example:
5914
5915 env.AppendUnique(FRAMEWORKPATH='#myframeworkdir')
5916
5917 will add
5918
5919 ... -Fmyframeworkdir
5920
5921 to the compiler and linker command lines.
5922
5923
5924 _FRAMEWORKPATH
5925 On Mac OS X with gcc, an automatically-generated construction
5926 variable containing the linker command-line options correspond‐
5927 ing to $FRAMEWORKPATH.
5928
5929
5930 FRAMEWORKPATHPREFIX
5931 On Mac OS X with gcc, the prefix to be used for the FRAMEWORK‐
5932 PATH entries. (see $FRAMEWORKPATH). The default value is -F.
5933
5934
5935 FRAMEWORKPREFIX
5936 On Mac OS X with gcc, the prefix to be used for linking in
5937 frameworks (see $FRAMEWORKS). The default value is -framework.
5938
5939
5940 _FRAMEWORKS
5941 On Mac OS X with gcc, an automatically-generated construction
5942 variable containing the linker command-line options for linking
5943 with FRAMEWORKS.
5944
5945
5946 FRAMEWORKS
5947 On Mac OS X with gcc, a list of the framework names to be linked
5948 into a program or shared library or bundle. The default value
5949 is the empty list. For example:
5950
5951 env.AppendUnique(FRAMEWORKS=Split('System Cocoa SystemConfiguration'))
5952
5953 FRAMEWORKSFLAGS
5954 On Mac OS X with gcc, general user-supplied frameworks options
5955 to be added at the end of a command line building a loadable
5956 module. (This has been largely superseded by the $FRAMEWORK‐
5957 PATH, $FRAMEWORKPATHPREFIX, $FRAMEWORKPREFIX and $FRAMEWORKS
5958 variables described above.)
5959
5960
5961 GS The Ghostscript program used to convert PostScript to PDF files.
5962
5963
5964 GSCOM The Ghostscript command line used to convert PostScript to PDF
5965 files.
5966
5967
5968 GSCOMSTR
5969 The string displayed when Ghostscript is used to convert a Post‐
5970 Script file to a PDF file. If this is not set, then $GSCOM (the
5971 command line) is displayed.
5972
5973
5974 GSFLAGS
5975 General options passed to the Ghostscript program when convert‐
5976 ing PostScript to PDF files.
5977
5978
5979 HOST_ARCH
5980 Sets the host architecture for Visual Studio compiler. If not
5981 set, default to the detected host architecture: note that this
5982 may depend on the python you are using. This variable must be
5983 passed as an argument to the Environment() constructor; setting
5984 it later has no effect.
5985
5986 Valid values are the same as for $TARGET_ARCH.
5987
5988 This is currently only used on Windows, but in the future it
5989 will be used on other OSes as well.
5990
5991
5992 HOST_OS
5993 The name of the host operating system used to create the
5994 Environment.
5995 If a platform is specified when creating the Environ‐
5996 ment, then
5997 that Platform's logic will handle setting this value.
5998 This value is immutable, and should not be changed by
5999 the user after
6000 the Environment is initialized.
6001 Currently only set for Win32.
6002
6003
6004 IDLSUFFIXES
6005 The list of suffixes of files that will be scanned for IDL
6006 implicit dependencies (#include or import lines). The default
6007 list is:
6008
6009 [".idl", ".IDL"]
6010
6011
6012 IMPLICIT_COMMAND_DEPENDENCIES
6013 Controls whether or not SCons will add implicit dependencies for
6014 the commands executed to build targets.
6015
6016 By default, SCons will add to each target an implicit dependency
6017 on the command represented by the first argument on any command
6018 line it executes. The specific file for the dependency is found
6019 by searching the PATH variable in the ENV environment used to
6020 execute the command.
6021
6022 If the construction variable $IMPLICIT_COMMAND_DEPENDENCIES is
6023 set to a false value (None, False, 0, etc.), then the implicit
6024 dependency will not be added to the targets built with that con‐
6025 struction environment.
6026
6027 env = Environment(IMPLICIT_COMMAND_DEPENDENCIES = 0)
6028
6029
6030 INCPREFIX
6031 The prefix used to specify an include directory on the C com‐
6032 piler command line. This will be appended to the beginning of
6033 each directory in the $CPPPATH and $FORTRANPATH construction
6034 variables when the $_CPPINCFLAGS and $_FORTRANINCFLAGS variables
6035 are automatically generated.
6036
6037
6038 INCSUFFIX
6039 The suffix used to specify an include directory on the C com‐
6040 piler command line. This will be appended to the end of each
6041 directory in the $CPPPATH and $FORTRANPATH construction vari‐
6042 ables when the $_CPPINCFLAGS and $_FORTRANINCFLAGS variables are
6043 automatically generated.
6044
6045
6046 INSTALL
6047 A function to be called to install a file into a destination
6048 file name. The default function copies the file into the desti‐
6049 nation (and sets the destination file's mode and permission bits
6050 to match the source file's). The function takes the following
6051 arguments:
6052
6053 def install(dest, source, env):
6054
6055 dest is the path name of the destination file. source is the
6056 path name of the source file. env is the construction environ‐
6057 ment (a dictionary of construction values) in force for this
6058 file installation.
6059
6060
6061 INSTALLSTR
6062 The string displayed when a file is installed into a destination
6063 file name. The default is:
6064 Install file: "$SOURCE" as "$TARGET"
6065
6066
6067 INTEL_C_COMPILER_VERSION
6068 Set by the "intelc" Tool to the major version number of the
6069 Intel C compiler selected for use.
6070
6071
6072 JAR The Java archive tool.
6073
6074
6075 JARCHDIR
6076 The directory to which the Java archive tool should change
6077 (using the -C option).
6078
6079
6080 JARCOM The command line used to call the Java archive tool.
6081
6082
6083 JARCOMSTR
6084 The string displayed when the Java archive tool is called If
6085 this is not set, then $JARCOM (the command line) is displayed.
6086
6087 env = Environment(JARCOMSTR = "JARchiving $SOURCES into $TARGET")
6088
6089
6090 JARFLAGS
6091 General options passed to the Java archive tool. By default
6092 this is set to cf to create the necessary jar file.
6093
6094
6095 JARSUFFIX
6096 The suffix for Java archives: .jar by default.
6097
6098
6099 JAVABOOTCLASSPATH
6100 Specifies the list of directories that will be added to the
6101 &javac; command line via the -bootclasspath option. The indi‐
6102 vidual directory names will be separated by the operating sys‐
6103 tem's path separate character (: on UNIX/Linux/POSIX, ; on Win‐
6104 dows).
6105
6106
6107 JAVAC The Java compiler.
6108
6109
6110 JAVACCOM
6111 The command line used to compile a directory tree containing
6112 Java source files to corresponding Java class files. Any
6113 options specified in the $JAVACFLAGS construction variable are
6114 included on this command line.
6115
6116
6117 JAVACCOMSTR
6118 The string displayed when compiling a directory tree of Java
6119 source files to corresponding Java class files. If this is not
6120 set, then $JAVACCOM (the command line) is displayed.
6121
6122 env = Environment(JAVACCOMSTR = "Compiling class files $TARGETS from $SOURCES")
6123
6124
6125 JAVACFLAGS
6126 General options that are passed to the Java compiler.
6127
6128
6129 JAVACLASSDIR
6130 The directory in which Java class files may be found. This is
6131 stripped from the beginning of any Java .class file names sup‐
6132 plied to the JavaH builder.
6133
6134
6135 JAVACLASSPATH
6136 Specifies the list of directories that will be searched for Java
6137 .class file. The directories in this list will be added to the
6138 &javac; and &javah; command lines via the -classpath option.
6139 The individual directory names will be separated by the operat‐
6140 ing system's path separate character (: on UNIX/Linux/POSIX, ;
6141 on Windows).
6142
6143 Note that this currently just adds the specified directory via
6144 the -classpath option. &SCons; does not currently search the
6145 $JAVACLASSPATH directories for dependency .class files.
6146
6147
6148 JAVACLASSSUFFIX
6149 The suffix for Java class files; .class by default.
6150
6151
6152 JAVAH The Java generator for C header and stub files.
6153
6154
6155 JAVAHCOM
6156 The command line used to generate C header and stub files from
6157 Java classes. Any options specified in the $JAVAHFLAGS con‐
6158 struction variable are included on this command line.
6159
6160
6161 JAVAHCOMSTR
6162 The string displayed when C header and stub files are generated
6163 from Java classes. If this is not set, then $JAVAHCOM (the com‐
6164 mand line) is displayed.
6165
6166 env = Environment(JAVAHCOMSTR = "Generating header/stub file(s) $TARGETS from $SOURCES")
6167
6168
6169 JAVAHFLAGS
6170 General options passed to the C header and stub file generator
6171 for Java classes.
6172
6173
6174 JAVASOURCEPATH
6175 Specifies the list of directories that will be searched for
6176 input .java file. The directories in this list will be added to
6177 the &javac; command line via the -sourcepath option. The indi‐
6178 vidual directory names will be separated by the operating sys‐
6179 tem's path separate character (: on UNIX/Linux/POSIX, ; on Win‐
6180 dows).
6181
6182 Note that this currently just adds the specified directory via
6183 the -sourcepath option. &SCons; does not currently search the
6184 $JAVASOURCEPATH directories for dependency .java files.
6185
6186
6187 JAVASUFFIX
6188 The suffix for Java files; .java by default.
6189
6190
6191 JAVAVERSION
6192 Specifies the Java version being used by the Java() builder.
6193 This is not currently used to select one version of the Java
6194 compiler vs. another. Instead, you should set this to specify
6195 the version of Java supported by your &javac; compiler. The
6196 default is 1.4.
6197
6198 This is sometimes necessary because Java 1.5 changed the file
6199 names that are created for nested anonymous inner classes, which
6200 can cause a mismatch with the files that &SCons; expects will be
6201 generated by the &javac; compiler. Setting $JAVAVERSION to 1.5
6202 (or 1.6, as appropriate) can make &SCons; realize that a Java
6203 1.5 or 1.6 build is actually up to date.
6204
6205
6206 LATEX The LaTeX structured formatter and typesetter.
6207
6208
6209 LATEXCOM
6210 The command line used to call the LaTeX structured formatter and
6211 typesetter.
6212
6213
6214 LATEXCOMSTR
6215 The string displayed when calling the LaTeX structured formatter
6216 and typesetter. If this is not set, then $LATEXCOM (the command
6217 line) is displayed.
6218
6219 env = Environment(LATEXCOMSTR = "Building $TARGET from LaTeX input $SOURCES")
6220
6221
6222 LATEXFLAGS
6223 General options passed to the LaTeX structured formatter and
6224 typesetter.
6225
6226
6227 LATEXRETRIES
6228 The maximum number of times that LaTeX will be re-run if the
6229 .log generated by the $LATEXCOM command indicates that there are
6230 undefined references. The default is to try to resolve unde‐
6231 fined references by re-running LaTeX up to three times.
6232
6233
6234 LATEXSUFFIXES
6235 The list of suffixes of files that will be scanned for LaTeX
6236 implicit dependencies (\include or \import files). The default
6237 list is:
6238
6239 [".tex", ".ltx", ".latex"]
6240
6241
6242 LDMODULE
6243 The linker for building loadable modules. By default, this is
6244 the same as $SHLINK.
6245
6246
6247 LDMODULECOM
6248 The command line for building loadable modules. On Mac OS X,
6249 this uses the $LDMODULE, $LDMODULEFLAGS and $FRAMEWORKSFLAGS
6250 variables. On other systems, this is the same as $SHLINK.
6251
6252
6253 LDMODULECOMSTR
6254 The string displayed when building loadable modules. If this is
6255 not set, then $LDMODULECOM (the command line) is displayed.
6256
6257
6258 LDMODULEFLAGS
6259 General user options passed to the linker for building loadable
6260 modules.
6261
6262
6263 LDMODULEPREFIX
6264 The prefix used for loadable module file names. On Mac OS X,
6265 this is null; on other systems, this is the same as $SHLIBPRE‐
6266 FIX.
6267
6268
6269 LDMODULESUFFIX
6270 The suffix used for loadable module file names. On Mac OS X,
6271 this is null; on other systems, this is the same as $SHLIBSUF‐
6272 FIX.
6273
6274
6275 LEX The lexical analyzer generator.
6276
6277
6278 LEXCOM The command line used to call the lexical analyzer generator to
6279 generate a source file.
6280
6281
6282 LEXCOMSTR
6283 The string displayed when generating a source file using the
6284 lexical analyzer generator. If this is not set, then $LEXCOM
6285 (the command line) is displayed.
6286
6287 env = Environment(LEXCOMSTR = "Lex'ing $TARGET from $SOURCES")
6288
6289
6290 LEXFLAGS
6291 General options passed to the lexical analyzer generator.
6292
6293
6294 _LIBDIRFLAGS
6295 An automatically-generated construction variable containing the
6296 linker command-line options for specifying directories to be
6297 searched for library. The value of $_LIBDIRFLAGS is created by
6298 appending $LIBDIRPREFIX and $LIBDIRSUFFIX to the beginning and
6299 end of each directory in $LIBPATH.
6300
6301
6302 LIBDIRPREFIX
6303 The prefix used to specify a library directory on the linker
6304 command line. This will be appended to the beginning of each
6305 directory in the $LIBPATH construction variable when the $_LIB‐
6306 DIRFLAGS variable is automatically generated.
6307
6308
6309 LIBDIRSUFFIX
6310 The suffix used to specify a library directory on the linker
6311 command line. This will be appended to the end of each direc‐
6312 tory in the $LIBPATH construction variable when the $_LIB‐
6313 DIRFLAGS variable is automatically generated.
6314
6315
6316 LIBEMITTER
6317 TODO
6318
6319
6320 _LIBFLAGS
6321 An automatically-generated construction variable containing the
6322 linker command-line options for specifying libraries to be
6323 linked with the resulting target. The value of $_LIBFLAGS is
6324 created by appending $LIBLINKPREFIX and $LIBLINKSUFFIX to the
6325 beginning and end of each filename in $LIBS.
6326
6327
6328 LIBLINKPREFIX
6329 The prefix used to specify a library to link on the linker com‐
6330 mand line. This will be appended to the beginning of each
6331 library in the $LIBS construction variable when the $_LIBFLAGS
6332 variable is automatically generated.
6333
6334
6335 LIBLINKSUFFIX
6336 The suffix used to specify a library to link on the linker com‐
6337 mand line. This will be appended to the end of each library in
6338 the $LIBS construction variable when the $_LIBFLAGS variable is
6339 automatically generated.
6340
6341
6342 LIBPATH
6343 The list of directories that will be searched for libraries.
6344 The implicit dependency scanner will search these directories
6345 for include files. Don't explicitly put include directory argu‐
6346 ments in $LINKFLAGS or $SHLINKFLAGS because the result will be
6347 non-portable and the directories will not be searched by the
6348 dependency scanner. Note: directory names in LIBPATH will be
6349 looked-up relative to the SConscript directory when they are
6350 used in a command. To force scons to look-up a directory rela‐
6351 tive to the root of the source tree use #:
6352
6353 env = Environment(LIBPATH='#/libs')
6354
6355 The directory look-up can also be forced using the Dir() func‐
6356 tion:
6357
6358 libs = Dir('libs')
6359 env = Environment(LIBPATH=libs)
6360
6361 The directory list will be added to command lines through the
6362 automatically-generated $_LIBDIRFLAGS construction variable,
6363 which is constructed by appending the values of the $LIBDIRPRE‐
6364 FIXand$LIBDIRSUFFIX construction variables to the beginning and
6365 end of each directory in $LIBPATH. Any command lines you define
6366 that need the LIBPATH directory list should include $_LIB‐
6367 DIRFLAGS:
6368
6369 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
6370
6371
6372 LIBPREFIX
6373 The prefix used for (static) library file names. A default
6374 value is set for each platform (posix, win32, os2, etc.), but
6375 the value is overridden by individual tools (ar, mslib, sgiar,
6376 sunar, tlib, etc.) to reflect the names of the libraries they
6377 create.
6378
6379
6380 LIBPREFIXES
6381 A list of all legal prefixes for library file names. When
6382 searching for library dependencies, SCons will look for files
6383 with these prefixes, the base library name, and suffixes in the
6384 $LIBSUFFIXES list.
6385
6386
6387 LIBS A list of one or more libraries that will be linked with any
6388 executable programs created by this environment.
6389
6390 The library list will be added to command lines through the
6391 automatically-generated $_LIBFLAGS construction variable, which
6392 is constructed by appending the values of the $LIBLINKPRE‐
6393 FIXand$LIBLINKSUFFIX construction variables to the beginning and
6394 end of each filename in $LIBS. Any command lines you define
6395 that need the LIBS library list should include $_LIBFLAGS:
6396
6397 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
6398
6399 If you add a File object to the $LIBS list, the name of that
6400 file will be added to $_LIBFLAGS, and thus the link line, as is,
6401 without $LIBLINKPREFIX or $LIBLINKSUFFIX. For example:
6402
6403 env.Append(LIBS=File('/tmp/mylib.so'))
6404
6405 In all cases, scons will add dependencies from the executable
6406 program to all the libraries in this list.
6407
6408
6409 LIBSUFFIX
6410 The suffix used for (static) library file names. A default
6411 value is set for each platform (posix, win32, os2, etc.), but
6412 the value is overridden by individual tools (ar, mslib, sgiar,
6413 sunar, tlib, etc.) to reflect the names of the libraries they
6414 create.
6415
6416
6417 LIBSUFFIXES
6418 A list of all legal suffixes for library file names. When
6419 searching for library dependencies, SCons will look for files
6420 with prefixes, in the $LIBPREFIXES list, the base library name,
6421 and these suffixes.
6422
6423
6424 LICENSE
6425 The abbreviated name of the license under which this project is
6426 released (gpl, lpgl, bsd etc.). See http://www.open‐
6427 source.org/licenses/alphabetical for a list of license names.
6428
6429
6430 LINESEPARATOR
6431 The separator used by the Substfile() and Textfile() builders.
6432 This value is used between sources when constructing the target.
6433 It defaults to the current system line separator.
6434
6435
6436 LINK The linker.
6437
6438
6439 LINKCOM
6440 The command line used to link object files into an executable.
6441
6442
6443 LINKCOMSTR
6444 The string displayed when object files are linked into an exe‐
6445 cutable. If this is not set, then $LINKCOM (the command line)
6446 is displayed.
6447
6448 env = Environment(LINKCOMSTR = "Linking $TARGET")
6449
6450
6451 LINKFLAGS
6452 General user options passed to the linker. Note that this vari‐
6453 able should not contain -l (or similar) options for linking with
6454 the libraries listed in $LIBS, nor -L (or similar) library
6455 search path options that scons generates automatically from
6456 $LIBPATH. See $_LIBFLAGS above, for the variable that expands
6457 to library-link options, and $_LIBDIRFLAGS above, for the vari‐
6458 able that expands to library search path options.
6459
6460
6461 M4 The M4 macro preprocessor.
6462
6463
6464 M4COM The command line used to pass files through the M4 macro pre‐
6465 processor.
6466
6467
6468 M4COMSTR
6469 The string displayed when a file is passed through the M4 macro
6470 preprocessor. If this is not set, then $M4COM (the command
6471 line) is displayed.
6472
6473
6474 M4FLAGS
6475 General options passed to the M4 macro preprocessor.
6476
6477
6478 MAKEINDEX
6479 The makeindex generator for the TeX formatter and typesetter and
6480 the LaTeX structured formatter and typesetter.
6481
6482
6483 MAKEINDEXCOM
6484 The command line used to call the makeindex generator for the
6485 TeX formatter and typesetter and the LaTeX structured formatter
6486 and typesetter.
6487
6488
6489 MAKEINDEXCOMSTR
6490 The string displayed when calling the makeindex generator for
6491 the TeX formatter and typesetter and the LaTeX structured for‐
6492 matter and typesetter. If this is not set, then $MAKEINDEXCOM
6493 (the command line) is displayed.
6494
6495
6496 MAKEINDEXFLAGS
6497 General options passed to the makeindex generator for the TeX
6498 formatter and typesetter and the LaTeX structured formatter and
6499 typesetter.
6500
6501
6502 MAXLINELENGTH
6503 The maximum number of characters allowed on an external command
6504 line. On Win32 systems, link lines longer than this many char‐
6505 acters are linked via a temporary file name.
6506
6507
6508 MIDL The Microsoft IDL compiler.
6509
6510
6511 MIDLCOM
6512 The command line used to pass files to the Microsoft IDL com‐
6513 piler.
6514
6515
6516 MIDLCOMSTR
6517 The string displayed when the Microsoft IDL copmiler is called.
6518 If this is not set, then $MIDLCOM (the command line) is dis‐
6519 played.
6520
6521
6522 MIDLFLAGS
6523 General options passed to the Microsoft IDL compiler.
6524
6525
6526 MSSDK_DIR
6527 The directory containing the Microsoft SDK (either Platform SDK
6528 or Windows SDK) to be used for compilation.
6529
6530
6531 MSSDK_VERSION
6532 The version string of the Microsoft SDK (either Platform SDK or
6533 Windows SDK) to be used for compilation. Supported versions
6534 include 6.1, 6.0A, 6.0, 2003R2 and 2003R1.
6535
6536
6537 MSVC_BATCH
6538 When set to any true value, specifies that SCons should batch
6539 compilation of object files when calling the Microsoft Visual
6540 C/C++ compiler. All compilations of source files from the same
6541 source directory that generate target files in a same output
6542 directory and were configured in SCons using the same construc‐
6543 tion environment will be built in a single call to the compiler.
6544 Only source files that have changed since their object files
6545 were built will be passed to each compiler invocation (via the
6546 $CHANGED_SOURCES construction variable). Any compilations where
6547 the object (target) file base name (minus the .obj) does not
6548 match the source file base name will be compiled separately.
6549
6550
6551 MSVC_USE_SCRIPT
6552 Use a batch script to set up Microsoft Visual Studio compiler
6553
6554 $MSVC_USE_SCRIPToverrides$MSVC_VERSIONand$TARGET_ARCH. If set
6555 to the name of a Visual Studio .bat file (e.g. vcvars.bat),
6556 SCons will run that bat file and extract the relevant variables
6557 from the result (typically %INCLUDE%, %LIB%, and %PATH%). Set‐
6558 ting MSVC_USE_SCRIPT to None bypasses the Visual Studio autode‐
6559 tection entirely; use this if you are running SCons in a Visual
6560 Studio cmd window and importing the shell's environment vari‐
6561 ables.
6562
6563
6564 MSVC_VERSION
6565 Sets the preferred version of Microsoft Visual C/C++ to use.
6566
6567 If $MSVC_VERSION is not set, SCons will (by default) select the
6568 latest version of Visual C/C++ installed on your system. If the
6569 specified version isn't installed, tool initialization will
6570 fail. This variable must be passed as an argument to the Envi‐
6571 ronment() constructor; setting it later has no effect. Set it
6572 to an unexpected value (e.g. "XXX") to see the valid values on
6573 your system.
6574
6575
6576 MSVS When the Microsoft Visual Studio tools are initialized, they set
6577 up this dictionary with the following keys:
6578
6579 VERSION: the version of MSVS being used (can be set via
6580 $MSVS_VERSION)
6581
6582 VERSIONS: the available versions of MSVS installed
6583
6584 VCINSTALLDIR: installed directory of Visual C++
6585
6586 VSINSTALLDIR: installed directory of Visual Studio
6587
6588 FRAMEWORKDIR: installed directory of the .NET framework
6589
6590 FRAMEWORKVERSIONS: list of installed versions of the .NET frame‐
6591 work, sorted latest to oldest.
6592
6593 FRAMEWORKVERSION: latest installed version of the .NET framework
6594
6595 FRAMEWORKSDKDIR: installed location of the .NET SDK.
6596
6597 PLATFORMSDKDIR: installed location of the Platform SDK.
6598
6599 PLATFORMSDK_MODULES: dictionary of installed Platform SDK mod‐
6600 ules, where the dictionary keys are keywords for the various
6601 modules, and the values are 2-tuples where the first is the
6602 release date, and the second is the version number.
6603
6604 If a value isn't set, it wasn't available in the registry.
6605
6606
6607 MSVS_ARCH
6608 Sets the architecture for which the generated project(s) should
6609 build.
6610
6611 The default value is x86. amd64 is also supported by &SCons;
6612 for some Visual Studio versions. Trying to set $MSVS_ARCH to an
6613 architecture that's not supported for a given Visual Studio ver‐
6614 sion will generate an error.
6615
6616
6617 MSVS_PROJECT_GUID
6618 The string placed in a generated Microsoft Visual Studio project
6619 file as the value of the ProjectGUID attribute. There is no
6620 default value. If not defined, a new GUID is generated.
6621
6622
6623 MSVS_SCC_AUX_PATH
6624 The path name placed in a generated Microsoft Visual Studio
6625 project file as the value of the SccAuxPath attribute if the
6626 MSVS_SCC_PROVIDER construction variable is also set. There is
6627 no default value.
6628
6629
6630 MSVS_SCC_CONNECTION_ROOT
6631 The root path of projects in your SCC workspace, i.e the path
6632 under which all project and solution files will be generated. It
6633 is used as a reference path from which the relative paths of the
6634 generated Microsoft Visual Studio project and solution files are
6635 computed. The relative project file path is placed as the value
6636 of the SccLocalPath attribute of the project file and as the
6637 values of the SccProjectFilePathRelativizedFromConnection[i]
6638 (where [i] ranges from 0 to the number of projects in the solu‐
6639 tion) attributes of the GlobalSection(SourceCodeControl) section
6640 of the Microsoft Visual Studio solution file. Similarly the
6641 relative solution file path is placed as the values of the
6642 SccLocalPath[i] (where [i] ranges from 0 to the number of
6643 projects in the solution) attributes of the GlobalSec‐
6644 tion(SourceCodeControl) section of the Microsoft Visual Studio
6645 solution file. This is used only if the MSVS_SCC_PROVIDER con‐
6646 struction variable is also set. The default value is the cur‐
6647 rent working directory.
6648
6649
6650 MSVS_SCC_PROJECT_NAME
6651 The project name placed in a generated Microsoft Visual Studio
6652 project file as the value of the SccProjectName attribute if the
6653 MSVS_SCC_PROVIDER construction variable is also set. In this
6654 case the string is also placed in the SccProjectName0 attribute
6655 of the GlobalSection(SourceCodeControl) section of the Microsoft
6656 Visual Studio solution file. There is no default value.
6657
6658
6659 MSVS_SCC_PROVIDER
6660 The string placed in a generated Microsoft Visual Studio project
6661 file as the value of the SccProvider attribute. The string is
6662 also placed in the SccProvider0 attribute of the GlobalSec‐
6663 tion(SourceCodeControl) section of the Microsoft Visual Studio
6664 solution file. There is no default value.
6665
6666
6667 MSVS_VERSION
6668 Sets the preferred version of Microsoft Visual Studio to use.
6669
6670 If $MSVS_VERSION is not set, &SCons; will (by default) select
6671 the latest version of Visual Studio installed on your system.
6672 So, if you have version 6 and version 7 (MSVS .NET) installed,
6673 it will prefer version 7. You can override this by specifying
6674 the MSVS_VERSION variable in the Environment initialization,
6675 setting it to the appropriate version ('6.0' or '7.0', for exam‐
6676 ple). If the specified version isn't installed, tool initial‐
6677 ization will fail.
6678
6679 This is obsolete: use $MSVC_VERSION instead. If $MSVS_VERSION is
6680 set and $MSVC_VERSIONisnot,$MSVC_VERSIONwillbesetautomatical‐
6681 lyto$MSVS_VERSION. If both are set to different values, scons
6682 will raise an error.
6683
6684
6685 MSVSBUILDCOM
6686 The build command line placed in a generated Microsoft Visual
6687 Studio project file. The default is to have Visual Studio
6688 invoke SCons with any specified build targets.
6689
6690
6691 MSVSCLEANCOM
6692 The clean command line placed in a generated Microsoft Visual
6693 Studio project file. The default is to have Visual Studio
6694 invoke SCons with the -c option to remove any specified targets.
6695
6696
6697 MSVSENCODING
6698 The encoding string placed in a generated Microsoft Visual Stu‐
6699 dio project file. The default is encoding Windows-1252.
6700
6701
6702 MSVSPROJECTCOM
6703 The action used to generate Microsoft Visual Studio project
6704 files.
6705
6706
6707 MSVSPROJECTSUFFIX
6708 The suffix used for Microsoft Visual Studio project (DSP) files.
6709 The default value is .vcproj when using Visual Studio version
6710 7.x (.NET) or later version, and .dsp when using earlier ver‐
6711 sions of Visual Studio.
6712
6713
6714 MSVSREBUILDCOM
6715 The rebuild command line placed in a generated Microsoft Visual
6716 Studio project file. The default is to have Visual Studio
6717 invoke SCons with any specified rebuild targets.
6718
6719
6720 MSVSSCONS
6721 The SCons used in generated Microsoft Visual Studio project
6722 files. The default is the version of SCons being used to gener‐
6723 ate the project file.
6724
6725
6726 MSVSSCONSCOM
6727 The default SCons command used in generated Microsoft Visual
6728 Studio project files.
6729
6730
6731 MSVSSCONSCRIPT
6732 The sconscript file (that is, SConstruct or SConscript file)
6733 that will be invoked by Visual Studio project files (through the
6734 $MSVSSCONSCOM variable). The default is the same sconscript
6735 file that contains the call to MSVSProject() to build the
6736 project file.
6737
6738
6739 MSVSSCONSFLAGS
6740 The SCons flags used in generated Microsoft Visual Studio
6741 project files.
6742
6743
6744 MSVSSOLUTIONCOM
6745 The action used to generate Microsoft Visual Studio solution
6746 files.
6747
6748
6749 MSVSSOLUTIONSUFFIX
6750 The suffix used for Microsoft Visual Studio solution (DSW)
6751 files. The default value is .sln when using Visual Studio ver‐
6752 sion 7.x (.NET), and .dsw when using earlier versions of Visual
6753 Studio.
6754
6755
6756 MT The program used on Windows systems to embed manifests into DLLs
6757 and EXEs. See also $WINDOWS_EMBED_MANIFEST.
6758
6759
6760 MTEXECOM
6761 The Windows command line used to embed manifests into executa‐
6762 bles. See also $MTSHLIBCOM.
6763
6764
6765 MTFLAGS
6766 Flags passed to the $MT manifest embedding program (Windows
6767 only).
6768
6769
6770 MTSHLIBCOM
6771 The Windows command line used to embed manifests into shared
6772 libraries (DLLs). See also $MTEXECOM.
6773
6774
6775 MWCW_VERSION
6776 The version number of the MetroWerks CodeWarrior C compiler to
6777 be used.
6778
6779
6780 MWCW_VERSIONS
6781 A list of installed versions of the MetroWerks CodeWarrior C
6782 compiler on this system.
6783
6784
6785 NAME Specfies the name of the project to package.
6786
6787
6788 no_import_lib
6789 When set to non-zero, suppresses creation of a corresponding
6790 Windows static import lib by the SharedLibrary builder when used
6791 with MinGW, Microsoft Visual Studio or Metrowerks. This also
6792 suppresses creation of an export (.exp) file when using Micro‐
6793 soft Visual Studio.
6794
6795
6796 OBJPREFIX
6797 The prefix used for (static) object file names.
6798
6799
6800 OBJSUFFIX
6801 The suffix used for (static) object file names.
6802
6803
6804 P4 The Perforce executable.
6805
6806
6807 P4COM The command line used to fetch source files from Perforce.
6808
6809
6810 P4COMSTR
6811 The string displayed when fetching a source file from Perforce.
6812 If this is not set, then $P4COM (the command line) is displayed.
6813
6814
6815 P4FLAGS
6816 General options that are passed to Perforce.
6817
6818
6819 PACKAGEROOT
6820 Specifies the directory where all files in resulting archive
6821 will be placed if applicable. The default value is "$NAME-$VER‐
6822 SION".
6823
6824
6825 PACKAGETYPE
6826 Selects the package type to build. Currently these are avail‐
6827 able:
6828
6829 * msi - Microsoft Installer
6830 * rpm - Redhat Package Manger
6831 * ipkg - Itsy Package Management System
6832 * tarbz2 - compressed tar
6833 * targz - compressed tar
6834 * zip - zip file
6835 * src_tarbz2 - compressed tar source
6836 * src_targz - compressed tar source
6837 * src_zip - zip file source
6838
6839 This may be overridden with the "package_type" command line
6840 option.
6841
6842
6843 PACKAGEVERSION
6844 The version of the package (not the underlying project). This
6845 is currently only used by the rpm packager and should reflect
6846 changes in the packaging, not the underlying project code
6847 itself.
6848
6849
6850 PCH The Microsoft Visual C++ precompiled header that will be used
6851 when compiling object files. This variable is ignored by tools
6852 other than Microsoft Visual C++. When this variable is defined
6853 SCons will add options to the compiler command line to cause it
6854 to use the precompiled header, and will also set up the depen‐
6855 dencies for the PCH file. Example:
6856
6857 env['PCH'] = 'StdAfx.pch'
6858
6859
6860 PCHCOM The command line used by the PCH() builder to generated a pre‐
6861 compiled header.
6862
6863
6864 PCHCOMSTR
6865 The string displayed when generating a precompiled header. If
6866 this is not set, then $PCHCOM (the command line) is displayed.
6867
6868
6869 PCHPDBFLAGS
6870 A construction variable that, when expanded, adds the /yD flag
6871 to the command line only if the $PDB construction variable is
6872 set.
6873
6874
6875 PCHSTOP
6876 This variable specifies how much of a source file is precom‐
6877 piled. This variable is ignored by tools other than Microsoft
6878 Visual C++, or when the PCH variable is not being used. When
6879 this variable is define it must be a string that is the name of
6880 the header that is included at the end of the precompiled por‐
6881 tion of the source files, or the empty string if the "#pragma
6882 hrdstop" construct is being used:
6883
6884 env['PCHSTOP'] = 'StdAfx.h'
6885
6886
6887 PDB The Microsoft Visual C++ PDB file that will store debugging
6888 information for object files, shared libraries, and programs.
6889 This variable is ignored by tools other than Microsoft Visual
6890 C++. When this variable is defined SCons will add options to
6891 the compiler and linker command line to cause them to generate
6892 external debugging information, and will also set up the depen‐
6893 dencies for the PDB file. Example:
6894
6895 env['PDB'] = 'hello.pdb'
6896
6897 The Visual C++ compiler switch that SCons uses by default to
6898 generate PDB information is /Z7. This works correctly with par‐
6899 allel (-j) builds because it embeds the debug information in the
6900 intermediate object files, as opposed to sharing a single PDB
6901 file between multiple object files. This is also the only way
6902 to get debug information embedded into a static library. Using
6903 the /Zi instead may yield improved link-time performance,
6904 although parallel builds will no longer work. You can generate
6905 PDB files with the /Zi switch by overriding the default
6906 $CCPDBFLAGS variable; see the entry for that variable for spe‐
6907 cific examples.
6908
6909
6910 PDFCOM A deprecated synonym for $DVIPDFCOM.
6911
6912
6913 PDFLATEX
6914 The &pdflatex; utility.
6915
6916
6917 PDFLATEXCOM
6918 The command line used to call the &pdflatex; utility.
6919
6920
6921 PDFLATEXCOMSTR
6922 The string displayed when calling the &pdflatex; utility. If
6923 this is not set, then $PDFLATEXCOM (the command line) is dis‐
6924 played.
6925
6926 env = Environment(PDFLATEX;COMSTR = "Building $TARGET from LaTeX input $SOURCES")
6927
6928
6929 PDFLATEXFLAGS
6930 General options passed to the &pdflatex; utility.
6931
6932
6933 PDFPREFIX
6934 The prefix used for PDF file names.
6935
6936
6937 PDFSUFFIX
6938 The suffix used for PDF file names.
6939
6940
6941 PDFTEX The &pdftex; utility.
6942
6943
6944 PDFTEXCOM
6945 The command line used to call the &pdftex; utility.
6946
6947
6948 PDFTEXCOMSTR
6949 The string displayed when calling the &pdftex; utility. If this
6950 is not set, then $PDFTEXCOM (the command line) is displayed.
6951
6952 env = Environment(PDFTEXCOMSTR = "Building $TARGET from TeX input $SOURCES")
6953
6954
6955 PDFTEXFLAGS
6956 General options passed to the &pdftex; utility.
6957
6958
6959 PKGCHK On Solaris systems, the package-checking program that will be
6960 used (along with $PKGINFO) to look for installed versions of the
6961 Sun PRO C++ compiler. The default is /usr/sbin/pgkchk.
6962
6963
6964 PKGINFO
6965 On Solaris systems, the package information program that will be
6966 used (along with $PKGCHK) to look for installed versions of the
6967 Sun PRO C++ compiler. The default is pkginfo.
6968
6969
6970 PLATFORM
6971 The name of the platform used to create the Environment. If no
6972 platform is specified when the Environment is created, scons
6973 autodetects the platform.
6974
6975 env = Environment(tools = [])
6976 if env['PLATFORM'] == 'cygwin':
6977 Tool('mingw')(env)
6978 else:
6979 Tool('msvc')(env)
6980
6981
6982 PRINT_CMD_LINE_FUNC
6983 A Python function used to print the command lines as they are
6984 executed (assuming command printing is not disabled by the -q or
6985 -s options or their equivalents). The function should take four
6986 arguments: s, the command being executed (a string), target, the
6987 target being built (file node, list, or string name(s)), source,
6988 the source(s) used (file node, list, or string name(s)), and
6989 env, the environment being used.
6990
6991 The function must do the printing itself. The default implemen‐
6992 tation, used if this variable is not set or is None, is:
6993 def print_cmd_line(s, target, source, env):
6994 sys.stdout.write(s + "\n")
6995
6996 Here's an example of a more interesting function:
6997
6998 def print_cmd_line(s, target, source, env):
6999 sys.stdout.write("Building %s -> %s...\n" %
7000 (' and '.join([str(x) for x in source]),
7001 ' and '.join([str(x) for x in target])))
7002 env=Environment(PRINT_CMD_LINE_FUNC=print_cmd_line)
7003 env.Program('foo', 'foo.c')
7004
7005 This just prints "Building targetname from sourcename..."
7006 instead of the actual commands. Such a function could also log
7007 the actual commands to a log file, for example.
7008
7009
7010 PROGEMITTER
7011 TODO
7012
7013
7014 PROGPREFIX
7015 The prefix used for executable file names.
7016
7017
7018 PROGSUFFIX
7019 The suffix used for executable file names.
7020
7021
7022 PSCOM The command line used to convert TeX DVI files into a PostScript
7023 file.
7024
7025
7026 PSCOMSTR
7027 The string displayed when a TeX DVI file is converted into a
7028 PostScript file. If this is not set, then $PSCOM (the command
7029 line) is displayed.
7030
7031
7032 PSPREFIX
7033 The prefix used for PostScript file names.
7034
7035
7036 PSSUFFIX
7037 The prefix used for PostScript file names.
7038
7039
7040 QT_AUTOSCAN
7041 Turn off scanning for mocable files. Use the Moc Builder to
7042 explicitly specify files to run moc on.
7043
7044
7045 QT_BINPATH
7046 The path where the qt binaries are installed. The default value
7047 is '$QTDIR/bin'.
7048
7049
7050 QT_CPPPATH
7051 The path where the qt header files are installed. The default
7052 value is '$QTDIR/include'. Note: If you set this variable to
7053 None, the tool won't change the $CPPPATH construction variable.
7054
7055
7056 QT_DEBUG
7057 Prints lots of debugging information while scanning for moc
7058 files.
7059
7060
7061 QT_LIB Default value is 'qt'. You may want to set this to 'qt-mt'.
7062 Note: If you set this variable to None, the tool won't change
7063 the $LIBS variable.
7064
7065
7066 QT_LIBPATH
7067 The path where the qt libraries are installed. The default
7068 value is '$QTDIR/lib'. Note: If you set this variable to None,
7069 the tool won't change the $LIBPATH construction variable.
7070
7071
7072 QT_MOC Default value is '$QT_BINPATH/moc'.
7073
7074
7075 QT_MOCCXXPREFIX
7076 Default value is ''. Prefix for moc output files, when source is
7077 a cxx file.
7078
7079
7080 QT_MOCCXXSUFFIX
7081 Default value is '.moc'. Suffix for moc output files, when
7082 source is a cxx file.
7083
7084
7085 QT_MOCFROMCXXCOM
7086 Command to generate a moc file from a cpp file.
7087
7088
7089 QT_MOCFROMCXXCOMSTR
7090 The string displayed when generating a moc file from a cpp file.
7091 If this is not set, then $QT_MOCFROMCXXCOM (the command line) is
7092 displayed.
7093
7094
7095 QT_MOCFROMCXXFLAGS
7096 Default value is '-i'. These flags are passed to moc, when mocc‐
7097 ing a C++ file.
7098
7099
7100 QT_MOCFROMHCOM
7101 Command to generate a moc file from a header.
7102
7103
7104 QT_MOCFROMHCOMSTR
7105 The string displayed when generating a moc file from a cpp file.
7106 If this is not set, then $QT_MOCFROMHCOM (the command line) is
7107 displayed.
7108
7109
7110 QT_MOCFROMHFLAGS
7111 Default value is ''. These flags are passed to moc, when moccing
7112 a header file.
7113
7114
7115 QT_MOCHPREFIX
7116 Default value is 'moc_'. Prefix for moc output files, when
7117 source is a header.
7118
7119
7120 QT_MOCHSUFFIX
7121 Default value is '$CXXFILESUFFIX'. Suffix for moc output files,
7122 when source is a header.
7123
7124
7125 QT_UIC Default value is '$QT_BINPATH/uic'.
7126
7127
7128 QT_UICCOM
7129 Command to generate header files from .ui files.
7130
7131
7132 QT_UICCOMSTR
7133 The string displayed when generating header files from .ui
7134 files. If this is not set, then $QT_UICCOM (the command line)
7135 is displayed.
7136
7137
7138 QT_UICDECLFLAGS
7139 Default value is ''. These flags are passed to uic, when creat‐
7140 ing a a h file from a .ui file.
7141
7142
7143 QT_UICDECLPREFIX
7144 Default value is ''. Prefix for uic generated header files.
7145
7146
7147 QT_UICDECLSUFFIX
7148 Default value is '.h'. Suffix for uic generated header files.
7149
7150
7151 QT_UICIMPLFLAGS
7152 Default value is ''. These flags are passed to uic, when creat‐
7153 ing a cxx file from a .ui file.
7154
7155
7156 QT_UICIMPLPREFIX
7157 Default value is 'uic_'. Prefix for uic generated implementation
7158 files.
7159
7160
7161 QT_UICIMPLSUFFIX
7162 Default value is '$CXXFILESUFFIX'. Suffix for uic generated
7163 implementation files.
7164
7165
7166 QT_UISUFFIX
7167 Default value is '.ui'. Suffix of designer input files.
7168
7169
7170 QTDIR The qt tool tries to take this from os.environ. It also ini‐
7171 tializes all QT_* construction variables listed below. (Note
7172 that all paths are constructed with python's os.path.join()
7173 method, but are listed here with the '/' separator for easier
7174 reading.) In addition, the construction environment variables
7175 $CPPPATH, $LIBPATH and $LIBS may be modified and the variables
7176 $PROGEMITTER,$SHLIBEMITTERand$LIBEMITTER are modified. Because
7177 the build-performance is affected when using this tool, you have
7178 to explicitly specify it at Environment creation:
7179
7180 Environment(tools=['default','qt'])
7181
7182 The qt tool supports the following operations:
7183
7184 Automatic moc file generation from header files. You do not
7185 have to specify moc files explicitly, the tool does it for you.
7186 However, there are a few preconditions to do so: Your header
7187 file must have the same filebase as your implementation file and
7188 must stay in the same directory. It must have one of the suf‐
7189 fixes .h, .hpp, .H, .hxx, .hh. You can turn off automatic moc
7190 file generation by setting QT_AUTOSCAN to 0. See also the cor‐
7191 responding Moc()() builder method.
7192
7193 Automatic moc file generation from cxx files. As stated in the
7194 qt documentation, include the moc file at the end of the cxx
7195 file. Note that you have to include the file, which is generated
7196 by the transformation ${QT_MOCCXXPREFIX}<basename>${QT_MOC‐
7197 CXXSUFFIX}, by default <basename>.moc. A warning is generated
7198 after building the moc file, if you do not include the correct
7199 file. If you are using VariantDir, you may need to specify
7200 duplicate=1. You can turn off automatic moc file generation by
7201 setting QT_AUTOSCAN to 0. See also the corresponding Moc()
7202 builder method.
7203
7204 Automatic handling of .ui files. The implementation files gen‐
7205 erated from .ui files are handled much the same as yacc or lex
7206 files. Each .ui file given as a source of Program, Library or
7207 SharedLibrary will generate three files, the declaration file,
7208 the implementation file and a moc file. Because there are also
7209 generated headers, you may need to specify duplicate=1 in calls
7210 to VariantDir. See also the corresponding Uic() builder method.
7211
7212
7213 RANLIB The archive indexer.
7214
7215
7216 RANLIBCOM
7217 The command line used to index a static library archive.
7218
7219
7220 RANLIBCOMSTR
7221 The string displayed when a static library archive is indexed.
7222 If this is not set, then $RANLIBCOM (the command line) is dis‐
7223 played.
7224
7225 env = Environment(RANLIBCOMSTR = "Indexing $TARGET")
7226
7227
7228 RANLIBFLAGS
7229 General options passed to the archive indexer.
7230
7231
7232 RC The resource compiler used to build a Microsoft Visual C++
7233 resource file.
7234
7235
7236 RCCOM The command line used to build a Microsoft Visual C++ resource
7237 file.
7238
7239
7240 RCCOMSTR
7241 The string displayed when invoking the resource compiler to
7242 build a Microsoft Visual C++ resource file. If this is not set,
7243 then $RCCOM (the command line) is displayed.
7244
7245
7246 RCFLAGS
7247 The flags passed to the resource compiler by the RES builder.
7248
7249
7250 RCINCFLAGS
7251 An automatically-generated construction variable containing the
7252 command-line options for specifying directories to be searched
7253 by the resource compiler. The value of $RCINCFLAGS is created
7254 by appending $RCINCPREFIX and $RCINCSUFFIX to the beginning and
7255 end of each directory in $CPPPATH.
7256
7257
7258 RCINCPREFIX
7259 The prefix (flag) used to specify an include directory on the
7260 resource compiler command line. This will be appended to the
7261 beginning of each directory in the $CPPPATH construction vari‐
7262 able when the $RCINCFLAGS variable is expanded.
7263
7264
7265 RCINCSUFFIX
7266 The suffix used to specify an include directory on the resource
7267 compiler command line. This will be appended to the end of each
7268 directory in the $CPPPATH construction variable when the
7269 $RCINCFLAGS variable is expanded.
7270
7271
7272 RCS The RCS executable. Note that this variable is not actually
7273 used for the command to fetch source files from RCS; see the
7274 $RCS_CO construction variable, below.
7275
7276
7277 RCS_CO The RCS "checkout" executable, used to fetch source files from
7278 RCS.
7279
7280
7281 RCS_COCOM
7282 The command line used to fetch (checkout) source files from RCS.
7283
7284
7285 RCS_COCOMSTR
7286 The string displayed when fetching a source file from RCS. If
7287 this is not set, then $RCS_COCOM (the command line) is dis‐
7288 played.
7289
7290
7291 RCS_COFLAGS
7292 Options that are passed to the $RCS_CO command.
7293
7294
7295 RDirs A function that converts a string into a list of Dir instances
7296 by searching the repositories.
7297
7298
7299 REGSVR The program used on Windows systems to register a newly-built
7300 DLL library whenever the SharedLibrary() builder is passed a
7301 keyword argument of register=1.
7302
7303
7304 REGSVRCOM
7305 The command line used on Windows systems to register a newly-
7306 built DLL library whenever the SharedLibrary() builder is passed
7307 a keyword argument of register=1.
7308
7309
7310 REGSVRCOMSTR
7311 The string displayed when registering a newly-built DLL file.
7312 If this is not set, then $REGSVRCOM (the command line) is dis‐
7313 played.
7314
7315
7316 REGSVRFLAGS
7317 Flags passed to the DLL registration program on Windows systems
7318 when a newly-built DLL library is registered. By default, this
7319 includes the /s that prevents dialog boxes from popping up and
7320 requiring user attention.
7321
7322
7323 RMIC The Java RMI stub compiler.
7324
7325
7326 RMICCOM
7327 The command line used to compile stub and skeleton class files
7328 from Java classes that contain RMI implementations. Any options
7329 specified in the $RMICFLAGS construction variable are included
7330 on this command line.
7331
7332
7333 RMICCOMSTR
7334 The string displayed when compiling stub and skeleton class
7335 files from Java classes that contain RMI implementations. If
7336 this is not set, then $RMICCOM (the command line) is displayed.
7337
7338 env = Environment(RMICCOMSTR = "Generating stub/skeleton class files $TARGETS from $SOURCES")
7339
7340
7341 RMICFLAGS
7342 General options passed to the Java RMI stub compiler.
7343
7344
7345 _RPATH An automatically-generated construction variable containing the
7346 rpath flags to be used when linking a program with shared
7347 libraries. The value of $_RPATH is created by appending $RPATH‐
7348 PREFIX and $RPATHSUFFIX to the beginning and end of each direc‐
7349 tory in $RPATH.
7350
7351
7352 RPATH A list of paths to search for shared libraries when running pro‐
7353 grams. Currently only used in the GNU (gnulink), IRIX (sgilink)
7354 and Sun (sunlink) linkers. Ignored on platforms and toolchains
7355 that don't support it. Note that the paths added to RPATH are
7356 not transformed by scons in any way: if you want an absolute
7357 path, you must make it absolute yourself.
7358
7359
7360 RPATHPREFIX
7361 The prefix used to specify a directory to be searched for shared
7362 libraries when running programs. This will be appended to the
7363 beginning of each directory in the $RPATH construction variable
7364 when the $_RPATH variable is automatically generated.
7365
7366
7367 RPATHSUFFIX
7368 The suffix used to specify a directory to be searched for shared
7369 libraries when running programs. This will be appended to the
7370 end of each directory in the $RPATH construction variable when
7371 the $_RPATH variable is automatically generated.
7372
7373
7374 RPCGEN The RPC protocol compiler.
7375
7376
7377 RPCGENCLIENTFLAGS
7378 Options passed to the RPC protocol compiler when generating
7379 client side stubs. These are in addition to any flags specified
7380 in the $RPCGENFLAGS construction variable.
7381
7382
7383 RPCGENFLAGS
7384 General options passed to the RPC protocol compiler.
7385
7386
7387 RPCGENHEADERFLAGS
7388 Options passed to the RPC protocol compiler when generating a
7389 header file. These are in addition to any flags specified in
7390 the $RPCGENFLAGS construction variable.
7391
7392
7393 RPCGENSERVICEFLAGS
7394 Options passed to the RPC protocol compiler when generating
7395 server side stubs. These are in addition to any flags specified
7396 in the $RPCGENFLAGS construction variable.
7397
7398
7399 RPCGENXDRFLAGS
7400 Options passed to the RPC protocol compiler when generating XDR
7401 routines. These are in addition to any flags specified in the
7402 $RPCGENFLAGS construction variable.
7403
7404
7405 SCANNERS
7406 A list of the available implicit dependency scanners. New file
7407 scanners may be added by appending to this list, although the
7408 more flexible approach is to associate scanners with a specific
7409 Builder. See the sections "Builder Objects" and "Scanner
7410 Objects," below, for more information.
7411
7412
7413 SCCS The SCCS executable.
7414
7415
7416 SCCSCOM
7417 The command line used to fetch source files from SCCS.
7418
7419
7420 SCCSCOMSTR
7421 The string displayed when fetching a source file from a CVS
7422 repository. If this is not set, then $SCCSCOM (the command
7423 line) is displayed.
7424
7425
7426 SCCSFLAGS
7427 General options that are passed to SCCS.
7428
7429
7430 SCCSGETFLAGS
7431 Options that are passed specifically to the SCCS "get" subcom‐
7432 mand. This can be set, for example, to -e to check out editable
7433 files from SCCS.
7434
7435
7436 SCONS_HOME
7437 The (optional) path to the SCons library directory, initialized
7438 from the external environment. If set, this is used to con‐
7439 struct a shorter and more efficient search path in the $MSVSS‐
7440 CONS command line executed from Microsoft Visual Studio project
7441 files.
7442
7443
7444 SHCC The C compiler used for generating shared-library objects.
7445
7446
7447 SHCCCOM
7448 The command line used to compile a C source file to a shared-
7449 library object file. Any options specified in the $SHCFLAGS,
7450 $SHCCFLAGS and $CPPFLAGS construction variables are included on
7451 this command line.
7452
7453
7454 SHCCCOMSTR
7455 The string displayed when a C source file is compiled to a
7456 shared object file. If this is not set, then $SHCCCOM (the com‐
7457 mand line) is displayed.
7458
7459 env = Environment(SHCCCOMSTR = "Compiling shared object $TARGET")
7460
7461
7462 SHCCFLAGS
7463 Options that are passed to the C and C++ compilers to generate
7464 shared-library objects.
7465
7466
7467 SHCFLAGS
7468 Options that are passed to the C compiler (only; not C++) to
7469 generate shared-library objects.
7470
7471
7472 SHCXX The C++ compiler used for generating shared-library objects.
7473
7474
7475 SHCXXCOM
7476 The command line used to compile a C++ source file to a shared-
7477 library object file. Any options specified in the $SHCXXFLAGS
7478 and $CPPFLAGS construction variables are included on this com‐
7479 mand line.
7480
7481
7482 SHCXXCOMSTR
7483 The string displayed when a C++ source file is compiled to a
7484 shared object file. If this is not set, then $SHCXXCOM (the
7485 command line) is displayed.
7486
7487 env = Environment(SHCXXCOMSTR = "Compiling shared object $TARGET")
7488
7489
7490 SHCXXFLAGS
7491 Options that are passed to the C++ compiler to generate shared-
7492 library objects.
7493
7494
7495 SHELL A string naming the shell program that will be passed to the
7496 $SPAWN function. See the $SPAWN construction variable for more
7497 information.
7498
7499
7500 SHF77 The Fortran 77 compiler used for generating shared-library
7501 objects. You should normally set the $SHFORTRAN variable, which
7502 specifies the default Fortran compiler for all Fortran versions.
7503 You only need to set $SHF77 if you need to use a specific com‐
7504 piler or compiler version for Fortran 77 files.
7505
7506
7507 SHF77COM
7508 The command line used to compile a Fortran 77 source file to a
7509 shared-library object file. You only need to set $SHF77COM if
7510 you need to use a specific command line for Fortran 77 files.
7511 You should normally set the $SHFORTRANCOM variable, which speci‐
7512 fies the default command line for all Fortran versions.
7513
7514
7515 SHF77COMSTR
7516 The string displayed when a Fortran 77 source file is compiled
7517 to a shared-library object file. If this is not set, then
7518 $SHF77COM or $SHFORTRANCOM (the command line) is displayed.
7519
7520
7521 SHF77FLAGS
7522 Options that are passed to the Fortran 77 compiler to generated
7523 shared-library objects. You only need to set $SHF77FLAGS if you
7524 need to define specific user options for Fortran 77 files. You
7525 should normally set the $SHFORTRANFLAGS variable, which speci‐
7526 fies the user-specified options passed to the default Fortran
7527 compiler for all Fortran versions.
7528
7529
7530 SHF77PPCOM
7531 The command line used to compile a Fortran 77 source file to a
7532 shared-library object file after first running the file through
7533 the C preprocessor. Any options specified in the $SHF77FLAGS
7534 and $CPPFLAGS construction variables are included on this com‐
7535 mand line. You only need to set $SHF77PPCOM if you need to use
7536 a specific C-preprocessor command line for Fortran 77 files.
7537 You should normally set the $SHFORTRANPPCOM variable, which
7538 specifies the default C-preprocessor command line for all For‐
7539 tran versions.
7540
7541
7542 SHF77PPCOMSTR
7543 The string displayed when a Fortran 77 source file is compiled
7544 to a shared-library object file after first running the file
7545 through the C preprocessor. If this is not set, then
7546 $SHF77PPCOM or $SHFORTRANPPCOM (the command line) is displayed.
7547
7548
7549 SHF90 The Fortran 90 compiler used for generating shared-library
7550 objects. You should normally set the $SHFORTRAN variable, which
7551 specifies the default Fortran compiler for all Fortran versions.
7552 You only need to set $SHF90 if you need to use a specific com‐
7553 piler or compiler version for Fortran 90 files.
7554
7555
7556 SHF90COM
7557 The command line used to compile a Fortran 90 source file to a
7558 shared-library object file. You only need to set $SHF90COM if
7559 you need to use a specific command line for Fortran 90 files.
7560 You should normally set the $SHFORTRANCOM variable, which speci‐
7561 fies the default command line for all Fortran versions.
7562
7563
7564 SHF90COMSTR
7565 The string displayed when a Fortran 90 source file is compiled
7566 to a shared-library object file. If this is not set, then
7567 $SHF90COM or $SHFORTRANCOM (the command line) is displayed.
7568
7569
7570 SHF90FLAGS
7571 Options that are passed to the Fortran 90 compiler to generated
7572 shared-library objects. You only need to set $SHF90FLAGS if you
7573 need to define specific user options for Fortran 90 files. You
7574 should normally set the $SHFORTRANFLAGS variable, which speci‐
7575 fies the user-specified options passed to the default Fortran
7576 compiler for all Fortran versions.
7577
7578
7579 SHF90PPCOM
7580 The command line used to compile a Fortran 90 source file to a
7581 shared-library object file after first running the file through
7582 the C preprocessor. Any options specified in the $SHF90FLAGS
7583 and $CPPFLAGS construction variables are included on this com‐
7584 mand line. You only need to set $SHF90PPCOM if you need to use
7585 a specific C-preprocessor command line for Fortran 90 files.
7586 You should normally set the $SHFORTRANPPCOM variable, which
7587 specifies the default C-preprocessor command line for all For‐
7588 tran versions.
7589
7590
7591 SHF90PPCOMSTR
7592 The string displayed when a Fortran 90 source file is compiled
7593 to a shared-library object file after first running the file
7594 through the C preprocessor. If this is not set, then
7595 $SHF90PPCOM or $SHFORTRANPPCOM (the command line) is displayed.
7596
7597
7598 SHF95 The Fortran 95 compiler used for generating shared-library
7599 objects. You should normally set the $SHFORTRAN variable, which
7600 specifies the default Fortran compiler for all Fortran versions.
7601 You only need to set $SHF95 if you need to use a specific com‐
7602 piler or compiler version for Fortran 95 files.
7603
7604
7605 SHF95COM
7606 The command line used to compile a Fortran 95 source file to a
7607 shared-library object file. You only need to set $SHF95COM if
7608 you need to use a specific command line for Fortran 95 files.
7609 You should normally set the $SHFORTRANCOM variable, which speci‐
7610 fies the default command line for all Fortran versions.
7611
7612
7613 SHF95COMSTR
7614 The string displayed when a Fortran 95 source file is compiled
7615 to a shared-library object file. If this is not set, then
7616 $SHF95COM or $SHFORTRANCOM (the command line) is displayed.
7617
7618
7619 SHF95FLAGS
7620 Options that are passed to the Fortran 95 compiler to generated
7621 shared-library objects. You only need to set $SHF95FLAGS if you
7622 need to define specific user options for Fortran 95 files. You
7623 should normally set the $SHFORTRANFLAGS variable, which speci‐
7624 fies the user-specified options passed to the default Fortran
7625 compiler for all Fortran versions.
7626
7627
7628 SHF95PPCOM
7629 The command line used to compile a Fortran 95 source file to a
7630 shared-library object file after first running the file through
7631 the C preprocessor. Any options specified in the $SHF95FLAGS
7632 and $CPPFLAGS construction variables are included on this com‐
7633 mand line. You only need to set $SHF95PPCOM if you need to use
7634 a specific C-preprocessor command line for Fortran 95 files.
7635 You should normally set the $SHFORTRANPPCOM variable, which
7636 specifies the default C-preprocessor command line for all For‐
7637 tran versions.
7638
7639
7640 SHF95PPCOMSTR
7641 The string displayed when a Fortran 95 source file is compiled
7642 to a shared-library object file after first running the file
7643 through the C preprocessor. If this is not set, then
7644 $SHF95PPCOM or $SHFORTRANPPCOM (the command line) is displayed.
7645
7646
7647 SHFORTRAN
7648 The default Fortran compiler used for generating shared-library
7649 objects.
7650
7651
7652 SHFORTRANCOM
7653 The command line used to compile a Fortran source file to a
7654 shared-library object file.
7655
7656
7657 SHFORTRANCOMSTR
7658 The string displayed when a Fortran source file is compiled to a
7659 shared-library object file. If this is not set, then $SHFOR‐
7660 TRANCOM (the command line) is displayed.
7661
7662
7663 SHFORTRANFLAGS
7664 Options that are passed to the Fortran compiler to generate
7665 shared-library objects.
7666
7667
7668 SHFORTRANPPCOM
7669 The command line used to compile a Fortran source file to a
7670 shared-library object file after first running the file through
7671 the C preprocessor. Any options specified in the $SHFORTRAN‐
7672 FLAGS and $CPPFLAGS construction variables are included on this
7673 command line.
7674
7675
7676 SHFORTRANPPCOMSTR
7677 The string displayed when a Fortran source file is compiled to a
7678 shared-library object file after first running the file through
7679 the C preprocessor. If this is not set, then $SHFORTRANPPCOM
7680 (the command line) is displayed.
7681
7682
7683 SHLIBEMITTER
7684 TODO
7685
7686
7687 SHLIBPREFIX
7688 The prefix used for shared library file names.
7689
7690
7691 SHLIBSUFFIX
7692 The suffix used for shared library file names.
7693
7694
7695 SHLINK The linker for programs that use shared libraries.
7696
7697
7698 SHLINKCOM
7699 The command line used to link programs using shared libraries.
7700
7701
7702 SHLINKCOMSTR
7703 The string displayed when programs using shared libraries are
7704 linked. If this is not set, then $SHLINKCOM (the command line)
7705 is displayed.
7706
7707 env = Environment(SHLINKCOMSTR = "Linking shared $TARGET")
7708
7709
7710 SHLINKFLAGS
7711 General user options passed to the linker for programs using
7712 shared libraries. Note that this variable should not contain -l
7713 (or similar) options for linking with the libraries listed in
7714 $LIBS, nor -L (or similar) include search path options that
7715 scons generates automatically from $LIBPATH. See $_LIBFLAGS
7716 above, for the variable that expands to library-link options,
7717 and $_LIBDIRFLAGS above, for the variable that expands to
7718 library search path options.
7719
7720
7721 SHOBJPREFIX
7722 The prefix used for shared object file names.
7723
7724
7725 SHOBJSUFFIX
7726 The suffix used for shared object file names.
7727
7728
7729 SOURCE A reserved variable name that may not be set or used in a con‐
7730 struction environment. (See "Variable Substitution," below.)
7731
7732
7733 SOURCE_URL
7734 The URL (web address) of the location from which the project was
7735 retrieved. This is used to fill in the Source: field in the
7736 controlling information for Ipkg and RPM packages.
7737
7738
7739 SOURCES
7740 A reserved variable name that may not be set or used in a con‐
7741 struction environment. (See "Variable Substitution," below.)
7742
7743
7744 SPAWN A command interpreter function that will be called to execute
7745 command line strings. The function must expect the following
7746 arguments:
7747
7748 def spawn(shell, escape, cmd, args, env):
7749
7750 sh is a string naming the shell program to use. escape is a
7751 function that can be called to escape shell special characters
7752 in the command line. cmd is the path to the command to be exe‐
7753 cuted. args is the arguments to the command. env is a dictio‐
7754 nary of the environment variables in which the command should be
7755 executed.
7756
7757
7758 SUBST_DICT
7759 The dictionary used by the Substfile() or Textfile() builders
7760 for substitution values. It can be anything acceptable to the
7761 dict() constructor, so in addition to a dictionary, lists of
7762 tuples are also acceptable.
7763
7764
7765 SUBSTFILEPREFIX
7766 The prefix used for Substfile() file names, the null string by
7767 default.
7768
7769
7770 SUBSTFILESUFFIX
7771 The suffix used for Substfile() file names, the null string by
7772 default.
7773
7774
7775 SUMMARY
7776 A short summary of what the project is about. This is used to
7777 fill in the Summary: field in the controlling information for
7778 Ipkg and RPM packages, and as the Description: field in MSI
7779 packages.
7780
7781
7782 SWIG The scripting language wrapper and interface generator.
7783
7784
7785 SWIGCFILESUFFIX
7786 The suffix that will be used for intermediate C source files
7787 generated by the scripting language wrapper and interface gener‐
7788 ator. The default value is _wrap$CFILESUFFIX. By default, this
7789 value is used whenever the -c++ option is not specified as part
7790 of the $SWIGFLAGS construction variable.
7791
7792
7793 SWIGCOM
7794 The command line used to call the scripting language wrapper and
7795 interface generator.
7796
7797
7798 SWIGCOMSTR
7799 The string displayed when calling the scripting language wrapper
7800 and interface generator. If this is not set, then $SWIGCOM (the
7801 command line) is displayed.
7802
7803
7804 SWIGCXXFILESUFFIX
7805 The suffix that will be used for intermediate C++ source files
7806 generated by the scripting language wrapper and interface gener‐
7807 ator. The default value is _wrap$CFILESUFFIX. By default, this
7808 value is used whenever the -c++ option is specified as part of
7809 the $SWIGFLAGS construction variable.
7810
7811
7812 SWIGDIRECTORSUFFIX
7813 The suffix that will be used for intermediate C++ header files
7814 generated by the scripting language wrapper and interface gener‐
7815 ator. These are only generated for C++ code when the SWIG
7816 'directors' feature is turned on. The default value is _wrap.h.
7817
7818
7819 SWIGFLAGS
7820 General options passed to the scripting language wrapper and
7821 interface generator. This is where you should set -python,
7822 -perl5, -tcl, or whatever other options you want to specify to
7823 SWIG. If you set the -c++ option in this variable, scons will,
7824 by default, generate a C++ intermediate source file with the
7825 extension that is specified as the $CXXFILESUFFIX variable.
7826
7827
7828 _SWIGINCFLAGS
7829 An automatically-generated construction variable containing the
7830 SWIG command-line options for specifying directories to be
7831 searched for included files. The value of $_SWIGINCFLAGS is
7832 created by appending $SWIGINCPREFIX and $SWIGINCSUFFIX to the
7833 beginning and end of each directory in $SWIGPATH.
7834
7835
7836 SWIGINCPREFIX
7837 The prefix used to specify an include directory on the SWIG com‐
7838 mand line. This will be appended to the beginning of each
7839 directory in the $SWIGPATH construction variable when the
7840 $_SWIGINCFLAGS variable is automatically generated.
7841
7842
7843 SWIGINCSUFFIX
7844 The suffix used to specify an include directory on the SWIG com‐
7845 mand line. This will be appended to the end of each directory
7846 in the $SWIGPATH construction variable when the $_SWIGINCFLAGS
7847 variable is automatically generated.
7848
7849
7850 SWIGOUTDIR
7851 Specifies the output directory in which the scripting language
7852 wrapper and interface generator should place generated language-
7853 specific files. This will be used by SCons to identify the
7854 files that will be generated by the &swig; call, and translated
7855 into the swig -outdir option on the command line.
7856
7857
7858 SWIGPATH
7859 The list of directories that the scripting language wrapper and
7860 interface generate will search for included files. The SWIG
7861 implicit dependency scanner will search these directories for
7862 include files. The default is to use the same path specified as
7863 $CPPPATH.
7864
7865 Don't explicitly put include directory arguments in SWIGFLAGS;
7866 the result will be non-portable and the directories will not be
7867 searched by the dependency scanner. Note: directory names in
7868 SWIGPATH will be looked-up relative to the SConscript directory
7869 when they are used in a command. To force scons to look-up a
7870 directory relative to the root of the source tree use #:
7871
7872 env = Environment(SWIGPATH='#/include')
7873
7874 The directory look-up can also be forced using the Dir() func‐
7875 tion:
7876
7877 include = Dir('include')
7878 env = Environment(SWIGPATH=include)
7879
7880 The directory list will be added to command lines through the
7881 automatically-generated $_SWIGINCFLAGS construction variable,
7882 which is constructed by appending the values of the $SWIGINCPRE‐
7883 FIXand$SWIGINCSUFFIX construction variables to the beginning and
7884 end of each directory in $SWIGPATH. Any command lines you
7885 define that need the SWIGPATH directory list should include
7886 $_SWIGINCFLAGS:
7887
7888 env = Environment(SWIGCOM="my_swig -o $TARGET $_SWIGINCFLAGS $SORUCES")
7889
7890
7891 SWIGVERSION
7892 The version number of the SWIG tool.
7893
7894
7895 TAR The tar archiver.
7896
7897
7898 TARCOM The command line used to call the tar archiver.
7899
7900
7901 TARCOMSTR
7902 The string displayed when archiving files using the tar
7903 archiver. If this is not set, then $TARCOM (the command line)
7904 is displayed.
7905
7906 env = Environment(TARCOMSTR = "Archiving $TARGET")
7907
7908
7909 TARFLAGS
7910 General options passed to the tar archiver.
7911
7912
7913 TARGET A reserved variable name that may not be set or used in a con‐
7914 struction environment. (See "Variable Substitution," below.)
7915
7916
7917 TARGET_ARCH
7918 Sets the target architecture for Visual Studio compiler (i.e.
7919 the arch of the binaries generated by the compiler). If not set,
7920 default to $HOST_ARCH, or, if that is unset, to the architecture
7921 of the running machine's OS (note that the python build or
7922 architecture has no effect). This variable must be passed as an
7923 argument to the Environment() constructor; setting it later has
7924 no effect. This is currently only used on Windows, but in the
7925 future it will be used on other OSes as well.
7926
7927 Valid values for Windows are x86, i386 (for 32 bits); amd64,
7928 emt64, x86_64 (for 64 bits); and ia64 (Itanium). For example,
7929 if you want to compile 64-bit binaries, you would set TAR‐
7930 GET_ARCH='x86_64' in your SCons environment.
7931
7932
7933 TARGET_OS
7934 The name of the target operating system for the compiled
7935 objects
7936 created by this Environment.
7937 This defaults to the value of HOST_OS, and the user can
7938 override it.
7939 Currently only set for Win32.
7940
7941
7942 TARGETS
7943 A reserved variable name that may not be set or used in a con‐
7944 struction environment. (See "Variable Substitution," below.)
7945
7946
7947 TARSUFFIX
7948 The suffix used for tar file names.
7949
7950
7951 TEMPFILEPREFIX
7952 The prefix for a temporary file used to execute lines longer
7953 than $MAXLINELENGTH. The default is '@'. This may be set for
7954 toolchains that use other values, such as '-@' for the diab com‐
7955 piler or '-via' for ARM toolchain.
7956
7957
7958 TEX The TeX formatter and typesetter.
7959
7960
7961 TEXCOM The command line used to call the TeX formatter and typesetter.
7962
7963
7964 TEXCOMSTR
7965 The string displayed when calling the TeX formatter and typeset‐
7966 ter. If this is not set, then $TEXCOM (the command line) is
7967 displayed.
7968
7969 env = Environment(TEXCOMSTR = "Building $TARGET from TeX input $SOURCES")
7970
7971
7972 TEXFLAGS
7973 General options passed to the TeX formatter and typesetter.
7974
7975
7976 TEXINPUTS
7977 List of directories that the LaTeX program will search for
7978 include directories. The LaTeX implicit dependency scanner will
7979 search these directories for \include and \import files.
7980
7981
7982 TEXTFILEPREFIX
7983 The prefix used for Textfile() file names, the null string by
7984 default.
7985
7986
7987 TEXTFILESUFFIX
7988 The suffix used for Textfile() file names; .txt by default.
7989
7990
7991 TOOLS A list of the names of the Tool specifications that are part of
7992 this construction environment.
7993
7994
7995 UNCHANGED_SOURCES
7996 A reserved variable name that may not be set or used in a con‐
7997 struction environment. (See "Variable Substitution," below.)
7998
7999
8000 UNCHANGED_TARGETS
8001 A reserved variable name that may not be set or used in a con‐
8002 struction environment. (See "Variable Substitution," below.)
8003
8004
8005 VENDOR The person or organization who supply the packaged software.
8006 This is used to fill in the Vendor: field in the controlling
8007 information for RPM packages, and the Manufacturer: field in the
8008 controlling information for MSI packages.
8009
8010
8011 VERSION
8012 The version of the project, specified as a string.
8013
8014
8015 WIN32_INSERT_DEF
8016 A deprecated synonym for $WINDOWS_INSERT_DEF.
8017
8018
8019 WIN32DEFPREFIX
8020 A deprecated synonym for $WINDOWSDEFPREFIX.
8021
8022
8023 WIN32DEFSUFFIX
8024 A deprecated synonym for $WINDOWSDEFSUFFIX.
8025
8026
8027 WIN32EXPPREFIX
8028 A deprecated synonym for $WINDOWSEXPSUFFIX.
8029
8030
8031 WIN32EXPSUFFIX
8032 A deprecated synonym for $WINDOWSEXPSUFFIX.
8033
8034
8035 WINDOWS_EMBED_MANIFEST
8036 Set this variable to True or 1 to embed the compiler-generated
8037 manifest (normally ${TARGET}.manifest) into all Windows exes and
8038 DLLs built with this environment, as a resource during their
8039 link step. This is done using $MT and $MTEXECOM and $MTSHLIB‐
8040 COM.
8041
8042
8043 WINDOWS_INSERT_DEF
8044 When this is set to true, a library build of a Windows shared
8045 library (.dllfile) will also build a corresponding .def file at
8046 the same time, if a .def file is not already listed as a build
8047 target. The default is 0 (do not build a .def file).
8048
8049
8050 WINDOWS_INSERT_MANIFEST
8051 When this is set to true, scons will be aware of the .manifest
8052 files generated by Microsoft Visua C/C++ 8.
8053
8054
8055 WINDOWSDEFPREFIX
8056 The prefix used for Windows .def file names.
8057
8058
8059 WINDOWSDEFSUFFIX
8060 The suffix used for Windows .def file names.
8061
8062
8063 WINDOWSEXPPREFIX
8064 The prefix used for Windows .exp file names.
8065
8066
8067 WINDOWSEXPSUFFIX
8068 The suffix used for Windows .exp file names.
8069
8070
8071 WINDOWSPROGMANIFESTPREFIX
8072 The prefix used for executable program .manifest files generated
8073 by Microsoft Visual C/C++.
8074
8075
8076 WINDOWSPROGMANIFESTSUFFIX
8077 The suffix used for executable program .manifest files generated
8078 by Microsoft Visual C/C++.
8079
8080
8081 WINDOWSSHLIBMANIFESTPREFIX
8082 The prefix used for shared library .manifest files generated by
8083 Microsoft Visual C/C++.
8084
8085
8086 WINDOWSSHLIBMANIFESTSUFFIX
8087 The suffix used for shared library .manifest files generated by
8088 Microsoft Visual C/C++.
8089
8090
8091 X_IPK_DEPENDS
8092 This is used to fill in the Depends: field in the controlling
8093 information for Ipkg packages.
8094
8095
8096 X_IPK_DESCRIPTION
8097 This is used to fill in the Description: field in the control‐
8098 ling information for Ipkg packages. The default value is $SUM‐
8099 MARY0DESCRIPTION
8100
8101 X_IPK_MAINTAINER
8102 This is used to fill in the Maintainer: field in the controlling
8103 information for Ipkg packages.
8104
8105
8106 X_IPK_PRIORITY
8107 This is used to fill in the Priority: field in the controlling
8108 information for Ipkg packages.
8109
8110
8111 X_IPK_SECTION
8112 This is used to fill in the Section: field in the controlling
8113 information for Ipkg packages.
8114
8115
8116 X_MSI_LANGUAGE
8117 This is used to fill in the Language: attribute in the control‐
8118 ling information for MSI packages.
8119
8120
8121 X_MSI_LICENSE_TEXT
8122 The text of the software license in RTF format. Carriage return
8123 characters will be replaced with the RTF equivalent \\par.
8124
8125
8126 X_MSI_UPGRADE_CODE
8127 TODO
8128
8129
8130 X_RPM_AUTOREQPROV
8131 This is used to fill in the AutoReqProv: field in the RPM .spec
8132 file.
8133
8134
8135 X_RPM_BUILD
8136 internal, but overridable
8137
8138
8139 X_RPM_BUILDREQUIRES
8140 This is used to fill in the BuildRequires: field in the RPM
8141 .spec file.
8142
8143
8144 X_RPM_BUILDROOT
8145 internal, but overridable
8146
8147
8148 X_RPM_CLEAN
8149 internal, but overridable
8150
8151
8152 X_RPM_CONFLICTS
8153 This is used to fill in the Conflicts: field in the RPM .spec
8154 file.
8155
8156
8157 X_RPM_DEFATTR
8158 This value is used as the default attributes for the files in
8159 the RPM package. The default value is (-,root,root).
8160
8161
8162 X_RPM_DISTRIBUTION
8163 This is used to fill in the Distribution: field in the RPM .spec
8164 file.
8165
8166
8167 X_RPM_EPOCH
8168 This is used to fill in the Epoch: field in the controlling
8169 information for RPM packages.
8170
8171
8172 X_RPM_EXCLUDEARCH
8173 This is used to fill in the ExcludeArch: field in the RPM .spec
8174 file.
8175
8176
8177 X_RPM_EXLUSIVEARCH
8178 This is used to fill in the ExclusiveArch: field in the RPM
8179 .spec file.
8180
8181
8182 X_RPM_GROUP
8183 This is used to fill in the Group: field in the RPM .spec file.
8184
8185
8186 X_RPM_GROUP_lang
8187 This is used to fill in the Group(lang): field in the RPM .spec
8188 file. Note that lang is not literal and should be replaced by
8189 the appropriate language code.
8190
8191
8192 X_RPM_ICON
8193 This is used to fill in the Icon: field in the RPM .spec file.
8194
8195
8196 X_RPM_INSTALL
8197 internal, but overridable
8198
8199
8200 X_RPM_PACKAGER
8201 This is used to fill in the Packager: field in the RPM .spec
8202 file.
8203
8204
8205 X_RPM_POSTINSTALL
8206 This is used to fill in the %post: section in the RPM .spec
8207 file.
8208
8209
8210 X_RPM_POSTUNINSTALL
8211 This is used to fill in the %postun: section in the RPM .spec
8212 file.
8213
8214
8215 X_RPM_PREFIX
8216 This is used to fill in the Prefix: field in the RPM .spec file.
8217
8218
8219 X_RPM_PREINSTALL
8220 This is used to fill in the %pre: section in the RPM .spec file.
8221
8222
8223 X_RPM_PREP
8224 internal, but overridable
8225
8226
8227 X_RPM_PREUNINSTALL
8228 This is used to fill in the %preun: section in the RPM .spec
8229 file.
8230
8231
8232 X_RPM_PROVIDES
8233 This is used to fill in the Provides: field in the RPM .spec
8234 file.
8235
8236
8237 X_RPM_REQUIRES
8238 This is used to fill in the Requires: field in the RPM .spec
8239 file.
8240
8241
8242 X_RPM_SERIAL
8243 This is used to fill in the Serial: field in the RPM .spec file.
8244
8245
8246 X_RPM_URL
8247 This is used to fill in the Url: field in the RPM .spec file.
8248
8249
8250 YACC The parser generator.
8251
8252
8253 YACCCOM
8254 The command line used to call the parser generator to generate a
8255 source file.
8256
8257
8258 YACCCOMSTR
8259 The string displayed when generating a source file using the
8260 parser generator. If this is not set, then $YACCCOM (the com‐
8261 mand line) is displayed.
8262
8263 env = Environment(YACCCOMSTR = "Yacc'ing $TARGET from $SOURCES")
8264
8265
8266 YACCFLAGS
8267 General options passed to the parser generator. If $YACCFLAGS
8268 contains a -d option, SCons assumes that the call will also cre‐
8269 ate a .h file (if the yacc source file ends in a .y suffix) or a
8270 .hpp file (if the yacc source file ends in a .yy suffix)
8271
8272
8273 YACCHFILESUFFIX
8274 The suffix of the C header file generated by the parser genera‐
8275 tor when the -d option is used. Note that setting this variable
8276 does not cause the parser generator to generate a header file
8277 with the specified suffix, it exists to allow you to specify
8278 what suffix the parser generator will use of its own accord.
8279 The default value is .h.
8280
8281
8282 YACCHXXFILESUFFIX
8283 The suffix of the C++ header file generated by the parser gener‐
8284 ator when the -d option is used. Note that setting this vari‐
8285 able does not cause the parser generator to generate a header
8286 file with the specified suffix, it exists to allow you to spec‐
8287 ify what suffix the parser generator will use of its own accord.
8288 The default value is .hpp, except on Mac OS X, where the default
8289 is ${TARGET.suffix}.h. because the default &bison; parser gen‐
8290 erator just appends .h to the name of the generated C++ file.
8291
8292
8293 YACCVCGFILESUFFIX
8294 The suffix of the file containing the VCG grammar automaton def‐
8295 inition when the --graph= option is used. Note that setting
8296 this variable does not cause the parser generator to generate a
8297 VCG file with the specified suffix, it exists to allow you to
8298 specify what suffix the parser generator will use of its own
8299 accord. The default value is .vcg.
8300
8301
8302 ZIP The zip compression and file packaging utility.
8303
8304
8305 ZIPCOM The command line used to call the zip utility, or the internal
8306 Python function used to create a zip archive.
8307
8308
8309 ZIPCOMPRESSION
8310 The compression flag from the Python zipfile module used by the
8311 internal Python function to control whether the zip archive is
8312 compressed or not. The default value is zipfile.ZIP_DEFLATED,
8313 which creates a compressed zip archive. This value has no
8314 effect if the zipfile module is unavailable.
8315
8316
8317 ZIPCOMSTR
8318 The string displayed when archiving files using the zip utility.
8319 If this is not set, then $ZIPCOM (the command line or internal
8320 Python function) is displayed.
8321
8322 env = Environment(ZIPCOMSTR = "Zipping $TARGET")
8323
8324
8325 ZIPFLAGS
8326 General options passed to the zip utility.
8327
8328
8329 ZIPSUFFIX
8330 The suffix used for zip file names.
8331
8332
8333 Construction variables can be retrieved and set using the Dictionary
8334 method of the construction environment:
8335
8336 dict = env.Dictionary()
8337 dict["CC"] = "cc"
8338
8339 or using the [] operator:
8340
8341 env["CC"] = "cc"
8342
8343 Construction variables can also be passed to the construction environ‐
8344 ment constructor:
8345
8346 env = Environment(CC="cc")
8347
8348 or when copying a construction environment using the Clone method:
8349
8350 env2 = env.Clone(CC="cl.exe")
8351
8352
8353 Configure Contexts
8354 scons supports configure contexts, an integrated mechanism similar to
8355 the various AC_CHECK macros in GNU autoconf for testing for the exis‐
8356 tence of C header files, libraries, etc. In contrast to autoconf,
8357 scons does not maintain an explicit cache of the tested values, but
8358 uses its normal dependency tracking to keep the checked values up to
8359 date. However, users may override this behaviour with the --config com‐
8360 mand line option.
8361
8362 The following methods can be used to perform checks:
8363
8364
8365 Configure(env, [custom_tests, conf_dir, log_file, config_h, clean,
8366 help])
8367
8368 env.Configure([custom_tests, conf_dir, log_file, config_h, clean,
8369 help])
8370 This creates a configure context, which can be used to perform
8371 checks. env specifies the environment for building the tests.
8372 This environment may be modified when performing checks. cus‐
8373 tom_tests is a dictionary containing custom tests. See also the
8374 section about custom tests below. By default, no custom tests
8375 are added to the configure context. conf_dir specifies a direc‐
8376 tory where the test cases are built. Note that this directory
8377 is not used for building normal targets. The default value is
8378 the directory #/.sconf_temp. log_file specifies a file which
8379 collects the output from commands that are executed to check for
8380 the existence of header files, libraries, etc. The default is
8381 the file #/config.log. If you are using the VariantDir()
8382 method, you may want to specify a subdirectory under your vari‐
8383 ant directory. config_h specifies a C header file where the
8384 results of tests will be written, e.g. #define HAVE_STDIO_H,
8385 #define HAVE_LIBM, etc. The default is to not write a config.h
8386 file. You can specify the same config.h file in multiple calls
8387 to Configure, in which case scons will concatenate all results
8388 in the specified file. Note that SCons uses its normal depen‐
8389 dency checking to decide if it's necessary to rebuild the speci‐
8390 fied config_h file. This means that the file is not necessarily
8391 re-built each time scons is run, but is only rebuilt if its con‐
8392 tents will have changed and some target that depends on the con‐
8393 fig_h file is being built.
8394
8395 The optional clean and help arguments can be used to suppress
8396 execution of the configuration tests when the -c/--clean or
8397 -H/-h/--help options are used, respectively. The default behav‐
8398 ior is always to execute configure context tests, since the
8399 results of the tests may affect the list of targets to be
8400 cleaned or the help text. If the configure tests do not affect
8401 these, then you may add the clean=False or help=False arguments
8402 (or both) to avoid unnecessary test execution.
8403
8404 A created Configure instance has the following associated methods:
8405
8406
8407 SConf.Finish(context)
8408
8409 sconf.Finish()
8410 This method should be called after configuration is done. It
8411 returns the environment as modified by the configuration checks
8412 performed. After this method is called, no further checks can
8413 be performed with this configuration context. However, you can
8414 create a new Configure context to perform additional checks.
8415 Only one context should be active at a time.
8416
8417 The following Checks are predefined. (This list will likely
8418 grow larger as time goes by and developers contribute new useful
8419 tests.)
8420
8421
8422 SConf.CheckHeader(context, header, [include_quotes, language])
8423
8424 sconf.CheckHeader(header, [include_quotes, language])
8425 Checks if header is usable in the specified language. header
8426 may be a list, in which case the last item in the list is the
8427 header file to be checked, and the previous list items are
8428 header files whose #include lines should precede the header line
8429 being checked for. The optional argument include_quotes must be
8430 a two character string, where the first character denotes the
8431 opening quote and the second character denotes the closing
8432 quote. By default, both characters are " (double quote). The
8433 optional argument language should be either C or C++ and selects
8434 the compiler to be used for the check. Returns 1 on success and
8435 0 on failure.
8436
8437
8438 SConf.CheckCHeader(context, header, [include_quotes])
8439
8440 sconf.CheckCHeader(header, [include_quotes])
8441 This is a wrapper around SConf.CheckHeader which checks if
8442 header is usable in the C language. header may be a list, in
8443 which case the last item in the list is the header file to be
8444 checked, and the previous list items are header files whose
8445 #include lines should precede the header line being checked for.
8446 The optional argument include_quotes must be a two character
8447 string, where the first character denotes the opening quote and
8448 the second character denotes the closing quote (both default to
8449 "). Returns 1 on success and 0 on failure.
8450
8451
8452 SConf.CheckCXXHeader(context, header, [include_quotes])
8453
8454 sconf.CheckCXXHeader(header, [include_quotes])
8455 This is a wrapper around SConf.CheckHeader which checks if
8456 header is usable in the C++ language. header may be a list, in
8457 which case the last item in the list is the header file to be
8458 checked, and the previous list items are header files whose
8459 #include lines should precede the header line being checked for.
8460 The optional argument include_quotes must be a two character
8461 string, where the first character denotes the opening quote and
8462 the second character denotes the closing quote (both default to
8463 "). Returns 1 on success and 0 on failure.
8464
8465
8466 SConf.CheckFunc(context,, function_name, [header, language])
8467
8468 sconf.CheckFunc(function_name, [header, language])
8469 Checks if the specified C or C++ function is available. func‐
8470 tion_name is the name of the function to check for. The
8471 optional header argument is a string that will be placed at the
8472 top of the test file that will be compiled to check if the func‐
8473 tion exists; the default is:
8474 #ifdef __cplusplus
8475 extern "C"
8476 #endif
8477 char function_name();
8478 The optional language argument should be C or C++ and selects the com‐
8479 piler to be used for the check; the default is "C".
8480
8481
8482 SConf.CheckLib(context, [library, symbol, header, language, autoadd=1])
8483
8484 sconf.CheckLib([library, symbol, header, language, autoadd=1])
8485 Checks if library provides symbol. If the value of autoadd is 1
8486 and the library provides the specified symbol, appends the
8487 library to the LIBS construction environment variable. library
8488 may also be None (the default), in which case symbol is checked
8489 with the current LIBS variable, or a list of library names, in
8490 which case each library in the list will be checked for symbol.
8491 If symbol is not set or is None, then SConf.CheckLib() just
8492 checks if you can link against the specified library. The
8493 optional language argument should be C or C++ and selects the
8494 compiler to be used for the check; the default is "C". The
8495 default value for autoadd is 1. This method returns 1 on suc‐
8496 cess and 0 on error.
8497
8498
8499 SConf.CheckLibWithHeader(context, library, header, language, [call,
8500 autoadd])
8501
8502 sconf.CheckLibWithHeader(library, header, language, [call, autoadd])
8503
8504 In contrast to the SConf.CheckLib call, this call provides a
8505 more sophisticated way to check against libraries. Again,
8506 library specifies the library or a list of libraries to check.
8507 header specifies a header to check for. header may be a list,
8508 in which case the last item in the list is the header file to be
8509 checked, and the previous list items are header files whose
8510 #include lines should precede the header line being checked for.
8511 language may be one of 'C','c','CXX','cxx','C++' and 'c++'.
8512 call can be any valid expression (with a trailing ';'). If call
8513 is not set, the default simply checks that you can link against
8514 the specified library. autoadd specifies whether to add the
8515 library to the environment (only if the check succeeds). This
8516 method returns 1 on success and 0 on error.
8517
8518
8519 SConf.CheckType(context, type_name, [includes, language])
8520
8521 sconf.CheckType(type_name, [includes, language])
8522 Checks for the existence of a type defined by typedef.
8523 type_name specifies the typedef name to check for. includes is
8524 a string containing one or more #include lines that will be
8525 inserted into the program that will be run to test for the exis‐
8526 tence of the type. The optional language argument should be C
8527 or C++ and selects the compiler to be used for the check; the
8528 default is "C". Example:
8529 sconf.CheckType('foo_type', '#include "my_types.h"', 'C++')
8530
8531
8532 Configure.CheckCC(self)
8533 Checks whether the C compiler (as defined by the CC construction
8534 variable) works by trying to compile a small source file.
8535
8536 By default, SCons only detects if there is a program with the
8537 correct name, not if it is a functioning compiler.
8538
8539 This uses the exact same command than the one used by the object
8540 builder for C source file, so it can be used to detect if a par‐
8541 ticular compiler flag works or not.
8542
8543
8544 Configure.CheckCXX(self)
8545 Checks whether the C++ compiler (as defined by the CXX construc‐
8546 tion variable) works by trying to compile a small source file.
8547 By default, SCons only detects if there is a program with the
8548 correct name, not if it is a functioning compiler.
8549
8550 This uses the exact same command than the one used by the object
8551 builder for CXX source files, so it can be used to detect if a
8552 particular compiler flag works or not.
8553
8554
8555 Configure.CheckSHCC(self)
8556 Checks whether the C compiler (as defined by the SHCC construc‐
8557 tion variable) works by trying to compile a small source file.
8558 By default, SCons only detects if there is a program with the
8559 correct name, not if it is a functioning compiler.
8560
8561 This uses the exact same command than the one used by the object
8562 builder for C source file, so it can be used to detect if a par‐
8563 ticular compiler flag works or not. This does not check whether
8564 the object code can be used to build a shared library, only that
8565 the compilation (not link) succeeds.
8566
8567
8568 Configure.CheckSHCXX(self)
8569 Checks whether the C++ compiler (as defined by the SHCXX con‐
8570 struction variable) works by trying to compile a small source
8571 file. By default, SCons only detects if there is a program with
8572 the correct name, not if it is a functioning compiler.
8573
8574 This uses the exact same command than the one used by the object
8575 builder for CXX source files, so it can be used to detect if a
8576 particular compiler flag works or not. This does not check
8577 whether the object code can be used to build a shared library,
8578 only that the compilation (not link) succeeds.
8579
8580 Example of a typical Configure usage:
8581
8582 env = Environment()
8583 conf = Configure( env )
8584 if not conf.CheckCHeader( 'math.h' ):
8585 print 'We really need math.h!'
8586 Exit(1)
8587 if conf.CheckLibWithHeader( 'qt', 'qapp.h', 'c++',
8588 'QApplication qapp(0,0);' ):
8589 # do stuff for qt - usage, e.g.
8590 conf.env.Append( CPPFLAGS = '-DWITH_QT' )
8591 env = conf.Finish()
8592
8593
8594 SConf.CheckTypeSize(context, type_name, [header, language, expect])
8595
8596 sconf.CheckTypeSize(type_name, [header, language, expect])
8597 Checks for the size of a type defined by typedef. type_name
8598 specifies the typedef name to check for. The optional header
8599 argument is a string that will be placed at the top of the test
8600 file that will be compiled to check if the function exists; the
8601 default is empty. The optional language argument should be C or
8602 C++ and selects the compiler to be used for the check; the
8603 default is "C". The optional expect argument should be an inte‐
8604 ger. If this argument is used, the function will only check
8605 whether the type given in type_name has the expected size (in
8606 bytes). For example, CheckTypeSize('short', expect = 2) will
8607 return success only if short is two bytes.
8608
8609
8610
8611 SConf.CheckDeclaration(context, symbol, [includes, language])
8612
8613 sconf.CheckDeclaration(symbol, [includes, language])
8614 Checks if the specified symbol is declared. includes is a
8615 string containing one or more #include lines that will be
8616 inserted into the program that will be run to test for the exis‐
8617 tence of the type. The optional language argument should be C
8618 or C++ and selects the compiler to be used for the check; the
8619 default is "C".
8620
8621
8622 SConf.Define(context, symbol, [value, comment])
8623
8624 sconf.Define(symbol, [value, comment])
8625 This function does not check for anything, but defines a pre‐
8626 processor symbol that will be added to the configuration header
8627 file. It is the equivalent of AC_DEFINE, and defines the symbol
8628 name with the optional value and the optional comment comment.
8629
8630
8631 Examples:
8632
8633 env = Environment()
8634 conf = Configure( env )
8635
8636 # Puts the following line in the config header file:
8637 # #define A_SYMBOL
8638 conf.Define('A_SYMBOL')
8639
8640 # Puts the following line in the config header file:
8641 # #define A_SYMBOL 1
8642 conf.Define('A_SYMBOL', 1)
8643
8644
8645 Be careful about quoting string values, though:
8646
8647 env = Environment()
8648 conf = Configure( env )
8649
8650 # Puts the following line in the config header file:
8651 # #define A_SYMBOL YA
8652 conf.Define('A_SYMBOL', "YA")
8653
8654 # Puts the following line in the config header file:
8655 # #define A_SYMBOL "YA"
8656 conf.Define('A_SYMBOL', '"YA"')
8657
8658
8659 For comment:
8660
8661 env = Environment()
8662 conf = Configure( env )
8663
8664 # Puts the following lines in the config header file:
8665 # /* Set to 1 if you have a symbol */
8666 # #define A_SYMBOL 1
8667 conf.Define('A_SYMBOL', 1, 'Set to 1 if you have a symbol')
8668
8669 You can define your own custom checks. in addition to the predefined
8670 checks. These are passed in a dictionary to the Configure function.
8671 This dictionary maps the names of the checks to user defined Python
8672 callables (either Python functions or class instances implementing the
8673 __call__ method). The first argument of the call is always a CheckCon‐
8674 text instance followed by the arguments, which must be supplied by the
8675 user of the check. These CheckContext instances define the following
8676 methods:
8677
8678
8679 CheckContext.Message(self, text)
8680
8681 Usually called before the check is started. text will be dis‐
8682 played to the user, e.g. 'Checking for library X...'
8683
8684
8685 CheckContext.Result(self,, res)
8686
8687 Usually called after the check is done. res can be either an
8688 integer or a string. In the former case, 'yes' (res != 0) or
8689 'no' (res == 0) is displayed to the user, in the latter case the
8690 given string is displayed.
8691
8692
8693 CheckContext.TryCompile(self, text, extension)
8694 Checks if a file with the specified extension (e.g. '.c') con‐
8695 taining text can be compiled using the environment's Object
8696 builder. Returns 1 on success and 0 on failure.
8697
8698
8699 CheckContext.TryLink(self, text, extension)
8700 Checks, if a file with the specified extension (e.g. '.c') con‐
8701 taining text can be compiled using the environment's Program
8702 builder. Returns 1 on success and 0 on failure.
8703
8704
8705 CheckContext.TryRun(self, text, extension)
8706 Checks, if a file with the specified extension (e.g. '.c') con‐
8707 taining text can be compiled using the environment's Program
8708 builder. On success, the program is run. If the program executes
8709 successfully (that is, its return status is 0), a tuple (1, out‐
8710 putStr) is returned, where outputStr is the standard output of
8711 the program. If the program fails execution (its return status
8712 is non-zero), then (0, '') is returned.
8713
8714
8715 CheckContext.TryAction(self, action, [text, extension])
8716 Checks if the specified action with an optional source file
8717 (contents text , extension extension = '' ) can be executed.
8718 action may be anything which can be converted to a scons Action.
8719 On success, (1, outputStr) is returned, where outputStr is the
8720 content of the target file. On failure (0, '') is returned.
8721
8722
8723 CheckContext.TryBuild(self, builder, [text, extension])
8724 Low level implementation for testing specific builds; the meth‐
8725 ods above are based on this method. Given the Builder instance
8726 builder and the optional text of a source file with optional
8727 extension, this method returns 1 on success and 0 on failure. In
8728 addition, self.lastTarget is set to the build target node, if
8729 the build was successful.
8730
8731 Example for implementing and using custom tests:
8732
8733 def CheckQt(context, qtdir):
8734 context.Message( 'Checking for qt ...' )
8735 lastLIBS = context.env['LIBS']
8736 lastLIBPATH = context.env['LIBPATH']
8737 lastCPPPATH= context.env['CPPPATH']
8738 context.env.Append(LIBS = 'qt', LIBPATH = qtdir + '/lib', CPPPATH = qtdir + '/include' )
8739 ret = context.TryLink("""
8740 #include <qapp.h>
8741 int main(int argc, char **argv) {
8742 QApplication qapp(argc, argv);
8743 return 0;
8744 }
8745 """)
8746 if not ret:
8747 context.env.Replace(LIBS = lastLIBS, LIBPATH=lastLIBPATH, CPPPATH=lastCPPPATH)
8748 context.Result( ret )
8749 return ret
8750
8751 env = Environment()
8752 conf = Configure( env, custom_tests = { 'CheckQt' : CheckQt } )
8753 if not conf.CheckQt('/usr/lib/qt'):
8754 print 'We really need qt!'
8755 Exit(1)
8756 env = conf.Finish()
8757
8758
8759 Command-Line Construction Variables
8760 Often when building software, some variables must be specified at build
8761 time. For example, libraries needed for the build may be in non-stan‐
8762 dard locations, or site-specific compiler options may need to be passed
8763 to the compiler. scons provides a Variables object to support overrid‐
8764 ing construction variables on the command line:
8765 $ scons VARIABLE=foo
8766 The variable values can also be specified in a text-based SConscript
8767 file. To create a Variables object, call the Variables() function:
8768
8769
8770 Variables([files], [args])
8771 This creates a Variables object that will read construction
8772 variables from the file or list of filenames specified in files.
8773 If no files are specified, or the files argument is None, then
8774 no files will be read. The optional argument args is a dictio‐
8775 nary of values that will override anything read from the speci‐
8776 fied files; it is primarily intended to be passed the ARGUMENTS
8777 dictionary that holds variables specified on the command line.
8778 Example:
8779
8780 vars = Variables('custom.py')
8781 vars = Variables('overrides.py', ARGUMENTS)
8782 vars = Variables(None, {FOO:'expansion', BAR:7})
8783
8784 Variables objects have the following methods:
8785
8786
8787 Add(key, [help, default, validator, converter])
8788 This adds a customizable construction variable to the Variables
8789 object. key is the name of the variable. help is the help text
8790 for the variable. default is the default value of the variable;
8791 if the default value is None and there is no explicit value
8792 specified, the construction variable will not be added to the
8793 construction environment. validator is called to validate the
8794 value of the variable, and should take three arguments: key,
8795 value, and environment. The recommended way to handle an
8796 invalid value is to raise an exception (see example below).
8797 converter is called to convert the value before putting it in
8798 the environment, and should take either a value, or the value
8799 and environment, as parameters. The converter must return a
8800 value, which will be converted into a string before being vali‐
8801 dated by the validator (if any) and then added to the environ‐
8802 ment.
8803
8804 Examples:
8805
8806 vars.Add('CC', 'The C compiler')
8807
8808 def validate_color(key, val, env):
8809 if not val in ['red', 'blue', 'yellow']:
8810 raise Exception("Invalid color value '%s'" % val)
8811 vars.Add('COLOR', validator=valid_color)
8812
8813
8814 AddVariables(list)
8815 A wrapper script that adds multiple customizable construction
8816 variables to a Variables object. list is a list of tuple or
8817 list objects that contain the arguments for an individual call
8818 to the Add method.
8819
8820 opt.AddVariables(
8821 ('debug', '', 0),
8822 ('CC', 'The C compiler'),
8823 ('VALIDATE', 'An option for testing validation',
8824 'notset', validator, None),
8825 )
8826
8827
8828 Update(env, [args])
8829 This updates a construction environment env with the customized
8830 construction variables. Any specified variables that are not
8831 configured for the Variables object will be saved and may be
8832 retrieved with the UnknownVariables() method, below.
8833
8834 Normally this method is not called directly, but is called indi‐
8835 rectly by passing the Variables object to the Environment()
8836 function:
8837
8838 env = Environment(variables=vars)
8839
8840
8841 The text file(s) that were specified when the Variables object
8842 was created are executed as Python scripts, and the values of
8843 (global) Python variables set in the file are added to the con‐
8844 struction environment.
8845
8846 Example:
8847
8848 CC = 'my_cc'
8849
8850
8851 UnknownVariables()
8852 Returns a dictionary containing any variables that were speci‐
8853 fied either in the files or the dictionary with which the Vari‐
8854 ables object was initialized, but for which the Variables object
8855 was not configured.
8856
8857 env = Environment(variables=vars)
8858 for key, value in vars.UnknownVariables():
8859 print "unknown variable: %s=%s" % (key, value)
8860
8861
8862 Save(filename, env)
8863 This saves the currently set variables into a script file named
8864 filename that can be used on the next invocation to automati‐
8865 cally load the current settings. This method combined with the
8866 Variables method can be used to support caching of variables
8867 between runs.
8868
8869 env = Environment()
8870 vars = Variables(['variables.cache', 'custom.py'])
8871 vars.Add(...)
8872 vars.Update(env)
8873 vars.Save('variables.cache', env)
8874
8875
8876 GenerateHelpText(env, [sort])
8877 This generates help text documenting the customizable construc‐
8878 tion variables suitable to passing in to the Help() function.
8879 env is the construction environment that will be used to get the
8880 actual values of customizable variables. Calling with an
8881 optional sort function will cause the output to be sorted by the
8882 specified argument. The specific sort function should take two
8883 arguments and return -1, 0 or 1 (like the standard Python cmp
8884 function).
8885
8886 Help(vars.GenerateHelpText(env))
8887 Help(vars.GenerateHelpText(env, sort=cmp))
8888
8889
8890 FormatVariableHelpText(env, opt, help, default, actual)
8891 This method returns a formatted string containing the printable
8892 help text for one option. It is normally not called directly,
8893 but is called by the GenerateHelpText() method to create the
8894 returned help text. It may be overridden with your own function
8895 that takes the arguments specified above and returns a string of
8896 help text formatted to your liking. Note that the GenerateHelp‐
8897 Text() will not put any blank lines or extra characters in
8898 between the entries, so you must add those characters to the
8899 returned string if you want the entries separated.
8900
8901 def my_format(env, opt, help, default, actual):
8902 fmt = "108s: default=%s actual=%s (%s)0
8903 return fmt % (opt, default. actual, help)
8904 vars.FormatVariableHelpText = my_format
8905
8906 To make it more convenient to work with customizable Variables, scons
8907 provides a number of functions that make it easy to set up various
8908 types of Variables:
8909
8910
8911 BoolVariable(key, help, default)
8912 Return a tuple of arguments to set up a Boolean option. The
8913 option will use the specified name key, have a default value of
8914 default, and display the specified help text. The option will
8915 interpret the values y, yes, t, true, 1, on and all as true, and
8916 the values n, no, f, false, 0, off and none as false.
8917
8918
8919 EnumVariable(key, help, default, allowed_values, [map, ignorecase])
8920 Return a tuple of arguments to set up an option whose value may
8921 be one of a specified list of legal enumerated values. The
8922 option will use the specified name key, have a default value of
8923 default, and display the specified help text. The option will
8924 only support those values in the allowed_values list. The
8925 optional map argument is a dictionary that can be used to con‐
8926 vert input values into specific legal values in the allowed_val‐
8927 ues list. If the value of ignore_case is 0 (the default), then
8928 the values are case-sensitive. If the value of ignore_case is
8929 1, then values will be matched case-insensitive. If the value
8930 of ignore_case is 1, then values will be matched case-insensi‐
8931 tive, and all input values will be converted to lower case.
8932
8933
8934 ListVariable(key, help, default, names, [,map])
8935 Return a tuple of arguments to set up an option whose value may
8936 be one or more of a specified list of legal enumerated values.
8937 The option will use the specified name key, have a default value
8938 of default, and display the specified help text. The option
8939 will only support the values all, none, or the values in the
8940 names list. More than one value may be specified, with all val‐
8941 ues separated by commas. The default may be a string of comma-
8942 separated default values, or a list of the default values. The
8943 optional map argument is a dictionary that can be used to con‐
8944 vert input values into specific legal values in the names list.
8945
8946
8947 PackageVariable(key, help, default)
8948 Return a tuple of arguments to set up an option whose value is a
8949 path name of a package that may be enabled, disabled or given an
8950 explicit path name. The option will use the specified name key,
8951 have a default value of default, and display the specified help
8952 text. The option will support the values yes, true, on, enable
8953 or search, in which case the specified default will be used, or
8954 the option may be set to an arbitrary string (typically the path
8955 name to a package that is being enabled). The option will also
8956 support the values no, false, off or disable to disable use of
8957 the specified option.
8958
8959
8960 PathVariable(key, help, default, [validator])
8961 Return a tuple of arguments to set up an option whose value is
8962 expected to be a path name. The option will use the specified
8963 name key, have a default value of default, and display the spec‐
8964 ified help text. An additional validator may be specified that
8965 will be called to verify that the specified path is acceptable.
8966 SCons supplies the following ready-made validators: PathVari‐
8967 able.PathExists (the default), which verifies that the specified
8968 path exists; PathVariable.PathIsFile, which verifies that the
8969 specified path is an existing file; PathVariable.PathIsDir,
8970 which verifies that the specified path is an existing directory;
8971 PathVariable.PathIsDirCreate, which verifies that the specified
8972 path is a directory and will create the specified directory if
8973 the path does not exist; and PathVariable.PathAccept, which sim‐
8974 ply accepts the specific path name argument without validation,
8975 and which is suitable if you want your users to be able to spec‐
8976 ify a directory path that will be created as part of the build
8977 process, for example. You may supply your own validator func‐
8978 tion, which must take three arguments (key, the name of the
8979 variable to be set; val, the specified value being checked; and
8980 env, the construction environment) and should raise an exception
8981 if the specified value is not acceptable.
8982
8983 These functions make it convenient to create a number of variables with
8984 consistent behavior in a single call to the AddVariables method:
8985
8986 vars.AddVariables(
8987 BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
8988 EnumVariable('debug', 'debug output and symbols', 'no'
8989 allowed_values=('yes', 'no', 'full'),
8990 map={}, ignorecase=0), # case sensitive
8991 ListVariable('shared',
8992 'libraries to build as shared libraries',
8993 'all',
8994 names = list_of_libs),
8995 PackageVariable('x11',
8996 'use X11 installed here (yes = search some places)',
8997 'yes'),
8998 PathVariable('qtdir', 'where the root of Qt is installed', qtdir),
8999 PathVariable('foopath', 'where the foo library is installed', foopath,
9000 PathVariable.PathIsDir),
9001
9002 )
9003
9004
9005 File and Directory Nodes
9006 The File() and Dir() functions return File and Dir Nodes, respectively.
9007 python objects, respectively. Those objects have several user-visible
9008 attributes and methods that are often useful:
9009
9010
9011 path The build path of the given file or directory. This path is
9012 relative to the top-level directory (where the SConstruct file
9013 is found). The build path is the same as the source path if
9014 variant_dir is not being used.
9015
9016
9017 abspath
9018 The absolute build path of the given file or directory.
9019
9020
9021 srcnode()
9022 The srcnode() method returns another File or Dir object repre‐
9023 senting the source path of the given File or Dir. The
9024
9025 # Get the current build dir's path, relative to top.
9026 Dir('.').path
9027 # Current dir's absolute path
9028 Dir('.').abspath
9029 # Next line is always '.', because it is the top dir's path relative to itself.
9030 Dir('#.').path
9031 File('foo.c').srcnode().path # source path of the given source file.
9032
9033 # Builders also return File objects:
9034 foo = env.Program('foo.c')
9035 print "foo will be built in %s"%foo.path
9036
9037 A Dir Node or File Node can also be used to create file and subdirec‐
9038 tory Nodes relative to the generating Node. A Dir Node will place the
9039 new Nodes within the directory it represents. A File node will place
9040 the new Nodes within its parent directory (that is, "beside" the file
9041 in question). If d is a Dir (directory) Node and f is a File (file)
9042 Node, then these methods are available:
9043
9044
9045 d.Dir(name)
9046 Returns a directory Node for a subdirectory of d named name.
9047
9048
9049 d.File(name)
9050 Returns a file Node for a file within d named name.
9051
9052
9053 d.Entry(name)
9054 Returns an unresolved Node within d named name.
9055
9056
9057 f.Dir(name)
9058 Returns a directory named name within the parent directory of f.
9059
9060
9061 f.File(name)
9062 Returns a file named name within the parent directory of f.
9063
9064
9065 f.Entry(name)
9066 Returns an unresolved Node named name within the parent direc‐
9067 tory of f.
9068
9069 For example:
9070
9071 # Get a Node for a file within a directory
9072 incl = Dir('include')
9073 f = incl.File('header.h')
9074
9075 # Get a Node for a subdirectory within a directory
9076 dist = Dir('project-3.2.1)
9077 src = dist.Dir('src')
9078
9079 # Get a Node for a file in the same directory
9080 cfile = File('sample.c')
9081 hfile = cfile.File('sample.h')
9082
9083 # Combined example
9084 docs = Dir('docs')
9085 html = docs.Dir('html')
9086 index = html.File('index.html')
9087 css = index.File('app.css')
9088
9089
9091 Builder Objects
9092 scons can be extended to build different types of targets by adding new
9093 Builder objects to a construction environment. In general, you should
9094 only need to add a new Builder object when you want to build a new type
9095 of file or other external target. If you just want to invoke a differ‐
9096 ent compiler or other tool to build a Program, Object, Library, or any
9097 other type of output file for which scons already has an existing
9098 Builder, it is generally much easier to use those existing Builders in
9099 a construction environment that sets the appropriate construction vari‐
9100 ables (CC, LINK, etc.).
9101
9102 Builder objects are created using the Builder function. The Builder
9103 function accepts the following arguments:
9104
9105
9106 action The command line string used to build the target from the
9107 source. action can also be: a list of strings representing the
9108 command to be executed and its arguments (suitable for enclosing
9109 white space in an argument), a dictionary mapping source file
9110 name suffixes to any combination of command line strings (if the
9111 builder should accept multiple source file extensions), a Python
9112 function; an Action object (see the next section); or a list of
9113 any of the above.
9114
9115 An action function takes three arguments: source - a list of
9116 source nodes, target - a list of target nodes, env - the con‐
9117 struction environment.
9118
9119
9120 prefix The prefix that will be prepended to the target file name. This
9121 may be specified as a:
9122
9123
9124 * string,
9125
9126
9127 * callable object - a function or other callable that takes
9128 two arguments (a construction environment and a list of
9129 sources) and returns a prefix,
9130
9131
9132 * dictionary - specifies a mapping from a specific source
9133 suffix (of the first source specified) to a correspond‐
9134 ing target prefix. Both the source suffix and target
9135 prefix specifications may use environment variable sub‐
9136 stitution, and the target prefix (the 'value' entries
9137 in the dictionary) may also be a callable object. The
9138 default target prefix may be indicated by a dictionary
9139 entry with a key value of None.
9140
9141 b = Builder("build_it < $SOURCE > $TARGET",
9142 prefix = "file-")
9143
9144 def gen_prefix(env, sources):
9145 return "file-" + env['PLATFORM'] + '-'
9146 b = Builder("build_it < $SOURCE > $TARGET",
9147 prefix = gen_prefix)
9148
9149 b = Builder("build_it < $SOURCE > $TARGET",
9150 suffix = { None: "file-",
9151 "$SRC_SFX_A": gen_prefix })
9152
9153
9154 suffix The suffix that will be appended to the target file name. This
9155 may be specified in the same manner as the prefix above. If the
9156 suffix is a string, then scons will append a '.' to the begin‐
9157 ning of the suffix if it's not already there. The string
9158 returned by callable object (or obtained from the dictionary) is
9159 untouched and must append its own '.' to the beginning if one
9160 is desired.
9161
9162 b = Builder("build_it < $SOURCE > $TARGET"
9163 suffix = "-file")
9164
9165 def gen_suffix(env, sources):
9166 return "." + env['PLATFORM'] + "-file"
9167 b = Builder("build_it < $SOURCE > $TARGET",
9168 suffix = gen_suffix)
9169
9170 b = Builder("build_it < $SOURCE > $TARGET",
9171 suffix = { None: ".sfx1",
9172 "$SRC_SFX_A": gen_suffix })
9173
9174
9175 ensure_suffix
9176 When set to any true value, causes scons to add the target suf‐
9177 fix specified by the suffix keyword to any target strings that
9178 have a different suffix. (The default behavior is to leave
9179 untouched any target file name that looks like it already has
9180 any suffix.)
9181
9182 b1 = Builder("build_it < $SOURCE > $TARGET"
9183 suffix = ".out")
9184 b2 = Builder("build_it < $SOURCE > $TARGET"
9185 suffix = ".out",
9186 ensure_suffix)
9187 env = Environment()
9188 env['BUILDERS']['B1'] = b1
9189 env['BUILDERS']['B2'] = b2
9190
9191 # Builds "foo.txt" because ensure_suffix is not set.
9192 env.B1('foo.txt', 'foo.in')
9193
9194 # Builds "bar.txt.out" because ensure_suffix is set.
9195 env.B2('bar.txt', 'bar.in')
9196
9197
9198 src_suffix
9199 The expected source file name suffix. This may be a string or a
9200 list of strings.
9201
9202
9203 target_scanner
9204 A Scanner object that will be invoked to find implicit dependen‐
9205 cies for this target file. This keyword argument should be used
9206 for Scanner objects that find implicit dependencies based only
9207 on the target file and the construction environment, not for
9208 implicit dependencies based on source files. (See the section
9209 "Scanner Objects" below, for information about creating Scanner
9210 objects.)
9211
9212
9213 source_scanner
9214 A Scanner object that will be invoked to find implicit dependen‐
9215 cies in any source files used to build this target file. This
9216 is where you would specify a scanner to find things like
9217 #include lines in source files. The pre-built DirScanner Scan‐
9218 ner object may be used to indicate that this Builder should scan
9219 directory trees for on-disk changes to files that scons does not
9220 know about from other Builder or function calls. (See the sec‐
9221 tion "Scanner Objects" below, for information about creating
9222 your own Scanner objects.)
9223
9224
9225 target_factory
9226 A factory function that the Builder will use to turn any targets
9227 specified as strings into SCons Nodes. By default, SCons
9228 assumes that all targets are files. Other useful target_factory
9229 values include Dir, for when a Builder creates a directory tar‐
9230 get, and Entry, for when a Builder can create either a file or
9231 directory target.
9232
9233 Example:
9234
9235 MakeDirectoryBuilder = Builder(action=my_mkdir, target_factory=Dir)
9236 env = Environment()
9237 env.Append(BUILDERS = {'MakeDirectory':MakeDirectoryBuilder})
9238 env.MakeDirectory('new_directory', [])
9239
9240
9241 Note that the call to the MakeDirectory Builder needs to specify
9242 an empty source list to make the string represent the builder's
9243 target; without that, it would assume the argument is the
9244 source, and would try to deduce the target name from it, which
9245 in the absence of an automatically-added prefix or suffix would
9246 lead to a matching target and source name and a circular depen‐
9247 dency.
9248
9249
9250 source_factory
9251 A factory function that the Builder will use to turn any sources
9252 specified as strings into SCons Nodes. By default, SCons
9253 assumes that all source are files. Other useful source_factory
9254 values include Dir, for when a Builder uses a directory as a
9255 source, and Entry, for when a Builder can use files or directo‐
9256 ries (or both) as sources.
9257
9258 Example:
9259
9260 CollectBuilder = Builder(action=my_mkdir, source_factory=Entry)
9261 env = Environment()
9262 env.Append(BUILDERS = {'Collect':CollectBuilder})
9263 env.Collect('archive', ['directory_name', 'file_name'])
9264
9265
9266 emitter
9267 A function or list of functions to manipulate the target and
9268 source lists before dependencies are established and the tar‐
9269 get(s) are actually built. emitter can also be a string con‐
9270 taining a construction variable to expand to an emitter function
9271 or list of functions, or a dictionary mapping source file suf‐
9272 fixes to emitter functions. (Only the suffix of the first
9273 source file is used to select the actual emitter function from
9274 an emitter dictionary.)
9275
9276 An emitter function takes three arguments: source - a list of
9277 source nodes, target - a list of target nodes, env - the con‐
9278 struction environment. An emitter must return a tuple contain‐
9279 ing two lists, the list of targets to be built by this builder,
9280 and the list of sources for this builder.
9281
9282 Example:
9283
9284 def e(target, source, env):
9285 return (target + ['foo.foo'], source + ['foo.src'])
9286
9287 # Simple association of an emitter function with a Builder.
9288 b = Builder("my_build < $TARGET > $SOURCE",
9289 emitter = e)
9290
9291 def e2(target, source, env):
9292 return (target + ['bar.foo'], source + ['bar.src'])
9293
9294 # Simple association of a list of emitter functions with a Builder.
9295 b = Builder("my_build < $TARGET > $SOURCE",
9296 emitter = [e, e2])
9297
9298 # Calling an emitter function through a construction variable.
9299 env = Environment(MY_EMITTER = e)
9300 b = Builder("my_build < $TARGET > $SOURCE",
9301 emitter = '$MY_EMITTER')
9302
9303 # Calling a list of emitter functions through a construction variable.
9304 env = Environment(EMITTER_LIST = [e, e2])
9305 b = Builder("my_build < $TARGET > $SOURCE",
9306 emitter = '$EMITTER_LIST')
9307
9308 # Associating multiple emitters with different file
9309 # suffixes using a dictionary.
9310 def e_suf1(target, source, env):
9311 return (target + ['another_target_file'], source)
9312 def e_suf2(target, source, env):
9313 return (target, source + ['another_source_file'])
9314 b = Builder("my_build < $TARGET > $SOURCE",
9315 emitter = {'.suf1' : e_suf1,
9316 '.suf2' : e_suf2})
9317
9318
9319 multi Specifies whether this builder is allowed to be called multiple
9320 times for the same target file(s). The default is 0, which means
9321 the builder can not be called multiple times for the same target
9322 file(s). Calling a builder multiple times for the same target
9323 simply adds additional source files to the target; it is not
9324 allowed to change the environment associated with the target,
9325 specify addition environment overrides, or associate a different
9326 builder with the target.
9327
9328
9329 env A construction environment that can be used to fetch source code
9330 using this Builder. (Note that this environment is not used for
9331 normal builds of normal target files, which use the environment
9332 that was used to call the Builder for the target file.)
9333
9334
9335 generator
9336 A function that returns a list of actions that will be executed
9337 to build the target(s) from the source(s). The returned
9338 action(s) may be an Action object, or anything that can be con‐
9339 verted into an Action object (see the next section).
9340
9341 The generator function takes four arguments: source - a list of
9342 source nodes, target - a list of target nodes, env - the con‐
9343 struction environment, for_signature - a Boolean value that
9344 specifies whether the generator is being called for generating a
9345 build signature (as opposed to actually executing the command).
9346 Example:
9347
9348 def g(source, target, env, for_signature):
9349 return [["gcc", "-c", "-o"] + target + source]
9350
9351 b = Builder(generator=g)
9352
9353
9354 The generator and action arguments must not both be used for the
9355 same Builder.
9356
9357
9358 src_builder
9359 Specifies a builder to use when a source file name suffix does
9360 not match any of the suffixes of the builder. Using this argu‐
9361 ment produces a multi-stage builder.
9362
9363
9364 single_source
9365 Specifies that this builder expects exactly one source file per
9366 call. Giving more than one source file without target files
9367 results in implicitely calling the builder multiple times (once
9368 for each source given). Giving multiple source files together
9369 with target files results in a UserError exception.
9370
9371
9372 The generator and action arguments must not both be used for the
9373 same Builder.
9374
9375
9376 source_ext_match
9377 When the specified action argument is a dictionary, the default
9378 behavior when a builder is passed multiple source files is to
9379 make sure that the extensions of all the source files match. If
9380 it is legal for this builder to be called with a list of source
9381 files with different extensions, this check can be suppressed by
9382 setting source_ext_match to None or some other non-true value.
9383 When source_ext_match is disable, scons will use the suffix of
9384 the first specified source file to select the appropriate action
9385 from the action dictionary.
9386
9387 In the following example, the setting of source_ext_match pre‐
9388 vents scons from exiting with an error due to the mismatched
9389 suffixes of foo.in and foo.extra.
9390
9391 b = Builder(action={'.in' : 'build $SOURCES > $TARGET'},
9392 source_ext_match = None)
9393
9394 env = Environment(BUILDERS = {'MyBuild':b})
9395 env.MyBuild('foo.out', ['foo.in', 'foo.extra'])
9396
9397
9398 env A construction environment that can be used to fetch source code
9399 using this Builder. (Note that this environment is not used for
9400 normal builds of normal target files, which use the environment
9401 that was used to call the Builder for the target file.)
9402
9403 b = Builder(action="build < $SOURCE > $TARGET")
9404 env = Environment(BUILDERS = {'MyBuild' : b})
9405 env.MyBuild('foo.out', 'foo.in', my_arg = 'xyzzy')
9406
9407
9408 chdir A directory from which scons will execute the action(s) speci‐
9409 fied for this Builder. If the chdir argument is a string or a
9410 directory Node, scons will change to the specified directory.
9411 If the chdir is not a string or Node and is non-zero, then scons
9412 will change to the target file's directory.
9413
9414 Note that scons will not automatically modify its expansion of
9415 construction variables like $TARGET and $SOURCE when using the
9416 chdir keyword argument--that is, the expanded file names will
9417 still be relative to the top-level SConstruct directory, and
9418 consequently incorrect relative to the chdir directory.
9419 Builders created using chdir keyword argument, will need to use
9420 construction variable expansions like ${TARGET.file} and
9421 ${SOURCE.file} to use just the filename portion of the targets
9422 and source.
9423
9424 b = Builder(action="build < ${SOURCE.file} > ${TARGET.file}",
9425 chdir=1)
9426 env = Environment(BUILDERS = {'MyBuild' : b})
9427 env.MyBuild('sub/dir/foo.out', 'sub/dir/foo.in')
9428
9429 WARNING: Python only keeps one current directory location for all of
9430 the threads. This means that use of the chdir argument will not work
9431 with the SCons -j option, because individual worker threads spawned by
9432 SCons interfere with each other when they start changing directory.
9433
9434 Any additional keyword arguments supplied when a Builder object is cre‐
9435 ated (that is, when the Builder() function is called) will be set in
9436 the executing construction environment when the Builder object is
9437 called. The canonical example here would be to set a construction
9438 variable to the repository of a source code system.
9439
9440 Any additional keyword arguments supplied when a Builder object is
9441 called will only be associated with the target created by that particu‐
9442 lar Builder call (and any other files built as a result of the call).
9443
9444 These extra keyword arguments are passed to the following functions:
9445 command generator functions, function Actions, and emitter functions.
9446
9447
9448 Action Objects
9449 The Builder() function will turn its action keyword argument into an
9450 appropriate internal Action object. You can also explicity create
9451 Action objects using the Action() global function, which can then be
9452 passed to the Builder() function. This can be used to configure an
9453 Action object more flexibly, or it may simply be more efficient than
9454 letting each separate Builder object create a separate Action when mul‐
9455 tiple Builder objects need to do the same thing.
9456
9457 The Action() global function returns an appropriate object for the
9458 action represented by the type of the first argument:
9459
9460
9461 Action If the first argument is already an Action object, the object is
9462 simply returned.
9463
9464
9465 String If the first argument is a string, a command-line Action is
9466 returned. Note that the command-line string may be preceded by
9467 an @ (at-sign) to suppress printing of the specified command
9468 line, or by a - (hyphen) to ignore the exit status from the
9469 specified command:
9470
9471 Action('$CC -c -o $TARGET $SOURCES')
9472
9473 # Doesn't print the line being executed.
9474 Action('@build $TARGET $SOURCES')
9475
9476 # Ignores return value
9477 Action('-build $TARGET $SOURCES')
9478
9479
9480 List If the first argument is a list, then a list of Action objects
9481 is returned. An Action object is created as necessary for each
9482 element in the list. If an element within the list is itself a
9483 list, the internal list is the command and arguments to be exe‐
9484 cuted via the command line. This allows white space to be
9485 enclosed in an argument by defining a command in a list within a
9486 list:
9487
9488 Action([['cc', '-c', '-DWHITE SPACE', '-o', '$TARGET', '$SOURCES']])
9489
9490
9491 Function
9492 If the first argument is a Python function, a function Action is
9493 returned. The Python function must take three keyword argu‐
9494 ments, target (a Node object representing the target file),
9495 source (a Node object representing the source file) and env (the
9496 construction environment used for building the target file).
9497 The target and source arguments may be lists of Node objects if
9498 there is more than one target file or source file. The actual
9499 target and source file name(s) may be retrieved from their Node
9500 objects via the built-in Python str() function:
9501
9502 target_file_name = str(target)
9503 source_file_names = map(lambda x: str(x), source)
9504
9505 The function should return 0 or None to indicate a successful
9506 build of the target file(s). The function may raise an excep‐
9507 tion or return a non-zero exit status to indicate an unsuccess‐
9508 ful build.
9509
9510 def build_it(target = None, source = None, env = None):
9511 # build the target from the source
9512 return 0
9513
9514 a = Action(build_it)
9515
9516 If the action argument is not one of the above, None is returned.
9517
9518 The second argument is optional and is used to define the output which
9519 is printed when the Action is actually performed. In the absence of
9520 this parameter, or if it's an empty string, a default output depending
9521 on the type of the action is used. For example, a command-line action
9522 will print the executed command. The argument must be either a Python
9523 function or a string.
9524
9525 In the first case, it's a function that returns a string to be printed
9526 to describe the action being executed. The function may also be speci‐
9527 fied by the strfunction= keyword argument. Like a function to build a
9528 file, this function must take three keyword arguments: target (a Node
9529 object representing the target file), source (a Node object represent‐
9530 ing the source file) and env (a construction environment). The target
9531 and source arguments may be lists of Node objects if there is more than
9532 one target file or source file.
9533
9534 In the second case, you provide the string itself. The string may also
9535 be specified by the cmdstr= keyword argument. The string typically
9536 contains variables, notably $TARGET(S) and $SOURCE(S), or consists of
9537 just a single variable, which is optionally defined somewhere else.
9538 SCons itself heavily uses the latter variant.
9539
9540 Examples:
9541
9542 def build_it(target, source, env):
9543 # build the target from the source
9544 return 0
9545
9546 def string_it(target, source, env):
9547 return "building '%s' from '%s'" % (target[0], source[0])
9548
9549 # Use a positional argument.
9550 f = Action(build_it, string_it)
9551 s = Action(build_it, "building '$TARGET' from '$SOURCE'")
9552
9553 # Alternatively, use a keyword argument.
9554 f = Action(build_it, strfunction=string_it)
9555 s = Action(build_it, cmdstr="building '$TARGET' from '$SOURCE'")
9556
9557 # You can provide a configurable variable.
9558 l = Action(build_it, '$STRINGIT')
9559
9560 The third and succeeding arguments, if present, may either be a con‐
9561 struction variable or a list of construction variables whose values
9562 will be included in the signature of the Action when deciding whether a
9563 target should be rebuilt because the action changed. The variables may
9564 also be specified by a varlist= keyword parameter; if both are present,
9565 they are combined. This is necessary whenever you want a target to be
9566 rebuilt when a specific construction variable changes. This is not
9567 often needed for a string action, as the expanded variables will nor‐
9568 mally be part of the command line, but may be needed if a Python func‐
9569 tion action uses the value of a construction variable when generating
9570 the command line.
9571
9572 def build_it(target, source, env):
9573 # build the target from the 'XXX' construction variable
9574 open(target[0], 'w').write(env['XXX'])
9575 return 0
9576
9577 # Use positional arguments.
9578 a = Action(build_it, '$STRINGIT', ['XXX'])
9579
9580 # Alternatively, use a keyword argument.
9581 a = Action(build_it, varlist=['XXX'])
9582
9583 The Action() global function can be passed the following optional key‐
9584 word arguments to modify the Action object's behavior:
9585
9586
9587 chdir The chdir keyword argument specifies that scons will exe‐
9588 cute the action after changing to the specified directory. If
9589 the chdir argument is a string or a directory Node, scons will
9590 change to the specified directory. If the chdir argument is not
9591 a string or Node and is non-zero, then scons will change to the
9592 target file's directory.
9593
9594 Note that scons will not automatically modify its expansion of
9595 construction variables like $TARGET and $SOURCE when using the
9596 chdir keyword argument--that is, the expanded file names will
9597 still be relative to the top-level SConstruct directory, and
9598 consequently incorrect relative to the chdir directory.
9599 Builders created using chdir keyword argument, will need to use
9600 construction variable expansions like ${TARGET.file} and
9601 ${SOURCE.file} to use just the filename portion of the targets
9602 and source.
9603
9604 a = Action("build < ${SOURCE.file} > ${TARGET.file}",
9605 chdir=1)
9606
9607
9608 exitstatfunc The Action() global function also takes an exit‐
9609 statfunc keyword argument which specifies a function that is
9610 passed the exit status (or return value) from the specified
9611 action and can return an arbitrary or modified value. This can
9612 be used, for example, to specify that an Action object's return
9613 value should be ignored under special conditions and SCons
9614 should, therefore, consider that the action always suceeds:
9615
9616 def always_succeed(s):
9617 # Always return 0, which indicates success.
9618 return 0
9619 a = Action("build < ${SOURCE.file} > ${TARGET.file}",
9620 exitstatfunc=always_succeed)
9621
9622
9623 batch_key The batch_key keyword argument can be used to specify
9624 that the Action can create multiple target files by processing
9625 multiple independent source files simultaneously. (The canoni‐
9626 cal example is "batch compilation" of multiple object files by
9627 passing multiple source files to a single invocation of a com‐
9628 piler such as Microsoft's Visual C / C++ compiler.) If the
9629 batch_key argument is any non-False, non-callable Python value,
9630 the configured Action object will cause scons to collect all
9631 targets built with the Action object and configured with the
9632 same construction environment into single invocations of the
9633 Action object's command line or function. Command lines will
9634 typically want to use the CHANGED_SOURCES construction variable
9635 (and possibly CHANGED_TARGETS as well) to only pass to the com‐
9636 mand line those sources that have actually changed since their
9637 targets were built.
9638
9639 Example:
9640
9641 a = Action('build $CHANGED_SOURCES', batch_key=True)
9642
9643 The batch_key argument may also be a callable function that returns a
9644 key that will be used to identify different "batches" of target files
9645 to be collected for batch building. A batch_key function must take the
9646 following arguments:
9647
9648
9649 action The action object.
9650
9651
9652 env The construction environment configured for the target.
9653
9654
9655 target The list of targets for a particular configured action.
9656
9657
9658 source The list of source for a particular configured action.
9659
9660 The returned key should typically be a tuple of values derived
9661 from the arguments, using any appropriate logic to decide how
9662 multiple invocations should be batched. For example, a
9663 batch_key function may decide to return the value of a specific
9664 construction variable from the env argument which will cause
9665 scons to batch-build targets with matching values of that vari‐
9666 able, or perhaps return the id() of the entire construction
9667 environment, in which case scons will batch-build all targets
9668 configured with the same construction environment. Returning
9669 None indicates that the particular target should not be part of
9670 any batched build, but instead will be built by a separate invo‐
9671 cation of action's command or function. Example:
9672
9673 def batch_key(action, env, target, source):
9674 tdir = target[0].dir
9675 if tdir.name == 'special':
9676 # Don't batch-build any target
9677 # in the special/ subdirectory.
9678 return None
9679 return (id(action), id(env), tdir)
9680 a = Action('build $CHANGED_SOURCES', batch_key=batch_key)
9681
9682
9683 Miscellaneous Action Functions
9684 scons supplies a number of functions that arrange for various common
9685 file and directory manipulations to be performed. These are similar in
9686 concept to "tasks" in the Ant build tool, although the implementation
9687 is slightly different. These functions do not actually perform the
9688 specified action at the time the function is called, but instead return
9689 an Action object that can be executed at the appropriate time. (In
9690 Object-Oriented terminology, these are actually Action Factory func‐
9691 tions that return Action objects.)
9692
9693 In practice, there are two natural ways that these Action Functions are
9694 intended to be used.
9695
9696 First, if you need to perform the action at the time the SConscript
9697 file is being read, you can use the Execute global function to do so:
9698 Execute(Touch('file'))
9699
9700 Second, you can use these functions to supply Actions in a list for use
9701 by the Command method. This can allow you to perform more complicated
9702 sequences of file manipulation without relying on platform-specific
9703 external commands: that
9704 env = Environment(TMPBUILD = '/tmp/builddir')
9705 env.Command('foo.out', 'foo.in',
9706 [Mkdir('$TMPBUILD'),
9707 Copy('$TMPBUILD', '${SOURCE.dir}'),
9708 "cd $TMPBUILD && make",
9709 Delete('$TMPBUILD')])
9710
9711
9712 Chmod(dest, mode)
9713 Returns an Action object that changes the permissions on the
9714 specified dest file or directory to the specified mode. Exam‐
9715 ples:
9716
9717 Execute(Chmod('file', 0755))
9718
9719 env.Command('foo.out', 'foo.in',
9720 [Copy('$TARGET', '$SOURCE'),
9721 Chmod('$TARGET', 0755)])
9722
9723
9724 Copy(dest, src)
9725 Returns an Action object that will copy the src source file or
9726 directory to the dest destination file or directory. Examples:
9727
9728 Execute(Copy('foo.output', 'foo.input'))
9729
9730 env.Command('bar.out', 'bar.in',
9731 Copy('$TARGET', '$SOURCE'))
9732
9733
9734 Delete(entry, [must_exist])
9735 Returns an Action that deletes the specified entry, which may be
9736 a file or a directory tree. If a directory is specified, the
9737 entire directory tree will be removed. If the must_exist flag
9738 is set, then a Python error will be thrown if the specified
9739 entry does not exist; the default is must_exist=0, that is, the
9740 Action will silently do nothing if the entry does not exist.
9741 Examples:
9742
9743 Execute(Delete('/tmp/buildroot'))
9744
9745 env.Command('foo.out', 'foo.in',
9746 [Delete('${TARGET.dir}'),
9747 MyBuildAction])
9748
9749 Execute(Delete('file_that_must_exist', must_exist=1))
9750
9751
9752 Mkdir(dir)
9753 Returns an Action that creates the specified directory dir .
9754 Examples:
9755
9756 Execute(Mkdir('/tmp/outputdir'))
9757
9758 env.Command('foo.out', 'foo.in',
9759 [Mkdir('/tmp/builddir'),
9760 Copy('/tmp/builddir/foo.in', '$SOURCE'),
9761 "cd /tmp/builddir && make",
9762 Copy('$TARGET', '/tmp/builddir/foo.out')])
9763
9764
9765 Move(dest, src)
9766 Returns an Action that moves the specified src file or directory
9767 to the specified dest file or directory. Examples:
9768
9769 Execute(Move('file.destination', 'file.source'))
9770
9771 env.Command('output_file', 'input_file',
9772 [MyBuildAction,
9773 Move('$TARGET', 'file_created_by_MyBuildAction')])
9774
9775
9776 Touch(file)
9777 Returns an Action that updates the modification time on the
9778 specified file. Examples:
9779
9780 Execute(Touch('file_to_be_touched'))
9781
9782 env.Command('marker', 'input_file',
9783 [MyBuildAction,
9784 Touch('$TARGET')])
9785
9786
9787 Variable Substitution
9788 Before executing a command, scons performs construction variable inter‐
9789 polation on the strings that make up the command line of builders.
9790 Variables are introduced by a $ prefix. Besides construction vari‐
9791 ables, scons provides the following variables for each command execu‐
9792 tion:
9793
9794
9795 CHANGED_SOURCES
9796 The file names of all sources of the build command that have
9797 changed since the target was last built.
9798
9799
9800 CHANGED_TARGETS
9801 The file names of all targets that would be built from sources
9802 that have changed since the target was last built.
9803
9804
9805 SOURCE The file name of the source of the build command, or the file
9806 name of the first source if multiple sources are being built.
9807
9808
9809 SOURCES
9810 The file names of the sources of the build command.
9811
9812
9813 TARGET The file name of the target being built, or the file name of the
9814 first target if multiple targets are being built.
9815
9816
9817 TARGETS
9818 The file names of all targets being built.
9819
9820
9821 UNCHANGED_SOURCES
9822 The file names of all sources of the build command that have not
9823 changed since the target was last built.
9824
9825
9826 UNCHANGED_TARGETS
9827 The file names of all targets that would be built from sources
9828 that have not changed since the target was last built.
9829
9830 (Note that the above variables are reserved and may not be set
9831 in a construction environment.)
9832
9833
9834 For example, given the construction variable CC='cc', targets=['foo'],
9835 and sources=['foo.c', 'bar.c']:
9836
9837 action='$CC -c -o $TARGET $SOURCES'
9838
9839 would produce the command line:
9840
9841 cc -c -o foo foo.c bar.c
9842
9843 Variable names may be surrounded by curly braces ({}) to separate the
9844 name from the trailing characters. Within the curly braces, a variable
9845 name may have a Python slice subscript appended to select one or more
9846 items from a list. In the previous example, the string:
9847
9848 ${SOURCES[1]}
9849
9850 would produce:
9851
9852 bar.c
9853
9854 Additionally, a variable name may have the following special modifiers
9855 appended within the enclosing curly braces to modify the interpolated
9856 string:
9857
9858
9859 base The base path of the file name, including the directory path but
9860 excluding any suffix.
9861
9862
9863 dir The name of the directory in which the file exists.
9864
9865
9866 file The file name, minus any directory portion.
9867
9868
9869 filebase
9870 Just the basename of the file, minus any suffix and minus the
9871 directory.
9872
9873
9874 suffix Just the file suffix.
9875
9876
9877 abspath
9878 The absolute path name of the file.
9879
9880
9881 posix The POSIX form of the path, with directories separated by /
9882 (forward slashes) not backslashes. This is sometimes necessary
9883 on Windows systems when a path references a file on other
9884 (POSIX) systems.
9885
9886
9887 srcpath
9888 The directory and file name to the source file linked to this
9889 file through VariantDir(). If this file isn't linked, it just
9890 returns the directory and filename unchanged.
9891
9892
9893 srcdir The directory containing the source file linked to this file
9894 through VariantDir(). If this file isn't linked, it just
9895 returns the directory part of the filename.
9896
9897
9898 rsrcpath
9899 The directory and file name to the source file linked to this
9900 file through VariantDir(). If the file does not exist locally
9901 but exists in a Repository, the path in the Repository is
9902 returned. If this file isn't linked, it just returns the direc‐
9903 tory and filename unchanged.
9904
9905
9906 rsrcdir
9907 The Repository directory containing the source file linked to
9908 this file through VariantDir(). If this file isn't linked, it
9909 just returns the directory part of the filename.
9910
9911
9912 For example, the specified target will expand as follows for the corre‐
9913 sponding modifiers:
9914
9915 $TARGET => sub/dir/file.x
9916 ${TARGET.base} => sub/dir/file
9917 ${TARGET.dir} => sub/dir
9918 ${TARGET.file} => file.x
9919 ${TARGET.filebase} => file
9920 ${TARGET.suffix} => .x
9921 ${TARGET.abspath} => /top/dir/sub/dir/file.x
9922
9923 SConscript('src/SConscript', variant_dir='sub/dir')
9924 $SOURCE => sub/dir/file.x
9925 ${SOURCE.srcpath} => src/file.x
9926 ${SOURCE.srcdir} => src
9927
9928 Repository('/usr/repository')
9929 $SOURCE => sub/dir/file.x
9930 ${SOURCE.rsrcpath} => /usr/repository/src/file.x
9931 ${SOURCE.rsrcdir} => /usr/repository/src
9932
9933 Note that curly braces braces may also be used to enclose arbitrary
9934 Python code to be evaluated. (In fact, this is how the above modifiers
9935 are substituted, they are simply attributes of the Python objects that
9936 represent TARGET, SOURCES, etc.) See the section "Python Code Substi‐
9937 tution" below, for more thorough examples of how this can be used.
9938
9939 Lastly, a variable name may be a callable Python function associated
9940 with a construction variable in the environment. The function should
9941 take four arguments: target - a list of target nodes, source - a list
9942 of source nodes, env - the construction environment, for_signature - a
9943 Boolean value that specifies whether the function is being called for
9944 generating a build signature. SCons will insert whatever the called
9945 function returns into the expanded string:
9946
9947 def foo(target, source, env, for_signature):
9948 return "bar"
9949
9950 # Will expand $BAR to "bar baz"
9951 env=Environment(FOO=foo, BAR="$FOO baz")
9952
9953 You can use this feature to pass arguments to a Python function by cre‐
9954 ating a callable class that stores one or more arguments in an object,
9955 and then uses them when the __call__() method is called. Note that in
9956 this case, the entire variable expansion must be enclosed by curly
9957 braces so that the arguments will be associated with the instantiation
9958 of the class:
9959
9960 class foo(object):
9961 def __init__(self, arg):
9962 self.arg = arg
9963
9964 def __call__(self, target, source, env, for_signature):
9965 return self.arg + " bar"
9966
9967 # Will expand $BAR to "my argument bar baz"
9968 env=Environment(FOO=foo, BAR="${FOO('my argument')} baz")
9969
9970
9971 The special pseudo-variables $( and $) may be used to surround parts of
9972 a command line that may change without causing a rebuild--that is,
9973 which are not included in the signature of target files built with this
9974 command. All text between $( and $) will be removed from the command
9975 line before it is added to file signatures, and the $( and $) will be
9976 removed before the command is executed. For example, the command line:
9977
9978 echo Last build occurred $( $TODAY $). > $TARGET
9979
9980
9981 would execute the command:
9982
9983 echo Last build occurred $TODAY. > $TARGET
9984
9985
9986 but the command signature added to any target files would be:
9987
9988 echo Last build occurred . > $TARGET
9989
9990
9991 Python Code Substitution
9992 Any python code within ${-} pairs gets evaluated by python 'eval', with
9993 the python globals set to the current environment's set of construction
9994 variables. So in the following case:
9995 env['COND'] = 0
9996 env.Command('foo.out', 'foo.in',
9997 '''echo ${COND==1 and 'FOO' or 'BAR'} > $TARGET''')
9998 the command executed will be either
9999 echo FOO > foo.out
10000 or
10001 echo BAR > foo.out
10002 according to the current value of env['COND'] when the command is exe‐
10003 cuted. The evaluation occurs when the target is being built, not when
10004 the SConscript is being read. So if env['COND'] is changed later in
10005 the SConscript, the final value will be used.
10006
10007 Here's a more interesting example. Note that all of COND, FOO, and BAR
10008 are environment variables, and their values are substituted into the
10009 final command. FOO is a list, so its elements are interpolated sepa‐
10010 rated by spaces.
10011
10012 env=Environment()
10013 env['COND'] = 0
10014 env['FOO'] = ['foo1', 'foo2']
10015 env['BAR'] = 'barbar'
10016 env.Command('foo.out', 'foo.in',
10017 'echo ${COND==1 and FOO or BAR} > $TARGET')
10018
10019 # Will execute this:
10020 # echo foo1 foo2 > foo.out
10021
10022 SCons uses the following rules when converting construction variables
10023 into command lines:
10024
10025
10026 String When the value is a string it is interpreted as a space delim‐
10027 ited list of command line arguments.
10028
10029
10030 List When the value is a list it is interpreted as a list of command
10031 line arguments. Each element of the list is converted to a
10032 string.
10033
10034
10035 Other Anything that is not a list or string is converted to a string
10036 and interpreted as a single command line argument.
10037
10038
10039 Newline
10040 Newline characters (\n) delimit lines. The newline parsing is
10041 done after all other parsing, so it is not possible for argu‐
10042 ments (e.g. file names) to contain embedded newline characters.
10043 This limitation will likely go away in a future version of
10044 SCons.
10045
10046
10047 Scanner Objects
10048 You can use the Scanner function to define objects to scan new file
10049 types for implicit dependencies. The Scanner function accepts the fol‐
10050 lowing arguments:
10051
10052
10053 function
10054 This can be either: 1) a Python function that will process the
10055 Node (file) and return a list of File Nodes representing the
10056 implicit dependencies (file names) found in the contents; or: 2)
10057 a dictionary that maps keys (typically the file suffix, but see
10058 below for more discussion) to other Scanners that should be
10059 called.
10060
10061 If the argument is actually a Python function, the function must
10062 take three or four arguments:
10063
10064 def scanner_function(node, env, path):
10065
10066 def scanner_function(node, env, path, arg=None):
10067
10068 The node argument is the internal SCons node representing the
10069 file. Use str(node) to fetch the name of the file, and
10070 node.get_contents() to fetch contents of the file. Note that
10071 the file is not guaranteed to exist before the scanner is
10072 called, so the scanner function should check that if there's any
10073 chance that the scanned file might not exist (for example, if
10074 it's built from other files).
10075
10076 The env argument is the construction environment for the scan.
10077 Fetch values from it using the env.Dictionary() method.
10078
10079 The path argument is a tuple (or list) of directories that can
10080 be searched for files. This will usually be the tuple returned
10081 by the path_function argument (see below).
10082
10083 The arg argument is the argument supplied when the scanner was
10084 created, if any.
10085
10086
10087 name The name of the Scanner. This is mainly used to identify the
10088 Scanner internally.
10089
10090
10091 argument
10092 An optional argument that, if specified, will be passed to the
10093 scanner function (described above) and the path function (speci‐
10094 fied below).
10095
10096
10097 skeys An optional list that can be used to determine which scanner
10098 should be used for a given Node. In the usual case of scanning
10099 for file names, this argument will be a list of suffixes for the
10100 different file types that this Scanner knows how to scan. If
10101 the argument is a string, then it will be expanded into a list
10102 by the current environment.
10103
10104
10105 path_function
10106 A Python function that takes four or five arguments: a construc‐
10107 tion environment, a Node for the directory containing the SCon‐
10108 script file in which the first target was defined, a list of
10109 target nodes, a list of source nodes, and an optional argument
10110 supplied when the scanner was created. The path_function
10111 returns a tuple of directories that can be searched for files to
10112 be returned by this Scanner object. (Note that the Find‐
10113 PathDirs() function can be used to return a ready-made
10114 path_function for a given construction variable name, instead of
10115 having to write your own function from scratch.)
10116
10117
10118 node_class
10119 The class of Node that should be returned by this Scanner
10120 object. Any strings or other objects returned by the scanner
10121 function that are not of this class will be run through the
10122 node_factory function.
10123
10124
10125 node_factory
10126 A Python function that will take a string or other object and
10127 turn it into the appropriate class of Node to be returned by
10128 this Scanner object.
10129
10130
10131 scan_check
10132 An optional Python function that takes two arguments, a Node
10133 (file) and a construction environment, and returns whether the
10134 Node should, in fact, be scanned for dependencies. This check
10135 can be used to eliminate unnecessary calls to the scanner func‐
10136 tion when, for example, the underlying file represented by a
10137 Node does not yet exist.
10138
10139
10140 recursive
10141 An optional flag that specifies whether this scanner should be
10142 re-invoked on the dependency files returned by the scanner.
10143 When this flag is not set, the Node subsystem will only invoke
10144 the scanner on the file being scanned, and not (for example)
10145 also on the files specified by the #include lines in the file
10146 being scanned. recursive may be a callable function, in which
10147 case it will be called with a list of Nodes found and should
10148 return a list of Nodes that should be scanned recursively; this
10149 can be used to select a specific subset of Nodes for additional
10150 scanning.
10151
10152 Note that scons has a global SourceFileScanner object that is used by
10153 the Object(), SharedObject(), and StaticObject() builders to decide
10154 which scanner should be used for different file extensions. You can
10155 using the SourceFileScanner.add_scanner() method to add your own Scan‐
10156 ner object to the scons infrastructure that builds target programs or
10157 libraries from a list of source files of different types:
10158
10159 def xyz_scan(node, env, path):
10160 contents = node.get_text_contents()
10161 # Scan the contents and return the included files.
10162
10163 XYZScanner = Scanner(xyz_scan)
10164
10165 SourceFileScanner.add_scanner('.xyz', XYZScanner)
10166
10167 env.Program('my_prog', ['file1.c', 'file2.f', 'file3.xyz'])
10168
10169
10171 SCons and its configuration files are very portable, due largely to its
10172 implementation in Python. There are, however, a few portability issues
10173 waiting to trap the unwary.
10174
10175 .C file suffix
10176 SCons handles the upper-case .C file suffix differently, depending on
10177 the capabilities of the underlying system. On a case-sensitive system
10178 such as Linux or UNIX, SCons treats a file with a .C suffix as a C++
10179 source file. On a case-insensitive system such as Windows, SCons
10180 treats a file with a .C suffix as a C source file.
10181
10182 .F file suffix
10183 SCons handles the upper-case .F file suffix differently, depending on
10184 the capabilities of the underlying system. On a case-sensitive system
10185 such as Linux or UNIX, SCons treats a file with a .F suffix as a For‐
10186 tran source file that is to be first run through the standard C pre‐
10187 processor. On a case-insensitive system such as Windows, SCons treats
10188 a file with a .F suffix as a Fortran source file that should not be run
10189 through the C preprocessor.
10190
10191 Windows: Cygwin Tools and Cygwin Python vs. Windows Pythons
10192 Cygwin supplies a set of tools and utilities that let users work on a
10193 Windows system using a more POSIX-like environment. The Cygwin tools,
10194 including Cygwin Python, do this, in part, by sharing an ability to
10195 interpret UNIX-like path names. For example, the Cygwin tools will
10196 internally translate a Cygwin path name like /cygdrive/c/mydir to an
10197 equivalent Windows pathname of C:/mydir (equivalent to C:\mydir).
10198
10199 Versions of Python that are built for native Windows execution, such as
10200 the python.org and ActiveState versions, do not have the Cygwin path
10201 name semantics. This means that using a native Windows version of
10202 Python to build compiled programs using Cygwin tools (such as gcc,
10203 bison, and flex) may yield unpredictable results. "Mixing and match‐
10204 ing" in this way can be made to work, but it requires careful attention
10205 to the use of path names in your SConscript files.
10206
10207 In practice, users can sidestep the issue by adopting the following
10208 rules: When using gcc, use the Cygwin-supplied Python interpreter to
10209 run SCons; when using Microsoft Visual C/C++ (or some other Windows
10210 compiler) use the python.org or ActiveState version of Python to run
10211 SCons.
10212
10213 Windows: scons.bat file
10214 On Windows systems, SCons is executed via a wrapper scons.bat file.
10215 This has (at least) two ramifications:
10216
10217 First, Windows command-line users that want to use variable assignment
10218 on the command line may have to put double quotes around the assign‐
10219 ments:
10220
10221 scons "FOO=BAR" "BAZ=BLEH"
10222
10223 Second, the Cygwin shell does not recognize this file as being the same
10224 as an scons command issued at the command-line prompt. You can work
10225 around this either by executing scons.bat from the Cygwin command line,
10226 or by creating a wrapper shell script named scons .
10227
10228
10229 MinGW
10230 The MinGW bin directory must be in your PATH environment variable or
10231 the PATH variable under the ENV construction variable for SCons to
10232 detect and use the MinGW tools. When running under the native Windows
10233 Python interpreter, SCons will prefer the MinGW tools over the Cygwin
10234 tools, if they are both installed, regardless of the order of the bin
10235 directories in the PATH variable. If you have both MSVC and MinGW
10236 installed and you want to use MinGW instead of MSVC, then you must
10237 explictly tell SCons to use MinGW by passing
10238
10239 tools=['mingw']
10240
10241 to the Environment() function, because SCons will prefer the MSVC tools
10242 over the MinGW tools.
10243
10244
10246 To help you get started using SCons, this section contains a brief
10247 overview of some common tasks.
10248
10249
10250 Basic Compilation From a Single Source File
10251 env = Environment()
10252 env.Program(target = 'foo', source = 'foo.c')
10253
10254 Note: Build the file by specifying the target as an argument ("scons
10255 foo" or "scons foo.exe"). or by specifying a dot ("scons .").
10256
10257
10258 Basic Compilation From Multiple Source Files
10259 env = Environment()
10260 env.Program(target = 'foo', source = Split('f1.c f2.c f3.c'))
10261
10262
10263 Setting a Compilation Flag
10264 env = Environment(CCFLAGS = '-g')
10265 env.Program(target = 'foo', source = 'foo.c')
10266
10267
10268 Search The Local Directory For .h Files
10269 Note: You do not need to set CCFLAGS to specify -I options by hand.
10270 SCons will construct the right -I options from CPPPATH.
10271
10272 env = Environment(CPPPATH = ['.'])
10273 env.Program(target = 'foo', source = 'foo.c')
10274
10275
10276 Search Multiple Directories For .h Files
10277 env = Environment(CPPPATH = ['include1', 'include2'])
10278 env.Program(target = 'foo', source = 'foo.c')
10279
10280
10281 Building a Static Library
10282 env = Environment()
10283 env.StaticLibrary(target = 'foo', source = Split('l1.c l2.c'))
10284 env.StaticLibrary(target = 'bar', source = ['l3.c', 'l4.c'])
10285
10286
10287 Building a Shared Library
10288 env = Environment()
10289 env.SharedLibrary(target = 'foo', source = ['l5.c', 'l6.c'])
10290 env.SharedLibrary(target = 'bar', source = Split('l7.c l8.c'))
10291
10292
10293 Linking a Local Library Into a Program
10294 env = Environment(LIBS = 'mylib', LIBPATH = ['.'])
10295 env.Library(target = 'mylib', source = Split('l1.c l2.c'))
10296 env.Program(target = 'prog', source = ['p1.c', 'p2.c'])
10297
10298
10299 Defining Your Own Builder Object
10300 Notice that when you invoke the Builder, you can leave off the target
10301 file suffix, and SCons will add it automatically.
10302
10303 bld = Builder(action = 'pdftex < $SOURCES > $TARGET'
10304 suffix = '.pdf',
10305 src_suffix = '.tex')
10306 env = Environment(BUILDERS = {'PDFBuilder' : bld})
10307 env.PDFBuilder(target = 'foo.pdf', source = 'foo.tex')
10308
10309 # The following creates "bar.pdf" from "bar.tex"
10310 env.PDFBuilder(target = 'bar', source = 'bar')
10311
10312 Note also that the above initialization overwrites the default Builder
10313 objects, so the Environment created above can not be used call Builders
10314 like env.Program(), env.Object(), env.StaticLibrary(), etc.
10315
10316
10317 Adding Your Own Builder Object to an Environment
10318 bld = Builder(action = 'pdftex < $SOURCES > $TARGET'
10319 suffix = '.pdf',
10320 src_suffix = '.tex')
10321 env = Environment()
10322 env.Append(BUILDERS = {'PDFBuilder' : bld})
10323 env.PDFBuilder(target = 'foo.pdf', source = 'foo.tex')
10324 env.Program(target = 'bar', source = 'bar.c')
10325
10326 You also can use other Pythonic techniques to add to the BUILDERS con‐
10327 struction variable, such as:
10328
10329 env = Environment()
10330 env['BUILDERS]['PDFBuilder'] = bld
10331
10332
10333 Defining Your Own Scanner Object
10334 The following example shows an extremely simple scanner (the
10335 kfile_scan() function) that doesn't use a search path at all and simply
10336 returns the file names present on any include lines in the scanned
10337 file. This would implicitly assume that all included files live in the
10338 top-level directory:
10339
10340 import re
10341
10342 include_re = re.compile(r'^include\s+(\S+)$', re.M)
10343
10344 def kfile_scan(node, env, path, arg):
10345 contents = node.get_text_contents()
10346 includes = include_re.findall(contents)
10347 return env.File(includes)
10348
10349 kscan = Scanner(name = 'kfile',
10350 function = kfile_scan,
10351 argument = None,
10352 skeys = ['.k'])
10353 scanners = Environment().Dictionary('SCANNERS')
10354 env = Environment(SCANNERS = scanners + [kscan])
10355
10356 env.Command('foo', 'foo.k', 'kprocess < $SOURCES > $TARGET')
10357
10358 bar_in = File('bar.in')
10359 env.Command('bar', bar_in, 'kprocess $SOURCES > $TARGET')
10360 bar_in.target_scanner = kscan
10361
10362 It is important to note that you have to return a list of File nodes
10363 from the scan function, simple strings for the file names won't do. As
10364 in the examples we are showing here, you can use the File() function of
10365 your current Environment in order to create nodes on the fly from a
10366 sequence of file names with relative paths.
10367
10368 Here is a similar but more complete example that searches a path of
10369 directories (specified as the MYPATH construction variable) for files
10370 that actually exist:
10371
10372 import re
10373 import os
10374 include_re = re.compile(r'^include\s+(\S+)$', re.M)
10375
10376 def my_scan(node, env, path, arg):
10377 contents = node.get_text_contents()
10378 includes = include_re.findall(contents)
10379 if includes == []:
10380 return []
10381 results = []
10382 for inc in includes:
10383 for dir in path:
10384 file = str(dir) + os.sep + inc
10385 if os.path.exists(file):
10386 results.append(file)
10387 break
10388 return env.File(results)
10389
10390 scanner = Scanner(name = 'myscanner',
10391 function = my_scan,
10392 argument = None,
10393 skeys = ['.x'],
10394 path_function = FindPathDirs('MYPATH')
10395 )
10396 scanners = Environment().Dictionary('SCANNERS')
10397 env = Environment(SCANNERS = scanners + [scanner],
10398 MYPATH = ['incs'])
10399
10400 env.Command('foo', 'foo.x', 'xprocess < $SOURCES > $TARGET')
10401
10402 The FindPathDirs() function used in the previous example returns a
10403 function (actually a callable Python object) that will return a list of
10404 directories specified in the $MYPATH construction variable. It lets
10405 SCons detect the file incs/foo.inc , even if foo.x contains the line
10406 include foo.inc only. If you need to customize how the search path is
10407 derived, you would provide your own path_function argument when creat‐
10408 ing the Scanner object, as follows:
10409
10410 # MYPATH is a list of directories to search for files in
10411 def pf(env, dir, target, source, arg):
10412 top_dir = Dir('#').abspath
10413 results = []
10414 if 'MYPATH' in env:
10415 for p in env['MYPATH']:
10416 results.append(top_dir + os.sep + p)
10417 return results
10418
10419 scanner = Scanner(name = 'myscanner',
10420 function = my_scan,
10421 argument = None,
10422 skeys = ['.x'],
10423 path_function = pf
10424 )
10425
10426
10427 Creating a Hierarchical Build
10428 Notice that the file names specified in a subdirectory's SConscript
10429 file are relative to that subdirectory.
10430
10431 SConstruct:
10432
10433 env = Environment()
10434 env.Program(target = 'foo', source = 'foo.c')
10435
10436 SConscript('sub/SConscript')
10437
10438 sub/SConscript:
10439
10440 env = Environment()
10441 # Builds sub/foo from sub/foo.c
10442 env.Program(target = 'foo', source = 'foo.c')
10443
10444 SConscript('dir/SConscript')
10445
10446 sub/dir/SConscript:
10447
10448 env = Environment()
10449 # Builds sub/dir/foo from sub/dir/foo.c
10450 env.Program(target = 'foo', source = 'foo.c')
10451
10452
10453 Sharing Variables Between SConscript Files
10454 You must explicitly Export() and Import() variables that you want to
10455 share between SConscript files.
10456
10457 SConstruct:
10458
10459 env = Environment()
10460 env.Program(target = 'foo', source = 'foo.c')
10461
10462 Export("env")
10463 SConscript('subdirectory/SConscript')
10464
10465 subdirectory/SConscript:
10466
10467 Import("env")
10468 env.Program(target = 'foo', source = 'foo.c')
10469
10470
10471 Building Multiple Variants From the Same Source
10472 Use the variant_dir keyword argument to the SConscript function to
10473 establish one or more separate variant build directory trees for a
10474 given source directory:
10475
10476 SConstruct:
10477
10478 cppdefines = ['FOO']
10479 Export("cppdefines")
10480 SConscript('src/SConscript', variant_dir='foo')
10481
10482 cppdefines = ['BAR']
10483 Export("cppdefines")
10484 SConscript('src/SConscript', variant_dir='bar')
10485
10486 src/SConscript:
10487
10488 Import("cppdefines")
10489 env = Environment(CPPDEFINES = cppdefines)
10490 env.Program(target = 'src', source = 'src.c')
10491
10492 Note the use of the Export() method to set the "cppdefines" variable to
10493 a different value each time we call the SConscript function.
10494
10495
10496 Hierarchical Build of Two Libraries Linked With a Program
10497 SConstruct:
10498
10499 env = Environment(LIBPATH = ['#libA', '#libB'])
10500 Export('env')
10501 SConscript('libA/SConscript')
10502 SConscript('libB/SConscript')
10503 SConscript('Main/SConscript')
10504
10505 libA/SConscript:
10506
10507 Import('env')
10508 env.Library('a', Split('a1.c a2.c a3.c'))
10509
10510 libB/SConscript:
10511
10512 Import('env')
10513 env.Library('b', Split('b1.c b2.c b3.c'))
10514
10515 Main/SConscript:
10516
10517 Import('env')
10518 e = env.Copy(LIBS = ['a', 'b'])
10519 e.Program('foo', Split('m1.c m2.c m3.c'))
10520
10521 The '#' in the LIBPATH directories specify that they're relative to the
10522 top-level directory, so they don't turn into "Main/libA" when they're
10523 used in Main/SConscript.
10524
10525 Specifying only 'a' and 'b' for the library names allows SCons to
10526 append the appropriate library prefix and suffix for the current plat‐
10527 form (for example, 'liba.a' on POSIX systems, 'a.lib' on Windows).
10528
10529
10530 Customizing construction variables from the command line.
10531 The following would allow the C compiler to be specified on the command
10532 line or in the file custom.py.
10533
10534 vars = Variables('custom.py')
10535 vars.Add('CC', 'The C compiler.')
10536 env = Environment(variables=vars)
10537 Help(vars.GenerateHelpText(env))
10538
10539 The user could specify the C compiler on the command line:
10540
10541 scons "CC=my_cc"
10542
10543 or in the custom.py file:
10544
10545 CC = 'my_cc'
10546
10547 or get documentation on the options:
10548
10549 $ scons -h
10550
10551 CC: The C compiler.
10552 default: None
10553 actual: cc
10554
10555
10556
10557 Using Microsoft Visual C++ precompiled headers
10558 Since windows.h includes everything and the kitchen sink, it can take
10559 quite some time to compile it over and over again for a bunch of object
10560 files, so Microsoft provides a mechanism to compile a set of headers
10561 once and then include the previously compiled headers in any object
10562 file. This technology is called precompiled headers. The general recipe
10563 is to create a file named "StdAfx.cpp" that includes a single header
10564 named "StdAfx.h", and then include every header you want to precompile
10565 in "StdAfx.h", and finally include "StdAfx.h" as the first header in
10566 all the source files you are compiling to object files. For example:
10567
10568 StdAfx.h:
10569 #include <windows.h>
10570 #include <my_big_header.h>
10571
10572 StdAfx.cpp:
10573 #include <StdAfx.h>
10574
10575 Foo.cpp:
10576 #include <StdAfx.h>
10577
10578 /* do some stuff */
10579
10580 Bar.cpp:
10581 #include <StdAfx.h>
10582
10583 /* do some other stuff */
10584
10585 SConstruct:
10586 env=Environment()
10587 env['PCHSTOP'] = 'StdAfx.h'
10588 env['PCH'] = env.PCH('StdAfx.cpp')[0]
10589 env.Program('MyApp', ['Foo.cpp', 'Bar.cpp'])
10590
10591 For more information see the document for the PCH builder, and the PCH
10592 and PCHSTOP construction variables. To learn about the details of pre‐
10593 compiled headers consult the MSDN documention for /Yc, /Yu, and /Yp.
10594
10595
10596 Using Microsoft Visual C++ external debugging information
10597 Since including debugging information in programs and shared libraries
10598 can cause their size to increase significantly, Microsoft provides a
10599 mechanism for including the debugging information in an external file
10600 called a PDB file. SCons supports PDB files through the PDB construc‐
10601 tion variable.
10602
10603 SConstruct:
10604 env=Environment()
10605 env['PDB'] = 'MyApp.pdb'
10606 env.Program('MyApp', ['Foo.cpp', 'Bar.cpp'])
10607
10608 For more information see the document for the PDB construction vari‐
10609 able.
10610
10611
10613 SCONS_LIB_DIR
10614 Specifies the directory that contains the SCons Python module
10615 directory (e.g. /home/aroach/scons-src-0.01/src/engine).
10616
10617
10618 SCONSFLAGS
10619 A string of options that will be used by scons in addition to
10620 those passed on the command line.
10621
10622
10624 scons User Manual, scons Design Document, scons source code.
10625
10626
10628 Steven Knight <knight@baldmt.com>
10629 Anthony Roach <aroach@electriceyeball.com>
10630
10631
10632
10633
10634 September 2011 SCONS(1)