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()
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
args.extend(['-o', binary])
if options.verbose:
- print ' '.join(args)
+ print_(' '.join(args))
run(args)
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)
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!')
import ninja_syntax
+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")
+
parser = OptionParser()
platforms = ['linux', 'freebsd', 'solaris', 'mingw', 'windows']
profilers = ['gmon', 'pprof']
default="ninja")
(options, args) = parser.parse_args()
if args:
- print 'ERROR: extra unparsed command-line arguments:', args
+ print_('ERROR: extra unparsed command-line arguments:', args)
sys.exit(1)
platform = options.platform
n.build(src('depfile_parser.cc'), 're2c', src('depfile_parser.in.cc'))
n.build(src('lexer.cc'), 're2c', src('lexer.in.cc'))
else:
- print ("warning: A compatible version of re2c (>= 0.11.3) was not found; "
+ print_("warning: A compatible version of re2c (>= 0.11.3) was not found; "
"changes to src/*.in.cc will not affect your build.")
n.newline()
n.build('all', 'phony', all_targets)
-print 'wrote %s.' % BUILD_FILENAME
+print_('wrote %s.' % BUILD_FILENAME)
if variables:
if isinstance(variables, dict):
- iterator = variables.iteritems()
+ iterator = iter(variables.items())
else:
iterator = iter(variables)
# limitations under the License.
import unittest
-from StringIO import StringIO
+
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
import ninja_syntax