2 <!ENTITY % scons SYSTEM "../scons.mod">
4 <!ENTITY % builders-mod SYSTEM "builders.mod">
6 <!ENTITY % functions-mod SYSTEM "functions.mod">
8 <!ENTITY % tools-mod SYSTEM "tools.mod">
10 <!ENTITY % variables-mod SYSTEM "variables.mod">
14 <variablelist xmlns="http://www.scons.org/dbxsd/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
15 <varlistentry id="b-CFile">
16 <term><function>CFile</function>()</term>
17 <term><replaceable>env</replaceable>.<methodname>CFile</methodname>()</term>
19 Builds a C source file given a lex (<filename>.l</filename>)
20 or yacc (<filename>.y</filename>) input file.
21 The suffix specified by the &cv-link-CFILESUFFIX; &consvar;
22 (<filename>.c</filename> by default)
23 is automatically added to the target
24 if it is not already present.
30 env.CFile(target='foo.c', source='foo.l')
33 env.CFile(target='bar', source='bar.y')
38 <varlistentry id="b-Command">
39 <term><function>Command</function>()</term>
40 <term><replaceable>env</replaceable>.<methodname>Command</methodname>()</term>
42 The &b-Command; "Builder" is actually
43 a function that looks like a Builder,
44 but takes a required third argument, which is the
45 action to take to construct the target
46 from the source, used for "one-off" builds
47 where a full builder is not needed.
48 Thus it does not follow the builder
49 calling rules described at the start of this section.
50 See instead the &f-link-Command; function description
51 for the calling syntax and details.
55 <varlistentry id="b-CompilationDatabase">
56 <term><function>CompilationDatabase</function>()</term>
57 <term><replaceable>env</replaceable>.<methodname>CompilationDatabase</methodname>()</term>
59 &b-CompilationDatabase; is a special builder which
60 adds a target to create a JSON formatted
61 compilation database compatible with
62 <systemitem>clang</systemitem> tooling
64 <ulink url="https://clang.llvm.org/docs/JSONCompilationDatabase.html">LLVM specification</ulink>).
65 This database is suitable for consumption by various
66 tools and editors who can use it to obtain build and
67 dependency information which otherwise would be
69 The builder does not require any source files to be specified,
70 rather it arranges to emit information about all
71 of the C, C++ and assembler source/output pairs
72 identified in the build that are not excluded by the
73 optional filter &cv-link-COMPILATIONDB_PATH_FILTER;.
74 The target is subject to the usual &SCons; target
78 If called with no arguments,
79 the builder will default to a target name of
80 <filename>compile_commands.json</filename>.
83 If called with a single positional argument,
84 &scons; will "deduce" the target name from that source
85 argument, giving it the same name, and then
87 This is the usual way to call the builder if a
88 non-default target name is wanted.
91 If called with either the <parameter>target=</parameter>
92 or <parameter>source=</parameter> keyword arguments,
93 the value of the argument is taken as the target name.
94 If called with both, the <parameter>target=</parameter>
95 value is used and <parameter>source=</parameter> is ignored.
96 If called with multiple sources,
97 the source list will be ignored,
98 since there is no way to deduce what the intent was;
99 in this case the default target name will be used.
103 You must load the &t-compilation_db; tool prior to specifying
104 any part of your build or some source/output
105 files will not show up in the compilation database.
109 <emphasis>Available since &scons; 4.0.</emphasis>
113 <varlistentry id="b-CXXFile">
114 <term><function>CXXFile</function>()</term>
115 <term><replaceable>env</replaceable>.<methodname>CXXFile</methodname>()</term>
117 Builds a C++ source file given a lex (<filename>.ll</filename>)
118 or yacc (<filename>.yy</filename>)
120 The suffix specified by the &cv-link-CXXFILESUFFIX; &consvar;
121 (<filename>.cc</filename> by default)
122 is automatically added to the target
123 if it is not already present.
129 env.CXXFile(target='foo.cc', source='foo.ll')
132 env.CXXFile(target='bar', source='bar.yy')
137 <varlistentry id="b-DocbookEpub">
138 <term><function>DocbookEpub</function>()</term>
139 <term><replaceable>env</replaceable>.<methodname>DocbookEpub</methodname>()</term>
141 A pseudo-Builder, providing a Docbook toolchain for EPUB output.
144 <example_commands>env = Environment(tools=['docbook'])
145 env.DocbookEpub('manual.epub', 'manual.xml')
152 <example_commands>env = Environment(tools=['docbook'])
153 env.DocbookEpub('manual')
158 <varlistentry id="b-DocbookHtml">
159 <term><function>DocbookHtml</function>()</term>
160 <term><replaceable>env</replaceable>.<methodname>DocbookHtml</methodname>()</term>
162 A pseudo-Builder, providing a Docbook toolchain for HTML output.
164 <example_commands>env = Environment(tools=['docbook'])
165 env.DocbookHtml('manual.html', 'manual.xml')
170 <example_commands>env = Environment(tools=['docbook'])
171 env.DocbookHtml('manual')
175 <varlistentry id="b-DocbookHtmlChunked">
176 <term><function>DocbookHtmlChunked</function>()</term>
177 <term><replaceable>env</replaceable>.<methodname>DocbookHtmlChunked</methodname>()</term>
179 A pseudo-Builder providing a Docbook toolchain for chunked HTML output.
180 It supports the <parameter>base.dir</parameter> parameter. The
181 <filename>chunkfast.xsl</filename> file (requires "EXSLT") is used as the
182 default stylesheet. Basic syntax:
185 <example_commands>env = Environment(tools=['docbook'])
186 env.DocbookHtmlChunked('manual')
189 where <filename>manual.xml</filename> is the input file.
191 <para>If you use the <parameter>root.filename</parameter>
192 parameter in your own stylesheets you have to specify the new target name.
193 This ensures that the dependencies get correct, especially for the cleanup via <quote><literal>scons -c</literal></quote>:
195 <screen>env = Environment(tools=['docbook'])
196 env.DocbookHtmlChunked('mymanual.html', 'manual', xsl='htmlchunk.xsl')
198 <para>Some basic support for the <parameter>base.dir</parameter> parameter
199 is provided. You can add the <parameter>base_dir</parameter> keyword to
200 your Builder call, and the given prefix gets prepended to all the
203 <screen>env = Environment(tools=['docbook'])
204 env.DocbookHtmlChunked('manual', xsl='htmlchunk.xsl', base_dir='output/')
206 <para>Make sure that you don't forget the trailing slash for the base folder, else
207 your files get renamed only!
211 <varlistentry id="b-DocbookHtmlhelp">
212 <term><function>DocbookHtmlhelp</function>()</term>
213 <term><replaceable>env</replaceable>.<methodname>DocbookHtmlhelp</methodname>()</term>
215 A pseudo-Builder, providing a Docbook toolchain for HTMLHELP output.
219 <example_commands>env = Environment(tools=['docbook'])
220 env.DocbookHtmlhelp('manual')
223 where <filename>manual.xml</filename> is the input file.
226 <para>If you use the <parameter>root.filename</parameter>
227 parameter in your own stylesheets you have to specify the new target name.
228 This ensures that the dependencies get correct, especially for the cleanup via <quote><userinput>scons -c</userinput></quote>:
230 <screen>env = Environment(tools=['docbook'])
231 env.DocbookHtmlhelp('mymanual.html', 'manual', xsl='htmlhelp.xsl')
233 <para>Some basic support for the <parameter>base.dir</parameter> parameter
234 is provided. You can add the <parameter>base_dir</parameter> keyword to
235 your Builder call, and the given prefix gets prepended to all the
238 <screen>env = Environment(tools=['docbook'])
239 env.DocbookHtmlhelp('manual', xsl='htmlhelp.xsl', base_dir='output/')
241 <para>Make sure that you don't forget the trailing slash for the base folder, else
242 your files get renamed only!
247 <varlistentry id="b-DocbookMan">
248 <term><function>DocbookMan</function>()</term>
249 <term><replaceable>env</replaceable>.<methodname>DocbookMan</methodname>()</term>
251 A pseudo-Builder, providing a Docbook toolchain for Man page output.
255 <example_commands>env = Environment(tools=['docbook'])
256 env.DocbookMan('manual')
259 where <filename>manual.xml</filename> is the input file. Note, that
260 you can specify a target name, but the actual output names are automatically
261 set from the <literal>refname</literal> entries in your XML source.
265 <varlistentry id="b-DocbookPdf">
266 <term><function>DocbookPdf</function>()</term>
267 <term><replaceable>env</replaceable>.<methodname>DocbookPdf</methodname>()</term>
269 A pseudo-Builder, providing a Docbook toolchain for PDF output.
272 <example_commands>env = Environment(tools=['docbook'])
273 env.DocbookPdf('manual.pdf', 'manual.xml')
280 <example_commands>env = Environment(tools=['docbook'])
281 env.DocbookPdf('manual')
286 <varlistentry id="b-DocbookSlidesHtml">
287 <term><function>DocbookSlidesHtml</function>()</term>
288 <term><replaceable>env</replaceable>.<methodname>DocbookSlidesHtml</methodname>()</term>
290 A pseudo-Builder, providing a Docbook toolchain for HTML slides output.
293 <example_commands>env = Environment(tools=['docbook'])
294 env.DocbookSlidesHtml('manual')
297 <para>If you use the <parameter>titlefoil.html</parameter> parameter in
298 your own stylesheets you have to give the new target name. This ensures
299 that the dependencies get correct, especially for the cleanup via
300 <quote><userinput>scons -c</userinput></quote>:
302 <screen>env = Environment(tools=['docbook'])
303 env.DocbookSlidesHtml('mymanual.html','manual', xsl='slideshtml.xsl')
306 <para>Some basic support for the <parameter>base.dir</parameter> parameter
308 can add the <parameter>base_dir</parameter> keyword to your Builder
309 call, and the given prefix gets prepended to all the created filenames:
311 <screen>env = Environment(tools=['docbook'])
312 env.DocbookSlidesHtml('manual', xsl='slideshtml.xsl', base_dir='output/')
314 <para>Make sure that you don't forget the trailing slash for the base folder, else
315 your files get renamed only!
320 <varlistentry id="b-DocbookSlidesPdf">
321 <term><function>DocbookSlidesPdf</function>()</term>
322 <term><replaceable>env</replaceable>.<methodname>DocbookSlidesPdf</methodname>()</term>
324 A pseudo-Builder, providing a Docbook toolchain for PDF slides output.
327 <example_commands>env = Environment(tools=['docbook'])
328 env.DocbookSlidesPdf('manual.pdf', 'manual.xml')
335 <example_commands>env = Environment(tools=['docbook'])
336 env.DocbookSlidesPdf('manual')
340 <varlistentry id="b-DocbookXInclude">
341 <term><function>DocbookXInclude</function>()</term>
342 <term><replaceable>env</replaceable>.<methodname>DocbookXInclude</methodname>()</term>
344 A pseudo-Builder, for resolving XIncludes in a separate processing step.
347 <example_commands>env = Environment(tools=['docbook'])
348 env.DocbookXInclude('manual_xincluded.xml', 'manual.xml')
352 <varlistentry id="b-DocbookXslt">
353 <term><function>DocbookXslt</function>()</term>
354 <term><replaceable>env</replaceable>.<methodname>DocbookXslt</methodname>()</term>
356 A pseudo-Builder, applying a given XSL transformation to the input file.
359 <example_commands>env = Environment(tools=['docbook'])
360 env.DocbookXslt('manual_transformed.xml', 'manual.xml', xsl='transform.xslt')
363 <para>Note, that this builder requires the <parameter>xsl</parameter> parameter
368 <varlistentry id="b-DVI">
369 <term><function>DVI</function>()</term>
370 <term><replaceable>env</replaceable>.<methodname>DVI</methodname>()</term>
372 Builds a <filename>.dvi</filename> file
373 from a <filename>.tex</filename>,
374 <filename>.ltx</filename> or <filename>.latex</filename> input file.
375 If the source file suffix is <filename>.tex</filename>,
377 will examine the contents of the file;
379 <literal>\documentclass</literal>
381 <literal>\documentstyle</literal>
382 is found, the file is assumed to be a LaTeX file and
383 the target is built by invoking the &cv-link-LATEXCOM; command line;
384 otherwise, the &cv-link-TEXCOM; command line is used.
385 If the file is a LaTeX file,
388 builder method will also examine the contents
390 <filename>.aux</filename>
391 file and invoke the &cv-link-BIBTEX; command line
393 <literal>bibdata</literal>
395 start &cv-link-MAKEINDEX; to generate an index if a
396 <filename>.ind</filename>
398 and will examine the contents
399 <filename>.log</filename>
400 file and re-run the &cv-link-LATEXCOM; command
401 if the log file says it is necessary.
405 The suffix <filename>.dvi</filename>
406 (hard-coded within TeX itself)
407 is automatically added to the target
408 if it is not already present.
413 # builds from aaa.tex
414 env.DVI(target = 'aaa.dvi', source = 'aaa.tex')
416 env.DVI(target = 'bbb', source = 'bbb.ltx')
417 # builds from ccc.latex
418 env.DVI(target = 'ccc.dvi', source = 'ccc.latex')
422 <varlistentry id="b-Gs">
423 <term><function>Gs</function>()</term>
424 <term><replaceable>env</replaceable>.<methodname>Gs</methodname>()</term>
426 A Builder for explicitly calling the <application>gs</application> executable.
427 Depending on the underlying OS, the different names <application>gs</application>,
428 <application>gsos2</application> and <application>gswin32c</application>
432 env = Environment(tools=['gs'])
436 GSFLAGS='-dNOPAUSE -dBATCH -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -q',
441 <varlistentry id="b-Install">
442 <term><function>Install</function>()</term>
443 <term><replaceable>env</replaceable>.<methodname>Install</methodname>()</term>
445 Installs one or more source files or directories
446 in the specified target,
447 which must be a directory.
448 The names of the specified source files or directories
449 remain the same within the destination directory. The
450 sources may be given as a string or as a node returned by
455 env.Install(target='/usr/local/bin', source=['foo', 'bar'])
459 Note that if target paths chosen for the
460 &Install; builder (and the related &InstallAs; and
461 &InstallVersionedLib; builders) are outside the
462 project tree, such as in the example above,
463 they may not be selected for "building" by default,
464 since in the absence of other instructions
465 &scons; builds targets that are underneath the top directory
466 (the directory that contains the &SConstruct; file,
467 usually the current directory).
468 Use command line targets or the &Default; function
473 If the <option>--install-sandbox</option> command line
474 option is given, the target directory will be prefixed
475 by the directory path specified.
476 This is useful to test installs without installing to
477 a "live" location in the system.
481 See also &FindInstalledFiles;.
482 For more thoughts on installation, see the User Guide
483 (particularly the section on Command-Line Targets
484 and the chapters on Installing Files and on Alias Targets).
489 <varlistentry id="b-InstallAs">
490 <term><function>InstallAs</function>()</term>
491 <term><replaceable>env</replaceable>.<methodname>InstallAs</methodname>()</term>
493 Installs one or more source files or directories
495 allowing changing a file or directory name
496 as part of the installation.
497 It is an error if the
501 arguments list different numbers of files or directories.
505 env.InstallAs(target='/usr/local/bin/foo',
507 env.InstallAs(target=['../lib/libfoo.a', '../lib/libbar.a'],
508 source=['libFOO.a', 'libBAR.a'])
512 See the note under &Install;.
517 <varlistentry id="b-InstallVersionedLib">
518 <term><function>InstallVersionedLib</function>()</term>
519 <term><replaceable>env</replaceable>.<methodname>InstallVersionedLib</methodname>()</term>
521 Installs a versioned shared library. The symlinks appropriate to the
522 architecture will be generated based on symlinks of the source library.
526 env.InstallVersionedLib(target='/usr/local/bin/foo',
527 source='libxyz.1.5.2.so')
531 See the note under &Install;.
536 <varlistentry id="b-Jar">
537 <term><function>Jar</function>()</term>
538 <term><replaceable>env</replaceable>.<methodname>Jar</methodname>()</term>
540 Builds a Java archive (<filename>.jar</filename>) file
541 from the specified list of sources.
542 Any directories in the source list
543 will be searched for <filename>.class</filename> files).
544 Any <filename>.java</filename> files in the source list
545 will be compiled to <filename>.class</filename> files
546 by calling the &b-link-Java; Builder.
550 If the &cv-link-JARCHDIR; value is set, the
552 command will change to the specified directory using the
555 If &cv-JARCHDIR; is not set explicitly,
556 &SCons; will use the top of any subdirectory tree
557 in which Java <filename>.class</filename>
558 were built by the &b-link-Java; Builder.
562 If the contents any of the source files begin with the string
563 <literal>Manifest-Version</literal>,
564 the file is assumed to be a manifest
573 env.Jar(target = 'foo.jar', source = 'classes')
575 env.Jar(target = 'bar.jar',
576 source = ['bar1.java', 'bar2.java'])
580 <varlistentry id="b-Java">
581 <term><function>Java</function>()</term>
582 <term><replaceable>env</replaceable>.<methodname>Java</methodname>()</term>
584 Builds one or more Java class files.
585 The sources may be any combination of explicit
586 <filename>.java</filename>
588 or directory trees which will be scanned
589 for <filename>.java</filename> files.
593 SCons will parse each source <filename>.java</filename> file
595 (including inner classes)
596 defined within that file,
597 and from that figure out the
598 target <filename>.class</filename> files that will be created.
599 The class files will be placed underneath
600 the specified target directory.
604 SCons will also search each Java file
605 for the Java package name,
606 which it assumes can be found on a line
607 beginning with the string
608 <literal>package</literal>
610 the resulting <filename>.class</filename> files
611 will be placed in a directory reflecting
612 the specified package name.
615 <filename>Foo.java</filename>
616 defining a single public
617 <classname>Foo</classname>
619 containing a package name of
620 <classname>sub.dir</classname>
621 will generate a corresponding
622 <filename>sub/dir/Foo.class</filename>
631 env.Java(target='classes', source='src')
632 env.Java(target='classes', source=['src1', 'src2'])
633 env.Java(target='classes', source=['File1.java', 'File2.java'])
637 Java source files can use the native encoding for the underlying OS.
638 Since SCons compiles in simple ASCII mode by default,
639 the compiler will generate warnings about unmappable characters,
640 which may lead to errors as the file is processed further.
641 In this case, the user must specify the
642 <literal>LANG</literal>
643 environment variable to tell the compiler what encoding is used.
644 For portibility, it's best if the encoding is hard-coded
645 so that the compile will work if it is done on a system
646 with a different encoding.
651 env['ENV']['LANG'] = 'en_GB.UTF-8'
655 <varlistentry id="b-JavaH">
656 <term><function>JavaH</function>()</term>
657 <term><replaceable>env</replaceable>.<methodname>JavaH</methodname>()</term>
659 Builds C header and source files for
660 implementing Java native methods.
661 The target can be either a directory
662 in which the header files will be written,
663 or a header file name which
664 will contain all of the definitions.
665 The source can be the names of <filename>.class</filename> files,
666 the names of <filename>.java</filename> files
667 to be compiled into <filename>.class</filename> files
668 by calling the &b-link-Java; builder method,
669 or the objects returned from the
675 If the construction variable
676 &cv-link-JAVACLASSDIR;
677 is set, either in the environment
678 or in the call to the
680 builder method itself,
681 then the value of the variable
682 will be stripped from the
683 beginning of any <filename>.class</filename> file names.
691 # builds java_native.h
692 classes = env.Java(target="classdir", source="src")
693 env.JavaH(target="java_native.h", source=classes)
695 # builds include/package_foo.h and include/package_bar.h
696 env.JavaH(target="include", source=["package/foo.class", "package/bar.class"])
698 # builds export/foo.h and export/bar.h
701 source=["classes/foo.class", "classes/bar.class"],
702 JAVACLASSDIR="classes",
708 Java versions starting with 10.0 no longer use the
709 <command>javah</command> command for generating JNI
710 headers/sources, and indeed have removed the command entirely
711 (see Java Enhancement Proposal
712 <ulink url="https:openjdk.java.net/jeps/313">JEP 313</ulink>),
713 making this tool harder to use for that purpose.
714 &SCons; may autodiscover a <command>javah</command>
715 belonging to an older release if there are multiple Java
716 versions on the system, which will lead to incorrect results.
717 To use with a newer Java, override the default values of &cv-link-JAVAH;
718 (to contain the path to the <command>javac</command>)
719 and &cv-link-JAVAHFLAGS; (to contain at least a <option>-h</option>
720 flag) and note that generating headers with
721 <command>javac</command> requires supplying source
722 <filename>.java</filename> files only,
723 not <filename>.class</filename> files.
728 <varlistentry id="b-Library">
729 <term><function>Library</function>()</term>
730 <term><replaceable>env</replaceable>.<methodname>Library</methodname>()</term>
738 <varlistentry id="b-LoadableModule">
739 <term><function>LoadableModule</function>()</term>
740 <term><replaceable>env</replaceable>.<methodname>LoadableModule</methodname>()</term>
745 On Mac OS X (Darwin) platforms,
746 this creates a loadable module bundle.
750 <varlistentry id="b-M4">
751 <term><function>M4</function>()</term>
752 <term><replaceable>env</replaceable>.<methodname>M4</methodname>()</term>
754 Builds an output file from an M4 input file.
755 This uses a default &cv-link-M4FLAGS; value of
757 which considers all warnings to be fatal
758 and stops on the first warning
759 when using the GNU version of m4.
764 env.M4(target = 'foo.c', source = 'foo.c.m4')
768 <varlistentry id="b-Moc">
769 <term><function>Moc</function>()</term>
770 <term><replaceable>env</replaceable>.<methodname>Moc</methodname>()</term>
772 Builds an output file from a <command>moc</command> input file.
773 <command>moc</command> input files are either header files or C++ files.
774 This builder is only available after using the
775 tool &t-link-qt3;. See the &cv-link-QT3DIR; variable for more information.
780 env.Moc('foo.h') # generates moc_foo.cc
781 env.Moc('foo.cpp') # generates foo.moc
785 <varlistentry id="b-MOFiles">
786 <term><function>MOFiles</function>()</term>
787 <term><replaceable>env</replaceable>.<methodname>MOFiles</methodname>()</term>
789 This builder belongs to &t-link-msgfmt; tool. The builder compiles
790 <literal>PO</literal> files to <literal>MO</literal> files.
794 <emphasis>Example 1</emphasis>.
795 Create <filename>pl.mo</filename> and <filename>en.mo</filename> by compiling
796 <filename>pl.po</filename> and <filename>en.po</filename>:
800 env.MOFiles(['pl', 'en'])
804 <emphasis>Example 2</emphasis>.
805 Compile files for languages defined in <filename>LINGUAS</filename> file:
809 env.MOFiles(LINGUAS_FILE = 1)
813 <emphasis>Example 3</emphasis>.
814 Create <filename>pl.mo</filename> and <filename>en.mo</filename> by compiling
815 <filename>pl.po</filename> and <filename>en.po</filename> plus files for
816 languages defined in <filename>LINGUAS</filename> file:
820 env.MOFiles(['pl', 'en'], LINGUAS_FILE = 1)
824 <emphasis>Example 4</emphasis>.
825 Compile files for languages defined in <filename>LINGUAS</filename> file
830 env['LINGUAS_FILE'] = 1
835 <varlistentry id="b-MSVSProject">
836 <term><function>MSVSProject</function>()</term>
837 <term><replaceable>env</replaceable>.<methodname>MSVSProject</methodname>()</term>
839 Build a Microsoft Visual C++ project file and solution file.
842 Builds a C++ project file based on the
843 version of Visual Studio (or to be more precise, of MSBuild)
844 that is configured: either the latest installed version,
845 or the version specified by
846 &cv-link-MSVC_VERSION; in the current &consenv;.
847 For Visual Studio 6.0 a <filename>.dsp</filename> file is generated.
848 For Visual Studio versions 2002-2008,
849 a <filename>.vcproj</filename> file is generated.
850 For Visual Studio 2010 and later a <filename>.vcxproj</filename>
852 Note there are multiple versioning schemes involved in
853 the Microsoft compilation environment -
854 see the description of &cv-link-MSVC_VERSION; for equivalences.
855 &SCons; does not know how to construct project files for
856 other languages (such as <filename>.csproj</filename> for C#,
857 <filename>.vbproj</filename> for Visual Basic or
858 <filename>.pyproject</filename> for Python)).
861 For the <filename>.vcxproj</filename> file, the underlying
862 format is the MSBuild XML Schema, and the details conform to:
863 <ulink url="https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure">
864 https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure</ulink>.
865 The generated solution file enables Visual Studio to
866 understand the project structure, and allows building it
867 using MSBuild to call back to &SCons;.
868 The project file encodes a toolset version that has been
869 selected by &SCons; as described above. Since recent Visual
870 Studio versions support multiple concurrent toolsets,
871 use &cv-link-MSVC_VERSION; to select the desired one if
872 it does not match the &SCons; default.
873 The project file also includes entries which describe
874 how to call &SCons; to build the project from within Visual Studio
875 (or from an MSBuild command line).
876 In some situations &SCons; may generate this incorrectly -
877 notably when using the <emphasis>scons-local</emphasis>
878 distribution, which is not installed in a way that that
879 matches the default invocation line.
880 If so, the &cv-link-SCONS_HOME; &consvar; can be used to describe
881 the right way to locate the &SCons; code so that it can be imported.
884 By default, a matching solution file for the project is also generated.
885 This behavior may be disabled by
886 specifying <parameter>auto_build_solution=0</parameter>
887 to the &b-MSVSProject; builder.
888 The solution file can also be independently
889 generated by calling the &b-MSVSSolution; builder,
890 such as in the case where a solution should describe
892 See the &b-link-MSVSSolution; description for further information.
895 The &b-MSVSProject; builder accepts several keyword arguments
896 describing lists of filenames to be placed into the project file.
898 <parameter>srcs</parameter>,
899 <parameter>incs</parameter>,
900 <parameter>localincs</parameter>,
901 <parameter>resources</parameter>,
902 and <parameter>misc</parameter>
904 The names are intended to be self-explanatory, but note that the
905 filenames need to be specified as strings, <emphasis>not</emphasis>
906 as &SCons; File Nodes
907 (for example if you generate files for inclusion by using the
908 &f-link-Glob; function, the results should be converted to
909 a list of strings before passing them to &b-MSVSProject;).
910 This is because Visual Studio and MSBuild know nothing about &SCons;
912 Each of the filename lists are individually optional, but at
913 least one list must be specified for the resulting project file to
917 In addition to the above lists of values, the following values
918 may be specified as keyword arguments:
922 <term><parameter>target</parameter></term>
925 The name of the target <filename>.dsp</filename>
926 or <filename>.vcproj</filename> file.
927 The correct suffix for the version of Visual Studio
928 must be used, but the &cv-link-MSVSPROJECTSUFFIX;
929 &consvar; will be defined to the correct
930 value (see example below).
935 <term><parameter>variant</parameter></term>
938 The name of this particular variant. Except for Visual Studio 6
939 projects, this can also be a list of variant names. These
940 are typically things like "Debug" or "Release", but
941 really can be anything you want. For Visual Studio
942 7 projects, they may also specify a target platform
943 separated from the variant name by a <literal>|</literal>
944 (vertical pipe) character: <literal>Debug|Xbox</literal>.
945 The default target platform is Win32. Multiple calls
946 to &b-MSVSProject; with different variants are allowed;
947 all variants will be added to the project file with
948 their appropriate build targets and sources.
953 <term><parameter>cmdargs</parameter></term>
956 Additional command line arguments
957 for the different variants. The number of
958 <parameter>cmdargs</parameter> entries must match the number
959 of <parameter>variant</parameter> entries, or be empty (not
960 specified). If you give only one, it will automatically
961 be propagated to all variants.
966 <term><parameter>cppdefines</parameter></term>
969 Preprocessor definitions for the different variants.
970 The number of <parameter>cppdefines</parameter> entries
971 must match the number of <parameter>variant</parameter>
972 entries, or be empty (not specified). If you give
973 only one, it will automatically be propagated to all
974 variants. If you don't give this parameter, &SCons;
975 will use the invoking environment's
976 &cv-link-CPPDEFINES; entry for all variants.
981 <term><parameter>cppflags</parameter></term>
984 Compiler flags for the different variants.
985 If a <option>/std:c++</option> flag is found then
986 <option>/Zc:__cplusplus</option> is appended to the
987 flags if not already found, this ensures that Intellisense
988 uses the <option>/std:c++</option> switch.
989 The number of <parameter>cppflags</parameter> entries
990 must match the number of <parameter>variant</parameter>
991 entries, or be empty (not specified). If you give
992 only one, it will automatically be propagated to all
993 variants. If you don't give this parameter, SCons
994 will combine the invoking environment's
995 &cv-link-CCFLAGS;, &cv-link-CXXFLAGS;,
996 &cv-link-CPPFLAGS; entries for all variants.
1001 <term><parameter>cpppaths</parameter></term>
1004 Compiler include paths for the different variants.
1005 The number of <parameter>cpppaths</parameter> entries
1006 must match the number of <parameter>variant</parameter>
1007 entries, or be empty (not specified). If you give
1008 only one, it will automatically be propagated to all
1009 variants. If you don't give this parameter, SCons
1010 will use the invoking environment's
1011 &cv-link-CPPPATH; entry for all variants.
1016 <term><parameter>buildtarget</parameter></term>
1019 An optional string, node, or list of strings
1020 or nodes (one per build variant), to tell
1021 the Visual Studio debugger what output target
1022 to use in what build variant. The number of
1023 <parameter>buildtarget</parameter> entries must match the
1024 number of <parameter>variant</parameter> entries.
1029 <term><parameter>runfile</parameter></term>
1032 The name of the file that Visual Studio 7 and
1033 later will run and debug. This appears as the
1034 value of the <parameter>Output</parameter> field in the
1035 resulting Visual C++ project file. If this is not
1036 specified, the default is the same as the specified
1037 <parameter>buildtarget</parameter> value.
1044 &SCons; and Microsoft Visual Studio understand projects in
1045 different ways, and the mapping is sometimes imperfect:
1048 Because &SCons; always executes its build commands
1049 from the directory in which the &SConstruct; file is located,
1050 if you generate a project file in a different directory
1051 than the directory of the &SConstruct; file, users will not be able to
1052 double-click on the file name in compilation error messages
1053 displayed in the Visual Studio console output window. This can
1054 be remedied by adding the Visual C/C++ <option>/FC</option>
1055 compiler option to the &cv-link-CCFLAGS; variable so that
1056 the compiler will print the full path name of any files that
1057 cause compilation errors.
1060 If the project file is only used to teach the Visual Studio
1061 project browser about the file layout there should be no issues,
1062 However, Visual Studio should not be used to make changes
1063 to the project structure, build options, etc. as these will
1064 (a) not feed back to the &SCons; description of the project
1065 and (b) be lost if &SCons; regenerates the project file.
1066 The SConscript files should remain the definitive description
1070 If the project file is used to drive MSBuild (such as selecting
1071 "build" from the Visual Studio interface) you lose the direct
1072 control of target selection and command-line options you would
1073 have if launching the build directly from &SCons;,
1074 because these will be hardcoded in the project file to the
1075 values specified in the &b-MSVSProject; call.
1076 You can regain some of this control by defining multiple variants,
1077 using multiple &b-MSVSProject; calls to arrange different build
1078 targets, arguments, defines, flags and paths for different variants.
1081 If the build is divided into a solution with multiple MSBuild
1082 projects the mapping is further strained. In this case,
1083 it is important not to set Visual Studio to do parallel builds,
1084 as it will then launch the separate project builds in parallel,
1085 and &SCons; does not work well if called that way.
1086 Instead you can set up the &SCons; build for parallel building -
1087 see the &f-link-SetOption; function for how to do this with
1088 <parameter>num_jobs</parameter>.
1092 <para>Example usage:</para>
1094 barsrcs = ['bar.cpp']
1096 barlocalincs = ['StdAfx.h']
1097 barresources = ['bar.rc', 'resource.h']
1098 barmisc = ['bar_readme.txt']
1100 dll = env.SharedLibrary(target='bar.dll', source=barsrcs)
1101 buildtarget = [s for s in dll if str(s).endswith('dll')]
1103 target='Bar' + env['MSVSPROJECTSUFFIX'],
1106 localincs=barlocalincs,
1107 resources=barresources,
1109 buildtarget=buildtarget,
1116 <term><parameter>DebugSettings</parameter></term>
1119 A dictionary of debug settings that get written
1120 to the <filename>.vcproj.user</filename> or the
1121 <filename>.vcxproj.user</filename> file, depending on the
1122 version installed. As for <parameter>cmdargs</parameter>,
1123 you can specify a <parameter>DebugSettings</parameter>
1124 dictionary per variant. If you give only one, it will
1125 be propagated to all variants.
1128 <emphasis>Changed in version 2.4:</emphasis>
1129 Added the optional <parameter>DebugSettings</parameter> parameter.
1135 Currently, only Visual Studio v9.0 and Visual Studio
1136 version v11 are implemented, for other versions no file
1137 is generated. To generate the user file, you just need to
1138 add a <parameter>DebugSettings</parameter> dictionary to the
1139 environment with the right parameters for your MSVS version. If
1140 the dictionary is empty, or does not contain any good value,
1141 no file will be generated.
1144 Following is a more contrived example, involving the setup
1145 of a project for variants and DebugSettings:
1148 # Assuming you store your defaults in a file
1149 vars = Variables('variables.py')
1150 msvcver = vars.args.get('vc', '9')
1152 # Check command args to force one Microsoft Visual Studio version
1153 if msvcver == '9' or msvcver == '11':
1154 env = Environment(MSVC_VERSION=msvcver + '.0', MSVC_BATCH=False)
1160 action='store_true',
1163 help="Create Visual C++ project file",
1167 # 1. Configure your Debug Setting dictionary with options you want in the list
1168 # of allowed options, for instance if you want to create a user file to launch
1169 # a specific application for testing your dll with Microsoft Visual Studio 2008 (v9):
1172 'Command': 'c:\\myapp\\using\\thisdll.exe',
1173 'WorkingDirectory': 'c:\\myapp\\using\\',
1174 'CommandArguments': '-p password',
1176 # 'DebuggerType':'3',
1178 # 'RemoteMachine': None,
1179 # 'RemoteCommand': None,
1182 # 'SQLDebugging': None,
1183 # 'Environment': '',
1184 # 'EnvironmentMerge':'true',
1185 # 'DebuggerFlavor': None,
1186 # 'MPIRunCommand': None,
1187 # 'MPIRunArguments': None,
1188 # 'MPIRunWorkingDirectory': None,
1189 # 'ApplicationCommand': None,
1190 # 'ApplicationArguments': None,
1191 # 'ShimCommand': None,
1192 # 'MPIAcceptMode': None,
1193 # 'MPIAcceptFilter': None,
1197 # 2. Because there are a lot of different options depending on the Microsoft
1198 # Visual Studio version, if you use more than one version you have to
1199 # define a dictionary per version, for instance if you want to create a user
1200 # file to launch a specific application for testing your dll with Microsoft
1201 # Visual Studio 2012 (v11):
1203 V10DebugSettings = {
1204 'LocalDebuggerCommand': 'c:\\myapp\\using\\thisdll.exe',
1205 'LocalDebuggerWorkingDirectory': 'c:\\myapp\\using\\',
1206 'LocalDebuggerCommandArguments': '-p password',
1207 # 'LocalDebuggerEnvironment': None,
1208 # 'DebuggerFlavor': 'WindowsLocalDebugger',
1209 # 'LocalDebuggerAttach': None,
1210 # 'LocalDebuggerDebuggerType': None,
1211 # 'LocalDebuggerMergeEnvironment': None,
1212 # 'LocalDebuggerSQLDebugging': None,
1213 # 'RemoteDebuggerCommand': None,
1214 # 'RemoteDebuggerCommandArguments': None,
1215 # 'RemoteDebuggerWorkingDirectory': None,
1216 # 'RemoteDebuggerServerName': None,
1217 # 'RemoteDebuggerConnection': None,
1218 # 'RemoteDebuggerDebuggerType': None,
1219 # 'RemoteDebuggerAttach': None,
1220 # 'RemoteDebuggerSQLDebugging': None,
1221 # 'DeploymentDirectory': None,
1222 # 'AdditionalFiles': None,
1223 # 'RemoteDebuggerDeployDebugCppRuntime': None,
1224 # 'WebBrowserDebuggerHttpUrl': None,
1225 # 'WebBrowserDebuggerDebuggerType': None,
1226 # 'WebServiceDebuggerHttpUrl': None,
1227 # 'WebServiceDebuggerDebuggerType': None,
1228 # 'WebServiceDebuggerSQLDebugging': None,
1232 # 3. Select the dictionary you want depending on the version of visual Studio
1233 # Files you want to generate.
1235 if not env.GetOption('userfile'):
1237 elif env.get('MSVC_VERSION', None) == '9.0':
1238 dbgSettings = V9DebugSettings
1239 elif env.get('MSVC_VERSION', None) == '11.0':
1240 dbgSettings = V10DebugSettings
1245 # 4. Add the dictionary to the DebugSettings keyword.
1247 barsrcs = ['bar.cpp', 'dllmain.cpp', 'stdafx.cpp']
1248 barincs = ['targetver.h']
1249 barlocalincs = ['StdAfx.h']
1250 barresources = ['bar.rc', 'resource.h']
1251 barmisc = ['ReadMe.txt']
1253 dll = env.SharedLibrary(target='bar.dll', source=barsrcs)
1256 target='Bar' + env['MSVSPROJECTSUFFIX'],
1259 localincs=barlocalincs,
1260 resources=barresources,
1262 buildtarget=[dll[0]] * 2,
1263 variant=('Debug|Win32', 'Release|Win32'),
1264 cmdargs=f'vc={msvcver}',
1265 DebugSettings=(dbgSettings, {}),
1270 <varlistentry id="b-MSVSSolution">
1271 <term><function>MSVSSolution</function>()</term>
1272 <term><replaceable>env</replaceable>.<methodname>MSVSSolution</methodname>()</term>
1273 <listitem><para>Build a Microsoft Visual Studio Solution file.</para>
1275 Builds a Visual Studio solution file based on the
1276 version of Visual Studio that is configured: either the
1277 latest installed version, or the version specified by
1278 &cv-link-MSVC_VERSION; in the &consenv;. For
1279 Visual Studio 6, a <filename>.dsw</filename> file is generated.
1280 For Visual Studio .NET 2002 and later,
1281 it will generate a <filename>.sln</filename> file.
1282 Note there are multiple versioning schemes involved in
1283 the Microsoft compilation environment -
1284 see the description of &cv-link-MSVC_VERSION; for equivalences.
1287 The solution file is a container for one or more projects,
1288 and follows the format described at
1289 <ulink url="https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file">
1290 https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file</ulink>.
1292 <para>The following values must be specified:</para>
1295 <term><parameter>target</parameter></term>
1298 The name of the target <filename>.dsw</filename> or
1299 <filename>.sln</filename> file. The correct
1300 suffix for the version of Visual Studio must be used,
1301 but the value &cv-link-MSVSSOLUTIONSUFFIX; will be
1302 defined to the correct value (see example below).
1307 <term><parameter>variant</parameter></term>
1310 The name of this particular variant, or a list of
1311 variant names (the latter is only supported for MSVS
1312 7 solutions). These are typically things like "Debug"
1313 or "Release", but really can be anything you want. For
1314 MSVS 7 they may also specify target platform, like this
1315 <literal>"Debug|Xbox"</literal>. Default platform is Win32.
1320 <term><parameter>projects</parameter></term>
1323 A list of project file names, or Project nodes returned
1324 by calls to the &b-link-MSVSProject; Builder, to be placed
1325 into the solution file.
1326 Note that these filenames need to be specified as strings,
1327 NOT as &SCons; File Nodes.
1328 This is because the solution file will be interpreted by MSBuild
1329 and by Visual Studio, which know nothing about &SCons; Node types.
1334 <para>Example Usage:</para>
1337 target="Bar" + env["MSVSSOLUTIONSUFFIX"],
1338 projects=["bar" + env["MSVSPROJECTSUFFIX"]],
1344 <varlistentry id="b-Ninja">
1345 <term><function>Ninja</function>()</term>
1346 <term><replaceable>env</replaceable>.<methodname>Ninja</methodname>()</term>
1348 A special builder which
1349 adds a target to create a Ninja build file.
1350 The builder does not require any source files to be specified.
1353 <para>This is an experimental feature. To enable it you must use one of the following methods
1356 <!-- NOTE DO NOT INDENT example_commands CONTENTS AS IT WILL ALTER THE FORMATTING-->
1358 # On the command line
1359 --experimental=ninja
1361 # Or in your SConstruct
1362 SetOption('experimental', 'ninja')
1365 <para>This functionality is subject to change and/or removal without deprecation cycle.</para>
1368 To use this tool you need to install the &Python; &ninja; package,
1369 as the tool by default depends on being able to do an
1370 <systemitem>import</systemitem> of the package
1371 <!-- (although see &cv-link-__NINJA_NO;).-->
1372 This can be done via:
1374 python -m pip install ninja
1381 If called with no arguments,
1382 the builder will default to a target name of
1383 <filename>ninja.build</filename>.
1386 If called with a single positional argument,
1387 &scons; will "deduce" the target name from that source
1388 argument, giving it the same name, and then
1390 This is the usual way to call the builder if a
1391 non-default target name is wanted.
1394 If called with either the
1395 <parameter>target=</parameter>
1396 or <parameter>source=</parameter> keyword arguments,
1397 the value of the argument is taken as the target name.
1398 If called with both, the
1399 <parameter>target=</parameter>
1400 value is used and <parameter>source=</parameter> is ignored.
1401 If called with multiple sources,
1402 the source list will be ignored,
1403 since there is no way to deduce what the intent was;
1404 in this case the default target name will be used.
1407 <emphasis>Available since &scons; 4.2.</emphasis>
1411 <varlistentry id="b-Object">
1412 <term><function>Object</function>()</term>
1413 <term><replaceable>env</replaceable>.<methodname>Object</methodname>()</term>
1421 <varlistentry id="b-Package">
1422 <term><function>Package</function>()</term>
1423 <term><replaceable>env</replaceable>.<methodname>Package</methodname>()</term>
1425 Builds software distribution packages.
1426 A <firstterm>package</firstterm> is a container format which
1427 includes files to install along with metadata.
1428 Packaging is optional, and must be enabled by specifying
1429 the &t-link-packaging; tool. For example:
1433 env = Environment(tools=['default', 'packaging'])
1437 &SCons; can build packages in a number of well known packaging formats.
1438 The target package type may be selected with the
1439 the &cv-link-PACKAGETYPE; construction variable
1440 or the <option>--package-type</option> command line option.
1441 The package type may be a list, in which case &SCons; will attempt
1442 to build packages for each type in the list. Example:
1446 env.Package(PACKAGETYPE=['src_zip', 'src_targz'], <replaceable>...other args...</replaceable>)
1450 The currently supported packagers are:
1453 <informaltable rowsep="1" colsep="1" frame="topbot">
1456 <row><entry><literal>msi</literal></entry><entry>Microsoft Installer package</entry></row>
1457 <row><entry><literal>rpm</literal></entry><entry>RPM Package Manger package</entry></row>
1458 <row><entry><literal>ipkg</literal></entry><entry>Itsy Package Management package</entry></row>
1459 <row><entry><literal>tarbz2</literal></entry><entry>bzip2-compressed tar file</entry></row>
1460 <row><entry><literal>targz</literal></entry><entry>gzip-compressed tar file</entry></row>
1461 <row><entry><literal>tarxz</literal></entry><entry>xz-compressed tar file</entry></row>
1462 <row><entry><literal>zip</literal></entry><entry>zip file</entry></row>
1463 <row><entry><literal>src_tarbz2</literal></entry><entry>bzip2-compressed tar file suitable as source to another packager</entry></row>
1464 <row><entry><literal>src_targz</literal></entry><entry>gzip-compressed tar file suitable as source to another packager</entry></row>
1465 <row><entry><literal>src_tarxz</literal></entry><entry>xz-compressed tar file suitable as source to another packager</entry></row>
1466 <row><entry><literal>src_zip</literal></entry><entry>zip file suitable as source to another packager</entry></row>
1472 The file list to include in the package may be specified with
1473 the &source; keyword argument. If omitted,
1474 the &f-link-FindInstalledFiles; function is called behind the scenes
1475 to select all files that have an &b-link-Install;, &b-link-InstallAs;
1476 or &b-link-InstallVersionedLib; Builder attached.
1477 If the ⌖ keyword argument is omitted, the target name(s)
1478 will be deduced from the package type(s).
1482 The metadata comes partly from attributes of the files to be packaged,
1483 and partly from packaging <firstterm>tags</firstterm>.
1484 Tags can be passed as keyword arguments
1485 to the &b-Package; builder call,
1486 and may also be attached to files
1487 (or more accurately, Nodes representing files)
1488 with the &f-link-Tag; function.
1489 Some package-level tags are mandatory, and will lead to errors if omitted.
1490 The mandatory tags vary depending on the package type.
1491 <!-- TODO: should document which tags are mandatory for which packager -->
1495 While packaging, the builder uses a temporary location named
1496 by the value of the &cv-link-PACKAGEROOT; variable -
1497 the package sources are copied there before packaging.
1505 env = Environment(tools=["default", "packaging"])
1506 env.Install("/bin/", "my_program")
1513 SUMMARY="balalalalal",
1514 DESCRIPTION="this should be really really long",
1515 X_RPM_GROUP="Application/fu",
1516 SOURCE_URL="https://foo.org/foo-1.2.3.tar.gz",
1521 In this example, the target <filename>/bin/my_program</filename>
1522 created by the &b-Install; call would not be built by default
1523 since it is not under the project top directory.
1524 However, since no <parameter>source</parameter>
1525 is specified to the &b-Package; builder,
1526 it is selected for packaging by the default sources rule.
1527 Since packaging is done using &cv-link-PACKAGEROOT;, no write is
1528 actually done to the system's <filename>/bin</filename> directory,
1529 and the target <emphasis>will</emphasis> be selected since
1530 after rebasing to underneath &cv-PACKAGEROOT; it is now under
1531 the top directory of the project.
1536 <varlistentry id="b-PCH">
1537 <term><function>PCH</function>()</term>
1538 <term><replaceable>env</replaceable>.<methodname>PCH</methodname>()</term>
1540 Builds a Microsoft Visual C++ precompiled header.
1541 Calling this builder
1542 returns a list of two target nodes: the PCH as the first element,
1543 and the object file as the second element.
1544 Normally the object file is ignored.
1545 The &b-PCH; builder is generally used in
1546 conjunction with the &cv-link-PCH; &consvar; to force object files to use
1547 the precompiled header:
1551 env['PCH'] = env.PCH('StdAfx.cpp')[0]
1556 This builder is specific to the PCH implementation
1557 in Microsoft Visual C++.
1558 Other compiler chains also implement precompiled header support,
1559 but &b-PCH; does not work with them at this time.
1560 As a result, the builder is only generated into the
1561 construction environment when
1562 Microsoft Visual C++ is being used as the compiler.
1565 The builder only works correctly in a C++ project.
1566 The Microsoft implementation distinguishes between
1567 precompiled headers from C and C++.
1568 Use of the builder will cause the PCH generation to happen with a flag
1569 that tells <application>cl.exe</application> all of the
1570 files are C++ files; if that PCH file is then supplied when
1571 compiling a C source file,
1572 <application>cl.exe</application> will fail the build with
1573 a compatibility violation.
1576 If possible, arrange the project so that a
1577 C++ source file passed to the &b-PCH; builder
1578 is not also included in the list of sources
1579 to be otherwise compiled in the project.
1580 &SCons; will correctly track that file in the dependency tree
1581 as a result of the &b-PCH; call,
1582 and (for MSVC 11.0 and greater) automatically add the
1583 corresponding object file to the link line.
1584 If the source list is automatically generated,
1585 for example using the &f-link-Glob; function,
1586 it may be necessary to remove that file from the list.
1591 <varlistentry id="b-PDF">
1592 <term><function>PDF</function>()</term>
1593 <term><replaceable>env</replaceable>.<methodname>PDF</methodname>()</term>
1595 Builds a <filename>.pdf</filename> file
1596 from a <filename>.dvi</filename> input file
1597 (or, by extension, a <filename>.tex</filename>,
1598 <filename>.ltx</filename>,
1600 <filename>.latex</filename> input file).
1601 The suffix specified by the &cv-link-PDFSUFFIX; construction variable
1602 (<filename>.pdf</filename> by default)
1603 is added automatically to the target
1604 if it is not already present. Example:
1608 # builds from aaa.tex
1609 env.PDF(target = 'aaa.pdf', source = 'aaa.tex')
1610 # builds bbb.pdf from bbb.dvi
1611 env.PDF(target = 'bbb', source = 'bbb.dvi')
1615 <varlistentry id="b-POInit">
1616 <term><function>POInit</function>()</term>
1617 <term><replaceable>env</replaceable>.<methodname>POInit</methodname>()</term>
1619 This builder belongs to &t-link-msginit; tool. The builder initializes missing
1620 <literal>PO</literal> file(s) if &cv-link-POAUTOINIT; is set. If
1621 &cv-link-POAUTOINIT; is not set (default), &b-POInit; prints instruction for
1622 user (that is supposed to be a translator), telling how the
1623 <literal>PO</literal> file should be initialized. In normal projects
1624 <emphasis>you should not use &b-POInit; and use &b-link-POUpdate;
1625 instead</emphasis>. &b-link-POUpdate; chooses intelligently between
1626 <command>msgmerge(1)</command> and <command>msginit(1)</command>. &b-POInit;
1627 always uses <command>msginit(1)</command> and should be regarded as builder for
1628 special purposes or for temporary use (e.g. for quick, one time initialization
1629 of a bunch of <literal>PO</literal> files) or for tests.
1633 Target nodes defined through &b-POInit; are not built by default (they're
1634 <literal>Ignore</literal>d from <literal>'.'</literal> node) but are added to
1635 special <literal>Alias</literal> (<literal>'po-create'</literal> by default).
1636 The alias name may be changed through the &cv-link-POCREATE_ALIAS;
1637 construction variable. All <literal>PO</literal> files defined through
1638 &b-POInit; may be easily initialized by <command>scons po-create</command>.
1642 <emphasis>Example 1</emphasis>.
1643 Initialize <filename>en.po</filename> and <filename>pl.po</filename> from
1644 <filename>messages.pot</filename>:
1648 env.POInit(['en', 'pl']) # messages.pot --> [en.po, pl.po]
1652 <emphasis>Example 2</emphasis>.
1653 Initialize <filename>en.po</filename> and <filename>pl.po</filename> from
1654 <filename>foo.pot</filename>:
1658 env.POInit(['en', 'pl'], ['foo']) # foo.pot --> [en.po, pl.po]
1662 <emphasis>Example 3</emphasis>.
1663 Initialize <filename>en.po</filename> and <filename>pl.po</filename> from
1664 <filename>foo.pot</filename> but using &cv-link-POTDOMAIN; construction
1669 env.POInit(['en', 'pl'], POTDOMAIN='foo') # foo.pot --> [en.po, pl.po]
1673 <emphasis>Example 4</emphasis>.
1674 Initialize <literal>PO</literal> files for languages defined in
1675 <filename>LINGUAS</filename> file. The files will be initialized from template
1676 <filename>messages.pot</filename>:
1680 env.POInit(LINGUAS_FILE = 1) # needs 'LINGUAS' file
1684 <emphasis>Example 5</emphasis>.
1685 Initialize <filename>en.po</filename> and <filename>pl.pl</filename>
1686 <literal>PO</literal> files plus files for languages defined in
1687 <filename>LINGUAS</filename> file. The files will be initialized from template
1688 <filename>messages.pot</filename>:
1692 env.POInit(['en', 'pl'], LINGUAS_FILE = 1)
1696 <emphasis>Example 6</emphasis>.
1697 You may preconfigure your environment first, and then initialize
1698 <literal>PO</literal> files:
1702 env['POAUTOINIT'] = 1
1703 env['LINGUAS_FILE'] = 1
1704 env['POTDOMAIN'] = 'foo'
1708 which has same efect as:
1712 env.POInit(POAUTOINIT = 1, LINGUAS_FILE = 1, POTDOMAIN = 'foo')
1716 <varlistentry id="b-PostScript">
1717 <term><function>PostScript</function>()</term>
1718 <term><replaceable>env</replaceable>.<methodname>PostScript</methodname>()</term>
1720 Builds a <filename>.ps</filename> file
1721 from a <filename>.dvi</filename> input file
1722 (or, by extension, a <filename>.tex</filename>,
1723 <filename>.ltx</filename>,
1725 <filename>.latex</filename> input file).
1726 The suffix specified by the &cv-link-PSSUFFIX; construction variable
1727 (<filename>.ps</filename> by default)
1728 is added automatically to the target
1729 if it is not already present. Example:
1733 # builds from aaa.tex
1734 env.PostScript(target = 'aaa.ps', source = 'aaa.tex')
1735 # builds bbb.ps from bbb.dvi
1736 env.PostScript(target = 'bbb', source = 'bbb.dvi')
1740 <varlistentry id="b-POTUpdate">
1741 <term><function>POTUpdate</function>()</term>
1742 <term><replaceable>env</replaceable>.<methodname>POTUpdate</methodname>()</term>
1744 The builder belongs to &t-link-xgettext; tool. The builder updates target
1745 <literal>POT</literal> file if exists or creates one if it doesn't. The node is
1746 not built by default (i.e. it is <literal>Ignore</literal>d from
1747 <literal>'.'</literal>), but only on demand (i.e. when given
1748 <literal>POT</literal> file is required or when special alias is invoked). This
1749 builder adds its targe node (<filename>messages.pot</filename>, say) to a
1750 special alias (<literal>pot-update</literal> by default, see
1751 &cv-link-POTUPDATE_ALIAS;) so you can update/create them easily with
1752 <command>scons pot-update</command>. The file is not written until there is no
1753 real change in internationalized messages (or in comments that enter
1754 <literal>POT</literal> file).
1758 <note> <para>You may see <command>xgettext(1)</command> being invoked by the
1759 &t-link-xgettext; tool even if there is no real change in internationalized
1760 messages (so the <literal>POT</literal> file is not being updated). This
1761 happens every time a source file has changed. In such case we invoke
1762 <command>xgettext(1)</command> and compare its output with the content of
1763 <literal>POT</literal> file to decide whether the file should be updated or
1768 <emphasis>Example 1.</emphasis>
1769 Let's create <filename>po/</filename> directory and place following
1770 <filename>SConstruct</filename> script there:
1773 # SConstruct in 'po/' subdir
1774 env = Environment( tools = ['default', 'xgettext'] )
1775 env.POTUpdate(['foo'], ['../a.cpp', '../b.cpp'])
1776 env.POTUpdate(['bar'], ['../c.cpp', '../d.cpp'])
1779 Then invoke scons few times:
1782 user@host:$ scons # Does not create foo.pot nor bar.pot
1783 user@host:$ scons foo.pot # Updates or creates foo.pot
1784 user@host:$ scons pot-update # Updates or creates foo.pot and bar.pot
1785 user@host:$ scons -c # Does not clean foo.pot nor bar.pot.
1788 the results shall be as the comments above say.
1792 <emphasis>Example 2.</emphasis>
1793 The &b-POTUpdate; builder may be used with no target specified, in which
1794 case default target <filename>messages.pot</filename> will be used. The
1795 default target may also be overridden by setting &cv-link-POTDOMAIN; construction
1796 variable or providing it as an override to &b-POTUpdate; builder:
1800 env = Environment( tools = ['default', 'xgettext'] )
1801 env['POTDOMAIN'] = "foo"
1802 env.POTUpdate(source = ["a.cpp", "b.cpp"]) # Creates foo.pot ...
1803 env.POTUpdate(POTDOMAIN = "bar", source = ["c.cpp", "d.cpp"]) # and bar.pot
1807 <emphasis>Example 3.</emphasis>
1808 The sources may be specified within separate file, for example
1809 <filename>POTFILES.in</filename>:
1812 # POTFILES.in in 'po/' subdirectory
1818 The name of the file (<filename>POTFILES.in</filename>) containing the list of
1819 sources is provided via &cv-link-XGETTEXTFROM;:
1822 # SConstruct file in 'po/' subdirectory
1823 env = Environment( tools = ['default', 'xgettext'] )
1824 env.POTUpdate(XGETTEXTFROM = 'POTFILES.in')
1828 <emphasis>Example 4.</emphasis>
1829 You may use &cv-link-XGETTEXTPATH; to define source search path. Assume, for
1830 example, that you have files <filename>a.cpp</filename>,
1831 <filename>b.cpp</filename>, <filename>po/SConstruct</filename>,
1832 <filename>po/POTFILES.in</filename>. Then your <literal>POT</literal>-related
1833 files could look as below:
1836 # POTFILES.in in 'po/' subdirectory
1843 # SConstruct file in 'po/' subdirectory
1844 env = Environment( tools = ['default', 'xgettext'] )
1845 env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH='../')
1849 <emphasis>Example 5.</emphasis>
1850 Multiple search directories may be defined within a list, i.e.
1851 <literal>XGETTEXTPATH = ['dir1', 'dir2', ...]</literal>. The order in the list
1852 determines the search order of source files. The path to the first file found
1857 Let's create <filename>0/1/po/SConstruct</filename> script:
1860 # SConstruct file in '0/1/po/' subdirectory
1861 env = Environment( tools = ['default', 'xgettext'] )
1862 env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../', '../../'])
1865 and <filename>0/1/po/POTFILES.in</filename>:
1868 # POTFILES.in in '0/1/po/' subdirectory
1873 Write two <filename>*.cpp</filename> files, the first one is
1874 <filename>0/a.cpp</filename>:
1878 gettext("Hello from ../../a.cpp")
1881 and the second is <filename>0/1/a.cpp</filename>:
1885 gettext("Hello from ../a.cpp")
1888 then run scons. You'll obtain <literal>0/1/po/messages.pot</literal> with the
1889 message <literal>"Hello from ../a.cpp"</literal>. When you reverse order in
1890 <varname>$XGETTEXTFOM</varname>, i.e. when you write SConscript as
1893 # SConstruct file in '0/1/po/' subdirectory
1894 env = Environment( tools = ['default', 'xgettext'] )
1895 env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../../', '../'])
1898 then the <filename>messages.pot</filename> will contain
1899 <literal>msgid "Hello from ../../a.cpp"</literal> line and not
1900 <literal>msgid "Hello from ../a.cpp"</literal>.
1905 <varlistentry id="b-POUpdate">
1906 <term><function>POUpdate</function>()</term>
1907 <term><replaceable>env</replaceable>.<methodname>POUpdate</methodname>()</term>
1909 The builder belongs to &t-link-msgmerge; tool. The builder updates
1910 <literal>PO</literal> files with <command>msgmerge(1)</command>, or initializes
1911 missing <literal>PO</literal> files as described in documentation of
1912 &t-link-msginit; tool and &b-link-POInit; builder (see also
1913 &cv-link-POAUTOINIT;). Note, that &b-POUpdate; <emphasis>does not add its
1914 targets to <literal>po-create</literal> alias</emphasis> as &b-link-POInit;
1919 Target nodes defined through &b-POUpdate; are not built by default
1920 (they're <literal>Ignore</literal>d from <literal>'.'</literal> node). Instead,
1921 they are added automatically to special <literal>Alias</literal>
1922 (<literal>'po-update'</literal> by default). The alias name may be changed
1923 through the &cv-link-POUPDATE_ALIAS; construction variable. You can easily
1924 update <literal>PO</literal> files in your project by <command>scons
1925 po-update</command>.
1929 <emphasis>Example 1.</emphasis>
1930 Update <filename>en.po</filename> and <filename>pl.po</filename> from
1931 <filename>messages.pot</filename> template (see also &cv-link-POTDOMAIN;),
1932 assuming that the later one exists or there is rule to build it (see
1933 &b-link-POTUpdate;):
1937 env.POUpdate(['en','pl']) # messages.pot --> [en.po, pl.po]
1941 <emphasis>Example 2.</emphasis>
1942 Update <filename>en.po</filename> and <filename>pl.po</filename> from
1943 <filename>foo.pot</filename> template:
1947 env.POUpdate(['en', 'pl'], ['foo']) # foo.pot --> [en.po, pl.pl]
1951 <emphasis>Example 3.</emphasis>
1952 Update <filename>en.po</filename> and <filename>pl.po</filename> from
1953 <filename>foo.pot</filename> (another version):
1957 env.POUpdate(['en', 'pl'], POTDOMAIN='foo') # foo.pot -- > [en.po, pl.pl]
1961 <emphasis>Example 4.</emphasis>
1962 Update files for languages defined in <filename>LINGUAS</filename> file. The
1963 files are updated from <filename>messages.pot</filename> template:
1967 env.POUpdate(LINGUAS_FILE = 1) # needs 'LINGUAS' file
1971 <emphasis>Example 5.</emphasis>
1972 Same as above, but update from <filename>foo.pot</filename> template:
1976 env.POUpdate(LINGUAS_FILE = 1, source = ['foo'])
1980 <emphasis>Example 6.</emphasis>
1981 Update <filename>en.po</filename> and <filename>pl.po</filename> plus files for
1982 languages defined in <filename>LINGUAS</filename> file. The files are updated
1983 from <filename>messages.pot</filename> template:
1986 # produce 'en.po', 'pl.po' + files defined in 'LINGUAS':
1987 env.POUpdate(['en', 'pl' ], LINGUAS_FILE = 1)
1991 <emphasis>Example 7.</emphasis>
1992 Use &cv-link-POAUTOINIT; to automatically initialize <literal>PO</literal> file
1993 if it doesn't exist:
1997 env.POUpdate(LINGUAS_FILE = 1, POAUTOINIT = 1)
2001 <emphasis>Example 8.</emphasis>
2002 Update <literal>PO</literal> files for languages defined in
2003 <filename>LINGUAS</filename> file. The files are updated from
2004 <filename>foo.pot</filename> template. All necessary settings are
2005 pre-configured via environment.
2009 env['POAUTOINIT'] = 1
2010 env['LINGUAS_FILE'] = 1
2011 env['POTDOMAIN'] = 'foo'
2017 <varlistentry id="b-Program">
2018 <term><function>Program</function>()</term>
2019 <term><replaceable>env</replaceable>.<methodname>Program</methodname>()</term>
2021 Builds an executable given one or more object files
2022 or C, C++, D, or Fortran source files.
2023 If any C, C++, D or Fortran source files are specified,
2024 then they will be automatically
2025 compiled to object files using the
2028 see that builder method's description for
2029 a list of legal source file suffixes
2030 and how they are interpreted.
2031 The target executable file prefix,
2032 specified by the &cv-link-PROGPREFIX; &consvar;
2033 (nothing by default),
2035 specified by the &cv-link-PROGSUFFIX; &consvar;
2036 (by default, <filename>.exe</filename> on Windows systems,
2037 nothing on POSIX systems),
2038 are automatically added to the target if not already present.
2043 env.Program(target='foo', source=['foo.o', 'bar.c', 'baz.f'])
2047 <varlistentry id="b-ProgramAllAtOnce">
2048 <term><function>ProgramAllAtOnce</function>()</term>
2049 <term><replaceable>env</replaceable>.<methodname>ProgramAllAtOnce</methodname>()</term>
2051 Builds an executable from D sources without first creating individual
2052 objects for each file.
2055 D sources can be compiled file-by-file as C and C++ source are, and
2056 D is integrated into the &scons; Object and Program builders for
2057 this model of build. D codes can though do whole source
2058 meta-programming (some of the testing frameworks do this). For this
2059 it is imperative that all sources are compiled and linked in a single
2060 call to the D compiler. This builder serves that purpose.
2063 env.ProgramAllAtOnce('executable', ['mod_a.d, mod_b.d', 'mod_c.d'])
2066 This command will compile the modules mod_a, mod_b, and mod_c in a
2067 single compilation process without first creating object files for
2068 the modules. Some of the D compilers will create executable.o others
2073 <varlistentry id="b-RES">
2074 <term><function>RES</function>()</term>
2075 <term><replaceable>env</replaceable>.<methodname>RES</methodname>()</term>
2077 Builds a Microsoft Visual C++ resource file.
2078 This builder method is only provided
2079 when Microsoft Visual C++ or MinGW is being used as the compiler. The
2080 <filename>.res</filename>
2082 <filename>.o</filename>
2083 for MinGW) suffix is added to the target name if no other suffix is given.
2085 file is scanned for implicit dependencies as though it were a C file.
2090 env.RES('resource.rc')
2094 <varlistentry id="b-RMIC">
2095 <term><function>RMIC</function>()</term>
2096 <term><replaceable>env</replaceable>.<methodname>RMIC</methodname>()</term>
2098 Builds stub and skeleton class files
2100 from Java <filename>.class</filename> files.
2101 The target is a directory
2102 relative to which the stub
2103 and skeleton class files will be written.
2104 The source can be the names of <filename>.class</filename> files,
2105 or the objects return from the
2111 If the construction variable
2112 &cv-link-JAVACLASSDIR;
2113 is set, either in the environment
2114 or in the call to the
2116 builder method itself,
2117 then the value of the variable
2118 will be stripped from the
2119 beginning of any <filename>.class </filename>
2124 classes = env.Java(target='classdir', source='src')
2125 env.RMIC(target='outdir1', source=classes)
2128 source=['package/foo.class', 'package/bar.class'],
2132 source=['classes/foo.class', 'classes/bar.class'],
2133 JAVACLASSDIR='classes',
2138 <varlistentry id="b-RPCGenClient">
2139 <term><function>RPCGenClient</function>()</term>
2140 <term><replaceable>env</replaceable>.<methodname>RPCGenClient</methodname>()</term>
2142 Generates an RPC client stub (<filename>_clnt.c</filename>) file
2143 from a specified RPC (<filename>.x</filename>) source file.
2144 Because rpcgen only builds output files
2145 in the local directory,
2146 the command will be executed
2147 in the source file's directory by default.
2151 # Builds src/rpcif_clnt.c
2152 env.RPCGenClient('src/rpcif.x')
2156 <varlistentry id="b-RPCGenHeader">
2157 <term><function>RPCGenHeader</function>()</term>
2158 <term><replaceable>env</replaceable>.<methodname>RPCGenHeader</methodname>()</term>
2160 Generates an RPC header (<filename>.h</filename>) file
2161 from a specified RPC (<filename>.x</filename>) source file.
2162 Because rpcgen only builds output files
2163 in the local directory,
2164 the command will be executed
2165 in the source file's directory by default.
2169 # Builds src/rpcif.h
2170 env.RPCGenHeader('src/rpcif.x')
2174 <varlistentry id="b-RPCGenService">
2175 <term><function>RPCGenService</function>()</term>
2176 <term><replaceable>env</replaceable>.<methodname>RPCGenService</methodname>()</term>
2178 Generates an RPC server-skeleton (<filename>_svc.c</filename>) file
2179 from a specified RPC (<filename>.x</filename>) source file.
2180 Because rpcgen only builds output files
2181 in the local directory,
2182 the command will be executed
2183 in the source file's directory by default.
2187 # Builds src/rpcif_svc.c
2188 env.RPCGenClient('src/rpcif.x')
2192 <varlistentry id="b-RPCGenXDR">
2193 <term><function>RPCGenXDR</function>()</term>
2194 <term><replaceable>env</replaceable>.<methodname>RPCGenXDR</methodname>()</term>
2196 Generates an RPC XDR routine (<filename>_xdr.c</filename>) file
2197 from a specified RPC (<filename>.x</filename>) source file.
2198 Because rpcgen only builds output files
2199 in the local directory,
2200 the command will be executed
2201 in the source file's directory by default.
2205 # Builds src/rpcif_xdr.c
2206 env.RPCGenClient('src/rpcif.x')
2210 <varlistentry id="b-SharedLibrary">
2211 <term><function>SharedLibrary</function>()</term>
2212 <term><replaceable>env</replaceable>.<methodname>SharedLibrary</methodname>()</term>
2214 Builds a shared library
2215 (<filename>.so</filename> on a POSIX system,
2216 <filename>.dll</filename> on Windows)
2217 given one or more object files
2218 or C, C++, D or Fortran source files.
2219 If any source files are given,
2220 then they will be automatically
2221 compiled to object files.
2222 The target library file prefix,
2223 specified by the &cv-link-SHLIBPREFIX; &consvar;
2224 (by default, <filename>lib</filename> on POSIX systems,
2225 nothing on Windows systems),
2227 specified by the &cv-link-SHLIBSUFFIX; &consvar;
2228 (by default, <filename>.dll</filename> on Windows systems,
2229 <filename>.so</filename> on POSIX systems),
2230 are automatically added to the target if not already present.
2235 env.SharedLibrary(target='bar', source=['bar.c', 'foo.o'])
2239 On Windows systems, the
2241 builder method will always build an import library
2242 (<filename>.lib</filename>)
2243 in addition to the shared library (<filename>.dll</filename>),
2244 adding a <filename>.lib</filename> library with the same basename
2245 if there is not already a <filename>.lib</filename> file explicitly
2246 listed in the targets.
2250 On Cygwin systems, the
2252 builder method will always build an import library
2253 (<filename>.dll.a</filename>)
2254 in addition to the shared library (<filename>.dll</filename>),
2255 adding a <filename>.dll.a</filename> library with the same basename
2256 if there is not already a <filename>.dll.a</filename> file explicitly
2257 listed in the targets.
2261 Any object files listed in the
2262 <parameter>source</parameter>
2263 must have been built for a shared library
2268 will raise an error if there is any mismatch.
2272 On some platforms, there is a distinction between a shared library
2273 (loaded automatically by the system to resolve external references)
2274 and a loadable module (explicitly loaded by user action).
2275 For maximum portability, use the &b-link-LoadableModule; builder for the latter.
2279 When the &cv-link-SHLIBVERSION; &consvar; is defined, a versioned
2280 shared library is created. This modifies &cv-link-SHLINKFLAGS; as required,
2281 adds the version number to the library name, and creates any
2282 symbolic links that are needed.
2286 env.SharedLibrary(target='bar', source=['bar.c', 'foo.o'], SHLIBVERSION='1.5.2')
2290 On a POSIX system, versions with a single token create exactly one symlink:
2291 <filename>libbar.so.6</filename> would have symlink <filename>libbar.so</filename> only.
2292 On a POSIX system, versions with two or more
2293 tokens create exactly two symlinks: <filename>libbar.so.2.3.1</filename> would have symlinks
2294 <filename>libbar.so</filename> and <filename>libbar.so.2</filename>; on a Darwin (OSX) system the library would be
2295 <filename>libbar.2.3.1.dylib</filename> and the link would be <filename>libbar.dylib</filename>.
2299 On Windows systems, specifying
2300 <parameter>register=1</parameter>
2301 will cause the <filename>.dll</filename> to be
2302 registered after it is built.
2303 The command that is run is determined by the &cv-link-REGSVR; &consvar;
2304 (<command>regsvr32</command> by default),
2305 and the flags passed are determined by &cv-link-REGSVRFLAGS;. By
2306 default, &cv-link-REGSVRFLAGS; includes the <option>/s</option> option,
2307 to prevent dialogs from popping
2308 up and requiring user attention when it is run. If you change
2309 &cv-link-REGSVRFLAGS;, be sure to include the <option>/s</option> option.
2314 env.SharedLibrary(target='bar', source=['bar.cxx', 'foo.obj'], register=1)
2318 will register <filename>bar.dll</filename> as a COM object
2319 when it is done linking it.
2323 <varlistentry id="b-SharedObject">
2324 <term><function>SharedObject</function>()</term>
2325 <term><replaceable>env</replaceable>.<methodname>SharedObject</methodname>()</term>
2327 Builds an object file intended for
2328 inclusion in a shared library.
2329 Source files must have one of the same set of extensions
2330 specified above for the
2333 On some platforms building a shared object requires additional
2335 (e.g. <option>-fPIC</option> for <command>gcc</command>)
2336 in addition to those needed to build a
2337 normal (static) object, but on some platforms there is no difference between a
2338 shared object and a normal (static) one. When there is a difference, SCons
2339 will only allow shared objects to be linked into a shared library, and will
2340 use a different suffix for shared objects. On platforms where there is no
2341 difference, SCons will allow both normal (static)
2342 and shared objects to be linked into a
2343 shared library, and will use the same suffix for shared and normal
2345 The target object file prefix,
2346 specified by the &cv-link-SHOBJPREFIX; &consvar;
2347 (by default, the same as &cv-link-OBJPREFIX;),
2349 specified by the &cv-link-SHOBJSUFFIX; &consvar;,
2350 are automatically added to the target if not already present.
2355 env.SharedObject(target='ddd', source='ddd.c')
2356 env.SharedObject(target='eee.o', source='eee.cpp')
2357 env.SharedObject(target='fff.obj', source='fff.for')
2361 Note that the source files will be scanned
2362 according to the suffix mappings in the
2363 <classname>SourceFileScanner</classname>
2365 See the manpage section "Scanner Objects"
2366 for more information.
2370 <varlistentry id="b-StaticLibrary">
2371 <term><function>StaticLibrary</function>()</term>
2372 <term><replaceable>env</replaceable>.<methodname>StaticLibrary</methodname>()</term>
2374 Builds a static library given one or more object files
2375 or C, C++, D or Fortran source files.
2376 If any source files are given,
2377 then they will be automatically
2378 compiled to object files.
2379 The static library file prefix,
2380 specified by the &cv-link-LIBPREFIX; &consvar;
2381 (by default, <filename>lib</filename> on POSIX systems,
2382 nothing on Windows systems),
2384 specified by the &cv-link-LIBSUFFIX; &consvar;
2385 (by default, <filename>.lib</filename> on Windows systems,
2386 <filename>.a</filename> on POSIX systems),
2387 are automatically added to the target if not already present.
2392 env.StaticLibrary(target='bar', source=['bar.c', 'foo.o'])
2396 Any object files listed in the
2397 <parameter>source</parameter>
2398 must have been built for a static library
2403 will raise an error if there is any mismatch.
2407 <varlistentry id="b-StaticObject">
2408 <term><function>StaticObject</function>()</term>
2409 <term><replaceable>env</replaceable>.<methodname>StaticObject</methodname>()</term>
2411 Builds a static object file
2412 from one or more C, C++, D, or Fortran source files.
2413 Source files must have one of the following extensions:
2417 .asm assembly language file
2418 .ASM assembly language file
2430 .F Windows: Fortran file
2431 POSIX: Fortran file + C pre-processor
2434 .fpp Fortran file + C pre-processor
2435 .FPP Fortran file + C pre-processor
2438 .s assembly language file
2439 .S Windows: assembly language file
2440 ARM: CodeSourcery Sourcery Lite
2441 .sx assembly language file + C pre-processor
2442 POSIX: assembly language file + C pre-processor
2443 .spp assembly language file + C pre-processor
2444 .SPP assembly language file + C pre-processor
2448 The target object file prefix,
2449 specified by the &cv-link-OBJPREFIX; &consvar;
2450 (nothing by default),
2452 specified by the &cv-link-OBJSUFFIX; &consvar;
2453 (<filename>.obj</filename> on Windows systems,
2454 <filename>.o</filename> on POSIX systems),
2455 are automatically added to the target if not already present.
2460 env.StaticObject(target='aaa', source='aaa.c')
2461 env.StaticObject(target='bbb.o', source='bbb.c++')
2462 env.StaticObject(target='ccc.obj', source='ccc.f')
2466 Note that the source files will be scanned
2467 according to the suffix mappings in the
2468 <classname>SourceFileScanner</classname>
2470 See the manpage section "Scanner Objects"
2471 for more information.
2475 <varlistentry id="b-Substfile">
2476 <term><function>Substfile</function>()</term>
2477 <term><replaceable>env</replaceable>.<methodname>Substfile</methodname>()</term>
2479 The &b-Substfile; builder creates a single text file from
2480 a template consisting of a file or set of files (or nodes),
2481 replacing text using the &cv-link-SUBST_DICT; &consvar; (if set).
2482 If a set, they are concatenated into the target file
2483 using the value of the
2484 &cv-link-LINESEPARATOR; &consvar; as a separator between contents;
2485 the separator is not emitted after the contents of the last file.
2486 Nested lists of source files
2487 are flattened. See also &b-link-Textfile;.
2491 By default the target file encoding is "utf-8" and can be changed by &cv-link-FILE_ENCODING;
2496 If a single source file name is specified and has a <filename>.in</filename> suffix,
2497 the suffix is stripped and the remainder of the name is used as the default target name.
2501 The prefix and suffix specified by the &cv-link-SUBSTFILEPREFIX;
2502 and &cv-link-SUBSTFILESUFFIX; &consvars;
2503 (an empty string by default in both cases)
2504 are automatically added to the target if they are not already present.
2508 If a construction variable named &cv-link-SUBST_DICT; is present,
2509 it may be either a Python dictionary or a sequence of
2510 (<replaceable>key</replaceable>, <replaceable>value</replaceable>) tuples.
2511 If it is a dictionary it is converted into a list of tuples
2512 with unspecified order,
2513 so if one key is a prefix of another key
2514 or if one substitution could be further expanded by another subsitition,
2515 it is unpredictable whether the expansion will occur.
2519 Any occurrences of a key in the source
2520 are replaced by the corresponding value,
2521 which may be a Python callable function or a string.
2522 If the value is a callable, it is called with no arguments to get a string.
2523 Strings are <emphasis>subst</emphasis>-expanded
2524 and the result replaces the key.
2528 env = Environment(tools=['default'])
2530 env['prefix'] = '/usr/bin'
2531 script_dict = {'@prefix@': '/bin', '@exec_prefix@': '$prefix'}
2532 env.Substfile('script.in', SUBST_DICT=script_dict)
2534 conf_dict = {'%VERSION%': '1.2.3', '%BASE%': 'MyProg'}
2535 env.Substfile('config.h.in', conf_dict, SUBST_DICT=conf_dict)
2537 # UNPREDICTABLE - one key is a prefix of another
2538 bad_foo = {'$foo': '$foo', '$foobar': '$foobar'}
2539 env.Substfile('foo.in', SUBST_DICT=bad_foo)
2541 # PREDICTABLE - keys are applied longest first
2542 good_foo = [('$foobar', '$foobar'), ('$foo', '$foo')]
2543 env.Substfile('foo.in', SUBST_DICT=good_foo)
2545 # UNPREDICTABLE - one substitution could be futher expanded
2546 bad_bar = {'@bar@': '@soap@', '@soap@': 'lye'}
2547 env.Substfile('bar.in', SUBST_DICT=bad_bar)
2549 # PREDICTABLE - substitutions are expanded in order
2550 good_bar = (('@bar@', '@soap@'), ('@soap@', 'lye'))
2551 env.Substfile('bar.in', SUBST_DICT=good_bar)
2553 # the SUBST_DICT may be in common (and not an override)
2555 subst = Environment(tools=['textfile'], SUBST_DICT=substitutions)
2556 substitutions['@foo@'] = 'foo'
2557 subst['SUBST_DICT']['@bar@'] = 'bar'
2560 [Value('#include "@foo@.h"'), Value('#include "@bar@.h"'), "common.in", "pgm1.in"],
2564 [Value('#include "@foo@.h"'), Value('#include "@bar@.h"'), "common.in", "pgm2.in"],
2570 <varlistentry id="b-Tar">
2571 <term><function>Tar</function>()</term>
2572 <term><replaceable>env</replaceable>.<methodname>Tar</methodname>()</term>
2574 Builds a tar archive of the specified files
2576 Unlike most builder methods,
2579 builder method may be called multiple times
2581 each additional call
2582 adds to the list of entries
2583 that will be built into the archive.
2584 Any source directories will
2585 be scanned for changes to
2587 regardless of whether or not
2589 knows about them from other Builder or function calls.
2593 env.Tar('src.tar', 'src')
2595 # Create the stuff.tar file.
2596 env.Tar('stuff', ['subdir1', 'subdir2'])
2597 # Also add "another" to the stuff.tar file.
2598 env.Tar('stuff', 'another')
2600 # Set TARFLAGS to create a gzip-filtered archive.
2601 env = Environment(TARFLAGS = '-c -z')
2602 env.Tar('foo.tar.gz', 'foo')
2604 # Also set the suffix to .tgz.
2605 env = Environment(TARFLAGS = '-c -z',
2611 <varlistentry id="b-Textfile">
2612 <term><function>Textfile</function>()</term>
2613 <term><replaceable>env</replaceable>.<methodname>Textfile</methodname>()</term>
2615 The &b-Textfile; builder generates a single text file from
2616 a template consisting of a list of strings, replacing text
2617 using the &cv-link-SUBST_DICT; &consvar; (if set) -
2618 see &b-link-Substfile; for a description of replacement.
2619 The strings will be separated in the target file using the
2621 &cv-link-LINESEPARATOR; &consvar;;
2622 the line separator is not emitted after the last string.
2623 Nested lists of source strings
2625 Source strings need not literally be Python strings:
2626 they can be Nodes or Python objects that convert cleanly
2627 to &f-link-Value; nodes.
2631 The prefix and suffix specified by the &cv-link-TEXTFILEPREFIX;
2632 and &cv-link-TEXTFILESUFFIX; &consvars;
2633 (by default an empty string and <filename>.txt</filename>, respectively)
2634 are automatically added to the target if they are not already present.
2637 By default the target file encoding is "utf-8" and can be changed by &cv-link-FILE_ENCODING;
2642 # builds/writes foo.txt
2643 env.Textfile(target='foo.txt', source=['Goethe', 42, 'Schiller'])
2645 # builds/writes bar.txt
2646 env.Textfile(target='bar', source=['lalala', 'tanteratei'], LINESEPARATOR='|*')
2648 # nested lists are flattened automatically
2649 env.Textfile(target='blob', source=['lalala', ['Goethe', 42, 'Schiller'], 'tanteratei'])
2651 # files may be used as input by wraping them in File()
2653 target='concat', # concatenate files with a marker between
2654 source=[File('concat1'), File('concat2')],
2655 LINESEPARATOR='====================\n',
2659 <para>Results:</para>
2661 <para><filename>foo.txt</filename></para>
2668 <para><filename>bar.txt</filename></para>
2673 <para><filename>blob.txt</filename></para>
2684 <varlistentry id="b-Translate">
2685 <term><function>Translate</function>()</term>
2686 <term><replaceable>env</replaceable>.<methodname>Translate</methodname>()</term>
2688 This pseudo-builder belongs to &t-link-gettext; toolset. The builder extracts
2689 internationalized messages from source files, updates <literal>POT</literal>
2690 template (if necessary) and then updates <literal>PO</literal> translations (if
2691 necessary). If &cv-link-POAUTOINIT; is set, missing <literal>PO</literal> files
2692 will be automatically created (i.e. without translator person intervention).
2693 The variables &cv-link-LINGUAS_FILE; and &cv-link-POTDOMAIN; are taken into
2694 acount too. All other construction variables used by &b-link-POTUpdate;, and
2695 &b-link-POUpdate; work here too.
2699 <emphasis>Example 1</emphasis>.
2700 The simplest way is to specify input files and output languages inline in
2701 a SCons script when invoking &b-Translate;
2704 # SConscript in 'po/' directory
2705 env = Environment( tools = ["default", "gettext"] )
2706 env['POAUTOINIT'] = 1
2707 env.Translate(['en','pl'], ['../a.cpp','../b.cpp'])
2711 <emphasis>Example 2</emphasis>.
2712 If you wish, you may also stick to conventional style known from
2713 <productname>autotools</productname>, i.e. using
2714 <filename>POTFILES.in</filename> and <filename>LINGUAS</filename> files
2731 env = Environment( tools = ["default", "gettext"] )
2732 env['POAUTOINIT'] = 1
2733 env['XGETTEXTPATH'] = ['../']
2734 env.Translate(LINGUAS_FILE = 1, XGETTEXTFROM = 'POTFILES.in')
2738 The last approach is perhaps the recommended one. It allows easily split
2739 internationalization/localization onto separate SCons scripts, where a script
2740 in source tree is responsible for translations (from sources to
2741 <literal>PO</literal> files) and script(s) under variant directories are
2742 responsible for compilation of <literal>PO</literal> to <literal>MO</literal>
2743 files to and for installation of <literal>MO</literal> files. The "gluing
2744 factor" synchronizing these two scripts is then the content of
2745 <filename>LINGUAS</filename> file. Note, that the updated
2746 <literal>POT</literal> and <literal>PO</literal> files are usually going to be
2747 committed back to the repository, so they must be updated within the source
2748 directory (and not in variant directories). Additionaly, the file listing of
2749 <filename>po/</filename> directory contains <filename>LINGUAS</filename> file,
2750 so the source tree looks familiar to translators, and they may work with the
2751 project in their usual way.
2755 <emphasis>Example 3</emphasis>.
2756 Let's prepare a development tree as below
2770 with <filename>build</filename> being variant directory. Write the top-level
2771 <filename>SConstruct</filename> script as follows
2775 env = Environment( tools = ["default", "gettext"] )
2776 VariantDir('build', 'src', duplicate = 0)
2777 env['POAUTOINIT'] = 1
2778 SConscript('src/po/SConscript.i18n', exports = 'env')
2779 SConscript('build/po/SConscript', exports = 'env')
2782 the <filename>src/po/SConscript.i18n</filename> as
2785 # src/po/SConscript.i18n
2787 env.Translate(LINGUAS_FILE=1, XGETTEXTFROM='POTFILES.in', XGETTEXTPATH=['../'])
2790 and the <filename>src/po/SConscript</filename>
2795 env.MOFiles(LINGUAS_FILE = 1)
2798 Such setup produces <literal>POT</literal> and <literal>PO</literal> files
2799 under source tree in <filename>src/po/</filename> and binary
2800 <literal>MO</literal> files under variant tree in
2801 <filename>build/po/</filename>. This way the <literal>POT</literal> and
2802 <literal>PO</literal> files are separated from other output files, which must
2803 not be committed back to source repositories (e.g. <literal>MO</literal>
2808 <note><para>In above example, the <literal>PO</literal> files are not updated,
2809 nor created automatically when you issue <command>scons '.'</command> command.
2810 The files must be updated (created) by hand via <command>scons
2811 po-update</command> and then <literal>MO</literal> files can be compiled by
2812 running <command>scons '.'</command>.</para></note>
2817 <varlistentry id="b-TypeLibrary">
2818 <term><function>TypeLibrary</function>()</term>
2819 <term><replaceable>env</replaceable>.<methodname>TypeLibrary</methodname>()</term>
2821 Builds a Windows type library (<filename>.tlb</filename>)
2822 file from an input IDL file (<filename>.idl</filename>).
2823 In addition, it will build the associated interface stub and
2825 naming them according to the base name of the <filename>.idl</filename> file.
2830 env.TypeLibrary(source="foo.idl")
2834 Will create <filename>foo.tlb</filename>,
2835 <filename>foo.h</filename>,
2836 <filename>foo_i.c</filename>,
2837 <filename>foo_p.c</filename>
2839 <filename>foo_data.c</filename>
2844 <varlistentry id="b-Uic">
2845 <term><function>Uic</function>()</term>
2846 <term><replaceable>env</replaceable>.<methodname>Uic</methodname>()</term>
2848 Builds a header file, an implementation file and a moc file from an ui file.
2849 and returns the corresponding nodes in the that order.
2850 This builder is only available after using the tool &t-link-qt3;.
2851 Note: you can specify <filename>.ui</filename> files directly as source
2852 files to the &b-link-Program;,
2853 &b-link-Library; and &b-link-SharedLibrary; builders
2854 without using this builder. Using this builder lets you override the standard
2855 naming conventions (be careful: prefixes are always prepended to names of
2856 built files; if you don't want prefixes, you may set them to ``).
2857 See the &cv-link-QT3DIR; variable for more information.
2862 env.Uic('foo.ui') # -> ['foo.h', 'uic_foo.cc', 'moc_foo.cc']
2864 target=Split('include/foo.h gen/uicfoo.cc gen/mocfoo.cc'),
2866 ) # -> ['include/foo.h', 'gen/uicfoo.cc', 'gen/mocfoo.cc']
2870 <varlistentry id="b-Zip">
2871 <term><function>Zip</function>()</term>
2872 <term><replaceable>env</replaceable>.<methodname>Zip</methodname>()</term>
2874 Builds a zip archive of the specified files
2876 Unlike most builder methods,
2879 builder method may be called multiple times
2881 each additional call
2882 adds to the list of entries
2883 that will be built into the archive.
2884 Any source directories will
2885 be scanned for changes to
2887 regardless of whether or not
2889 knows about them from other Builder or function calls.
2893 env.Zip('src.zip', 'src')
2895 # Create the stuff.zip file.
2896 env.Zip('stuff', ['subdir1', 'subdir2'])
2897 # Also add "another" to the stuff.tar file.
2898 env.Zip('stuff', 'another')