summaryrefslogtreecommitdiffstats
path: root/bootstrap.py
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap.py')
-rw-r--r--bootstrap.py64
1 files changed, 52 insertions, 12 deletions
diff --git a/bootstrap.py b/bootstrap.py
index 9a88c1c..1620bf3 100644
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -23,7 +23,6 @@
import os
import os.path
-import getopt
import string
import sys
@@ -50,14 +49,31 @@ All of these begin with the string "bootstrap_":
bootstrap.py script only updates the bootstrap copy if the
content of the source copy is different.
+ --bootstrap_src=DIR
+
+ Searches for the SCons files relative to the specified DIR,
+ then relative to the directory in which this bootstrap.py
+ script is found.
+
--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.
+the following SCons options:
+
+ -C, --directory
+
+ Changes to the specified directory before invoking SCons.
+ Because we change directory right away to the specified directory,
+ the SCons script itself doesn't need to, so this option gets
+ "eaten" by the bootstrap.py script.
+
+ -Y, --repository
+
+ These options 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
@@ -66,18 +82,23 @@ 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()
+search = [os.path.dirname(sys.argv[0])]
+if search[0] == '': search[0] = '.'
+
+# Note: We don't use the getopt module to process the command-line
+# arguments because we'd have to teach it about all of the SCons options.
+
+command_line_args = sys.argv[1:]
+
while command_line_args:
arg = command_line_args.pop(0)
@@ -87,7 +108,6 @@ while command_line_args:
except IndexError:
sys.stderr.write(requires_an_argument % arg)
sys.exit(1)
-
elif arg[:16] == '--bootstrap_dir=':
bootstrap_dir = arg[16:]
@@ -95,9 +115,31 @@ while command_line_args:
def must_copy(dst, src):
return 1
+ elif arg == '--bootstrap_src':
+ try:
+ search.insert(0, command_line_args.pop(0))
+ except IndexError:
+ sys.stderr.write(requires_an_argument % arg)
+ sys.exit(1)
+ elif arg[:16] == '--bootstrap_src=':
+ search.insert(0, arg[16:])
+
elif arg == '--bootstrap_update':
update_only = 1
+ elif arg in ('-C', '--directory'):
+ try:
+ dir = command_line_args.pop(0)
+ except IndexError:
+ sys.stderr.write(requires_an_argument % arg)
+ sys.exit(1)
+ else:
+ os.chdir(dir)
+ elif arg[:2] == '-C':
+ os.chdir(arg[2:])
+ elif arg[:12] == '--directory=':
+ os.chdir(arg[12:])
+
elif arg in ('-Y', '--repository'):
try:
dir = command_line_args.pop(0)
@@ -107,11 +149,9 @@ while command_line_args:
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)
@@ -122,8 +162,8 @@ while command_line_args:
def find(file, search=search):
for dir in search:
f = os.path.join(dir, file)
- if os.path.exists(f):
- return os.path.normpath(f)
+ if os.path.exists(f):
+ return os.path.normpath(f)
sys.stderr.write("could not find `%s' in search path:\n" % file)
sys.stderr.write("\t" + string.join(search, "\n\t") + "\n")
sys.exit(2)