summaryrefslogtreecommitdiffstats
path: root/configure.py
diff options
context:
space:
mode:
Diffstat (limited to 'configure.py')
-rwxr-xr-xconfigure.py72
1 files changed, 54 insertions, 18 deletions
diff --git a/configure.py b/configure.py
index 95f88b1..e4b9eb4 100755
--- a/configure.py
+++ b/configure.py
@@ -45,6 +45,8 @@ parser.add_option('--with-gtest', metavar='PATH',
parser.add_option('--with-python', metavar='EXE',
help='use EXE as the Python interpreter',
default=os.path.basename(sys.executable))
+parser.add_option('--with-msvc-helper', metavar='NAME',
+ help="name for ninja-msvc-helper binary (MSVC only)")
(options, args) = parser.parse_args()
if args:
print 'ERROR: extra unparsed command-line arguments:', args
@@ -97,7 +99,9 @@ def cxx(name, **kwargs):
return n.build(built(name + objext), 'cxx', src(name + '.cc'), **kwargs)
def binary(name):
if platform in ('mingw', 'windows'):
- return name + '.exe'
+ exe = name + '.exe'
+ n.build(name, 'phony', exe)
+ return exe
return name
n.variable('builddir', 'build')
@@ -108,8 +112,16 @@ else:
n.variable('ar', configure_env.get('AR', 'ar'))
if platform == 'windows':
- cflags = ['/nologo', '/Zi', '/W4', '/WX', '/wd4530', '/wd4100', '/wd4706',
- '/wd4512', '/wd4800', '/wd4702', '/wd4819', '/GR-',
+ cflags = ['/nologo', # Don't print startup banner.
+ '/Zi', # Create pdb with debug info.
+ '/W4', # Highest warning level.
+ '/WX', # Warnings as errors.
+ '/wd4530', '/wd4100', '/wd4706',
+ '/wd4512', '/wd4800', '/wd4702', '/wd4819',
+ '/GR-', # Disable RTTI.
+ # Disable size_t -> int truncation warning.
+ # We never have strings or arrays larger than 2**31.
+ '/wd4267',
'/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
'/DNINJA_PYTHON="%s"' % options.with_python]
ldflags = ['/DEBUG', '/libpath:$builddir']
@@ -167,8 +179,11 @@ n.variable('ldflags', ' '.join(shell_escape(flag) for flag in ldflags))
n.newline()
if platform == 'windows':
+ compiler = '$cxx'
+ if options.with_msvc_helper:
+ compiler = '%s -o $out -- $cxx /showIncludes' % options.with_msvc_helper
n.rule('cxx',
- command='$cxx $cflags -c $in /Fo$out',
+ command='%s $cflags -c $in /Fo$out' % compiler,
depfile='$out.d',
description='CXX $out')
else:
@@ -218,12 +233,23 @@ if platform not in ('mingw', 'windows'):
n.newline()
n.comment('the depfile parser and ninja lexers are generated using re2c.')
-n.rule('re2c',
- command='re2c -b -i --no-generation-date -o $out $in',
- description='RE2C $out')
-# Generate the .cc files in the source directory so we can check them in.
-n.build(src('depfile_parser.cc'), 're2c', src('depfile_parser.in.cc'))
-n.build(src('lexer.cc'), 're2c', src('lexer.in.cc'))
+def has_re2c():
+ import subprocess
+ try:
+ subprocess.call(['re2c', '-v'], stdout=subprocess.PIPE)
+ return True
+ except OSError:
+ return False
+if has_re2c():
+ n.rule('re2c',
+ command='re2c -b -i --no-generation-date -o $out $in',
+ description='RE2C $out')
+ # Generate the .cc files in the source directory so we can check them in.
+ 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: re2c not found; changes to src/*.in.cc will not affect "
+ "your build.")
n.newline()
n.comment('Core source files all build into ninja library.')
@@ -246,6 +272,8 @@ for name in ['build',
if platform in ('mingw', 'windows'):
objs += cxx('subprocess-win32')
if platform == 'windows':
+ objs += cxx('includes_normalize-win32')
+ objs += cxx('msvc_helper-win32')
objs += cxx('minidump-win32')
objs += cc('getopt')
else:
@@ -267,11 +295,19 @@ n.comment('Main executable is library plus main() function.')
objs = cxx('ninja')
ninja = n.build(binary('ninja'), 'link', objs, implicit=ninja_lib,
variables=[('libs', libs)])
-if 'ninja' not in ninja:
- n.build('ninja', 'phony', ninja)
n.newline()
all_targets += ninja
+if platform == 'windows':
+ n.comment('Helper for working with MSVC.')
+ msvc_helper = n.build(binary('ninja-msvc-helper'), 'link',
+ cxx('msvc_helper_main-win32'),
+ implicit=ninja_lib,
+ variables=[('libs', libs)])
+ n.default(msvc_helper)
+ n.newline()
+ all_targets += msvc_helper
+
n.comment('Tests all build into ninja_test executable.')
variables = []
@@ -288,10 +324,10 @@ if options.with_gtest:
else:
gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs
objs += n.build(built('gtest-all' + objext), 'cxx',
- os.path.join(path, 'src/gtest-all.cc'),
+ os.path.join(path, 'src', 'gtest-all.cc'),
variables=[('cflags', gtest_cflags)])
objs += n.build(built('gtest_main' + objext), 'cxx',
- os.path.join(path, 'src/gtest_main.cc'),
+ os.path.join(path, 'src', 'gtest_main.cc'),
variables=[('cflags', gtest_cflags)])
test_cflags = cflags + ['-DGTEST_HAS_RTTI=0',
@@ -315,14 +351,15 @@ for name in ['build_log_test',
'test',
'util_test']:
objs += cxx(name, variables=[('cflags', test_cflags)])
+if platform == 'windows':
+ for name in ['includes_normalize_test', 'msvc_helper_test']:
+ objs += cxx(name, variables=[('cflags', test_cflags)])
if platform != 'mingw' and platform != 'windows':
test_libs.append('-lpthread')
ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
variables=[('ldflags', test_ldflags),
('libs', test_libs)])
-if 'ninja_test' not in ninja_test:
- n.build('ninja_test', 'phony', ninja_test)
n.newline()
all_targets += ninja_test
@@ -370,7 +407,7 @@ n.rule('doxygen_mainpage',
command='$doxygen_mainpage_generator $in > $out',
description='DOXYGEN_MAINPAGE $out')
mainpage = n.build(built('doxygen_mainpage'), 'doxygen_mainpage',
- ['README', 'HACKING', 'COPYING'],
+ ['README', 'COPYING'],
implicit=['$doxygen_mainpage_generator'])
n.build('doxygen', 'doxygen', doc('doxygen.config'),
implicit=mainpage)
@@ -386,7 +423,6 @@ if host != 'mingw':
implicit=['configure.py', os.path.normpath('misc/ninja_syntax.py')])
n.newline()
-n.comment('Build only the main binary by default.')
n.default(ninja)
n.newline()