summaryrefslogtreecommitdiffstats
path: root/bootstrap.py
diff options
context:
space:
mode:
authorZaheer Chothia <zaheer.chothia@gmail.com>2012-10-18 13:02:48 (GMT)
committerZaheer Chothia <zaheer.chothia@gmail.com>2012-10-18 13:03:20 (GMT)
commit1d5daecfaf1853f87af1d99fb84c347576648474 (patch)
treebfaaf9021a0bfd8bf26d4788812b2a02860d11fb /bootstrap.py
parentb022e789fd9b087e0acbeca502d586d49dd3e2f2 (diff)
downloadNinja-1d5daecfaf1853f87af1d99fb84c347576648474.zip
Ninja-1d5daecfaf1853f87af1d99fb84c347576648474.tar.gz
Ninja-1d5daecfaf1853f87af1d99fb84c347576648474.tar.bz2
Add support for Python 3
Diffstat (limited to 'bootstrap.py')
-rwxr-xr-xbootstrap.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/bootstrap.py b/bootstrap.py
index 3032a9b..1c05094 100755
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -22,6 +22,14 @@ import shlex
import shutil
import subprocess
+if sys.version_info[0] == 3:
+ import builtins
+ print_ = getattr(builtins, "print")
+else:
+ def print_(*args):
+ sys.stdout.write(" ".join(str(x) for x in args))
+ sys.stdout.write("\n")
+
os.chdir(os.path.dirname(os.path.abspath(__file__)))
parser = OptionParser()
@@ -44,11 +52,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
@@ -103,7 +112,7 @@ else:
args.extend(['-o', binary])
if options.verbose:
- print ' '.join(args)
+ print_(' '.join(args))
run(args)
@@ -112,7 +121,7 @@ if options.verbose:
verbose = ['-v']
if sys.platform.startswith('win32'):
- print 'Building ninja using itself...'
+ print_('Building ninja using itself...')
run([sys.executable, 'configure.py', '--with-ninja=%s' % binary] +
conf_args)
run(['./' + binary] + verbose)
@@ -124,17 +133,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!')