1 SCons - a software construction tool
2 ####################################
4 .. image:: https://img.shields.io/badge/IRC-scons-blue.svg
5 :target: http://webchat.freenode.net/?channels=%23scons&uio=d4
8 .. image:: https://img.shields.io/sourceforge/dm/scons.svg
9 :target: https://sourceforge.net/projects/scons
10 :alt: Sourceforge Monthly Downloads
12 .. image:: https://img.shields.io/sourceforge/dt/scons.svg
13 :target: https://sourceforge.net/projects/scons
14 :alt: Sourceforge Total Downloads
16 .. image:: https://travis-ci.org/SCons/scons.svg?branch=master
17 :target: https://travis-ci.org/SCons/scons
18 :alt: Travis CI build status
20 .. image:: https://ci.appveyor.com/api/projects/status/github/SCons/scons?svg=true&branch=master
21 :target: https://ci.appveyor.com/project/SCons/scons
22 :alt: AppVeyor CI build Status
24 .. image:: https://codecov.io/gh/SCons/scons/branch/master/graph/badge.svg
25 :target: https://codecov.io/gh/SCons/scons
26 :alt: CodeCov Coverage Status
28 .. image:: https://github.com/SCons/scons/workflows/SCons%20Build/badge.svg
29 :target: https://github.com/SCons/scons/actions?query=workflow%3A%22SCons+Build%22
33 Welcome to the SCons development tree. The real purpose of this tree is to
34 package SCons for production distribution in a variety of formats, not just to
37 If all you want to do is install and run SCons, it will be easier for you to
38 download and install the scons-{version}.tar.gz or scons-{version}.zip package
39 rather than to work with the packaging logic in this tree.
41 To the extent that this tree is about building SCons packages, the *full*
42 development cycle is not just to test the code directly, but to package SCons,
43 unpack the package, "install" SCons in a test subdirectory, and then to run
44 the tests against the unpacked and installed software. This helps eliminate
45 problems caused by, for example, failure to update the list of files to be
48 For just working on making an individual change to the SCons source, however,
49 you don't actually need to build or install SCons; you *can* actually edit and
50 execute SCons in-place. See the following sections below for more
54 How to edit and execute SCons in-place.
57 Tips for debugging problems in SCons.
60 How to use the automated regression tests.
62 `Development Workflow`_
63 An example of how to put the edit/execute/test pieces
64 together in a reasonable development workflow.
70 Before going further, you can check that the package you have is the latest
71 version at the SCons download page:
73 http://www.scons.org/pages/download.html
76 Execution Requirements
77 ======================
79 Running SCons requires Python 3.5 or higher. There should be no other
80 dependencies or requirements to run scons
82 The default SCons configuration assumes use of the Microsoft Visual C++
83 compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++
84 compiler named 'c++', and a Fortran compiler named 'gfortran' (such as found
85 in the GNU C compiler suite) on any other type of system. You may, of course,
86 override these default values by appropriate configuration of Environment
87 construction variables.
89 By default, SCons knows how to search for available programming tools on
90 various systems--see the SCons man page for details. You may, of course,
91 override the default SCons choices made by appropriate configuration of
92 Environment construction variables.
95 Installation Requirements
96 =========================
101 Executing SCons Without Installing
102 ==================================
104 You can execute the SCons directly from this repository. For Linux or UNIX::
106 $ python scripts/scons.py [arguments]
110 C:\scons>python scripts\scons.py [arguments]
112 If you run SCons this way, it will execute `SConstruct` file for this repo,
113 which will build and pack SCons itself. Use the -C option to change directory
116 $ python scripts/scons.py -C /some/other/location [arguments]
122 Note: You don't need to build SCons packages or install SCons if you just
123 want to work on developing a patch. See the sections about `Making
124 Changes`_ and `Testing`_ below if you just want to submit a bug fix or
125 some new functionality.
127 Assuming your system satisfies the installation requirements in the previous
128 section, install SCons from this package by first populating the build/scons/
129 subdirectory. (For an easier way to install SCons, without having to populate
130 this directory, use the scons-{version}.tar.gz or scons-{version}.zip
134 Install the built SCons files
135 -----------------------------
137 Any of the above commands will populate the build/scons/ directory with the
138 necessary files and directory structure to use the Python-standard setup
139 script as follows on Linux or UNIX::
141 # python setup.py install
145 C:\scons>python setup.py install
147 By default, the above commands will do the following:
149 - Install scripts named "scons" and "sconsign" scripts in the default system
150 script directory (/usr/bin or C:\\Python\*\\Scripts, for example).
152 - Install "scons-3.1.2.exe" and "scons.exe" executables in the Python
153 prefix directory on Windows (C:\\Python\*, for example).
155 - Install the SCons build engine (a Python module) in the standard Python library directory
156 (/usr/lib/python\*/site-packages or C:\\Python*\\Lib\\site-packages).
161 Because SCons is implemented in a scripting language, you don't need to build
162 it in order to make changes and test them.
164 Virtually all of the SCons functionality exists in the "build engine," the
165 SCons subdirectory hierarchy that contains all of the modules that
166 make up SCons. The scripts/scons.py wrapper script exists mainly to find
167 the appropriate build engine library and then execute it.
169 In order to make your own changes locally and test them by hand, simply edit
170 modules in the local SCons subdirectory tree and then running
171 (see the section above about `Executing SCons Without Installing`_)::
173 $ python scripts/scons.py [arguments]
175 If you want to be able to just execute your modified version of SCons from the
176 command line, you can make it executable and add its directory to your $PATH
179 $ chmod 755 scripts/scons.py
180 $ export PATH=$PATH:`pwd`/scripts
182 You should then be able to run this version of SCons by just typing "scons.py"
183 at your UNIX or Linux command line.
185 Note that the regular SCons development process makes heavy use of automated
186 testing. See the `Testing`_ and `Development Workflow`_ sections below for more
187 information about the automated regression tests and how they can be used in a
188 development cycle to validate that your changes don't break existing
195 Python comes with a good interactive debugger. When debugging changes by hand
196 (i.e., when not using the automated tests), you can invoke SCons under control
197 of the Python debugger by specifying the --debug=pdb option::
199 $ scons --debug=pdb [arguments]
200 > /home/knight/scons/SCons/Script/Main.py(927)_main()
201 -> default_warnings = [ SCons.Warnings.CorruptSConsignWarning,
204 Once in the debugger, you can set breakpoints at lines in files in the build
205 engine modules by providing the path name of the file relative to the
206 top directory (that is, including the SCons/ as the first directory
209 (Pdb) b SCons/Tool/msvc.py:158
211 The debugger also supports single stepping, stepping into functions, printing
214 Trying to debug problems found by running the automated tests (see the
215 `Testing`_ section, below) is more difficult, because the test automation
216 harness re-invokes SCons and captures output. Consequently, there isn't an
217 easy way to invoke the Python debugger in a useful way on any particular SCons
218 call within a test script.
220 The most effective technique for debugging problems that occur during an
221 automated test is to use the good old tried-and-true technique of adding
222 statements to print tracing information. But note that you can't just use
223 the "print" function, or even "sys.stdout.write()" because those change the
224 SCons output, and the automated tests usually look for matches of specific
225 output strings to decide if a given SCons invocation passes the test -
226 so these additions may cause apparent failures different than the one you
229 To deal with this, SCons supports a Trace() function that (by default) will
230 print messages to your console screen ("/dev/tty" on UNIX or Linux, "con" on
231 Windows). By adding Trace() calls to the SCons source code::
233 def sample_method(self, value):
234 from SCons.Debug import Trace
235 Trace('called sample_method(%s, %s)\n' % (self, value))
237 You can then run automated tests that print any arbitrary information you wish
238 about what's going on inside SCons, without interfering with the test
241 The Trace() function can also redirect its output to a file, rather than the
244 def sample_method(self, value):
245 from SCons.Debug import Trace
246 Trace('called sample_method(%s, %s)\n' % (self, value),
249 Where the Trace() function sends its output is stateful: once you use the
250 "file=" argument, all subsequent calls to Trace() send their output to the
251 same file, until another call with a "file=" argument is reached.
257 Tests are run by the runtest.py script in this directory.
259 There are two types of tests in this package:
261 1. Unit tests for individual SCons modules live underneath the SCons
262 subdirectory and have the same base name as the module with "Tests.py"
263 appended--for example, the unit test for the Builder.py module is the
264 BuilderTests.py script.
266 2. End-to-end tests of SCons live in the test/ subdirectory.
268 You may specifically list one or more tests to be run::
270 $ python runtest.py SCons/BuilderTests.py
272 $ python runtest.py test/option-j.py test/Program.py
274 You also use the -f option to execute just the tests listed in a specified
280 $ python runtest.py -f testlist.txt
282 One test must be listed per line, and any lines that begin with '#' will be
283 ignored (allowing you, for example, to comment out tests that are currently
284 passing and then uncomment all of the tests in the file for a final validation
287 The runtest.py script also takes a -a option that searches the tree for all of
288 the tests and runs them::
290 $ python runtest.py -a
292 If more than one test is run, the runtest.py script prints a summary of how
293 many tests passed, failed, or yielded no result, and lists any unsuccessful
296 The above invocations all test directly the files underneath the SCons/
297 subdirectory, and do not require that a build be performed first.
302 Caveat: The point of this section isn't to describe one dogmatic workflow.
303 Just running the test suite can be time-consuming, and getting a patch to
304 pass all of the tests can be more so. If you're genuinely blocked, it may
305 make more sense to submit a patch with a note about which tests still
306 fail, and how. Someone else may be able to take your "initial draft" and
307 figure out how to improve it to fix the rest of the tests. So there's
308 plenty of room for use of good judgement.
310 The various techniques described in the above sections can be combined to
311 create simple and effective workflows that allow you to validate that patches
312 you submit to SCons don't break existing functionality and have adequate
313 testing, thereby increasing the speed with which they can be integrated.
315 For example, suppose your project's SCons configuration is blocked by an SCons
316 bug, and you decide you want to fix it and submit the patch. Here's one
317 possible way to go about doing that (using UNIX/Linux as the development
318 platform, Windows users can translate as appropriate)):
320 - Change to the top of your checked-out SCons tree.
322 - Confirm that the bug still exists in this version of SCons by using the -C
323 option to run the broken build::
325 $ python scripts/scons.py -C /home/me/broken_project .
327 - Fix the bug in SCons by editing appropriate module files underneath
330 - Confirm that you've fixed the bug affecting your project::
332 $ python scripts/scons.py -C /home/me/broken_project .
334 - Test to see if your fix had any unintended side effects that break existing
337 $ python runtest.py -a -o test.log
339 Be patient, there are more than 1100 test scripts in the whole suite. If you
340 are on UNIX/Linux, you can use::
342 $ python runtest.py -a | tee test.log
344 instead so you can monitor progress from your terminal.
346 If any test scripts fail, they will be listed in a summary at the end of the
347 log file. Some test scripts may also report NO RESULT because (for example)
348 your local system is the wrong type or doesn't have some installed utilities
349 necessary to run the script. In general, you can ignore the NO RESULT list,
350 beyond having checked once that the tests that matter to your change are
351 actually being executed on your test system!
353 - Cut-and-paste the list of failed tests into a file::
356 test/failed-test-1.py
357 test/failed-test-2.py
358 test/failed-test-3.py
362 - Now debug the test failures and fix them, either by changing SCons, or by
363 making necessary changes to the tests (if, for example, you have a strong
364 reason to change functionality, or if you find that the bug really is in the
365 test script itself). After each change, use the runtest.py -f option to
366 examine the effects of the change on the subset of tests that originally
370 $ python runtest.py -f failed.txt
372 Repeat this until all of the tests that originally failed now pass.
374 - Now you need to go back and validate that any changes you made while getting
375 the tests to pass didn't break the fix you originally put in, and didn't
376 introduce any *additional* unintended side effects that broke other tests::
378 $ python scripts/scons.py -C /home/me/broken_project .
379 $ python runtest.py -a -o test.log
381 If you find any newly-broken tests, add them to your "failed.txt" file and
382 go back to the previous step.
384 Of course, the above is only one suggested workflow. In practice, there is a
385 lot of room for judgment and experience to make things go quicker. For
386 example, if you're making a change to just the Java support, you might start
387 looking for regressions by just running the test/Java/\*.py tests instead of
388 running all of "runtest.py -a".
394 We use SCons (version 3.1.2 or later) to build its own packages. If you
395 already have an appropriate version of SCons installed on your system, you can
396 build everything by simply running it::
400 If you don't have SCons already installed on your
401 system, you can use the supplied bootstrap.py script (see the section above
402 about `Executing SCons Without Installing`_)::
404 $ python scripts/scons.py build/scons
406 Depending on the utilities installed on your system, any or all of the
407 following packages will be built::
409 SCons-4.0.0-py3-none-any.whl
410 SCons-4.2.0ayyyymmdd.tar.gz
411 SCons-4.2.0ayyyymmdd.zip
412 scons-doc-4.2.0ayyyymmdd.tar.gz
413 scons-local-4.2.0ayyyymmdd.tar.gz
414 scons-local-4.2.0ayyyymmdd.zip
416 The SConstruct file is supposed to be smart enough to avoid trying to build
417 packages for which you don't have the proper utilities installed.
419 If you receive a build error, please report it to the scons-devel mailing list
420 and open a bug report on the SCons bug tracker.
422 Note that in addition to creating the above packages, the default build will
423 also unpack one or more of the packages for testing.
426 Contents of this Package
427 ========================
429 Not guaranteed to be up-to-date (but better than nothing):
432 A subdirectory for benchmarking scripts, used to perform timing tests
433 to decide what specific idioms are most efficient for various parts of
434 the code base. We check these in so they're available in case we have
435 to revisit any of these decisions in the future.
438 Miscellaneous utilities used in SCons development. Right now,
439 some of the stuff here includes:
441 - a script that runs pychecker on our source tree;
443 - a script that counts source and test files and numbers of lines in each;
445 - a prototype script for capturing sample SCons output in xml files;
447 - a script that can profile and time a packaging build of SCons itself;
449 - a copy of xml_export, which can retrieve project data from SourceForge;
452 - scripts and a Python module for translating the SCons home-brew XML
453 documentation tags into DocBook and man page format
457 Obsolete packaging logic.
461 Files needed to construct a Debian package. The contents of this directory
462 are dictated by the Debian Policy Manual
463 (http://www.debian.org/doc/debian-policy). The package will not be
464 accepted into the Debian distribution unless the contents of this
465 directory satisfy the relevant Debian policies.
468 SCons documentation. A variety of things here, in various stages of
472 A copy of the copyright and terms under which SCons is distributed (the
473 Open Source Initiative-approved MIT license).
476 A copy of the copyright and terms under which SCons is distributed for
477 inclusion in the scons-local-{version} packages. This is the same as
478 LICENSE with a preamble that specifies the licensing terms are for SCons
479 itself, not any other package that includes SCons.
482 What you're looking at right now.
485 A README file for inclusion in the scons-local-{version} packages.
486 Similar to this file, but stripped down and modified for people looking at
487 including SCons in their shipped software.
490 Script for running SCons tests. By default, this will run a test against
491 the code in the local SCons tree, so you don't have to do a build before
492 testing your changes.
495 The file describing to SCons how to build the SCons distribution.
497 (It has been pointed out that it's hard to find the SCons API in this
498 SConstruct file, and that it looks a lot more like a pure Python script
499 than a build configuration file. That's mainly because all of the magick
500 we have to perform to deal with all of the different packaging formats
501 requires a lot of pure Python manipulation. In other words, don't look at
502 this file for an example of how easy it is to use SCons to build "normal"
506 Where the actual source code is kept, of course.
509 End-to-end tests of the SCons utility itself. These are separate from the
510 individual module unit tests, which live side-by-side with the modules
514 SCons testing framework.
519 See the RELEASE.txt file for notes about this specific release, including
520 known problems. See the CHANGES.txt file for a list of changes since the
523 The doc/man/scons.1 man page is included in this package, and contains a
524 section of small examples for getting started using SCons.
526 Additional documentation for SCons is available at:
528 http://www.scons.org/documentation.html
530 Documentation toolchain
531 =======================
533 For an overview see https://github.com/SCons/scons/blob/master/doc/overview.rst
538 SCons is distributed under the MIT license, a full copy of which is available
545 The SCons project welcomes bug reports and feature requests.
547 Please make sure you send email with the problem or feature request to
548 the SCons users mailing list, which you can join via the link below:
550 http://two.pairlist.net/mailman/listinfo/scons-users
552 Once you have discussed your issue on the users mailing list and the
553 community has confirmed that it is either a new bug or a duplicate of an
554 existing bug, then please follow the instructions the community provides
555 to file a new bug or to add yourself to the CC list for an existing bug
557 You can explore the list of existing bugs, which may include workarounds
558 for the problem you've run into on GitHub Issues:
560 https://github.com/SCons/scons/issues
566 An active mailing list for developers of SCons is available. You may
567 send questions or comments to the list at:
571 You may subscribe to the developer's mailing list using form on this page:
573 http://two.pairlist.net/mailman/listinfo/scons-dev
575 Subscription to the developer's mailing list is by approval. In practice, no
576 one is refused list membership, but we reserve the right to limit membership
577 in the future and/or weed out lurkers.
579 There are other mailing lists available for SCons users, for notification of
580 SCons code changes, and for notification of updated bug reports and project
581 documents. Please see our mailing lists page for details.
587 If you find SCons helpful, please consider making a donation (of cash,
588 software, or hardware) to support continued work on the project. Information
591 http://www.scons.org/donate.html
595 GitHub Sponsors button on https://github.com/scons/scons
601 Check the SCons web site at:
603 http://www.scons.org/
609 SCons was originally written by Steven Knight, knight at baldmt dot com.
610 Since around 2010 it has been maintained by the SCons
611 development team, co-managed by Bill Deegan and Gary Oberbrunner, with
612 many contributors, including but not at all limited to:
626 - Christoph Wiedemann
630 \... and many others.
632 Copyright (c) 2001 - 2020 The SCons Foundation