summaryrefslogtreecommitdiff
path: root/bootstrap.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2007-01-07 07:23:05 +0000
committerSteven Knight <knight@baldmt.com>2007-01-07 07:23:05 +0000
commited6878a4af79fb56fcf5564cb3aca9cbbeac4a69 (patch)
tree05e6aee9b46b530443e01bbb762b68775a6bb0ff /bootstrap.py
parent761c99b86da4f807e30c6aaafa876eed0c0f0f3e (diff)
downloadscons-ed6878a4af79fb56fcf5564cb3aca9cbbeac4a69.tar.gz
Merged revisions 1738-1754,1756 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core ........ r1741 | stevenknight | 2006-12-16 22:51:07 -0600 (Sat, 16 Dec 2006) | 1 line 0.96.D527 - Give the f90 and f95 Tool modules knowledge of how to build source files of earlier Fortran versions. ........ r1742 | stevenknight | 2006-12-16 23:22:54 -0600 (Sat, 16 Dec 2006) | 1 line 0.96.D528 - Better handling of timestamp fallback if there's no md5 module. ........ r1743 | stevenknight | 2006-12-17 00:21:31 -0600 (Sun, 17 Dec 2006) | 1 line 0.96.D529 - Fix portability of new tests on systems that don't have TeX installed. ........ r1744 | stevenknight | 2006-12-19 15:30:16 -0600 (Tue, 19 Dec 2006) | 1 line 0.96.D530 - Eliminate the ListBuilder subclass in favor of using the Executor's target lists. ........ r1745 | stevenknight | 2006-12-19 18:54:26 -0600 (Tue, 19 Dec 2006) | 1 line 0.96.D531 - Eliminate of MultiStepBuilder as a separate Builder subclass. ........ r1746 | garyo | 2006-12-21 13:21:08 -0600 (Thu, 21 Dec 2006) | 1 line Minor doc fix, thanks to Douglas Landgraf. ........ r1747 | stevenknight | 2006-12-21 17:13:55 -0600 (Thu, 21 Dec 2006) | 1 line 0.96.D533 - Add CFLAGS for options common to C/C++. (Gary Oberbrunner) ........ r1748 | stevenknight | 2007-01-03 19:48:05 -0600 (Wed, 03 Jan 2007) | 1 line 0.96.D534 - Fix signature storage when targets are retrieved from CacheDir(). ........ r1749 | stevenknight | 2007-01-04 16:48:47 -0600 (Thu, 04 Jan 2007) | 1 line 0.96.D535 - Teach the lex and yacc tools about target files generated by different flex/bison options, and about Objective C suffixes. (Pupeno) ........ r1750 | stevenknight | 2007-01-04 17:14:38 -0600 (Thu, 04 Jan 2007) | 1 line 0.96.D536 - Refactor duplicate disambiguation logic in Entry.get_contents(). ........ r1751 | stevenknight | 2007-01-05 13:00:54 -0600 (Fri, 05 Jan 2007) | 1 line 0.96.D537 - Fix lprof regression from 0.96.92. ........ r1752 | stevenknight | 2007-01-05 20:43:48 -0600 (Fri, 05 Jan 2007) | 1 line 0.96.D538 - Fix caching of Builder suffix matching (to fix lprof regression). ........ r1753 | stevenknight | 2007-01-06 00:03:16 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D539 - Fix --include-dir when using MinGW. (Paul) ........ r1754 | stevenknight | 2007-01-06 00:24:53 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D540 - Make bootstrap.py something useful to execute SCons out of a source directory. ........ r1756 | stevenknight | 2007-01-06 21:32:11 -0600 (Sat, 06 Jan 2007) | 1 line 0.96.D541 - Update the Copyright year string to include 2007. Automate updating the month+year string in man page title headers. Fix hard-coded __revision__ strings that crept into some older tests. ........
Diffstat (limited to 'bootstrap.py')
-rw-r--r--bootstrap.py139
1 files changed, 105 insertions, 34 deletions
diff --git a/bootstrap.py b/bootstrap.py
index c6a7db3a..9a88c1c8 100644
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -1,20 +1,3 @@
-"""bootstrap.py
-
-This is an Aegis-to-SCons build script that collects a copy of the
-current SCons into a bootstrap/ subdirectory and then executes it with
-the supplied command-line options.
-
-Right now, it only understands the SCons -Y option, which is the only
-one currently used. It collects the repositories specified by -Y and
-searches them, in order, for the pieces of SCons to copy into the local
-bootstrap/ subdirectory.
-
-This is essentially a minimal build of SCons to bootstrap ourselves into
-executing it for the full build of all the packages, as specified in our
-local SConstruct file.
-
-"""
-
#
# __COPYRIGHT__
#
@@ -44,13 +27,97 @@ import getopt
import string
import sys
+__doc__ = """bootstrap.py
+
+This script supports "bootstrap" execution of the current SCons in
+this local source tree by copying of all necessary Python scripts and
+modules from underneath the src/ subdirectory into a subdirectory (named
+"bootstrap/" by default), and then executing the copied SCons with the
+supplied command-line arguments.
+
+There are a handful of options that are specific to this bootstrap.py
+script and which are *not* passed on to the underlying SCons script.
+All of these begin with the string "bootstrap_":
+
+ --bootstrap_dir=DIR
+
+ Sets the name of the directory into which the SCons files will
+ be copied. The default is "bootstrap" in the local subdirectory.
+
+ --bootstrap_force
+
+ Forces a copy of all necessary files. By default, the
+ bootstrap.py script only updates the bootstrap copy if the
+ content of the source copy is different.
+
+ --bootstrap_update
+
+ Only updates the bootstrap subdirectory, and then exits.
+
+In addition to the above options, the bootstrap.py script understands
+the -Y and --repository= options, which are used under Aegis to specify
+a search path for the source files that may not have been copied in to
+the Aegis change.
+
+This is essentially a minimal build of SCons to bootstrap ourselves into
+executing it for the full build of all the packages, as specified in our
+local SConstruct file.
+"""
+
+bootstrap_dir = 'bootstrap'
+pass_through_args = []
search = ['.']
+update_only = None
+
+requires_an_argument = 'bootstrap.py: %s requires an argument\n'
+
+command_line_args = sys.argv[1:]
+
+def must_copy(dst, src):
+ if not os.path.exists(dst):
+ return 1
+ return open(dst, 'rb').read() != open(src, 'rb').read()
-opts, args = getopt.getopt(sys.argv[1:], "Y:", [])
+while command_line_args:
+ arg = command_line_args.pop(0)
-for o, a in opts:
- if o == '-Y':
- search.append(a)
+ if arg == '--bootstrap_dir':
+ try:
+ bootstrap_dir = command_line_args.pop(0)
+ except IndexError:
+ sys.stderr.write(requires_an_argument % arg)
+ sys.exit(1)
+
+ elif arg[:16] == '--bootstrap_dir=':
+ bootstrap_dir = arg[16:]
+
+ elif arg == '--bootstrap_force':
+ def must_copy(dst, src):
+ return 1
+
+ elif arg == '--bootstrap_update':
+ update_only = 1
+
+ elif arg in ('-Y', '--repository'):
+ try:
+ dir = command_line_args.pop(0)
+ except IndexError:
+ sys.stderr.write(requires_an_argument % arg)
+ sys.exit(1)
+ else:
+ search.append(dir)
+ pass_through_args.extend([arg, dir])
+
+ elif arg[:2] == '-Y':
+ search.append(arg[2:])
+ pass_through_args.append(arg)
+
+ elif arg[:13] == '--repository=':
+ search.append(arg[13:])
+ pass_through_args.append(arg)
+
+ else:
+ pass_through_args.append(arg)
def find(file, search=search):
for dir in search:
@@ -68,24 +135,28 @@ MANIFEST_in = find(os.path.join(src_engine, 'MANIFEST.in'))
files = [ scons_py ] + map(lambda x: os.path.join(src_engine, x[:-1]),
open(MANIFEST_in).readlines())
-subdir = 'bootstrap'
-
for file in files:
src = find(file)
- dst = os.path.join(subdir, file)
- dir, _ = os.path.split(dst)
- if not os.path.isdir(dir):
- os.makedirs(dir)
- contents = open(src, 'rb').read()
- try: os.unlink(dst)
- except: pass
- open(dst, 'wb').write(contents)
-
-args = [ sys.executable, os.path.join(subdir, scons_py) ] + sys.argv[1:]
+ dst = os.path.join(bootstrap_dir, file)
+ if must_copy(dst, src):
+ dir = os.path.split(dst)[0]
+ if not os.path.isdir(dir):
+ os.makedirs(dir)
+ try: os.unlink(dst)
+ except: pass
+ open(dst, 'wb').write( open(src, 'rb').read() )
+
+if update_only:
+ sys.exit(0)
+
+args = [
+ os.path.split(sys.executable)[1],
+ os.path.join(bootstrap_dir, scons_py)
+ ] + pass_through_args
sys.stdout.write(string.join(args, " ") + '\n')
sys.stdout.flush()
-os.environ['SCONS_LIB_DIR'] = os.path.join(subdir, src_engine)
+os.environ['SCONS_LIB_DIR'] = os.path.join(bootstrap_dir, src_engine)
os.execve(sys.executable, args, os.environ)