3 Copyright The SCons Foundation
5 This file is processed by the bin/SConsDoc.py module.
6 See its __doc__ string for a discussion of the format.
10 <!ENTITY % scons SYSTEM '../doc/scons.mod'>
12 <!ENTITY % builders-mod SYSTEM '../doc/generated/builders.mod'>
14 <!ENTITY % functions-mod SYSTEM '../doc/generated/functions.mod'>
16 <!ENTITY % tools-mod SYSTEM '../doc/generated/tools.mod'>
18 <!ENTITY % variables-mod SYSTEM '../doc/generated/variables.mod'>
22 <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
23 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24 xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
26 <cvar name ="_concat">
29 A function used to produce variables like &cv-link-_CPPINCFLAGS;. It takes
30 four mandatory arguments, and up to 4 additional optional arguments:
31 1) a prefix to concatenate onto each element,
32 2) a list of elements,
33 3) a suffix to concatenate onto each element,
34 4) an environment for variable interpolation,
35 5) an optional function that will be called to transform the list before concatenation,
36 6) an optionally specified target (Can use TARGET),
37 7) an optionally specified source (Can use SOURCE),
38 8) optional <parameter>affect_signature</parameter> flag which will wrap non-empty returned value with $( and $) to indicate the contents
39 should not affect the signature of the generated command line.
43 env['_CPPINCFLAGS'] = '${_concat(INCPREFIX, CPPPATH, INCSUFFIX, __env__, RDirs, TARGET, SOURCE, affect_signature=False)}'
48 <cvar name="CONFIGUREDIR">
51 The name of the directory in which
52 Configure context test files are written.
54 <filename>.sconf_temp</filename>
55 in the top-level directory
57 <filename>SConstruct</filename>
61 If variant directories are in use,
62 and the configure check results should not be
63 shared between variants,
64 you can set &cv-CONFIGUREDIR;
65 and &cv-link-CONFIGURELOG; so they are
66 unique per variant directory.
71 <cvar name="CONFIGURELOG">
74 The name of the &Configure; context log file.
76 <filename>config.log</filename>
77 in the top-level directory
79 <filename>SConstruct</filename>
83 If variant directories are in use,
84 and the configure check results should not be
85 shared between variants,
86 you can set &cv-link-CONFIGUREDIR;
87 and &cv-CONFIGURELOG; so they are
88 unique per variant directory.
93 <cvar name="_CPPDEFFLAGS">
96 An automatically-generated &consvar;
97 containing the C preprocessor command-line options
99 The value of &cv-link-_CPPDEFFLAGS; is created
100 by respectively prepending and appending
101 &cv-link-CPPDEFPREFIX; and &cv-link-CPPDEFSUFFIX;
102 to each definition in &cv-link-CPPDEFINES;.
107 <cvar name="CPPDEFINES">
110 A platform independent specification of C preprocessor macro definitions.
111 The definitions are added to command lines
112 through the automatically-generated
113 &cv-link-_CPPDEFFLAGS; &consvar;,
114 which is constructed according to
115 the contents of &cv-CPPDEFINES;:
121 If &cv-CPPDEFINES; is a string,
123 &cv-link-CPPDEFPREFIX; and &cv-link-CPPDEFSUFFIX; &consvars;
124 are respectively prepended and appended to
125 each definition in &cv-CPPDEFINES;,
130 # Adds -Dxyz to POSIX compiler command lines,
131 # and /Dxyz to Microsoft Visual C++ command lines.
132 env = Environment(CPPDEFINES='xyz')
138 If &cv-CPPDEFINES; is a list,
140 &cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
141 are respectively prepended and appended to
142 each element in the list.
143 If any element is a tuple (or list)
144 then the first item of the tuple is the macro name
145 and the second is the macro definition.
146 If the definition is not omitted or <literal>None</literal>,
147 the name and definition are combined into a single
148 <literal>name=definition</literal> item
149 before the preending/appending.
153 # Adds -DB=2 -DA to POSIX compiler command lines,
154 # and /DB=2 /DA to Microsoft Visual C++ command lines.
155 env = Environment(CPPDEFINES=[('B', 2), 'A'])
161 If &cv-CPPDEFINES; is a dictionary,
163 &cv-CPPDEFPREFIX; and &cv-CPPDEFSUFFIX; &consvars;
164 are respectively prepended and appended to
165 each key from the dictionary.
166 If the value for a key is not <literal>None</literal>,
167 then the key (macro name) and the value
168 (macros definition) are combined into a single
169 <literal>name=definition</literal> item
170 before the prepending/appending.
174 # Adds -DA -DB=2 to POSIX compiler command lines,
175 # or /DA /DB=2 to Microsoft Visual C++ command lines.
176 env = Environment(CPPDEFINES={'B':2, 'A':None})
182 Depending on how contents are added to &cv-CPPDEFINES;,
183 it may be transformed into a compound type,
184 for example a list containing strings, tuples and/or dictionaries.
185 &SCons; can correctly expand such a compound type.
189 Note that &SCons; may call the compiler via a shell.
190 If a macro definition contains characters such as spaces that
191 have meaning to the shell, or is intended to be a string value,
192 you may need to use the shell's quoting syntax to avoid
193 interpretation by the shell before the preprocessor sees it.
194 Function-like macros are not supported via this mechanism
195 (and some compilers do not even implement that functionality
196 via the command lines).
197 When quoting, note that
198 one set of quote characters are used to define a &Python; string,
199 then quotes embedded inside that would be consumed by the shell
200 unless escaped. These examples may help illustrate:
204 env = Environment(CPPDEFINES=['USE_ALT_HEADER=\\"foo_alt.h\\"'])
205 env = Environment(CPPDEFINES=[('USE_ALT_HEADER', '\\"foo_alt.h\\"')])
209 :<emphasis>Changed in version 4.5</emphasis>:
210 &SCons; no longer sorts &cv-CPPDEFINES; values entered
211 in dictionary form. &Python; now preserves dictionary
212 keys in the order they are entered, so it is no longer
213 necessary to sort them to ensure a stable command line.
219 <cvar name="CPPDEFPREFIX">
222 The prefix used to specify preprocessor macro definitions
223 on the C compiler command line.
224 This will be prepended to each definition
225 in the &cv-link-CPPDEFINES; &consvar;
226 when the &cv-link-_CPPDEFFLAGS; variable is automatically generated.
231 <cvar name="CPPDEFSUFFIX">
234 The suffix used to specify preprocessor macro definitions
235 on the C compiler command line.
236 This will be appended to each definition
237 in the &cv-link-CPPDEFINES; &consvar;
238 when the &cv-link-_CPPDEFFLAGS; variable is automatically generated.
243 <cvar name="_CPPINCFLAGS">
246 An automatically-generated &consvar;
247 containing the C preprocessor command-line options
248 for specifying directories to be searched for include files.
249 The value of &cv-_CPPINCFLAGS; is created
250 by respectively prepending and appending
251 &cv-link-INCPREFIX; and &cv-link-INCSUFFIX;
252 to each directory in &cv-link-CPPPATH;.
257 <cvar name="CPPPATH">
260 The list of directories that the C preprocessor will search for include
261 directories. The C/C++ implicit dependency scanner will search these
262 directories for include files.
263 In general it's not advised to put include directory directives
264 directly into &cv-link-CCFLAGS; or &cv-link-CXXFLAGS;
265 as the result will be non-portable
266 and the directories will not be searched by the dependency scanner.
267 &cv-CPPPATH; should be a list of path strings,
268 or a single string, not a pathname list joined by
269 Python's <systemitem>os.pathsep</systemitem>.
274 directory names in &cv-CPPPATH;
275 will be looked-up relative to the directory of the SConscript file
276 when they are used in a command.
278 to look-up a directory relative to the root of the source tree use
279 the <literal>#</literal> prefix:
283 env = Environment(CPPPATH='#/include')
287 The directory look-up can also be forced using the
293 include = Dir('include')
294 env = Environment(CPPPATH=include)
298 The directory list will be added to command lines
299 through the automatically-generated
300 &cv-link-_CPPINCFLAGS; &consvar;,
301 which is constructed by
302 respectively prepending and appending the values of the
303 &cv-link-INCPREFIX; and &cv-link-INCSUFFIX; &consvars;
304 to each directory in &cv-link-CPPPATH;.
305 Any command lines you define that need
306 the &cv-CPPPATH; directory list should
307 include &cv-link-_CPPINCFLAGS;:
311 env = Environment(CCCOM="my_compiler $_CPPINCFLAGS -c -o $TARGET $SOURCE")
319 A function that converts a string
320 into a Dir instance relative to the target being built.
328 A function that converts a list of strings
329 into a list of Dir instances relative to the target being built.
334 <cvar name="DSUFFIXES">
337 The list of suffixes of files that will be scanned
338 for imported D package files.
339 The default list is <literal>['.d']</literal>.
347 A function that converts a string into a File instance relative to the
353 <cvar name="IDLSUFFIXES">
356 The list of suffixes of files that will be scanned
357 for IDL implicit dependencies
358 (#include or import lines).
368 <cvar name="INCPREFIX">
371 The prefix used to specify an include directory on the C compiler command
373 This will be prepended to each directory
374 in the &cv-link-CPPPATH; and &cv-link-FORTRANPATH; &consvars;
375 when the &cv-link-_CPPINCFLAGS; and &cv-link-_FORTRANINCFLAGS;
376 variables are automatically generated.
381 <cvar name="INCSUFFIX">
384 The suffix used to specify an include directory on the C compiler command
386 This will be appended to each directory
387 in the &cv-link-CPPPATH; and &cv-link-FORTRANPATH; &consvars;
388 when the &cv-link-_CPPINCFLAGS; and &cv-link-_FORTRANINCFLAGS;
389 variables are automatically generated.
394 <cvar name="INSTALL">
397 A function to be called to install a file into a
398 destination file name.
399 The default function copies the file into the destination
400 (and sets the destination file's mode and permission bits
401 to match the source file's).
402 The function takes the following arguments:
406 def install(dest, source, env):
410 <varname>dest</varname>
411 is the path name of the destination file.
412 <varname>source</varname>
413 is the path name of the source file.
414 <varname>env</varname>
415 is the construction environment
416 (a dictionary of construction values)
417 in force for this file installation.
422 <cvar name="INSTALLSTR">
425 The string displayed when a file is
426 installed into a destination file name.
430 Install file: "$SOURCE" as "$TARGET"
435 <cvar name="LATEXSUFFIXES">
438 The list of suffixes of files that will be scanned
439 for LaTeX implicit dependencies
440 (<literal>\include</literal> or <literal>\import</literal> files).
445 [".tex", ".ltx", ".latex"]
450 <cvar name="_LIBDIRFLAGS">
453 An automatically-generated construction variable
454 containing the linker command-line options
455 for specifying directories to be searched for library.
456 The value of &cv-_LIBDIRFLAGS; is created
457 by respectively prepending and appending &cv-link-LIBDIRPREFIX;
458 and &cv-link-LIBDIRSUFFIX;
459 to each directory in &cv-link-LIBPATH;.
464 <cvar name="LIBDIRPREFIX">
467 The prefix used to specify a library directory on the linker command line.
468 This will be prepended to each directory
469 in the &cv-link-LIBPATH; construction variable
470 when the &cv-link-_LIBDIRFLAGS; variable is automatically generated.
475 <cvar name="LIBDIRSUFFIX">
478 The suffix used to specify a library directory on the linker command line.
479 This will be appended to each directory
480 in the &cv-link-LIBPATH; construction variable
481 when the &cv-link-_LIBDIRFLAGS; variable is automatically generated.
486 <cvar name="_LIBFLAGS">
489 An automatically-generated construction variable
490 containing the linker command-line options
491 for specifying libraries to be linked with the resulting target.
492 The value of &cv-_LIBFLAGS; is created
493 by respectively prepending and appending &cv-link-LIBLINKPREFIX;
494 and &cv-link-LIBLINKSUFFIX;
495 to each filename in &cv-link-LIBS;.
500 <cvar name="LIBLINKPREFIX">
503 The prefix used to specify a library to link on the linker command line.
504 This will be prepended to each library
505 in the &cv-link-LIBS; construction variable
506 when the &cv-link-_LIBFLAGS; variable is automatically generated.
511 <cvar name="LIBLINKSUFFIX">
514 The suffix used to specify a library to link on the linker command line.
515 This will be appended to each library
516 in the &cv-link-LIBS; construction variable
517 when the &cv-link-_LIBFLAGS; variable is automatically generated.
522 <cvar name="LIBPATH">
525 The list of directories that will be searched for libraries
526 specified by the &cv-link-LIBS; &consvar;.
527 &cv-LIBPATH; should be a list of path strings,
528 or a single string, not a pathname list joined by
529 Python's <systemitem>os.pathsep</systemitem>.
531 The implicit dependency scanner will search these
532 directories for include files. Don't explicitly put include directory
533 arguments into &cv-LINKFLAGS; or &cv-SHLINKFLAGS;
534 because the result will be non-portable
535 and the directories will not be searched by the dependency scanner.
538 Do not put library search directives directly
539 into &cv-LINKFLAGS; or &cv-SHLINKFLAGS;
540 as the result will be non-portable.
546 directory names in &cv-LIBPATH; will be looked-up relative to the
547 directory of the SConscript file
548 when they are used in a command.
550 to look-up a directory relative to the root of the source tree use
551 the <literal>#</literal> prefix:
555 env = Environment(LIBPATH='#/libs')
559 The directory look-up can also be forced using the
560 &f-link-Dir; function:
565 env = Environment(LIBPATH=libs)
569 The directory list will be added to command lines
570 through the automatically-generated
571 &cv-link-_LIBDIRFLAGS;
572 construction variable,
573 which is constructed by
574 respectively prepending and appending the values of the
575 &cv-link-LIBDIRPREFIX; and &cv-link-LIBDIRSUFFIX;
576 construction variables
577 to each directory in &cv-LIBPATH;.
578 Any command lines you define that need
579 the &cv-LIBPATH; directory list should
580 include &cv-_LIBDIRFLAGS;:
584 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
592 The list of libraries
593 that will be added to the link line
594 for linking with any executable program, shared library, or loadable module
595 created by the &consenv; or override.
600 a string-valued library name should include
601 only the base library name,
602 without prefixes such as <filename>lib</filename>
603 or suffixes such as <filename>.so</filename> or <filename>.dll</filename>.
604 &SCons; <emphasis>will</emphasis> attempt to
605 strip prefixes from the &cv-link-LIBPREFIXES; list
606 and suffixes from the &cv-link-LIBSUFFIXES; list,
607 but depending on that behavior will make the build
609 for example, on a POSIX system,
610 no attempt will be made to strip a suffix like
611 <filename>.dll</filename>.
612 Library name strings in &cv-LIBS; should not include a path component:
613 instead use &cv-link-LIBPATH; to direct the compiler
614 to look for libraries in those paths,
615 plus any default paths the linker searches in.
616 If &cv-link-LIBLITERALPREFIX; is set to a non-empty string,
617 then a string-valued &cv-LIBS; entry
618 that starts with &cv-link-LIBLITERALPREFIX;
619 will cause the rest of the entry
620 to be searched for for unmodified,
621 but respecting normal library search paths
622 (this is an exception to the guideline above
623 about leaving off the prefix/suffix from the library name).
627 If a &cv-LIBS; entry is a Node object
628 (either as returned by a previous Builder call,
629 or as the result of an explicit call to &f-link-File;),
630 the pathname from that Node will be added to
632 and thus to the link line,
633 unmodified - without adding
637 Such entries are searched for literally
638 (including any path component);
639 the library search paths are not used.
644 env.Append(LIBS=File('/tmp/mylib.so'))
648 <!-- is this actually true? -->
649 For each &Builder; call that causes linking with libraries,
650 &SCons; will add the libraries in the setting of &cv-LIBS;
651 in effect at that moment to the dependecy graph
652 as dependencies of the target being generated.
656 The library list will transformed to command line
657 arguments through the automatically-generated
658 &cv-link-_LIBFLAGS; &consvar;
659 which is constructed by
660 respectively prepending and appending the values of the
661 &cv-link-LIBLINKPREFIX; and &cv-link-LIBLINKSUFFIX; &consvars;
662 to each library name.
666 Any command lines you define yourself that need
667 the libraries from &cv-LIBS; should include &cv-_LIBFLAGS;
668 (as well as &cv-link-_LIBDIRFLAGS;)
669 rather than &cv-LIBS;.
674 env = Environment(LINKCOM="my_linker $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET $SOURCE")
679 <cvar name="LIBLITERALPREFIX">
682 If the linker supports command line syntax directing
683 that the argument specifying a library should be
684 searched for literally (without modification),
685 &cv-LIBLITERALPREFIX; can be set to that indicator.
686 For example, the GNU linker follows this rule:
688 <literal>-l:foo</literal> searches the library path
689 for a filename called <literal>foo</literal>,
690 without converting it to
691 <literal>libfoo.so</literal> or
692 <literal>libfoo.a</literal>.
694 If &cv-LIBLITERALPREFIX; is set,
695 &SCons; will not transform a string-valued entry in
696 &cv-link-LIBS; that starts with that string.
697 The entry will still be surrounded with
698 &cv-link-LIBLINKPREFIX; and &cv-link-LIBLINKSUFFIX;
700 This is useful, for example,
701 in directing that a static library
702 be used when both a static and dynamic library are available
703 and linker policy is to prefer dynamic libraries.
704 Compared to the example in &cv-link-LIBS;,
707 env.Append(LIBS=":libmylib.a")
710 will let the linker select that specific (static)
711 library name if found in the library search path.
712 This differs from using a
713 <classname>File</classname> object
714 to specify the static library,
715 as the latter bypasses the library search path entirely.
723 A function that converts a string into a list of Dir instances by
724 searching the repositories.
729 <scons_function name="DefaultEnvironment">
730 <arguments signature="global">
735 Instantiates and returns the global &consenv; object.
736 This environment is used internally by SCons
737 when it executes many of the global functions listed in this section
738 (that is, those not called as methods of a specific &consenv;).
739 The &defenv; is a singleton:
740 the keyword arguments are used only on the first call;
741 on subsequent calls the already-constructed object is returned
742 and any keyword arguments are silently ignored.
743 The &defenv; can still be modified after instantiation
744 in the same way as any other &consenv;.
745 The &defenv; is independent:
746 modifying it has no effect on any other &consenv;
747 constructed by an &f-link-Environment; or &f-link-Clone; call.
751 It is not mandatory to call &f-DefaultEnvironment;:
752 the &defenv; is instantiated automatically when the
753 build phase begins if this function has not been called;
754 however calling it explicitly gives the opportunity to
755 affect and examine the contents of the &defenv;.
756 Instantiation happens even if no build instructions
757 appar to use it, as there are internal uses.
758 If there are no uses in the project &SConscript; files,
759 a small performance gain may be seen by calling
760 &f-DefaultEnvironment; with an empty tools list,
761 thus avoiding that part of the initialization cost.
762 This is mainly of interest in testing when &scons; is
763 launched repeatedly in a short time period:
766 DefaultEnvironment(tools=[])