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