# 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
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')
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
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!')
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
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)