<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Scons</id>
	<title>Scons - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Scons"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Scons&amp;action=history"/>
	<updated>2026-04-30T10:37:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Scons&amp;diff=304&amp;oldid=prev</id>
		<title>Kenneth: Created page with &quot;== scons ==  SCons: A software construction tool - http://www.scons.org/  SCons is a replacement for the make utility. As the make utility looks for a Makefile, scons looks fo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Scons&amp;diff=304&amp;oldid=prev"/>
		<updated>2014-07-01T21:13:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== scons ==  SCons: A software construction tool - http://www.scons.org/  SCons is a replacement for the make utility. As the make utility looks for a Makefile, scons looks fo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== scons ==&lt;br /&gt;
&lt;br /&gt;
SCons: A software construction tool - http://www.scons.org/&lt;br /&gt;
&lt;br /&gt;
SCons is a replacement for the make utility. As the make utility looks for a Makefile, scons looks for an SConstruct file by default. The format for the SConstruct file is a python script. Note that you do not have to know Python for basic operation of this build tool.&lt;br /&gt;
&lt;br /&gt;
-&lt;br /&gt;
&lt;br /&gt;
SCons - Wikipedia - http://en.wikipedia.org/wiki/SCons&lt;br /&gt;
&lt;br /&gt;
SCons is a computer software construction tool that automatically analyzes source code file dependencies and operating system adaptation requirements from a software project description and generates final binary executables for installation on the target operating system platform. Its function is analogous to the traditional GNU build system based on the make utility and the autoconf tools.&lt;br /&gt;
&lt;br /&gt;
SCons uses the Python general purpose programming language as a foundation, so that all software project configurations and build process implementations are Python scripts.&lt;br /&gt;
&lt;br /&gt;
* Configuration files are Python scripts, which means that user-written builds have access to a complete general-purpose programming language.&lt;br /&gt;
* Automatic dependency analysis built-in for C, C++ and Fortran. Dependency analysis is extensible through user-defined dependency scanners for other languages or file types. Unlike the GNU Compiler Collection&amp;#039;s (GCC) built-in dependency analysis, it uses a regular expression scan for included source files.&lt;br /&gt;
* Built-in support for C, C++, D, Java, Fortran, Objective-C, Yacc, Lex, Qt and SWIG, as well as TeX and LaTeX documents. Other languages or file types can be supported through user-defined Builders.&lt;br /&gt;
* Building from central repositories of source code and pre-built targets.&lt;br /&gt;
* Built-in support for fetching source files from revision control systems, such as SCCS, RCS, CVS, Subversion, BitKeeper and Perforce.&lt;br /&gt;
* Built-in support for Microsoft Visual Studio, including generation of .dsp, .dsw, .sln and .vcproj files.&lt;br /&gt;
* Detection of file content changes using MD5 signatures; optional, configurable support for traditional timestamps.&lt;br /&gt;
* Support for parallel builds which maintains a specified number of jobs running simultaneously regardless of directory hierarchy.&lt;br /&gt;
* Integrated Autoconf-like support for finding #include files, libraries, functions and typedefs.&lt;br /&gt;
* Global view of all dependencies, so multiple build passes or reordering targets is not required.&lt;br /&gt;
* Ability to share built files in a cache to speed up multiple builds - like ccache but for any type of target file, not just C/C++ compilation.&lt;br /&gt;
* Designed from the ground up for cross-platform builds, and known to work on POSIX systems (including GNU/Linux, IBM AIX and OS/2, *BSD Unices, HP-UX, SGI IRIX, Solaris), MS Windows NT, Apple OS X.&lt;br /&gt;
&lt;br /&gt;
== usage ==&lt;br /&gt;
&lt;br /&gt;
Bulding SConscript&lt;br /&gt;
 scons&lt;br /&gt;
&lt;br /&gt;
Cleaning Up After a Build:&lt;br /&gt;
 scons -c&lt;br /&gt;
&lt;br /&gt;
Bulding quiet:&lt;br /&gt;
 scons -Q&lt;br /&gt;
&lt;br /&gt;
== documentation ==&lt;br /&gt;
&lt;br /&gt;
SCons User Guide 2.3.0 (single file) - http://www.scons.org/doc/HTML/scons-user.html&lt;br /&gt;
&lt;br /&gt;
SCons User Guide 2.3.0 - http://www.scons.org/doc/HTML/scons-user/index.html&lt;br /&gt;
&lt;br /&gt;
== install ==&lt;br /&gt;
&lt;br /&gt;
=== RPMForge ===&lt;br /&gt;
&lt;br /&gt;
 yum --enablerepo rpmforge install scons&lt;br /&gt;
&lt;br /&gt;
=== Manual 2.3 ===&lt;br /&gt;
&lt;br /&gt;
 # Dependency - install Python&lt;br /&gt;
 &lt;br /&gt;
 #SVER=2.3.0&lt;br /&gt;
 SVER=2.3.1&lt;br /&gt;
 mkdir -p ~/.src ; cd ~/.src&lt;br /&gt;
 #wget http://sourceforge.net/projects/scons/files/scons/$SVER/scons-$SVER.tar.gz/download&lt;br /&gt;
 wget http://sourceforge.net/projects/scons/files/scons/$SVER/scons-$SVER.tar.gz/download -O scons-$SVER.tar.gz&lt;br /&gt;
 tar -zvxf scons-$SVER.tar.gz&lt;br /&gt;
 cd scons-$SVER&lt;br /&gt;
 python setup.py install&lt;br /&gt;
&lt;br /&gt;
=== Manual 2.1.0 ===&lt;br /&gt;
&lt;br /&gt;
 # Dependency - install Python&lt;br /&gt;
 mkdir -p ~/.src ; cd ~/.src&lt;br /&gt;
 wget http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz/download&lt;br /&gt;
 tar -zvxf scons-2.1.0.tar.gz&lt;br /&gt;
 cd scons-2.1.0&lt;br /&gt;
 python setup.py install&lt;br /&gt;
&lt;br /&gt;
=== Manual 1.3.1 ===&lt;br /&gt;
&lt;br /&gt;
 # Dependency - install Python&lt;br /&gt;
 mkdir -p ~/.src ; cd ~/.src&lt;br /&gt;
 wget http://prdownloads.sourceforge.net/scons/scons-1.3.1.tar.gz&lt;br /&gt;
 tar -zvxf scons-1.3.1.tar.gz&lt;br /&gt;
 cd scons-1.3.1&lt;br /&gt;
 python setup.py install&lt;br /&gt;
&lt;br /&gt;
=== Test Installation ===&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;print &amp;#039;Hello World&amp;#039;&amp;quot; &amp;gt; SConstruct&lt;br /&gt;
 scons&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
Some basic instructions: [http://www.daa.com.au/pipermail/pygtk/2005-December/011569.html]&lt;br /&gt;
	1- to compile, type &amp;#039;scons prefix=/foo/bar&amp;#039;&lt;br /&gt;
	2- to run unit tests, type &amp;#039;scons check&amp;#039;&lt;br /&gt;
	3- to install, type &amp;#039;scons install&amp;#039;&lt;br /&gt;
	4- to uninstall, type &amp;#039;scons -c install&amp;#039;&lt;br /&gt;
	5- to make a new tarball, type &amp;#039;scons dist&lt;br /&gt;
&lt;br /&gt;
== code ==&lt;br /&gt;
&lt;br /&gt;
=== help ===&lt;br /&gt;
&lt;br /&gt;
Text to display when scons called with &amp;#039;-h&amp;#039;&lt;br /&gt;
 # scons -h&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Help(&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
       Type: &amp;#039;scons program&amp;#039; to build the production program,&lt;br /&gt;
             &amp;#039;scons debug&amp;#039; to build the debug version.&lt;br /&gt;
       &amp;quot;&amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
env = Environment()&lt;br /&gt;
&lt;br /&gt;
Help(&amp;quot;\nType: &amp;#039;scons program&amp;#039; to build the production program.\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if env[&amp;#039;PLATFORM&amp;#039;] == &amp;#039;win32&amp;#039;:&lt;br /&gt;
    Help(&amp;quot;\nType: &amp;#039;scons windebug&amp;#039; to build the Windows debug version.\n&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== command line arguments ===&lt;br /&gt;
&lt;br /&gt;
* Options - Command-line options always begin with one or two - (hyphen) characters. SCons provides ways for you to examine and set options values from within your SConscript files, as well as the ability to define your own custom options.&lt;br /&gt;
* Variables - Any command-line argument containing an = (equal sign) is considered a variable setting with the form variable=value. SCons provides direct access to all of the command-line variable settings, the ability to apply command-line variable settings to construction environments, and functions for configuring specific types of variables (Boolean values, path names, etc.) with automatic validation of the user&amp;#039;s specified values. &lt;br /&gt;
* Targets - Any command-line argument that is not an option or a variable setting (does not begin with a hyphen and does not contain an equal sign) is considered a target that the user (presumably) wants SCons to build. A list of Node objects representing the target or targets to build. SCons provides access to the list of specified targets, as well as ways to set the default list of targets from within the SConscript files.&lt;br /&gt;
&lt;br /&gt;
--- variable=value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# scons fail=1&lt;br /&gt;
&lt;br /&gt;
# Make the build fail if we pass fail=1 on the command line&lt;br /&gt;
if ARGUMENTS.get(&amp;#039;fail&amp;#039;, 0):&lt;br /&gt;
    Command(&amp;#039;target&amp;#039;, &amp;#039;source&amp;#039;, [&amp;#039;/bin/false&amp;#039;])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# scons -Q debug=0&lt;br /&gt;
&lt;br /&gt;
env = Environment()&lt;br /&gt;
debug = ARGUMENTS.get(&amp;#039;debug&amp;#039;, 0)&lt;br /&gt;
if int(debug):&lt;br /&gt;
    env.Append(CCFLAGS = &amp;#039;-g&amp;#039;)&lt;br /&gt;
env.Program(&amp;#039;prog.c&amp;#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--- env[&amp;#039;option&amp;#039;]=value&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import os&lt;br /&gt;
num_cpu = int(os.environ.get(&amp;#039;NUM_CPU&amp;#039;, 2))&lt;br /&gt;
SetOption(&amp;#039;num_jobs&amp;#039;, num_cpu)&lt;br /&gt;
print &amp;quot;running with -j&amp;quot;, GetOption(&amp;#039;num_jobs&amp;#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 export NUM_CPU=&amp;quot;4&amp;quot;&lt;br /&gt;
 scons&lt;br /&gt;
&lt;br /&gt;
 scons -Q -j 3&lt;br /&gt;
&lt;br /&gt;
The above snippet of code sets the value of the --jobs option to the value specified in the $NUM_CPU environment variable. (This is one of the exception cases where the string is spelled differently from the from command-line option. The string for fetching or setting the --jobs value is num_jobs for historical reasons.)&lt;br /&gt;
&lt;br /&gt;
--- --option=value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
AddOption(&amp;#039;--prefix&amp;#039;,&lt;br /&gt;
          dest=&amp;#039;prefix&amp;#039;,&lt;br /&gt;
          type=&amp;#039;string&amp;#039;,&lt;br /&gt;
          nargs=1,&lt;br /&gt;
          action=&amp;#039;store&amp;#039;,&lt;br /&gt;
          metavar=&amp;#039;DIR&amp;#039;,&lt;br /&gt;
          help=&amp;#039;installation prefix&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
env = Environment(PREFIX = GetOption(&amp;#039;prefix&amp;#039;))&lt;br /&gt;
&lt;br /&gt;
installed_foo = env.Install(&amp;#039;$PREFIX/usr/bin&amp;#039;, &amp;#039;foo.in&amp;#039;)&lt;br /&gt;
Default(installed_foo)&lt;br /&gt;
&lt;br /&gt;
# scons -Q -n --prefix=/tmp/install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== command line targets ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# scons -Q bar&lt;br /&gt;
&lt;br /&gt;
if &amp;#039;bar&amp;#039; in COMMAND_LINE_TARGETS:&lt;br /&gt;
    print &amp;quot;Don&amp;#039;t forget to copy `bar&amp;#039; to the archive!&amp;quot;&lt;br /&gt;
Default(Program(&amp;#039;foo.c&amp;#039;))&lt;br /&gt;
Program(&amp;#039;bar.c&amp;#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== examples ==&lt;br /&gt;
&lt;br /&gt;
=== hello world ===&lt;br /&gt;
&lt;br /&gt;
Simple Builds - http://www.scons.org/doc/HTML/scons-user/c258.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat &amp;gt; hello.c &amp;lt;&amp;lt; &amp;quot;EOF&amp;quot;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main() {&lt;br /&gt;
  printf(&amp;quot;Hello\n&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# cat &amp;gt; SConstruct &amp;lt;&amp;lt; &amp;quot;EOF&amp;quot;&lt;br /&gt;
Program(&amp;#039;hello.c&amp;#039;)&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
# scons&lt;br /&gt;
scons: Reading SConscript files ...&lt;br /&gt;
scons: done reading SConscript files.&lt;br /&gt;
scons: Building targets ...&lt;br /&gt;
gcc -o hello.o -c hello.c&lt;br /&gt;
gcc -o hello hello.o&lt;br /&gt;
scons: done building targets.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== More Examples ===&lt;br /&gt;
&lt;br /&gt;
Example #1:&lt;br /&gt;
 Program(&amp;#039;hello.c&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Example #2:&lt;br /&gt;
 env = Environment()&lt;br /&gt;
 env.Append(CPPFLAGS=[&amp;#039;-Wall&amp;#039;,&amp;#039;-g&amp;#039;])&lt;br /&gt;
 env.Program(&amp;#039;hello&amp;#039;,&lt;br /&gt;
            [&amp;#039;hello.c&amp;#039;, &amp;#039;main.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
Example #3:&lt;br /&gt;
 env = Environment()&lt;br /&gt;
 env.Program(target=&amp;#039;bar&amp;#039;, source=[&amp;#039;foo.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
Example #4:&lt;br /&gt;
 print &amp;quot;Calling Program(&amp;#039;hello.c&amp;#039;)&amp;quot;&lt;br /&gt;
 Program(&amp;#039;hello.c&amp;#039;)&lt;br /&gt;
 print &amp;quot;Calling Program(&amp;#039;goodbye.c&amp;#039;)&amp;quot;&lt;br /&gt;
 Program(&amp;#039;goodbye.c&amp;#039;)&lt;br /&gt;
 print &amp;quot;Finished calling Program()&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Example #5:&lt;br /&gt;
 Program([&amp;#039;prog.c&amp;#039;, &amp;#039;file1.c&amp;#039;, &amp;#039;file2.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
 Program(&amp;#039;program&amp;#039;, [&amp;#039;prog.c&amp;#039;, &amp;#039;file1.c&amp;#039;, &amp;#039;file2.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
 common_sources = [&amp;#039;file1.c&amp;#039;, &amp;#039;file2.c&amp;#039;]&lt;br /&gt;
 Program(&amp;#039;program1&amp;#039;, common_sources + [&amp;#039;program1.c&amp;#039;])&lt;br /&gt;
 Program(&amp;#039;program2&amp;#039;, common_sources + [&amp;#039;program2.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
 Program(&amp;#039;program&amp;#039;, Split(&amp;#039;main.c file1.c file2.c&amp;#039;))&lt;br /&gt;
&lt;br /&gt;
 src_files = Split(&amp;#039;main.c file1.c file2.c&amp;#039;)&lt;br /&gt;
 Program(target = &amp;#039;program&amp;#039;, source = src_files)&lt;br /&gt;
&lt;br /&gt;
Example #6: (Glob)&lt;br /&gt;
 Program(&amp;#039;program&amp;#039;, Glob(&amp;#039;*.c&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
Library:&lt;br /&gt;
 Library(&amp;#039;foo&amp;#039;, [&amp;#039;f1.c&amp;#039;, &amp;#039;f2.c&amp;#039;, &amp;#039;f3.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
 StaticLibrary(&amp;#039;foo&amp;#039;, [&amp;#039;f1.c&amp;#039;, &amp;#039;f2.c&amp;#039;, &amp;#039;f3.c&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
 Library(&amp;#039;foo&amp;#039;, [&amp;#039;f1.c&amp;#039;, &amp;#039;f2.c&amp;#039;, &amp;#039;f3.c&amp;#039;])&lt;br /&gt;
 Program(&amp;#039;prog.c&amp;#039;, LIBS=[&amp;#039;foo&amp;#039;, &amp;#039;bar&amp;#039;], LIBPATH=&amp;#039;.&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 Program(&amp;#039;prog.c&amp;#039;, LIBS=[&amp;#039;foo&amp;#039;], LIBPATH=&amp;#039;.&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
 Program(&amp;#039;prog.c&amp;#039;, LIBS = &amp;#039;m&amp;#039;, LIBPATH = [&amp;#039;/usr/lib&amp;#039;, &amp;#039;/usr/local/lib&amp;#039;])&lt;br /&gt;
&lt;br /&gt;
Environment:&lt;br /&gt;
 env = Environment()&lt;br /&gt;
 print &amp;quot;CC is:&amp;quot;, env[&amp;#039;CC&amp;#039;]&lt;br /&gt;
&lt;br /&gt;
 import os&lt;br /&gt;
 env = Environment(CC = &amp;#039;gcc&amp;#039;, CCFLAGS = &amp;#039;-O2&amp;#039;)&lt;br /&gt;
 env.Program(&amp;#039;foo.c&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
 env = Environment(FOO = &amp;#039;foo&amp;#039;, BAR = &amp;#039;bar&amp;#039;)&lt;br /&gt;
 dict = env.Dictionary()&lt;br /&gt;
 for key in [&amp;#039;OBJSUFFIX&amp;#039;, &amp;#039;LIBSUFFIX&amp;#039;, &amp;#039;PROGSUFFIX&amp;#039;]:&lt;br /&gt;
     print &amp;quot;key = %s, value = %s&amp;quot; % (key, dict[key])&lt;br /&gt;
&lt;br /&gt;
 env = Environment()&lt;br /&gt;
 for item in sorted(env.Dictionary().items()):&lt;br /&gt;
     print &amp;quot;construction variable = &amp;#039;%s&amp;#039;, value = &amp;#039;%s&amp;#039;&amp;quot; % item&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>