From 6c596f1833a9e169e97356721d82a1ccf5fa37cc Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Mon, 3 Nov 2003 23:29:02 +0000 Subject: Sync CVS log from master Aegis repository. --- HOWTO/change.txt | 20 +- HOWTO/release.txt | 68 +++---- bin/linecount | 9 + doc/SConscript | 2 + doc/user/alias.in | 10 +- doc/user/alias.sgml | 40 ++-- doc/user/builders-built-in.in | 385 +++++++++++++++++++++++++++++++++++---- doc/user/builders-built-in.sgml | 383 ++++++++++++++++++++++++++++++++++---- doc/user/builders-commands.in | 4 +- doc/user/builders-commands.sgml | 12 +- doc/user/caching.in | 34 ++-- doc/user/caching.sgml | 53 +++--- doc/user/default.in | 16 +- doc/user/default.sgml | 39 ++-- doc/user/environments.in | 100 +++++----- doc/user/environments.sgml | 142 ++++++++------- doc/user/help.in | 4 +- doc/user/help.sgml | 7 +- doc/user/install.in | 23 ++- doc/user/install.sgml | 36 ++-- doc/user/libraries.in | 34 ++-- doc/user/libraries.sgml | 66 ++++--- doc/user/precious.in | 11 +- doc/user/precious.sgml | 17 +- doc/user/run.in | 54 +++++- doc/user/run.sgml | 53 +++++- doc/user/simple.in | 149 +++++++++++---- doc/user/simple.sgml | 207 +++++++++++++++------ src/engine/SCons/Node/FS.py | 62 ++++++- src/engine/SCons/Sig/SigTests.py | 36 ++++ src/engine/SCons/Sig/__init__.py | 36 ++-- src/script/sconsign.py | 9 +- test/SConsignFile.py | 3 +- test/sconsign-script.py | 4 +- 34 files changed, 1577 insertions(+), 551 deletions(-) diff --git a/HOWTO/change.txt b/HOWTO/change.txt index ff94988..e0d020f 100644 --- a/HOWTO/change.txt +++ b/HOWTO/change.txt @@ -30,28 +30,28 @@ Handling a change set: -- Distribute the change to scons-aedist: - aedist -s -p scons.0.92 {cnum} > scons.0.92.C{cnum}.ae - pine -attach scons.0.92.C{cnum}.ae scons-aedist@lists.sourceforge.net - Subject: scons.0.92 - {SUMMARY} - Body: aegis -l -p scons.0.92 -c {cnum} cd + aedist -s -p scons.0.93 {cnum} > scons.0.93.C{cnum}.ae + pine -attach scons.0.93.C{cnum}.ae scons-aedist@lists.sourceforge.net + Subject: scons.0.93 - {SUMMARY} + Body: aegis -l -p scons.0.93 -c {cnum} cd - rm scons.0.92.C{cnum}.ae + rm scons.0.93.C{cnum}.ae [This will eventually be automated.] -- Update the aedist baseline on the web site: - aedist -s -bl -p scons.0.92 > scons.0.92.ae - scp scons.0.92.ae stevenknight@scons.sourceforge.net:/home/groups/s/sc/scons/htdocs/scons.0.92.ae - rm scons.0.92.ae + aedist -s -bl -p scons.0.93 > scons.0.93.ae + scp scons.0.93.ae stevenknight@scons.sourceforge.net:/home/groups/s/sc/scons/htdocs/scons.0.93.ae + rm scons.0.93.ae [This will eventually be automated.] -- Distribute the change to CVS: export CVS_RSH=ssh - ae2cvs -n -aegis -p scons.0.92 -c {cnum} -u ~/SCons/scons - ae2cvs -X -aegis -p scons.0.92 -c {cnum} -u ~/SCons/scons + ae2cvs -n -aegis -p scons.0.93 -c {cnum} -u ~/SCons/scons + ae2cvs -X -aegis -p scons.0.93 -c {cnum} -u ~/SCons/scons If you need the "ae2cvs" Perl script, you can find a copy checked in to the bin/subdirectory. diff --git a/HOWTO/release.txt b/HOWTO/release.txt index f93c5a8..e89c709 100644 --- a/HOWTO/release.txt +++ b/HOWTO/release.txt @@ -41,11 +41,11 @@ Things to do to release a new version of SCons: ae_p scons.0 - aede {92} + aede {93} - aerpass {92} + aerpass {93} - aeib {92} + aeib {93} aeb @@ -59,16 +59,16 @@ Things to do to release a new version of SCons: START THE NEW BRANCH FOR RELEASE - aenbr -p scons.0 {93} + aenbr -p scons.0 {94} - aenc -p scons.0.{93} + aenc -p scons.0.{94} Call it something like, "Initialize the new branch for release." Cause = internal_enhancement. Exempt it from all tests (*_exempt = true). - ae_p scons.0.{93} + ae_p scons.0.{94} aedb 100 @@ -146,16 +146,16 @@ Things to do to release a new version of SCons: cd incoming bin - put scons-0.{93}-1.noarch.rpm - put scons-0.{93}-1.src.rpm - put scons-0.{93}.tar.gz - put scons-0.{93}.win32.exe - put scons-0.{93}.zip - put scons-local-0.{93}.tar.gz - put scons-local-0.{93}.zip - put scons-src-0.{93}.tar.gz - put scons-src-0.{93}.zip - put scons_0.{93}-1_all.deb + put scons-0.{94}-1.noarch.rpm + put scons-0.{94}-1.src.rpm + put scons-0.{94}.tar.gz + put scons-0.{94}.win32.exe + put scons-0.{94}.zip + put scons-local-0.{94}.tar.gz + put scons-local-0.{94}.zip + put scons-src-0.{94}.tar.gz + put scons-src-0.{94}.zip + put scons_0.{94}-1_all.deb Create the new release at the SourceForge project page: @@ -167,7 +167,7 @@ Things to do to release a new version of SCons: => Add Release - New release name: 0.{93} + New release name: 0.{94} Cut-and-paste or upload the RELEASE.txt file. @@ -184,12 +184,12 @@ Things to do to release a new version of SCons: Edit the file info: - scons-0.{93}-1.noarch.rpm Any .rpm - scons-0.{93}-1.src.rpm Any Source .rpm - scons-0.{93}.tar.gz Any .gz - scons-0.{93}.win32.exe i386 .exe (32-bit Windows) - scons-0.{93}.zip Any .zip - scons_0.{93}-1_all.deb Any .deb + scons-0.{94}-1.noarch.rpm Any .rpm + scons-0.{94}-1.src.rpm Any Source .rpm + scons-0.{94}.tar.gz Any .gz + scons-0.{94}.win32.exe i386 .exe (32-bit Windows) + scons-0.{94}.zip Any .zip + scons_0.{94}-1_all.deb Any .deb Click "Update/Refresh" for each file; this must be done one at a time. @@ -206,7 +206,7 @@ Things to do to release a new version of SCons: => Add Release - New release name: 0.{93} + New release name: 0.{94} Cut-and-paste or upload the RELEASE.txt file. @@ -223,8 +223,8 @@ Things to do to release a new version of SCons: Edit the file info: - scons-local-0.{93}.tar.gz Any .gz - scons-local-0.{93}.zip Any .zip + scons-local-0.{94}.tar.gz Any .gz + scons-local-0.{94}.zip Any .zip Click "Update/Refresh" for each file; this must be done one at a time. @@ -241,7 +241,7 @@ Things to do to release a new version of SCons: => Add Release - New release name: 0.{93} + New release name: 0.{94} Cut-and-paste or upload the RELEASE.txt file. @@ -258,8 +258,8 @@ Things to do to release a new version of SCons: Edit the file info: - scons-src-0.{93}.tar.gz Any .gz - scons-src-0.{93}.zip Any .zip + scons-src-0.{94}.tar.gz Any .gz + scons-src-0.{94}.zip Any .zip Click "Update/Refresh" for each file; this must be done one at a time. @@ -268,7 +268,7 @@ Things to do to release a new version of SCons: Release Notice section. - Hide release {0.90} at the SourceForge download page: + Hide release 0.{92} at the SourceForge download page: Go to the Admin page @@ -278,7 +278,7 @@ Things to do to release a new version of SCons: => Edit Releases - Release Name: {0.90} + Release Name: 0.{92} => Edit This Release @@ -295,7 +295,7 @@ Things to do to release a new version of SCons: => Edit Releases - Release Name: {0.90} + Release Name: 0.{92} => Edit This Release @@ -312,7 +312,7 @@ Things to do to release a new version of SCons: => Edit Releases - Release Name: {0.90} + Release Name: 0.{92} => Edit This Release @@ -322,7 +322,7 @@ Things to do to release a new version of SCons: - In the Bugs Tracker, add a Group for the new release {0.92} + In the Bugs Tracker, add a Group for the new release 0.{92} diff --git a/bin/linecount b/bin/linecount index 6034208..e344e2a 100644 --- a/bin/linecount +++ b/bin/linecount @@ -55,8 +55,17 @@ nbsl = filter(lambda x: x != '', slines) nctl = filter(lambda x: x[0] != '#', nbtl) ncsl = filter(lambda x: x[0] != '#', nbsl) +def ratio(over, under): + return "%.2f" % (float(len(over)) / float(len(under))) + +rfiles = ratio(tests, sources) +rlines = ratio(tlines, slines) +rnonblank = ratio(nbtl, nbsl) +rnoncomment = ratio(nctl, ncsl) + fmt = "%-8s %12s %12s %12s %12s" print fmt % ('', 'files', 'lines', 'non-blank', 'non-comment') print fmt % ('tests:', len(tests), len(tlines), len(nbtl), len(nctl)) print fmt % ('sources:', len(sources), len(slines), len(nbsl), len(ncsl)) +print fmt % ('ratio:', rfiles, rlines, rnonblank, rnoncomment) diff --git a/doc/SConscript b/doc/SConscript index b973fd4..976e0a6 100644 --- a/doc/SConscript +++ b/doc/SConscript @@ -174,6 +174,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. orig_env.Install(build, s) else: orig_env.SCons_revision(os.path.join(build, s), s) + Local(os.path.join(build, s)) # # For each document, build the document itself in HTML, Postscript, @@ -190,6 +191,7 @@ THIS IS AN AUTOMATICALLY-GENERATED FILE. DO NOT EDIT. else: orig_env.SCons_revision(os.path.join(build, doc, s), os.path.join(doc, s)) + Local(os.path.join(build, doc, s)) main = os.path.join(build, doc, 'main.sgml') out = 'main.out' diff --git a/doc/user/alias.in b/doc/user/alias.in index 22fc128..6cc68b0 100644 --- a/doc/user/alias.in +++ b/doc/user/alias.in @@ -50,7 +50,7 @@ - scons install + scons -Q install @@ -95,8 +95,8 @@ - scons install-bin - scons install-lib - scons -c __ROOT__/ - scons install + scons -Q install-bin + scons -Q install-lib + scons -Q -c __ROOT__/ + scons -Q install diff --git a/doc/user/alias.sgml b/doc/user/alias.sgml index 3f48ee0..a4b65da 100644 --- a/doc/user/alias.sgml +++ b/doc/user/alias.sgml @@ -45,7 +45,9 @@ - % scons install + % scons -Q install + cc -c -o hello.o hello.c + cc -o hello hello.o Install file: "hello" as "/usr/bin/hello" @@ -64,8 +66,8 @@ env = Environment() - p = env.Program('hello.c') - l = env.Library('hello.c') + p = env.Program('foo.c') + l = env.Library('bar.c') env.Install('/usr/bin', p) env.Install('/usr/lib', l) ib = env.Alias('install-bin', '/usr/bin') @@ -83,12 +85,28 @@ - % scons install-bin - Install file: "hello" as "/usr/bin/hello" - % scons install-lib - Install file: "libhello.a" as "/usr/lib/libhello.a" - % scons -c / - % scons install - Install file: "hello" as "/usr/bin/hello" - Install file: "libhello.a" as "/usr/lib/libhello.a" + % scons -Q install-bin + cc -c -o foo.o foo.c + cc -o foo foo.o + Install file: "foo" as "/usr/bin/foo" + % scons -Q install-lib + cc -c -o bar.o bar.c + ar r libbar.a bar.o + ranlib libbar.a + Install file: "libbar.a" as "/usr/lib/libbar.a" + % scons -Q -c / + Removed foo.o + Removed foo + Removed /usr/bin/foo + Removed bar.o + Removed libbar.a + Removed /usr/lib/libbar.a + % scons -Q install + cc -c -o foo.o foo.c + cc -o foo foo.o + Install file: "foo" as "/usr/bin/foo" + cc -c -o bar.o bar.c + ar r libbar.a bar.o + ranlib libbar.a + Install file: "libbar.a" as "/usr/lib/libbar.a" diff --git a/doc/user/builders-built-in.in b/doc/user/builders-built-in.in index 89f0af3..1d00a10 100644 --- a/doc/user/builders-built-in.in +++ b/doc/user/builders-built-in.in @@ -33,6 +33,9 @@ This section will describe all of the different types of files that you can build with &SCons;, and the built-in &Builder; objects used to build them. + By default, all of the &Builder; objects in this section + can be built either with or without an explicit + construction environment. @@ -52,8 +55,7 @@ - env = Environment() - env.Program('prog', 'file1.o') + Program('prog', 'file1.o') @@ -95,15 +97,14 @@ If you omit the ⌖, the base of the first input file name specified - because the base of the target + becomes the base of the target program created. For example: - env = Environment() - env.Program(['hello.c', 'goodbye.c']) + Program(['hello.c', 'goodbye.c']) @@ -114,6 +115,96 @@ + + + Two construction variables control what libraries + will be linked with the resulting program. + The &LIBS; variable is a list of the names of + libraries that will be linked into any programs, + and the &LIBPATH; variables is a list of + directories that will be searched for + the specified libraries. + &SCons; will construct the right command-line + options for the running system. + For example: + + + + + + env = Environment(LIBS = ['foo1', 'foo2'], + LIBPATH = ['/usr/dir1', 'dir2']) + env.Program(['hello.c', 'goodbye.c']) + + + int hello() { printf("Hello, world!\n"); } + + + int goodbye() { printf("Goodbye, world!\n"); } + + + + + + Will execute as follows on a POSIX system: + + + + + scons -Q + + + + + And execute as follows on a Windows system: + + + + + scons -Q + + + + + The &LIBS; construction variable + is turned into command line options + by appending the &LIBLINKPREFIX; and &LIBLINKSUFFIX; + construction variables to the beginning and end, + respectively, of each specified library. + + + + + + The &LIBPATH; construction variable + is turned into command line options + by appending the &LIBDIRPREFIX; and &LIBDIRSUFFIX; + construction variables to the beginning and end, + respectively, of each specified library. + + + + + + Other relevant construction variables + include those used by the &Object; + builders to affect how the + source files specified as input to the &Program; + builders are turned into object files; + see the next section. + + + + + + The command line used to control how a program is linked + is specified by the &LINKCOM; construction variable. + By default, it uses the + &LINK; construction variable + and the &LINKFLAGS; construction variable. + + +
@@ -122,7 +213,9 @@ &SCons; provides separate Builder objects - to create both static and shared object files. + to create static and shared object files. + The distinction becomes especially important when + archiving object files into different types of libraries. @@ -131,18 +224,78 @@ - XXX + The &StaticObject; Builder + is used to build an object file + suitable for static linking into a program, + or for inclusion in a static library. + The &source; argument is a single source-code file, + and the ⌖ argument is the + name of the static object file to be created. + For example: - XXX + StaticObject('file', 'file.c') + + + Will create the &file_o; + object file on a POSIX system, + the &file_obj; executable on a Windows system. + + + + + + The target file's prefix and suffix may be omitted, + and the values from the + $OBJPREFIX + and + $OBJSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(OBJPREFIX='my', OBJSUFFIX='.xxx') + env.StaticObject('file', 'file.c') + + + + + Will create an object file named + myfile.xxx + regardless of the system on which it is run. + + + + + + If you omit the ⌖, + the base of the first input + file name specified + beomces the base of the name + of the static object file to be created. + For example: + + + - XXX + StaticObject('file.c') + + + Will create the &file_o; + executable on a POSIX system, + the &file_obj; executable on a Windows system. + + +
@@ -150,36 +303,87 @@ - XXX + The &SharedObject; Builder + is used to build an object file + suitable for shared linking into a program, + or for inclusion in a shared library. + The &source; argument is a single source-code file, + and the ⌖ argument is the + name of the shared object file to be created. + For example: - XXX + SharedObject('file', 'file.c') - - XXX - + -
+ Will create the &file_o; + object file on a POSIX system, + the &file_obj; executable on a Windows system. -
- The &Object; Builder + - XXX + The target file's prefix and suffix may be omitted, + and the values from the + $SHOBJPREFIX + and + $SHOBJSUFFIX + construction variables + will be appended appropriately. + For example: - XXX + env = Environment(SHOBJPREFIX='my', SHOBJSUFFIX='.xxx') + env.SharedObject('file', 'file.c') - Creates a static object file. + Will create an object file named + myfile.xxx + regardless of the system on which it is run. + + + + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name + of the shared object file to be created. + For example: + + + + + SharedObject('file.c') + + + + + Will create the &file_o; + executable on a POSIX system, + the &file_obj; executable on a Windows system. + + + +
+ +
+ The &Object; Builder + + + + The &Object; Builder is a synonym for &StaticObject; + and is completely equivalent. @@ -193,7 +397,7 @@ &SCons; provides separate Builder objects - to create both static and shared libraries. + to create static and shared libraries. @@ -202,18 +406,73 @@ - XXX + The &StaticLibrary; Builder + is used to create a library + suitable for static linking into a program. + The &source; argument is one or more + source-code files or object files, + and the ⌖ argument is the + name of the static library to be created. + For example: - XXX + StaticLibrary('foo', ['file1.c', 'file2.c']) + + + The target file's prefix and suffix may be omitted, + and the values from the + $LIBPREFIX + and + $LIBSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(LIBPREFIX='my', LIBSUFFIX='.xxx') + env.StaticLibrary('lib', ['file1.o', 'file2.o']) + + + + + Will create an object file named + mylib.xxx + regardless of the system on which it is run. + + + + + StaticLibrary('foo', ['file1.c', 'file2.c']) + + + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name of the static object file to be created. + For example: + + + - XXX + StaticLibrary(['file.c', 'another.c']) + + + Will create the &libfile_a; + library on a POSIX system, + the &file_lib; library on a Windows system. + + +
@@ -221,32 +480,82 @@ - XXX + The &SharedLibrary; Builder + is used to create a shared library + suitable for linking with a program. + The &source; argument is one or more + source-code files or object files, + and the ⌖ argument is the + name of the shared library to be created. + For example: -
+ + SharedLibrary('foo', ['file1.c', 'file2.c']) + -
- The &Library; Builder + + + The target file's prefix and suffix may be omitted, + and the values from the + $SHLIBPREFIX + and + $SHLIBSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(SHLIBPREFIX='my', SHLIBSUFFIX='.xxx') + env.SharedLibrary('shared', ['file1.o', 'file2.o']) + - XXX + Will create an object file named + myshared.xxx + regardless of the system on which it is run. - XXX + SharedLibrary('foo', ['file1.c', 'file2.c']) + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name of the shared library to be created. + For example: + + + - XXX + SharedLibrary(['file.c', 'another.c']) - Creates a static library file. + Will create the &libfile_so; + library on a POSIX system, + the &file_dll; library on a Windows system. + + + +
+ +
+ The &Library; Builder + + + + The &Library; Builder is a synonym for &StaticLibrary; + and is completely equivalent. @@ -285,6 +594,8 @@ &SCons; supports two Builder objects that know how to build source files from other input files. + These are typically invoked "internally" + to turn files that need preprocessing into other source files. @@ -428,7 +739,7 @@ - scons . + scons -Q . @@ -457,7 +768,7 @@ - scons . + scons -Q . @@ -482,7 +793,7 @@ - scons . + scons -Q .
@@ -524,7 +835,7 @@ - scons . + scons -Q . @@ -536,7 +847,7 @@ - % scons . + % scons -Q . zip /home/my/project/zip.out file1 file2 diff --git a/doc/user/builders-built-in.sgml b/doc/user/builders-built-in.sgml index bb29cc4..3afbf19 100644 --- a/doc/user/builders-built-in.sgml +++ b/doc/user/builders-built-in.sgml @@ -33,6 +33,9 @@ This section will describe all of the different types of files that you can build with &SCons;, and the built-in &Builder; objects used to build them. + By default, all of the &Builder; objects in this section + can be built either with or without an explicit + construction environment. @@ -52,8 +55,7 @@ - env = Environment() - env.Program('prog', 'file1.o') + Program('prog', 'file1.o') @@ -95,15 +97,14 @@ If you omit the ⌖, the base of the first input file name specified - because the base of the target + becomes the base of the target program created. For example: - env = Environment() - env.Program(['hello.c', 'goodbye.c']) + Program(['hello.c', 'goodbye.c']) @@ -114,6 +115,94 @@ + + + Two construction variables control what libraries + will be linked with the resulting program. + The &LIBS; variable is a list of the names of + libraries that will be linked into any programs, + and the &LIBPATH; variables is a list of + directories that will be searched for + the specified libraries. + &SCons; will construct the right command-line + options for the running system. + For example: + + + + + env = Environment(LIBS = ['foo1', 'foo2'], + LIBPATH = ['/usr/dir1', 'dir2']) + env.Program(['hello.c', 'goodbye.c']) + + + + + Will execute as follows on a POSIX system: + + + + + % scons -Q + cc -c -o goodbye.o goodbye.c + cc -c -o hello.o hello.c + cc -o hello hello.o goodbye.o -L/usr/dir1 -Ldir2 -lfoo1 -lfoo2 + + + + + And execute as follows on a Windows system: + + + + + C:\>scons -Q + cl /nologo /c goodbye.c /Fogoodbye.obj + cl /nologo /c hello.c /Fohello.obj + link /nologo /OUT:hello.exe /LIBPATH:\usr\dir1 /LIBPATH:dir2 foo1.lib foo2.lib hello.obj goodbye.obj + + + + + The &LIBS; construction variable + is turned into command line options + by appending the &LIBLINKPREFIX; and &LIBLINKSUFFIX; + construction variables to the beginning and end, + respectively, of each specified library. + + + + + + The &LIBPATH; construction variable + is turned into command line options + by appending the &LIBDIRPREFIX; and &LIBDIRSUFFIX; + construction variables to the beginning and end, + respectively, of each specified library. + + + + + + Other relevant construction variables + include those used by the &Object; + builders to affect how the + source files specified as input to the &Program; + builders are turned into object files; + see the next section. + + + + + + The command line used to control how a program is linked + is specified by the &LINKCOM; construction variable. + By default, it uses the + &LINK; construction variable + and the &LINKFLAGS; construction variable. + + +
@@ -122,7 +211,9 @@ &SCons; provides separate Builder objects - to create both static and shared object files. + to create static and shared object files. + The distinction becomes especially important when + archiving object files into different types of libraries. @@ -131,18 +222,78 @@ - XXX + The &StaticObject; Builder + is used to build an object file + suitable for static linking into a program, + or for inclusion in a static library. + The &source; argument is a single source-code file, + and the ⌖ argument is the + name of the static object file to be created. + For example: - XXX + StaticObject('file', 'file.c') + + + Will create the &file_o; + object file on a POSIX system, + the &file_obj; executable on a Windows system. + + + + + + The target file's prefix and suffix may be omitted, + and the values from the + $OBJPREFIX + and + $OBJSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(OBJPREFIX='my', OBJSUFFIX='.xxx') + env.StaticObject('file', 'file.c') + + + + + Will create an object file named + myfile.xxx + regardless of the system on which it is run. + + + + + + If you omit the ⌖, + the base of the first input + file name specified + beomces the base of the name + of the static object file to be created. + For example: + + + - XXX + StaticObject('file.c') + + + Will create the &file_o; + executable on a POSIX system, + the &file_obj; executable on a Windows system. + + +
@@ -150,36 +301,87 @@ - XXX + The &SharedObject; Builder + is used to build an object file + suitable for shared linking into a program, + or for inclusion in a shared library. + The &source; argument is a single source-code file, + and the ⌖ argument is the + name of the shared object file to be created. + For example: - XXX + SharedObject('file', 'file.c') - - XXX - + -
+ Will create the &file_o; + object file on a POSIX system, + the &file_obj; executable on a Windows system. -
- The &Object; Builder + - XXX + The target file's prefix and suffix may be omitted, + and the values from the + $SHOBJPREFIX + and + $SHOBJSUFFIX + construction variables + will be appended appropriately. + For example: - XXX + env = Environment(SHOBJPREFIX='my', SHOBJSUFFIX='.xxx') + env.SharedObject('file', 'file.c') - Creates a static object file. + Will create an object file named + myfile.xxx + regardless of the system on which it is run. + + + + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name + of the shared object file to be created. + For example: + + + + + SharedObject('file.c') + + + + + Will create the &file_o; + executable on a POSIX system, + the &file_obj; executable on a Windows system. + + + +
+ +
+ The &Object; Builder + + + + The &Object; Builder is a synonym for &StaticObject; + and is completely equivalent. @@ -193,7 +395,7 @@ &SCons; provides separate Builder objects - to create both static and shared libraries. + to create static and shared libraries. @@ -202,18 +404,73 @@ - XXX + The &StaticLibrary; Builder + is used to create a library + suitable for static linking into a program. + The &source; argument is one or more + source-code files or object files, + and the ⌖ argument is the + name of the static library to be created. + For example: - XXX + StaticLibrary('foo', ['file1.c', 'file2.c']) + + + + + The target file's prefix and suffix may be omitted, + and the values from the + $LIBPREFIX + and + $LIBSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(LIBPREFIX='my', LIBSUFFIX='.xxx') + env.StaticLibrary('lib', ['file1.o', 'file2.o']) + + + + + Will create an object file named + mylib.xxx + regardless of the system on which it is run. + + + + + StaticLibrary('foo', ['file1.c', 'file2.c']) + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name of the static object file to be created. + For example: + + + - XXX + StaticLibrary(['file.c', 'another.c']) + + + Will create the &libfile_a; + library on a POSIX system, + the &file_lib; library on a Windows system. + + +
@@ -221,32 +478,82 @@ - XXX + The &SharedLibrary; Builder + is used to create a shared library + suitable for linking with a program. + The &source; argument is one or more + source-code files or object files, + and the ⌖ argument is the + name of the shared library to be created. + For example: -
+ + SharedLibrary('foo', ['file1.c', 'file2.c']) + -
- The &Library; Builder + + + The target file's prefix and suffix may be omitted, + and the values from the + $SHLIBPREFIX + and + $SHLIBSUFFIX + construction variables + will be appended appropriately. + For example: + + + + + env = Environment(SHLIBPREFIX='my', SHLIBSUFFIX='.xxx') + env.SharedLibrary('shared', ['file1.o', 'file2.o']) + - XXX + Will create an object file named + myshared.xxx + regardless of the system on which it is run. - XXX + SharedLibrary('foo', ['file1.c', 'file2.c']) + + + If you omit the ⌖, + the base of the first input + file name specified + becomes the base of the name of the shared library to be created. + For example: + + + - XXX + SharedLibrary(['file.c', 'another.c']) - Creates a static library file. + Will create the &libfile_so; + library on a POSIX system, + the &file_dll; library on a Windows system. + + + +
+ +
+ The &Library; Builder + + + + The &Library; Builder is a synonym for &StaticLibrary; + and is completely equivalent. @@ -285,6 +592,8 @@ &SCons; supports two Builder objects that know how to build source files from other input files. + These are typically invoked "internally" + to turn files that need preprocessing into other source files. @@ -417,7 +726,7 @@ - % scons . + % scons -Q . tar -c -f out1.tar file1 file2 tar -c -f out2.tar directory @@ -443,7 +752,7 @@ - % scons . + % scons -Q . tar -c -z -f out.tar.gz directory @@ -464,7 +773,7 @@ - % scons . + % scons -Q . tar -c -z -f out.tgz directory @@ -499,7 +808,7 @@ - % scons . + % scons -Q . zip("out.zip", ["file1", "file2"]) @@ -512,7 +821,7 @@ - % scons . + % scons -Q . zip /home/my/project/zip.out file1 file2 diff --git a/doc/user/builders-commands.in b/doc/user/builders-commands.in index 5fc2c73..2c72bbd 100644 --- a/doc/user/builders-commands.in +++ b/doc/user/builders-commands.in @@ -80,7 +80,7 @@ - scons . + scons -Q @@ -112,5 +112,5 @@ - scons . + scons -Q diff --git a/doc/user/builders-commands.sgml b/doc/user/builders-commands.sgml index e21f6d0..64c81e5 100644 --- a/doc/user/builders-commands.sgml +++ b/doc/user/builders-commands.sgml @@ -71,12 +71,12 @@ env = Environment() - env.Command('foo.out', 'foo.in', "sed 's/x/y/' < $TARGET > $SOURCE") + env.Command('foo.out', 'foo.in', "sed 's/x/y/' < $SOURCE > $TARGET") - % scons . - sed 's/x/y' < foo.in > foo.out + % scons -Q + sed 's/x/y/' < foo.in > foo.out @@ -96,13 +96,13 @@ env = Environment() - def build(target, source, env) - XXX + def build(target, source, env): + # Whatever it takes to build return None env.Command('foo.out', 'foo.in', build) - % scons . + % scons -Q build("foo.out", "foo.in") diff --git a/doc/user/caching.in b/doc/user/caching.in index 2301784..3c87761 100644 --- a/doc/user/caching.in +++ b/doc/user/caching.in @@ -93,9 +93,9 @@ - scons - scons -c - scons + scons -Q + scons -Q -c + scons -Q
@@ -129,9 +129,9 @@ - scons - scons -c - scons --cache-show + scons -Q + scons -Q -c + scons -Q --cache-show @@ -176,11 +176,11 @@ - scons - scons -c - scons - scons -c - scons --cache-disable + scons -Q + scons -Q -c + scons -Q + scons -Q -c + scons -Q --cache-disable @@ -217,12 +217,12 @@ - scons --cache-disable - scons -c - scons --cache-disable - scons --cache-force - scons -c - scons + scons -Q --cache-disable + scons -Q -c + scons -Q --cache-disable + scons -Q --cache-force + scons -Q -c + scons -Q diff --git a/doc/user/caching.sgml b/doc/user/caching.sgml index 3d9158e..223592e 100644 --- a/doc/user/caching.sgml +++ b/doc/user/caching.sgml @@ -81,16 +81,15 @@ - % scons - cc -c hello.c -o hello.o + % scons -Q + cc -c -o hello.o hello.c cc -o hello hello.o - % scons -c + % scons -Q -c Removed hello.o Removed hello - % scons + % scons -Q Retrieved `hello.o' from cache Retrieved `hello' from cache - % @@ -124,16 +123,15 @@ - % scons - cc -c hello.c -o hello.o + % scons -Q + cc -c -o hello.o hello.c cc -o hello hello.o - % scons -c + % scons -Q -c Removed hello.o Removed hello - % scons --cache-show - cc -c hello.c -o hello.o + % scons -Q --cache-show + cc -c -o hello.o hello.c cc -o hello hello.o - % @@ -178,22 +176,21 @@ - % scons - cc -c hello.c -o hello.o + % scons -Q + cc -c -o hello.o hello.c cc -o hello hello.o - % scons -c + % scons -Q -c Removed hello.o Removed hello - % scons + % scons -Q Retrieved `hello.o' from cache Retrieved `hello' from cache - % scons -c + % scons -Q -c Removed hello.o Removed hello - % scons --cache-disable - cc -c hello.c -o hello.o + % scons -Q --cache-disable + cc -c -o hello.o hello.c cc -o hello hello.o - % @@ -230,23 +227,23 @@ - % scons --cache-disable - cc -c hello.c -o hello.o + % scons -Q --cache-disable + cc -c -o hello.o hello.c cc -o hello hello.o - % scons -c + % scons -Q -c Removed hello.o Removed hello - % scons --cache-disable - cc -c hello.c -o hello.o + % scons -Q --cache-disable + cc -c -o hello.o hello.c cc -o hello hello.o - % scons --cache-force - % scons -c + % scons -Q --cache-force + scons: `.' is up to date. + % scons -Q -c Removed hello.o Removed hello - % scons + % scons -Q Retrieved `hello.o' from cache Retrieved `hello' from cache - % diff --git a/doc/user/default.in b/doc/user/default.in index dbe6ecd..2410da6 100644 --- a/doc/user/default.in +++ b/doc/user/default.in @@ -100,9 +100,9 @@ default list. - scons - scons - scons goodbye + scons -Q + scons -Q + scons -Q goodbye @@ -117,7 +117,7 @@ default list. - scons . + scons -Q . @@ -176,8 +176,8 @@ default list. - scons - scons . + scons -Q + scons -Q . @@ -211,6 +211,6 @@ default list. - scons - scons . + scons -Q + scons -Q . diff --git a/doc/user/default.sgml b/doc/user/default.sgml index f44719f..fa21bae 100644 --- a/doc/user/default.sgml +++ b/doc/user/default.sgml @@ -92,14 +92,14 @@ default list. - % scons - cc -c hello.c -o hello.o + % scons -Q + cc -c -o hello.o hello.c cc -o hello hello.o - % scons - % scons goodbye - cc -c goodbye.c -o goodbye.o + % scons -Q + scons: `hello' is up to date. + % scons -Q goodbye + cc -c -o goodbye.o goodbye.c cc -o goodbye goodbye.o - % @@ -114,12 +114,11 @@ default list. - % scons . - cc -c goodbye.c -o goodbye.o + % scons -Q . + cc -c -o goodbye.o goodbye.c cc -o goodbye goodbye.o - cc -c hello.c -o hello.o + cc -c -o hello.o hello.c cc -o hello hello.o - % @@ -167,15 +166,14 @@ default list. - % scons - cc -c prog1.c -o prog1.o + % scons -Q + cc -c -o prog1.o prog1.c cc -o prog1 prog1.o - cc -c prog3.c -o prog3.o + cc -c -o prog3.o prog3.c cc -o prog3 prog3.o - % scons . - cc -c prog2.c -o prog2.o + % scons -Q . + cc -c -o prog2.o prog2.c cc -o prog2 prog2.o - % @@ -201,12 +199,11 @@ default list. - % scons + % scons -Q scons: *** No targets specified and no Default() targets found. Stop. - % scons . - cc -c prog1.c -o prog1.o + % scons -Q . + cc -c -o prog1.o prog1.c cc -o prog1 prog1.o - cc -c prog2.c -o prog2.o + cc -c -o prog2.o prog2.c cc -o prog2 prog2.o - % diff --git a/doc/user/environments.in b/doc/user/environments.in index 7f022c1..2083d4f 100644 --- a/doc/user/environments.in +++ b/doc/user/environments.in @@ -410,10 +410,8 @@ environment undisturbed. - A &consenv; is created by the &Environment; - method which you have already seen. - What you haven't seen, though, - is that when you initialize a &consenv;, + A &consenv; is created by the &Environment; method. + When you initialize a &consenv;, you can set the values of the environment's &consvars; to control how a program is built. @@ -422,7 +420,7 @@ environment undisturbed. - + env = Environment(CC = 'gcc', CCFLAGS = '-O2') @@ -446,7 +444,7 @@ environment undisturbed. - scons + scons -Q
@@ -454,36 +452,21 @@ environment undisturbed. - So far, - all of our examples have - created a single &consenv; named - env. - env, however, - is simply a Python variable name, - and you can use any other variable name that you like. - For example: - - - - - my_env = Environment(CC = 'gcc', - CCFLAGS = '-O2') - - my_env.Program('foo.c') - - - - - This opens up the possibility of - using multiple &consenvs;, - each with a separate variable name. - We can then use these separate &consenvs; - to build different programs in different ways: + The real advantage of construction environments + become apparent when you realize + that you can create as many different construction + environments as you need, + each tailored to a different way to build + some piece of software or other file. + If, for example, we need to build + one program with the -O2 flag + and another with the -g (debug) flag, + we would do this like so: - + opt = Environment(CCFLAGS = '-O2') dbg = Environment(CCFLAGS = '-g') @@ -500,7 +483,7 @@ environment undisturbed. - scons + scons -Q @@ -514,7 +497,7 @@ environment undisturbed. - + opt = Environment(CCFLAGS = '-O2') dbg = Environment(CCFLAGS = '-g') @@ -534,7 +517,7 @@ environment undisturbed. - scons + scons -Q @@ -546,6 +529,9 @@ environment undisturbed. -O2 and one with a &CCFLAGS; value of -g. + &SCons; can't just decide that one of them + should take precedence over the other, + so it generates the error. To avoid this problem, we must explicitly specify that each environment compile @@ -559,7 +545,7 @@ environment undisturbed. - + opt = Environment(CCFLAGS = '-O2') dbg = Environment(CCFLAGS = '-g') @@ -579,7 +565,7 @@ environment undisturbed. Notice that each call to the &Object; builder returns a value, an internal &SCons; object that - represents the file that will be built. + represents the object file that will be built. We then use that object as input to the &Program; builder. This avoids having to specify explicitly @@ -591,7 +577,7 @@ environment undisturbed. - scons + scons -Q
@@ -622,7 +608,7 @@ environment undisturbed. that sets &CC; to &gcc;, and then creating two copies, one which sets &CCFLAGS; for optimization - and the other with sets &CCFLAGS; for debugging: + and the other which sets &CCFLAGS; for debugging: @@ -632,7 +618,7 @@ environment undisturbed. opt = env.Copy(CCFLAGS = '-O2') dbg = env.Copy(CCFLAGS = '-g') - e = opt.Object('foo', 'foo.c') + env.Program('foo', 'foo.c') o = opt.Object('foo-opt', 'foo.c') opt.Program(o) @@ -652,7 +638,7 @@ environment undisturbed. - scons + scons -Q @@ -684,8 +670,7 @@ environment undisturbed. - scons - CC is: cc + scons -Q @@ -703,22 +688,31 @@ environment undisturbed. env = Environment(FOO = 'foo', BAR = 'bar') dict = env.Dictionary() - for key, value in dict.items(): - print "key = %s, value = %s % (key, value) + for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: + print "key = %s, value = %s" % (key, dict[key])
This &SConstruct; file - will print the dictionary items for us as follows: + will print the specified dictionary items for us on POSIX + systems as follows: + + + + + scons -Q + + + + + And on Win32: - - % scons - key = FOO, value = foo - key = BAR, value = bar + + scons -Q @@ -765,7 +759,7 @@ environment undisturbed. - scons + scons -Q @@ -793,7 +787,7 @@ environment undisturbed. - scons + scons -Q @@ -821,7 +815,7 @@ environment undisturbed. - scons + scons -Q diff --git a/doc/user/environments.sgml b/doc/user/environments.sgml index 2cba46e..2be8614 100644 --- a/doc/user/environments.sgml +++ b/doc/user/environments.sgml @@ -410,10 +410,8 @@ environment undisturbed. - A &consenv; is created by the &Environment; - method which you have already seen. - What you haven't seen, though, - is that when you initialize a &consenv;, + A &consenv; is created by the &Environment; method. + When you initialize a &consenv;, you can set the values of the environment's &consvars; to control how a program is built. @@ -421,12 +419,12 @@ environment undisturbed. - + env = Environment(CC = 'gcc', CCFLAGS = '-O2') env.Program('foo.c') - + @@ -441,8 +439,8 @@ environment undisturbed. - % scons - gcc -c -O2 foo.c -o foo.o + % scons -Q + gcc -O2 -c -o foo.o foo.c gcc -o foo foo.o @@ -451,31 +449,16 @@ environment undisturbed. - So far, - all of our examples have - created a single &consenv; named - env. - env, however, - is simply a Python variable name, - and you can use any other variable name that you like. - For example: - - - - - my_env = Environment(CC = 'gcc', - CCFLAGS = '-O2') - - my_env.Program('foo.c') - - - - - This opens up the possibility of - using multiple &consenvs;, - each with a separate variable name. - We can then use these separate &consenvs; - to build different programs in different ways: + The real advantage of construction environments + become apparent when you realize + that you can create as many different construction + environments as you need, + each tailored to a different way to build + some piece of software or other file. + If, for example, we need to build + one program with the -O2 flag + and another with the -g (debug) flag, + we would do this like so: @@ -489,10 +472,10 @@ environment undisturbed.
- % scons - cc -c -O2 bar.c -o bar.o + % scons -Q + cc -g -c -o bar.o bar.c cc -o bar bar.o - cc -c -g foo.c -o foo.o + cc -O2 -c -o foo.o foo.c cc -o foo foo.o @@ -522,8 +505,9 @@ environment undisturbed. - % scons - scons: *** Two different environments were specified for the same target: foo.o + % scons -Q + + scons: *** Two different environments were specified for the same target: foo.o File "SConstruct", line 6, in ? @@ -536,6 +520,9 @@ environment undisturbed. -O2 and one with a &CCFLAGS; value of -g. + &SCons; can't just decide that one of them + should take precedence over the other, + so it generates the error. To avoid this problem, we must explicitly specify that each environment compile @@ -546,6 +533,9 @@ environment undisturbed. + + + opt = Environment(CCFLAGS = '-O2') dbg = Environment(CCFLAGS = '-g') @@ -561,7 +551,7 @@ environment undisturbed. Notice that each call to the &Object; builder returns a value, an internal &SCons; object that - represents the file that will be built. + represents the object file that will be built. We then use that object as input to the &Program; builder. This avoids having to specify explicitly @@ -573,10 +563,10 @@ environment undisturbed. - % scons - cc -c -g foo.c -o foo-dbg.o + % scons -Q + cc -g -c -o foo-dbg.o foo.c cc -o foo-dbg foo-dbg.o - cc -c -O2 foo.c -o foo-opt.o + cc -O2 -c -o foo-opt.o foo.c cc -o foo-opt foo-opt.o @@ -608,7 +598,7 @@ environment undisturbed. that sets &CC; to &gcc;, and then creating two copies, one which sets &CCFLAGS; for optimization - and the other with sets &CCFLAGS; for debugging: + and the other which sets &CCFLAGS; for debugging: @@ -617,7 +607,7 @@ environment undisturbed. opt = env.Copy(CCFLAGS = '-O2') dbg = env.Copy(CCFLAGS = '-g') - e = opt.Object('foo', 'foo.c') + env.Program('foo', 'foo.c') o = opt.Object('foo-opt', 'foo.c') opt.Program(o) @@ -633,12 +623,12 @@ environment undisturbed. - % scons - gcc -c foo.c -o foo.o + % scons -Q + gcc -c -o foo.o foo.c gcc -o foo foo.o - gcc -c -g foo.c -o foo-dbg.o + gcc -g -c -o foo-dbg.o foo.c gcc -o foo-dbg foo-dbg.o - gcc -c -O2 foo.c -o foo-opt.o + gcc -O2 -c -o foo-opt.o foo.c gcc -o foo-opt foo-opt.o @@ -669,8 +659,9 @@ environment undisturbed. - % scons + % scons -Q CC is: cc + scons: `.' is up to date. @@ -687,21 +678,38 @@ environment undisturbed. env = Environment(FOO = 'foo', BAR = 'bar') dict = env.Dictionary() - for key, value in dict.items(): - print "key = %s, value = %s % (key, value) + for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']: + print "key = %s, value = %s" % (key, dict[key]) This &SConstruct; file - will print the dictionary items for us as follows: + will print the specified dictionary items for us on POSIX + systems as follows: + + + + + % scons -Q + key = OBJSUFFIX, value = .o + key = LIBSUFFIX, value = .a + key = PROGSUFFIX, value = + scons: `.' is up to date. + + + + + And on Win32: - % scons - key = FOO, value = foo - key = BAR, value = bar + C:\>scons -Q + key = OBJSUFFIX, value = .obj + key = LIBSUFFIX, value = .lib + key = PROGSUFFIX, value = .exe + scons: `.' is up to date. @@ -727,7 +735,7 @@ environment undisturbed. - env = Environment(CCFLAGS = '-DDEFINE1) + env = Environment(CCFLAGS = '-DDEFINE1') env.Program('foo.c') env.Replace(CCFLAGS = '-DDEFINE2') env.Program('bar.c') @@ -740,11 +748,11 @@ environment undisturbed. - % scons - gcc -DDEFINE2 -c bar.c -o bar.o - gcc -o bar bar.o - gcc -DDEFINE2 -c foo.c -o foo.o - gcc -o foo foo.o + % scons -Q + cc -DDEFINE2 -c -o bar.o bar.c + cc -o bar bar.o + cc -DDEFINE1 -c -o foo.o foo.c + cc -o foo foo.o @@ -767,9 +775,9 @@ environment undisturbed. - % scons - gcc -DMY_VALUE -DLAST -c foo.c -o foo.o - gcc -o foo foo.o + % scons -Q + cc -DMY_VALUE -DLAST -c -o foo.o foo.c + cc -o foo foo.o @@ -792,9 +800,9 @@ environment undisturbed. - % scons - gcc -DFIRST -DMY_VALUE -c foo.c -o foo.o - gcc -o foo foo.o + % scons -Q + cc -DFIRST -DMY_VALUE -c -o foo.o foo.c + cc -o foo foo.o diff --git a/doc/user/help.in b/doc/user/help.in index 96e775b..087f3bf 100644 --- a/doc/user/help.in +++ b/doc/user/help.in @@ -28,14 +28,14 @@ It's often very useful to be able to give users some help that describes the specific targets, build options, etc., - that can be used for the build. + that can be used for your build. &SCons; provides the &Help; function to allow you to specify this help text: - + Help(""" Type: 'scons program' to build the production program, 'scons debug' to build the debug version. diff --git a/doc/user/help.sgml b/doc/user/help.sgml index 233809e..72e09aa 100644 --- a/doc/user/help.sgml +++ b/doc/user/help.sgml @@ -28,7 +28,7 @@ It's often very useful to be able to give users some help that describes the specific targets, build options, etc., - that can be used for the build. + that can be used for your build. &SCons; provides the &Help; function to allow you to specify this help text: @@ -60,8 +60,13 @@ % scons -h + scons: Reading SConscript files ... + scons: done reading SConscript files. + Type: 'scons program' to build the production program, 'scons debug' to build the debug version. + + Use scons -H for help about command-line options. diff --git a/doc/user/install.in b/doc/user/install.in index a263f65..370ca9f 100644 --- a/doc/user/install.in +++ b/doc/user/install.in @@ -62,8 +62,8 @@ - scons - scons __ROOT__/usr/bin + scons -Q + scons -Q __ROOT__/usr/bin @@ -100,9 +100,9 @@ - - scons - scons install + + scons -Q + scons -Q install
@@ -127,6 +127,9 @@ int main() { printf("Hello, world!\n"); } + + int main() { printf("Goodbye, world!\n"); } + @@ -152,7 +155,7 @@ - scons install + scons -Q install
@@ -191,7 +194,7 @@ - scons install + scons -Q install @@ -218,10 +221,14 @@ env.InstallAs(['__ROOT__/usr/bin/hello-new', '__ROOT__/usr/bin/goodbye-new'], [hello, goodbye]) + env.Alias('install', '__ROOT__/usr/bin')
int main() { printf("Hello, world!\n"); } + + int main() { printf("Goodbye, world!\n"); } +
@@ -234,7 +241,7 @@ - scons install + scons -Q install diff --git a/doc/user/install.sgml b/doc/user/install.sgml index 7f522e5..b7555b7 100644 --- a/doc/user/install.sgml +++ b/doc/user/install.sgml @@ -57,10 +57,10 @@ - % scons - cc -c hello.c -o hello.o + % scons -Q + cc -c -o hello.o hello.c cc -o hello hello.o - % scons /usr/bin + % scons -Q /usr/bin Install file: "hello" as "/usr/bin/hello" @@ -94,7 +94,10 @@ - % scons install + % scons -Q + cc -c -o hello.o hello.c + cc -o hello hello.o + % scons -Q install Install file: "hello" as "/usr/bin/hello" @@ -113,7 +116,7 @@ hello = env.Program('hello.c') goodbye = env.Program('goodbye.c') env.Install('/usr/bin', hello) - env.Install('/usr/bin', goodbye]) + env.Install('/usr/bin', goodbye) env.Alias('install', '/usr/bin') @@ -140,12 +143,12 @@ - % scons install - cc -c goodbye.c -o goodbye.o + % scons -Q install + cc -c -o goodbye.o goodbye.c cc -o goodbye goodbye.o - cc -c hello.c -o hello.o - cc -o hello hello.o Install file: "goodbye" as "/usr/bin/goodbye" + cc -c -o hello.o hello.c + cc -o hello hello.o Install file: "hello" as "/usr/bin/hello" @@ -180,8 +183,8 @@ - % scons install - cc -c hello.c -o hello.o + % scons -Q install + cc -c -o hello.o hello.c cc -o hello hello.o Install file: "hello" as "/usr/bin/hello-new" @@ -207,8 +210,9 @@ hello = env.Program('hello.c') goodbye = env.Program('goodbye.c') env.InstallAs(['/usr/bin/hello-new', - '/usr/bin/goodbye-new', + '/usr/bin/goodbye-new'], [hello, goodbye]) + env.Alias('install', '/usr/bin') @@ -221,12 +225,12 @@ - % scons install - cc -c goodbye.c -o goodbye.o + % scons -Q install + cc -c -o goodbye.o goodbye.c cc -o goodbye goodbye.o - cc -c hello.c -o hello.o - cc -o hello hello.o Install file: "goodbye" as "/usr/bin/goodbye-new" + cc -c -o hello.o hello.c + cc -o hello hello.o Install file: "hello" as "/usr/bin/hello-new" diff --git a/doc/user/libraries.in b/doc/user/libraries.in index 337b0da..a69bbee 100644 --- a/doc/user/libraries.in +++ b/doc/user/libraries.in @@ -43,8 +43,7 @@ - env = Environment() - env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) + Library('foo', ['f1.c', 'f2.c', 'f3.c']) int main() { printf("Hello, world!\n"); } @@ -69,8 +68,8 @@ - - scons + + scons -Q @@ -80,8 +79,8 @@ - - scons + + scons -Q @@ -110,14 +109,14 @@ and by specifying the directory in which the library will be found in the &LIBPATH; construction variable: + env = Environment(LIBS = 'foo', LIBPATH = '.') - - env = Environment(LIBS = 'foo', LIBPATH = '.') - env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) - env.Program('prog.c') + + Library('foo', ['f1.c', 'f2.c', 'f3.c']) + Program('prog.c', LIBS='foo', LIBPATH='.') int main() { printf("Hello, world!\n"); } @@ -149,8 +148,8 @@ - - scons + + scons -Q @@ -161,7 +160,7 @@ - scons + scons -Q @@ -191,9 +190,8 @@ - env = Environment(LIBS = 'm', + Program('prog.c', LIBS = 'm', LIBPATH = ['/usr/lib', '/usr/local/lib']) - env.Program('prog.c') int main() { printf("prog.c\n"); } @@ -235,8 +233,8 @@ - - scons + + scons -Q @@ -247,7 +245,7 @@ - scons + scons -Q diff --git a/doc/user/libraries.sgml b/doc/user/libraries.sgml index 6fc6c5d..118a560 100644 --- a/doc/user/libraries.sgml +++ b/doc/user/libraries.sgml @@ -42,8 +42,7 @@ - env = Environment() - env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) + Library('foo', ['f1.c', 'f2.c', 'f3.c']) @@ -51,15 +50,15 @@ &SCons; uses the appropriate library prefix and suffix for your system. So on POSIX or Linux systems, the above example would build as follows - (although &ranlib may not be called on all systems): + (although &ranlib; may not be called on all systems): - % scons - cc -c f1.c -o f1.o - cc -c f2.c -o f2.o - cc -c f3.c -o f3.o + % scons -Q + cc -c -o f1.o f1.c + cc -c -o f2.o f2.c + cc -c -o f3.o f3.c ar r libfoo.a f1.o f2.o f3.o ranlib libfoo.a @@ -72,10 +71,10 @@ - C:\>scons - cl /Fof1.obj f1.c - cl /Fof2.obj f2.c - cl /Fof3.obj f3.c + C:\>scons -Q + cl /nologo /c f1.c /Fof1.obj + cl /nologo /c f2.c /Fof2.obj + cl /nologo /c f3.c /Fof3.obj lib /nologo /OUT:foo.lib f1.obj f2.obj f3.obj @@ -105,13 +104,13 @@ and by specifying the directory in which the library will be found in the &LIBPATH; construction variable: + env = Environment(LIBS = 'foo', LIBPATH = '.') - env = Environment(LIBS = 'foo', LIBPATH = '.') - env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) - env.Program('prog.c') + Library('foo', ['f1.c', 'f2.c', 'f3.c']) + Program('prog.c', LIBS='foo', LIBPATH='.') @@ -131,14 +130,14 @@ - % scons - cc -c f1.c -o f1.o - cc -c f2.c -o f2.o - cc -c f3.c -o f3.o + % scons -Q + cc -c -o f1.o f1.c + cc -c -o f2.o f2.c + cc -c -o f3.o f3.c ar r libfoo.a f1.o f2.o f3.o ranlib libfoo.a - cc -c prog.c -o prog.o - cc -o prog -L. -lfoo prog.o + cc -c -o prog.o prog.c + cc -o prog prog.o -L. -lfoo @@ -149,13 +148,13 @@ - C:\>scons - cl /Fof1.obj f1.c - cl /Fof2.obj f2.c - cl /Fof3.obj f3.c + C:\>scons -Q + cl /nologo /c f1.c /Fof1.obj + cl /nologo /c f2.c /Fof2.obj + cl /nologo /c f3.c /Fof3.obj lib /nologo /OUT:foo.lib f1.obj f2.obj f3.obj - cl /Foprog.obj prog.c - link /OUT:prog.exe /LIBPATH:. foo.lib prog.obj + cl /nologo /c prog.c /Foprog.obj + link /nologo /OUT:prog.exe /LIBPATH:. foo.lib prog.obj @@ -184,9 +183,8 @@ - env = Environment(LIBS = 'm', + Program('prog.c', LIBS = 'm', LIBPATH = ['/usr/lib', '/usr/local/lib']) - env.Program('prog.c') @@ -225,9 +223,9 @@ - % scons - cc -c prog.c -o prog.o - cc -o prog -L/usr/lib -L/usr/local/lib -lm prog.o + % scons -Q + cc -c -o prog.o prog.c + cc -o prog prog.o -L/usr/lib -L/usr/local/lib -lm @@ -238,9 +236,9 @@ - C:\>scons - cl /Foprog.obj prog.c - link /nologo /OUT:program.exe /LIBPATH:\usr\lib;\usr\local\lib m.lib prog.obj + C:\>scons -Q + cl /nologo /c prog.c /Foprog.obj + link /nologo /OUT:prog.exe /LIBPATH:\usr\lib /LIBPATH:\usr\local\lib m.lib prog.obj diff --git a/doc/user/precious.in b/doc/user/precious.in index 2be22ec..95a2c56 100644 --- a/doc/user/precious.in +++ b/doc/user/precious.in @@ -55,8 +55,7 @@ which the C method is called. - env = Environment(XXX NEED LIBRARY FLAGS - LIBFLAGS = '-r') + env = Environment() lib = env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) env.Precious(lib) @@ -73,17 +72,19 @@ which the C method is called. - XXX: + Although the output doesn't look any different, + &SCons; does not, in fact, + delete the target library before rebuilding it: - scons + scons -Q - &SCons; will still delete files marked as &Precious; + &SCons; will, however, still delete files marked as &Precious; when the -c option is used. diff --git a/doc/user/precious.sgml b/doc/user/precious.sgml index 26ad345..4453d4b 100644 --- a/doc/user/precious.sgml +++ b/doc/user/precious.sgml @@ -54,26 +54,31 @@ which the C method is called. - env = Environment(XXX NEED LIBRARY FLAGS - LIBFLAGS = '-r') + env = Environment() lib = env.Library('foo', ['f1.c', 'f2.c', 'f3.c']) env.Precious(lib) - XXX: + Although the output doesn't look any different, + &SCons; does not, in fact, + delete the target library before rebuilding it: - % scons - XXX ANY INPUT HERE? + % scons -Q + cc -c -o f1.o f1.c + cc -c -o f2.o f2.c + cc -c -o f3.o f3.c + ar r libfoo.a f1.o f2.o f3.o + ranlib libfoo.a - &SCons; will still delete files marked as &Precious; + &SCons; will, however, still delete files marked as &Precious; when the -c option is used. diff --git a/doc/user/run.in b/doc/user/run.in index 83ca3d2..d8e19f8 100644 --- a/doc/user/run.in +++ b/doc/user/run.in @@ -316,6 +316,28 @@ do an unconstrained build before committing the integration).
+ Command-Line Options + + + + XXX + + + +
+ +
+ Getting at Command-Line Arguments + + + + XXX + + + +
+ +
Selective Builds @@ -357,7 +379,37 @@ do an unconstrained build before committing the integration). - XXX + Users may find themselves supplying + the same command-line options every time + they run &SCons;. + For example, a user might find that it saves time + to always specify a value of -j 2 + to run the builds in parallel. + + + + + + def b(target, source, env): + pass + def s(target, source, env): + return " ..." + a = Action(b, strfunction = s) + env = Environment(BUILDERS = {'A' : a}) + env.A('foo.out', 'foo.in') + + + foo.in + + + + + scons + export SCONSFLAGS="-Q" + scons + + + diff --git a/doc/user/run.sgml b/doc/user/run.sgml index 83ca3d2..9cdb07c 100644 --- a/doc/user/run.sgml +++ b/doc/user/run.sgml @@ -316,6 +316,28 @@ do an unconstrained build before committing the integration).
+ Command-Line Options + + + + XXX + + + +
+ +
+ Getting at Command-Line Arguments + + + + XXX + + + +
+ +
Selective Builds @@ -357,7 +379,36 @@ do an unconstrained build before committing the integration). - XXX + Users may find themselves supplying + the same command-line options every time + they run &SCons;. + For example, a user might find that it saves time + to always specify a value of -j 2 + to run the builds in parallel. + + + + + + + % scons + scons: Reading SConscript files ... + ... + scons: done reading SConscript files. + scons: Building targets ... + scons: `.' is up to date. + scons: done building targets. + % export SCONSFLAGS="-Q" + % scons + scons: Reading SConscript files ... + ... + scons: done reading SConscript files. + scons: Building targets ... + scons: `.' is up to date. + scons: done building targets. + + + diff --git a/doc/user/simple.in b/doc/user/simple.in index df82ea2..3940bc3 100644 --- a/doc/user/simple.in +++ b/doc/user/simple.in @@ -46,8 +46,7 @@ - env = Environment() - env.Program('hello.c') + Program('hello.c') int main() { printf("Hello, world!\n"); } @@ -148,9 +147,8 @@ - env = Environment() # Create an environment. # Arrange to build the "hello" program. - env.Program('hello.c') + Program('hello.c') # "hello.c" is the source file. @@ -166,6 +164,59 @@
+ Making the Output Less Verbose + + + + You've already seen how &SCons; prints + some messages about what it's doing, + surrounding the actual commands used to build the software: + + + + + scons + + + + + These messages emphasize the + order in which &SCons; does its work: + the configuration files + (generically referred to as &SConscript; files) + are read and executed first, + and only then are the target files built. + Among other benefits, these messages help to distinguish between + errors that occur while the configuration files are read, + and errors that occur while targets are being built. + + + + + + The drawback, of course, is that these messages clutter the output. + Fortunately, they're easily disabled by using + the &Q; option when invoking &SCons;: + + + + + scons -Q + + + + + Because we want this User's Guide to focus + on what &SCons; is actually doing, + we're going use the &Q; option + to remove these messages from the + output of all the remaining examples in this Guide. + + + +
+ +
Compiling Multiple Source Files @@ -184,8 +235,7 @@ - env = Environment() - env.Program(['prog.c', 'file1.c', 'file2.c']) + Program(['prog.c', 'file1.c', 'file2.c']) int main() { printf("prog.c\n"); } @@ -205,7 +255,7 @@ - scons + scons -Q @@ -231,8 +281,7 @@ - env = Environment() - env.Program('program', ['main.c', 'file1.c', 'file2.c']) + Program('program', ['main.c', 'file1.c', 'file2.c']) int main() { printf("prog.c\n"); } @@ -252,7 +301,7 @@ - scons + scons -Q @@ -262,7 +311,7 @@ - scons + scons -Q
@@ -298,27 +347,42 @@ - env = Environment() - env.Program('program', Split('main.c file1.c file2.')) + Program('program', Split('main.c file1.c file2.')) + (If you're already familiar with Python, + you'll have realized that this is similar to the + split() method + in the Python standard string module. + Unlike the string.split() method, + however, the &Split; function + does not require a string as input + and will wrap up a single non-string object in a list, + or return its argument untouched if it's already a list. + This comes in handy as a way to make sure + arbitrary values can be passed to &SCons; functions + without having to check the type of the variable by hand.) + + + + + Putting the call to the &Split; function - inside the env.Program call + inside the Program call can also be a little unwieldy. A more readable alternative is to assign the output from the &Split; call to a variable name, and then use the variable when calling the - env.Program function: + Program function: - env = Environment() list = Split('main.c file1.c file2.') - env.Program('program', list) + Program('program', list) @@ -333,11 +397,10 @@ - env = Environment() list = Split('main.c file1.c file2.c') - env.Program('program', list) + Program('program', list)
@@ -359,17 +422,31 @@ - env = Environment() list = Split('main.c file1.c file2.') - env.Program(target = 'program', source = list) + Program(target = 'program', source = list) + + + + + Because the keywords explicitly identify + what each argument is, + you can actually reverse the order if you prefer: + + + + + list = Split('main.c file1.c file2.') + Program(source = list, target = 'program') Whether or not you choose to use keyword arguments - to identify the target and source files - is purely a personal choice; - &SCons; functions the same either way. + to identify the target and source files, + and the order in which you specify them + when using keywords, + are purely personal choices; + &SCons; functions the same regardless. @@ -382,7 +459,7 @@ In order to compile multiple programs within the same &SConstruct; file, - simply call the env.Program method + simply call the Program method multiple times, once for each program you need to build: @@ -390,9 +467,8 @@ - env = Environment() - env.Program('foo.c') - env.Program('bar', ['bar1.c', 'bar2.c']) + Program('foo.c') + Program('bar', ['bar1.c', 'bar2.c']) int main() { printf("foo.c\n"); } @@ -412,7 +488,7 @@ - scons + scons -Q @@ -456,9 +532,8 @@ - env = Environment() - env.Program(Split('foo.c common1.c common2.c')) - env.Program('bar', Split('bar1.c bar2.c common1.c common2.c')) + Program(Split('foo.c common1.c common2.c')) + Program('bar', Split('bar1.c bar2.c common1.c common2.c')) int main() { printf("foo.c\n"); } @@ -482,12 +557,13 @@ &SCons; recognizes that the object files for the &common1_c; and &common2_c; source files each only need to be built once, - even though the files are listed multiple times: + even though the resulting object files are + each linked in to both of the resulting executable programs: - scons + scons -Q @@ -508,9 +584,8 @@ common = ['common1.c', 'common2.c'] foo_files = ['foo.c'] + common bar_files = ['bar1.c', 'bar2.c'] + common - env = Environment() - env.Program('foo', foo_files) - env.Program('bar', bar_files) + Program('foo', foo_files) + Program('bar', bar_files) diff --git a/doc/user/simple.sgml b/doc/user/simple.sgml index d97badc..02a57ef 100644 --- a/doc/user/simple.sgml +++ b/doc/user/simple.sgml @@ -45,8 +45,7 @@ - env = Environment() - env.Program('hello.c') + Program('hello.c') @@ -59,8 +58,12 @@ % scons - cc -c hello.c -o hello.o + scons: Reading SConscript files ... + scons: done reading SConscript files. + scons: Building targets ... + cc -c -o hello.o hello.c cc -o hello hello.o + scons: done building targets. @@ -72,8 +75,12 @@ C:\>scons - cl /Fohello.obj hello.c - link /Fohello.exe hello.obj + scons: Reading SConscript files ... + scons: done reading SConscript files. + scons: Building targets ... + cl /nologo /c hello.c /Fohello.obj + link /nologo /OUT:hello.exe hello.obj + scons: done building targets. @@ -147,9 +154,8 @@ - env = Environment() # Create an environment. # Arrange to build the "hello" program. - env.Program('hello.c') + Program('hello.c') # "hello.c" is the source file. @@ -165,6 +171,67 @@
+ Making the Output Less Verbose + + + + You've already seen how &SCons; prints + some messages about what it's doing, + surrounding the actual commands used to build the software: + + + + + C:\>scons + scons: Reading SConscript files ... + scons: done reading SConscript files. + scons: Building targets ... + cl /nologo /c hello.c /Fohello.obj + link /nologo /OUT:hello.exe hello.obj + scons: done building targets. + + + + + These messages emphasize the + order in which &SCons; does its work: + the configuration files + (generically referred to as &SConscript; files) + are read and executed first, + and only then are the target files built. + Among other benefits, these messages help to distinguish between + errors that occur while the configuration files are read, + and errors that occur while targets are being built. + + + + + + The drawback, of course, is that these messages clutter the output. + Fortunately, they're easily disabled by using + the &Q; option when invoking &SCons;: + + + + + C:\>scons -Q + cl /nologo /c hello.c /Fohello.obj + link /nologo /OUT:hello.exe hello.obj + + + + + Because we want this User's Guide to focus + on what &SCons; is actually doing, + we're going use the &Q; option + to remove these messages from the + output of all the remaining examples in this Guide. + + + +
+ +
Compiling Multiple Source Files @@ -182,8 +249,7 @@ - env = Environment() - env.Program(['prog.c', 'file1.c', 'file2.']) + Program(['prog.c', 'file1.c', 'file2.c']) @@ -193,10 +259,10 @@ - % scons - cc -c file1.c -o file1.o - cc -c file2.c -o file2.o - cc -c prog.c -o prog.o + % scons -Q + cc -c -o file1.o file1.c + cc -c -o file2.o file2.c + cc -c -o prog.o prog.c cc -o prog prog.o file1.o file2.o @@ -222,8 +288,7 @@ - env = Environment() - env.Program('program', ['main.c', 'file1.c', 'file2.']) + Program('program', ['main.c', 'file1.c', 'file2.c']) @@ -233,10 +298,10 @@ - % scons - cc -c file1.c -o file1.o - cc -c file2.c -o file2.o - cc -c main.c -o main.o + % scons -Q + cc -c -o file1.o file1.c + cc -c -o file2.o file2.c + cc -c -o main.o main.c cc -o program main.o file1.o file2.o @@ -247,11 +312,11 @@ - C:\>scons - cl /Fofile1.obj file1.c - cl /Fofile2.obj file2.c - cl /Fomain.obj main.c - link /Foprogram.exe main.obj file1.obj file2.obj + C:\>scons -Q + cl /nologo /c file1.c /Fofile1.obj + cl /nologo /c file2.c /Fofile2.obj + cl /nologo /c main.c /Fomain.obj + link /nologo /OUT:program.exe main.obj file1.obj file2.obj
@@ -287,27 +352,42 @@
- env = Environment() - env.Program('program', Split('main.c file1.c file2.')) + Program('program', Split('main.c file1.c file2.')) + (If you're already familiar with Python, + you'll have realized that this is similar to the + split() method + in the Python standard string module. + Unlike the string.split() method, + however, the &Split; function + does not require a string as input + and will wrap up a single non-string object in a list, + or return its argument untouched if it's already a list. + This comes in handy as a way to make sure + arbitrary values can be passed to &SCons; functions + without having to check the type of the variable by hand.) + + + + + Putting the call to the &Split; function - inside the env.Program call + inside the Program call can also be a little unwieldy. A more readable alternative is to assign the output from the &Split; call to a variable name, and then use the variable when calling the - env.Program function: + Program function: - env = Environment() list = Split('main.c file1.c file2.') - env.Program('program', list) + Program('program', list) @@ -322,11 +402,10 @@ - env = Environment() list = Split('main.c file1.c file2.c') - env.Program('program', list) + Program('program', list) @@ -348,17 +427,31 @@
- env = Environment() list = Split('main.c file1.c file2.') - env.Program(target = 'program', source = list) + Program(target = 'program', source = list) + + + + + Because the keywords explicitly identify + what each argument is, + you can actually reverse the order if you prefer: + + + + + list = Split('main.c file1.c file2.') + Program(source = list, target = 'program') Whether or not you choose to use keyword arguments - to identify the target and source files - is purely a personal choice; - &SCons; functions the same either way. + to identify the target and source files, + and the order in which you specify them + when using keywords, + are purely personal choices; + &SCons; functions the same regardless. @@ -371,16 +464,15 @@ In order to compile multiple programs within the same &SConstruct; file, - simply call the env.Program method + simply call the Program method multiple times, once for each program you need to build:
- env = Environment() - env.Program('foo.c') - env.Program('bar', ['bar1.c', 'bar2.c']) + Program('foo.c') + Program('bar', ['bar1.c', 'bar2.c']) @@ -390,11 +482,11 @@ - % scons - cc -c bar1.c -o bar1.o - cc -c bar2.c -o bar2.o + % scons -Q + cc -c -o bar1.o bar1.c + cc -c -o bar2.o bar2.c cc -o bar bar1.o bar2.o - cc -c foo.c -o foo.o + cc -c -o foo.o foo.c cc -o foo foo.o @@ -438,9 +530,8 @@
- env = Environment() - env.Program(Split('foo.c common1.c common2.c')) - env.Program('bar', Split('bar1.c bar2.c common1.c common2.c')) + Program(Split('foo.c common1.c common2.c')) + Program('bar', Split('bar1.c bar2.c common1.c common2.c')) @@ -448,18 +539,19 @@ &SCons; recognizes that the object files for the &common1_c; and &common2_c; source files each only need to be built once, - even though the files are listed multiple times: + even though the resulting object files are + each linked in to both of the resulting executable programs: - % scons - cc -c bar1.c -o bar1.o - cc -c bar2.c -o bar2.o - cc -c common1.c -o common1.o - cc -c common2.c -o common2.o + % scons -Q + cc -c -o bar1.o bar1.c + cc -c -o bar2.o bar2.c + cc -c -o common1.o common1.c + cc -c -o common2.o common2.c cc -o bar bar1.o bar2.o common1.o common2.o - cc -c foo.c -o foo.o + cc -c -o foo.o foo.c cc -o foo foo.o common1.o common2.o @@ -481,9 +573,8 @@ common = ['common1.c', 'common2.c'] foo_files = ['foo.c'] + common bar_files = ['bar1.c', 'bar2.c'] + common - env = Environment() - env.Program('foo', foo_files) - env.Program('bar', bar_files) + Program('foo', foo_files) + Program('bar', bar_files) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index a78a2c9..cffa2b5 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -41,6 +41,7 @@ import os.path import shutil import stat import string +import cStringIO import SCons.Action import SCons.Errors @@ -720,7 +721,7 @@ class FS: self._cwd = dir if change_os_dir: os.chdir(dir.abspath) - except: + except OSError: self._cwd = curr raise @@ -902,6 +903,17 @@ class FS: message = "building associated BuildDir targets: %s" % string.join(map(str, targets)) return targets, message +class DummyExecutor: + """Dummy executor class returned by Dir nodes to bamboozle SCons + into thinking we are an actual derived node, where our sources are + our directory entries.""" + def get_raw_contents(self): + return '' + def get_contents(self): + return '' + def get_timestamp(self): + return 0 + class Dir(Base): """A class for directories in a file system. """ @@ -924,12 +936,14 @@ class Dir(Base): self.abspath_ = self.abspath + os.sep self.repositories = [] self.srcdir = None + self.source_scanner = None self.entries = {} self.entries['.'] = self self.entries['..'] = self.dir self.cwd = self self.builder = 1 + self.searched = 0 self._sconsign = None self.build_dirs = [] @@ -1023,6 +1037,19 @@ class Dir(Base): self.all_children(scan)) def all_children(self, scan=1): + # Before we traverse our children, make sure we have created Nodes + # for any files that this directory contains. We need to do this + # so any change in a file in this directory will cause it to + # be out of date. + if not self.searched: + try: + for filename in os.listdir(self.abspath): + if filename != '.sconsign': + self.Entry(filename) + except OSError: + # Directory does not exist. No big deal + pass + self.searched = 1 keys = filter(lambda k: k != '.' and k != '..', self.entries.keys()) kids = map(lambda x, s=self: s.entries[x], keys) def c(one, two): @@ -1051,10 +1078,6 @@ class Dir(Base): """A directory does not get scanned.""" return None - def calc_signature(self, calc): - """A directory has no signature.""" - return None - def set_bsig(self, bsig): """A directory has no signature.""" bsig = None @@ -1064,9 +1087,12 @@ class Dir(Base): csig = None def get_contents(self): - """Return a fixed "contents" value of a directory.""" - return '' - + """Return aggregate contents of all our children.""" + contents = cStringIO.StringIO() + for kid in self.children(None): + contents.write(kid.get_contents()) + return contents.getvalue() + def prepare(self): pass @@ -1110,6 +1136,24 @@ class Dir(Base): return self.srcdir return Base.srcnode(self) + def get_executor(self, create=1): + """Fetch the action executor for this node. Create one if + there isn't already one, and requested to do so.""" + try: + executor = self.executor + except AttributeError: + executor = DummyExecutor() + self.executor = executor + return executor + + def get_timestamp(self): + """Return the latest timestamp from among our children""" + stamp = 0 + for kid in self.children(None): + if kid.get_timestamp() > stamp: + stamp = kid.get_timestamp() + return stamp + class File(Base): """A class for files in a file system. """ @@ -1432,7 +1476,7 @@ class File(Base): def rfile(self): try: return self._rfile - except: + except AttributeError: self._rfile = self if not self.exists(): n = self.fs.Rsearch(self.path, clazz=File, diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index c82d2c5..f297464 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -490,6 +490,41 @@ class SConsignDirFileTestCase(unittest.TestCase): assert f.get('foo') == (3, 1, 2) assert f.get_implicit('foo') == ['bar'] +class SConsignFileTestCase(unittest.TestCase): + + def runTest(self): + test = TestCmd.TestCmd(workdir = '') + file = test.workpath('sconsign_file') + + assert SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db + + SCons.Sig.SConsignFile(file) + + assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db + + class Fake_DBM: + def open(self, name, mode): + self.name = name + self.mode = mode + return self + + fake_dbm = Fake_DBM() + + SCons.Sig.SConsignFile(file, fake_dbm) + + assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db + assert not hasattr(fake_dbm, 'name'), fake_dbm + assert not hasattr(fake_dbm, 'mode'), fake_dbm + + SCons.Sig.SConsign_db = None + + SCons.Sig.SConsignFile(file, fake_dbm) + + assert not SCons.Sig.SConsign_db is None, SCons.Sig.SConsign_db + assert fake_dbm.name == file, fake_dbm.name + assert fake_dbm.mode == "c", fake_dbm.mode + + def suite(): suite = unittest.TestSuite() @@ -500,6 +535,7 @@ def suite(): suite.addTest(_SConsignTestCase()) suite.addTest(SConsignDBTestCase()) suite.addTest(SConsignDirFileTestCase()) + suite.addTest(SConsignFileTestCase()) return suite if __name__ == "__main__": diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 298db66..a2ebd5c 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -51,10 +51,6 @@ sig_files = [] SConsign_db = None -# 1 means use build signature for derived source files -# 0 means use content signature for derived source files -build_signature = 1 - def write(): global sig_files for sig_file in sig_files: @@ -121,7 +117,7 @@ class _SConsign: """ try: return self.entries[filename] - except: + except (KeyError, AttributeError): return SConsignEntry() def set_entry(self, filename, entry): @@ -202,6 +198,8 @@ class SConsignDB(_SConsign): if type(self.entries) is not type({}): self.entries = {} raise TypeError + except KeyboardInterrupt: + raise except: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt sconsign entry : %s"%self.dir.path) @@ -213,7 +211,11 @@ class SConsignDB(_SConsign): if self.dirty: global SConsign_db SConsign_db[self.dir.path] = cPickle.dumps(self.entries, 1) - SConsign_db.sync() + try: + SConsign_db.sync() + except AttributeError: + # Not all anydbm modules have sync() methods. + pass class SConsignDir(_SConsign): def __init__(self, fp=None, module=None): @@ -244,11 +246,13 @@ class SConsignDirFile(SConsignDir): try: fp = open(self.sconsign, 'rb') - except: + except IOError: fp = None try: SConsignDir.__init__(self, fp, module) + except KeyboardInterrupt: + raise except: SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning, "Ignoring corrupt .sconsign file: %s"%self.sconsign) @@ -274,11 +278,11 @@ class SConsignDirFile(SConsignDir): try: file = open(temp, 'wb') fname = temp - except: + except IOError: try: file = open(self.sconsign, 'wb') fname = self.sconsign - except: + except IOError: return cPickle.dump(self.entries, file, 1) file.close() @@ -287,29 +291,31 @@ class SConsignDirFile(SConsignDir): mode = os.stat(self.sconsign)[0] os.chmod(self.sconsign, 0666) os.unlink(self.sconsign) - except: + except OSError: pass try: os.rename(fname, self.sconsign) - except: + except OSError: open(self.sconsign, 'wb').write(open(fname, 'rb').read()) os.chmod(self.sconsign, mode) try: os.unlink(temp) - except: + except OSError: pass SConsignForDirectory = SConsignDirFile -def SConsignFile(name): +def SConsignFile(name, dbm_module=None): """ Arrange for all signatures to be stored in a global .sconsign.dbm file. """ global SConsign_db if SConsign_db is None: - import anydbm - SConsign_db = anydbm.open(name, "c") + if dbm_module is None: + import anydbm + dbm_module = anydbm + SConsign_db = dbm_module.open(name, "c") global SConsignForDirectory SConsignForDirectory = SConsignDB diff --git a/src/script/sconsign.py b/src/script/sconsign.py index 015f1db..cc9e58d 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -80,6 +80,7 @@ if sys.platform == 'win32': # sys.prefix is (likely) C:\Python*; # check only C:\Python*. prefs.append(sys.prefix) + prefs.append(os.path.join(sys.prefix, 'Lib', 'site-packages')) else: # On other (POSIX) platforms, things are more complicated due to # the variety of path names and library locations. Try to be smart @@ -121,7 +122,13 @@ else: # check only /foo/lib/scons*. prefs.append(sys.prefix) - prefs = map(lambda x: os.path.join(x, 'lib'), prefs) + temp = map(lambda x: os.path.join(x, 'lib'), prefs) + temp.extend(map(lambda x: os.path.join(x, + 'lib', + 'python' + sys.version[:3], + 'site-packages'), + prefs)) + prefs = temp # Look first for 'scons-__version__' in all of our preference libs, # then for 'scons'. diff --git a/test/SConsignFile.py b/test/SConsignFile.py index 29f2af2..606f20b 100644 --- a/test/SConsignFile.py +++ b/test/SConsignFile.py @@ -77,7 +77,8 @@ test.fail_test(os.path.exists(test.workpath('work1', 'subdir', '.sconsign'))) # test.write(['work2', 'SConstruct'], """ -SConsignFile('my_sconsign') +e = Environment(XXX = 'scons') +e.SConsignFile('my_${XXX}ign') B = Builder(action = "%s ../build.py $TARGETS $SOURCES") env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'f5.out', source = 'f5.in') diff --git a/test/sconsign-script.py b/test/sconsign-script.py index a5c0aa7..24e23a0 100644 --- a/test/sconsign-script.py +++ b/test/sconsign-script.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (c) 2001, 2002, 2003 Steven Knight +# __COPYRIGHT__ # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -22,7 +22,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "/home/scons/scons/branch.0/baseline/test/sconsign.py 0.90.D001 2003/06/25 15:32:24 knight" +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import string -- cgit v0.12