summaryrefslogtreecommitdiffstats
path: root/configure.py
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2024-04-11 16:44:05 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2024-04-11 16:44:05 (GMT)
commit65d0dfcbbea6b8ca7d8a3a0f673ecb522379e43c (patch)
tree7b30fc5f0a477efd075ab0f8eead78aa7554869b /configure.py
parent448ae1ccacd17025457ace965d78a45a113c70c6 (diff)
parent1dcebc6399dc76a9bdf643ad9722d7f2d7fee51c (diff)
downloadNinja-1.12.0.zip
Ninja-1.12.0.tar.gz
Ninja-1.12.0.tar.bz2
v1.12.0v1.12.0
Diffstat (limited to 'configure.py')
-rwxr-xr-xconfigure.py80
1 files changed, 31 insertions, 49 deletions
diff --git a/configure.py b/configure.py
index 4390434..6ee64a8 100755
--- a/configure.py
+++ b/configure.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright 2001 Google Inc. All Rights Reserved.
#
@@ -19,12 +19,9 @@
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 pipes
-import string
+import shlex
import subprocess
import sys
@@ -264,7 +261,7 @@ n.variable('configure_args', ' '.join(configure_args))
env_keys = set(['CXX', 'AR', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS'])
configure_env = dict((k, os.environ[k]) for k in os.environ if k in env_keys)
if configure_env:
- config_str = ' '.join([k + '=' + pipes.quote(configure_env[k])
+ config_str = ' '.join([k + '=' + shlex.quote(configure_env[k])
for k in configure_env])
n.variable('configure_env', config_str + '$ ')
n.newline()
@@ -305,7 +302,18 @@ if platform.is_msvc():
else:
n.variable('ar', configure_env.get('AR', 'ar'))
+def search_system_path(file_name):
+ """Find a file in the system path."""
+ for dir in os.environ['path'].split(';'):
+ path = os.path.join(dir, file_name)
+ if os.path.exists(path):
+ return path
+
+# Note that build settings are separately specified in CMakeLists.txt and
+# these lists should be kept in sync.
if platform.is_msvc():
+ if not search_system_path('cl.exe'):
+ raise Exception('cl.exe not found. Run again from the Developer Command Prompt for VS')
cflags = ['/showIncludes',
'/nologo', # Don't print startup banner.
'/Zi', # Create pdb with debug info.
@@ -320,6 +328,7 @@ if platform.is_msvc():
# Disable warnings about ignored typedef in DbgHelp.h
'/wd4091',
'/GR-', # Disable RTTI.
+ '/Zc:__cplusplus',
# Disable size_t -> int truncation warning.
# We never have strings or arrays larger than 2**31.
'/wd4267',
@@ -339,6 +348,7 @@ else:
'-Wno-unused-parameter',
'-fno-rtti',
'-fno-exceptions',
+ '-std=c++11',
'-fvisibility=hidden', '-pipe',
'-DNINJA_PYTHON="%s"' % options.with_python]
if options.debug:
@@ -474,7 +484,7 @@ n.comment('the depfile parser and ninja lexers are generated using re2c.')
def has_re2c():
try:
proc = subprocess.Popen(['re2c', '-V'], stdout=subprocess.PIPE)
- return int(proc.communicate()[0], 10) >= 1103
+ return int(proc.communicate()[0], 10) >= 1503
except OSError:
return False
if has_re2c():
@@ -485,20 +495,31 @@ 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.15.3) was not found; "
"changes to src/*.in.cc will not affect your build.")
n.newline()
-n.comment('Core source files all build into ninja library.')
cxxvariables = []
if platform.is_msvc():
cxxvariables = [('pdb', 'ninja.pdb')]
+
+n.comment('Generate a library for `ninja-re2c`.')
+re2c_objs = []
+for name in ['depfile_parser', 'lexer']:
+ re2c_objs += cxx(name, variables=cxxvariables)
+if platform.is_msvc():
+ n.build(built('ninja-re2c.lib'), 'ar', re2c_objs)
+else:
+ n.build(built('libninja-re2c.a'), 'ar', re2c_objs)
+n.newline()
+
+n.comment('Core source files all build into ninja library.')
+objs.extend(re2c_objs)
for name in ['build',
'build_log',
'clean',
'clparser',
'debug_flags',
- 'depfile_parser',
'deps_log',
'disk_interface',
'dyndep',
@@ -508,7 +529,6 @@ for name in ['build',
'graph',
'graphviz',
'json',
- 'lexer',
'line_printer',
'manifest_parser',
'metrics',
@@ -562,44 +582,6 @@ if options.bootstrap:
# build.ninja file.
n = ninja_writer
-n.comment('Tests all build into ninja_test executable.')
-
-objs = []
-if platform.is_msvc():
- cxxvariables = [('pdb', 'ninja_test.pdb')]
-
-for name in ['build_log_test',
- 'build_test',
- 'clean_test',
- 'clparser_test',
- 'depfile_parser_test',
- 'deps_log_test',
- 'dyndep_parser_test',
- 'disk_interface_test',
- 'edit_distance_test',
- 'graph_test',
- 'json_test',
- 'lexer_test',
- 'manifest_parser_test',
- 'missing_deps_test',
- 'ninja_test',
- 'state_test',
- 'status_test',
- 'string_piece_util_test',
- 'subprocess_test',
- 'test',
- 'util_test']:
- objs += cxx(name, variables=cxxvariables)
-if platform.is_windows():
- for name in ['includes_normalize_test', 'msvc_helper_test']:
- objs += cxx(name, variables=cxxvariables)
-
-ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
- variables=[('libs', libs)])
-n.newline()
-all_targets += ninja_test
-
-
n.comment('Ancillary executables.')
if platform.is_aix() and '-maix64' not in ldflags: