summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZaheer Chothia <zaheer.chothia@gmail.com>2012-10-19 07:46:09 (GMT)
committerZaheer Chothia <zaheer.chothia@gmail.com>2012-10-19 07:46:09 (GMT)
commitf4b1133d5c36b531a39606da4e1cadc38a784a2e (patch)
treec302b14bc96e7c25142e91c08555feb5f6a2a181
parent1d5daecfaf1853f87af1d99fb84c347576648474 (diff)
downloadNinja-f4b1133d5c36b531a39606da4e1cadc38a784a2e.zip
Ninja-f4b1133d5c36b531a39606da4e1cadc38a784a2e.tar.gz
Ninja-f4b1133d5c36b531a39606da4e1cadc38a784a2e.tar.bz2
Python scripts: use built-in print function.
-rwxr-xr-xbootstrap.py22
-rwxr-xr-xconfigure.py16
2 files changed, 13 insertions, 25 deletions
diff --git a/bootstrap.py b/bootstrap.py
index 1c05094..7dfc543 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
@@ -22,14 +24,6 @@ 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()
@@ -52,7 +46,7 @@ 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')
@@ -112,7 +106,7 @@ else:
args.extend(['-o', binary])
if options.verbose:
- print_(' '.join(args))
+ print(' '.join(args))
run(args)
@@ -121,7 +115,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)
@@ -133,7 +127,7 @@ 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
@@ -142,8 +136,8 @@ 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.""")
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!')
diff --git a/configure.py b/configure.py
index f716067..e41cf4e 100755
--- a/configure.py
+++ b/configure.py
@@ -19,6 +19,8 @@
Projects that use ninja themselves should either write a similar script
or use a meta-build system that supports Ninja output."""
+from __future__ import print_function
+
from optparse import OptionParser
import os
import sys
@@ -26,14 +28,6 @@ sys.path.insert(0, 'misc')
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']
@@ -58,7 +52,7 @@ parser.add_option('--with-ninja', metavar='NAME',
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
@@ -264,7 +258,7 @@ if has_re2c():
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()
@@ -444,4 +438,4 @@ if host == 'linux':
n.build('all', 'phony', all_targets)
-print_('wrote %s.' % BUILD_FILENAME)
+print('wrote %s.' % BUILD_FILENAME)