diff options
author | Evan Martin <martine@danga.com> | 2012-12-29 21:36:00 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-12-29 21:47:41 (GMT) |
commit | 2c953d1501de5195e2485185fa24a2ebfd76bbb5 (patch) | |
tree | 2fc88e378a6df571bb125d282b14475f2b9ba05c /bootstrap.py | |
parent | 7096bf1507f98be981aa14ffd9ed5a4a8b1c1494 (diff) | |
parent | 3249938cdf574058a066436aea06b0541ded6958 (diff) | |
download | Ninja-2c953d1501de5195e2485185fa24a2ebfd76bbb5.zip Ninja-2c953d1501de5195e2485185fa24a2ebfd76bbb5.tar.gz Ninja-2c953d1501de5195e2485185fa24a2ebfd76bbb5.tar.bz2 |
version 1.1.0v1.1.0
Diffstat (limited to 'bootstrap.py')
-rwxr-xr-x | bootstrap.py | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/bootstrap.py b/bootstrap.py index 3032a9b..a847df9 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + from optparse import OptionParser import sys import os @@ -29,6 +31,10 @@ parser.add_option('--verbose', action='store_true', help='enable verbose build',) parser.add_option('--x64', action='store_true', help='force 64-bit build (Windows)',) +# TODO: make this --platform to match configure.py. +parser.add_option('--windows', action='store_true', + help='force native Windows build (when using Cygwin Python)', + default=sys.platform.startswith('win32')) (options, conf_args) = parser.parse_args() def run(*args, **kwargs): @@ -44,11 +50,12 @@ if sys.platform.startswith('freebsd'): cflags.append('-I/usr/local/include') ldflags.append('-L/usr/local/lib') -print 'Building ninja manually...' +print('Building ninja manually...') try: os.mkdir('build') -except OSError, e: +except OSError: + e = sys.exc_info()[1] if e.errno != errno.EEXIST: raise @@ -63,7 +70,7 @@ for src in glob.glob('src/*.cc'): if filename == 'browse.cc': # Depends on generated header. continue - if sys.platform.startswith('win32'): + if options.windows: if src.endswith('-posix.cc'): continue else: @@ -72,7 +79,7 @@ for src in glob.glob('src/*.cc'): sources.append(src) -if sys.platform.startswith('win32'): +if options.windows: sources.append('src/getopt.c') vcdir = os.environ.get('VCINSTALLDIR') @@ -87,14 +94,14 @@ else: cflags.extend(['-Wno-deprecated', '-DNINJA_PYTHON="' + sys.executable + '"', '-DNINJA_BOOTSTRAP']) - if sys.platform.startswith('win32'): + if options.windows: cflags.append('-D_WIN32_WINNT=0x0501') if options.x64: cflags.append('-m64') args.extend(cflags) args.extend(ldflags) binary = 'ninja.bootstrap' -if sys.platform.startswith('win32'): +if options.windows: binary = 'ninja.bootstrap.exe' args.extend(sources) if vcdir: @@ -103,16 +110,20 @@ else: args.extend(['-o', binary]) if options.verbose: - print ' '.join(args) + print(' '.join(args)) -run(args) +try: + run(args) +except: + print('Failure running:', args) + raise verbose = [] if options.verbose: verbose = ['-v'] -if sys.platform.startswith('win32'): - print 'Building ninja using itself...' +if options.windows: + print('Building ninja using itself...') run([sys.executable, 'configure.py', '--with-ninja=%s' % binary] + conf_args) run(['./' + binary] + verbose) @@ -124,17 +135,17 @@ if sys.platform.startswith('win32'): for obj in glob.glob('*.obj'): os.unlink(obj) - print """ + print(""" Done! Note: to work around Windows file locking, where you can't rebuild an in-use binary, to run ninja after making any changes to build ninja itself you should run ninja.bootstrap instead. Your build is also configured to use ninja.bootstrap.exe as the MSVC helper; see the --with-ninja flag of -the --help output of configure.py.""" +the --help output of configure.py.""") else: - print 'Building ninja using itself...' + print('Building ninja using itself...') run([sys.executable, 'configure.py'] + conf_args) run(['./' + binary] + verbose) os.unlink(binary) - print 'Done!' + print('Done!') |