Update PR #3384's CHANGE.txt entry to include a note about the changed behavior
[scons.git] / README.rst
blob1d7b85800b7af6853a7fccd75e351fc34c5ed935
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
6    :alt: IRC
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
29 Welcome to the SCons development tree.  The real purpose of this tree is to
30 package SCons for production distribution in a variety of formats, not just to
31 hack SCons code.
33 If all you want to do is install and run SCons, it will be easier for you to
34 download and install the scons-{version}.tar.gz or scons-{version}.zip package
35 rather than to work with the packaging logic in this tree.
37 To the extent that this tree is about building SCons packages, the *full*
38 development cycle is not just to test the code directly, but to package SCons,
39 unpack the package, "install" SCons in a test subdirectory, and then to run
40 the tests against the unpacked and installed software.  This helps eliminate
41 problems caused by, for example, failure to update the list of files to be
42 packaged.
44 For just working on making an individual change to the SCons source, however,
45 you don't actually need to build or install SCons; you *can* actually edit and
46 execute SCons in-place.  See the following sections below for more
47 information:
49     `Making Changes`_
50         How to edit and execute SCons in-place.
52     `Debugging`_
53         Tips for debugging problems in SCons.
55     `Testing`_
56         How to use the automated regression tests.
58     `Development Workflow`_
59         An example of how to put the edit/execute/test pieces
60         together in a reasonable development workflow.
63 Latest Version
64 ==============
66 Before going further, you can check that the package you have is the latest
67 version at the SCons download page:
69         http://www.scons.org/pages/download.html
72 Execution Requirements
73 ======================
75 Running SCons requires Python 3.5 or higher. There should be no other
76 dependencies or requirements to run scons
78 The default SCons configuration assumes use of the Microsoft Visual C++
79 compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++
80 compiler named 'c++', and a Fortran compiler named 'gfortran' (such as found
81 in the GNU C compiler suite) on any other type of system.  You may, of course,
82 override these default values by appropriate configuration of Environment
83 construction variables.
85 By default, SCons knows how to search for available programming tools on
86 various systems--see the SCons man page for details.  You may, of course,
87 override the default SCons choices made by appropriate configuration of
88 Environment construction variables.
91 Installation Requirements
92 =========================
94 Nothing special.
97 Executing SCons Without Installing
98 ==================================
100 You can execute the SCons directly from this repository. For Linux or UNIX::
102     $ python scripts/scons.py [arguments]
104 Or on Windows::
106     C:\scons>python scripts\scons.py [arguments]
108 If you run SCons this way, it will execute `SConstruct` file for this repo,
109 which will build and pack SCons itself. Use the -C option to change directory
110 to your project::
112     $ python scripts/scons.py -C /some/other/location [arguments]
115 Installation
116 ============
118     Note: You don't need to build SCons packages or install SCons if you just
119     want to work on developing a patch.  See the sections about `Making
120     Changes`_ and `Testing`_ below if you just want to submit a bug fix or
121     some new functionality.
123 Assuming your system satisfies the installation requirements in the previous
124 section, install SCons from this package by first populating the build/scons/
125 subdirectory.  (For an easier way to install SCons, without having to populate
126 this directory, use the scons-{version}.tar.gz or scons-{version}.zip
127 package.)
130 Install the built SCons files
131 -----------------------------
133 Any of the above commands will populate the build/scons/ directory with the
134 necessary files and directory structure to use the Python-standard setup
135 script as follows on Linux or UNIX::
137         # python setup.py install
139 Or on Windows::
141         C:\scons>python setup.py install
143 By default, the above commands will do the following:
145 - Install scripts named "scons" and "sconsign" scripts in the default system
146   script directory (/usr/bin or C:\\Python\*\\Scripts, for example).
148 - Install "scons-3.1.2.exe" and "scons.exe" executables in the Python
149   prefix directory on Windows (C:\\Python\*, for example).
151 - Install the SCons build engine (a Python module) in the standard Python library directory
152   (/usr/lib/python\*/site-packages or C:\\Python*\\Lib\\site-packages).
154 Making Changes
155 ==============
157 Because SCons is implemented in a scripting language, you don't need to build
158 it in order to make changes and test them.
160 Virtually all of the SCons functionality exists in the "build engine," the
161 SCons subdirectory hierarchy that contains all of the modules that
162 make up SCons.  The scripts/scons.py wrapper script exists mainly to find
163 the appropriate build engine library and then execute it.
165 In order to make your own changes locally and test them by hand, simply edit
166 modules in the local SCons subdirectory tree and then running
167 (see the section above about `Executing SCons Without Installing`_)::
169     $ python scripts/scons.py [arguments]
171 If you want to be able to just execute your modified version of SCons from the
172 command line, you can make it executable and add its directory to your $PATH
173 like so::
175     $ chmod 755 scripts/scons.py
176     $ export PATH=$PATH:`pwd`/scripts
178 You should then be able to run this version of SCons by just typing "scons.py"
179 at your UNIX or Linux command line.
181 Note that the regular SCons development process makes heavy use of automated
182 testing.  See the `Testing`_ and `Development Workflow`_ sections below for more
183 information about the automated regression tests and how they can be used in a
184 development cycle to validate that your changes don't break existing
185 functionality.
188 Debugging
189 =========
191 Python comes with a good interactive debugger.  When debugging changes by hand
192 (i.e., when not using the automated tests), you can invoke SCons under control
193 of the Python debugger by specifying the --debug=pdb option::
195     $ scons --debug=pdb [arguments]
196     > /home/knight/scons/SCons/Script/Main.py(927)_main()
197     -> default_warnings = [ SCons.Warnings.CorruptSConsignWarning,
198     (Pdb)
200 Once in the debugger, you can set breakpoints at lines in files in the build
201 engine modules by providing the path name of the file relative to the
202 top directory (that is, including the SCons/ as the first directory
203 component)::
205     (Pdb) b SCons/Tool/msvc.py:158
207 The debugger also supports single stepping, stepping into functions, printing
208 variables, etc.
210 Trying to debug problems found by running the automated tests (see the
211 `Testing`_ section, below) is more difficult, because the test automation
212 harness re-invokes SCons and captures output. Consequently, there isn't an
213 easy way to invoke the Python debugger in a useful way on any particular SCons
214 call within a test script.
216 The most effective technique for debugging problems that occur during an
217 automated test is to use the good old tried-and-true technique of adding
218 statements to print tracing information.  But note that you can't just use
219 the "print" function, or even "sys.stdout.write()" because those change the
220 SCons output, and the automated tests usually look for matches of specific
221 output strings to decide if a given SCons invocation passes the test -
222 so these additions may cause apparent failures different than the one you
223 are trying to debug.
225 To deal with this, SCons supports a Trace() function that (by default) will
226 print messages to your console screen ("/dev/tty" on UNIX or Linux, "con" on
227 Windows).  By adding Trace() calls to the SCons source code::
229     def sample_method(self, value):
230         from SCons.Debug import Trace
231         Trace('called sample_method(%s, %s)\n' % (self, value))
233 You can then run automated tests that print any arbitrary information you wish
234 about what's going on inside SCons, without interfering with the test
235 automation.
237 The Trace() function can also redirect its output to a file, rather than the
238 screen::
240     def sample_method(self, value):
241         from SCons.Debug import Trace
242         Trace('called sample_method(%s, %s)\n' % (self, value),
243               file='trace.out')
245 Where the Trace() function sends its output is stateful: once you use the
246 "file=" argument, all subsequent calls to Trace() send their output to the
247 same file, until another call with a "file=" argument is reached.
250 Testing
251 =======
253 Tests are run by the runtest.py script in this directory.
255 There are two types of tests in this package:
257 1. Unit tests for individual SCons modules live underneath the SCons
258    subdirectory and have the same base name as the module with "Tests.py"
259    appended--for example, the unit test for the Builder.py module is the
260    BuilderTests.py script.
262 2. End-to-end tests of SCons live in the test/ subdirectory.
264 You may specifically list one or more tests to be run::
266         $ python runtest.py SCons/BuilderTests.py
268         $ python runtest.py test/option-j.py test/Program.py
270 You also use the -f option to execute just the tests listed in a specified
271 text file::
273         $ cat testlist.txt
274         test/option-j.py
275         test/Program.py
276         $ python runtest.py -f testlist.txt
278 One test must be listed per line, and any lines that begin with '#' will be
279 ignored (allowing you, for example, to comment out tests that are currently
280 passing and then uncomment all of the tests in the file for a final validation
281 run).
283 The runtest.py script also takes a -a option that searches the tree for all of
284 the tests and runs them::
286         $ python runtest.py -a
288 If more than one test is run, the runtest.py script prints a summary of how
289 many tests passed, failed, or yielded no result, and lists any unsuccessful
290 tests.
292 The above invocations all test directly the files underneath the SCons/
293 subdirectory, and do not require that a build be performed first.
295 Development Workflow
296 ====================
298     Caveat: The point of this section isn't to describe one dogmatic workflow.
299     Just running the test suite can be time-consuming, and getting a patch to
300     pass all of the tests can be more so.  If you're genuinely blocked, it may
301     make more sense to submit a patch with a note about which tests still
302     fail, and how.  Someone else may be able to take your "initial draft" and
303     figure out how to improve it to fix the rest of the tests.  So there's
304     plenty of room for use of good judgement.
306 The various techniques described in the above sections can be combined to
307 create simple and effective workflows that allow you to validate that patches
308 you submit to SCons don't break existing functionality and have adequate
309 testing, thereby increasing the speed with which they can be integrated.
311 For example, suppose your project's SCons configuration is blocked by an SCons
312 bug, and you decide you want to fix it and submit the patch.  Here's one
313 possible way to go about doing that (using UNIX/Linux as the development
314 platform, Windows users can translate as appropriate)):
316 - Change to the top of your checked-out SCons tree.
318 - Confirm that the bug still exists in this version of SCons by using the -C
319    option to run the broken build::
321       $ python scripts/scons.py -C /home/me/broken_project .
323 - Fix the bug in SCons by editing appropriate module files underneath
324   SCons.
326 - Confirm that you've fixed the bug affecting your project::
328       $ python scripts/scons.py -C /home/me/broken_project .
330 - Test to see if your fix had any unintended side effects that break existing
331   functionality::
333       $ python runtest.py -a -o test.log
335   Be patient, there are more than 1100 test scripts in the whole suite.  If you
336   are on UNIX/Linux, you can use::
338       $ python runtest.py -a | tee test.log
340   instead so you can monitor progress from your terminal.
342   If any test scripts fail, they will be listed in a summary at the end of the
343   log file.  Some test scripts may also report NO RESULT because (for example)
344   your local system is the wrong type or doesn't have some installed utilities
345   necessary to run the script.  In general, you can ignore the NO RESULT list,
346   beyond having checked once that the tests that matter to your change are
347   actually being executed on your test system!
349 - Cut-and-paste the list of failed tests into a file::
351       $ cat > failed.txt
352       test/failed-test-1.py
353       test/failed-test-2.py
354       test/failed-test-3.py
355       ^D
356       $
358 - Now debug the test failures and fix them, either by changing SCons, or by
359   making necessary changes to the tests (if, for example, you have a strong
360   reason to change functionality, or if you find that the bug really is in the
361   test script itself).  After each change, use the runtest.py -f option to
362   examine the effects of the change on the subset of tests that originally
363   failed::
365       $ [edit]
366       $ python runtest.py -f failed.txt
368   Repeat this until all of the tests that originally failed now pass.
370 - Now you need to go back and validate that any changes you made while getting
371   the tests to pass didn't break the fix you originally put in, and didn't
372   introduce any *additional* unintended side effects that broke other tests::
374       $ python scripts/scons.py -C /home/me/broken_project .
375       $ python runtest.py -a -o test.log
377   If you find any newly-broken tests, add them to your "failed.txt" file and
378   go back to the previous step.
380 Of course, the above is only one suggested workflow.  In practice, there is a
381 lot of room for judgment and experience to make things go quicker.  For
382 example, if you're making a change to just the Java support, you might start
383 looking for regressions by just running the test/Java/\*.py tests instead of
384 running all of "runtest.py -a".
387 Building Packages
388 =================
390 We use SCons (version 3.1.2 or later) to build its own packages.  If you
391 already have an appropriate version of SCons installed on your system, you can
392 build everything by simply running it::
394         $ scons
396 If you don't have SCons already installed on your
397 system, you can use the supplied bootstrap.py script (see the section above
398 about `Executing SCons Without Installing`_)::
400         $ python scripts/scons.py build/scons
402 Depending on the utilities installed on your system, any or all of the
403 following packages will be built::
405     SCons-4.0.0-py3-none-any.whl
406     SCons-4.2.0ayyyymmdd.tar.gz
407     SCons-4.2.0ayyyymmdd.zip
408     scons-doc-4.2.0ayyyymmdd.tar.gz
409     scons-local-4.2.0ayyyymmdd.tar.gz
410     scons-local-4.2.0ayyyymmdd.zip
412 The SConstruct file is supposed to be smart enough to avoid trying to build
413 packages for which you don't have the proper utilities installed.
415 If you receive a build error, please report it to the scons-devel mailing list
416 and open a bug report on the SCons bug tracker.
418 Note that in addition to creating the above packages, the default build will
419 also unpack one or more of the packages for testing.
422 Contents of this Package
423 ========================
425 Not guaranteed to be up-to-date (but better than nothing):
427 bench/
428     A subdirectory for benchmarking scripts, used to perform timing tests
429     to decide what specific idioms are most efficient for various parts of
430     the code base.  We check these in so they're available in case we have
431     to revisit any of these decisions in the future.
433 bin/
434     Miscellaneous utilities used in SCons development.  Right now,
435     some of the stuff here includes:
437     - a script that runs pychecker on our source tree;
439     - a script that counts source and test files and numbers of lines in each;
441     - a prototype script for capturing sample SCons output in xml files;
443     - a script that can profile and time a packaging build of SCons itself;
445     - a copy of xml_export, which can retrieve project data from SourceForge;
446       and
448     - scripts and a Python module for translating the SCons home-brew XML
449       documentation tags into DocBook and man page format
452 bootstrap.py
453     Obsolete packaging logic.
456 debian/
457     Files needed to construct a Debian package. The contents of this directory
458     are dictated by the Debian Policy Manual
459     (http://www.debian.org/doc/debian-policy). The package will not be
460     accepted into the Debian distribution unless the contents of this
461     directory satisfy the relevant Debian policies.
463 doc/
464     SCons documentation.  A variety of things here, in various stages of
465     (in)completeness.
467 LICENSE
468     A copy of the copyright and terms under which SCons is distributed (the
469     Open Source Initiative-approved MIT license).
471 LICENSE-local
472     A copy of the copyright and terms under which SCons is distributed for
473     inclusion in the scons-local-{version} packages.  This is the same as
474     LICENSE with a preamble that specifies the licensing terms are for SCons
475     itself, not any other package that includes SCons.
477 README.rst
478     What you're looking at right now.
480 README-local
481     A README file for inclusion in the scons-local-{version} packages.
482     Similar to this file, but stripped down and modified for people looking at
483     including SCons in their shipped software.
485 runtest.py
486     Script for running SCons tests.  By default, this will run a test against
487     the code in the local SCons tree, so you don't have to do a build before
488     testing your changes.
490 SConstruct
491     The file describing to SCons how to build the SCons distribution.
493     (It has been pointed out that it's hard to find the SCons API in this
494     SConstruct file, and that it looks a lot more like a pure Python script
495     than a build configuration file.  That's mainly because all of the magick
496     we have to perform to deal with all of the different packaging formats
497     requires a lot of pure Python manipulation.  In other words, don't look at
498     this file for an example of how easy it is to use SCons to build "normal"
499     software.)
501 SCons/
502     Where the actual source code is kept, of course.
504 test/
505     End-to-end tests of the SCons utility itself.  These are separate from the
506     individual module unit tests, which live side-by-side with the modules
507     under SCons.
509 testing/
510     SCons testing framework.
512 Documentation
513 =============
515 See the RELEASE.txt file for notes about this specific release, including
516 known problems.  See the CHANGES.txt file for a list of changes since the
517 previous release.
519 The doc/man/scons.1 man page is included in this package, and contains a
520 section of small examples for getting started using SCons.
522 Additional documentation for SCons is available at:
524         http://www.scons.org/documentation.html
526 Documentation toolchain
527 =======================
529 For an overview see https://github.com/SCons/scons/blob/master/doc/overview.rst
531 Licensing
532 =========
534 SCons is distributed under the MIT license, a full copy of which is available
535 in the LICENSE file.
538 Reporting Bugs
539 ==============
541 The SCons project welcomes bug reports and feature requests.
543 Please make sure you send email with the problem or feature request to
544 the SCons users mailing list, which you can join via the link below:
546         http://two.pairlist.net/mailman/listinfo/scons-users
548 Once you have discussed your issue on the users mailing list and the
549 community has confirmed that it is either a new bug or a duplicate of an
550 existing bug, then please follow the instructions the community provides
551 to file a new bug or to add yourself to the CC list for an existing bug
553 You can explore the list of existing bugs, which may include workarounds
554 for the problem you've run into on GitHub Issues:
556         https://github.com/SCons/scons/issues
559 Mailing Lists
560 =============
562 An active mailing list for developers of SCons is available.  You may
563 send questions or comments to the list at:
565         scons-dev@scons.org
567 You may subscribe to the developer's mailing list using form on this page:
569         http://two.pairlist.net/mailman/listinfo/scons-dev
571 Subscription to the developer's mailing list is by approval.  In practice, no
572 one is refused list membership, but we reserve the right to limit membership
573 in the future and/or weed out lurkers.
575 There are other mailing lists available for SCons users, for notification of
576 SCons code changes, and for notification of updated bug reports and project
577 documents.  Please see our mailing lists page for details.
580 Donations
581 =========
583 If you find SCons helpful, please consider making a donation (of cash,
584 software, or hardware) to support continued work on the project.  Information
585 is available at:
587         http://www.scons.org/donate.html
591 GitHub Sponsors button on https://github.com/scons/scons
594 For More Information
595 ====================
597 Check the SCons web site at:
599         http://www.scons.org/
602 Author Info
603 ===========
605 SCons was originally written by Steven Knight, knight at baldmt dot com.
606 Since around 2010 it has been maintained by the SCons
607 development team, co-managed by Bill Deegan and Gary Oberbrunner, with
608 many contributors, including but not at all limited to:
610 - Chad Austin
611 - Dirk Baechle
612 - Charles Crain
613 - William Deegan
614 - Steve Leblanc
615 - Rob Managan
616 - Greg Noel
617 - Gary Oberbrunner
618 - Anthony Roach
619 - Greg Spencer
620 - Tom Tanner
621 - Anatoly Techtonik
622 - Christoph Wiedemann
623 - Russel Winder
624 - Mats Wichmann
626 \... and many others.
628 Copyright (c) 2001 - 2020 The SCons Foundation