summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-08-16 05:26:46 (GMT)
committerEvan Martin <martine@danga.com>2012-08-16 05:26:46 (GMT)
commit9f72b1713412f62eae0540d9154f42dffe29bccd (patch)
treea870a03073e2cb56111e3920f3c5dae152acbcd9
parent77b4e27b3257f54bd537faf395f23ed283d53a39 (diff)
parent6c7fae2af8e5c2d34bdbed5d1c3c5739bb548ee8 (diff)
downloadNinja-9f72b1713412f62eae0540d9154f42dffe29bccd.zip
Ninja-9f72b1713412f62eae0540d9154f42dffe29bccd.tar.gz
Ninja-9f72b1713412f62eae0540d9154f42dffe29bccd.tar.bz2
Merge pull request #400 from nico/dynre2c
Only write re2c rules if a re2c binary is found in the PATH.
-rwxr-xr-xconfigure.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/configure.py b/configure.py
index 981d401..287f58a 100755
--- a/configure.py
+++ b/configure.py
@@ -233,12 +233,22 @@ 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:
+ n.comment('(re2c not found, using checked-in cc files instead.)')
n.newline()
n.comment('Core source files all build into ninja library.')