From aeeb99e49fd84dd1f890be6d4c9c7d361741e706 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 4 May 2012 08:33:46 -0700 Subject: Let configure.py remember its environment for rerunning. Without this, CXX is lost when ninja decides that it's time to regenerate build.ninja, which makes performance tweaking surprising. --- configure.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.py b/configure.py index 8f965c8..a719536 100755 --- a/configure.py +++ b/configure.py @@ -72,6 +72,9 @@ n.newline() n.comment('The arguments passed to configure.py, for rerunning it.') n.variable('configure_args', ' '.join(sys.argv[1:])) +env_keys = set(['CXX', 'AR', 'CFLAGS', 'LDFLAGS']) +configure_env = [k + '=' + os.environ[k] for k in os.environ if k in env_keys] +n.variable('configure_env', ' '.join(configure_env)) n.newline() objext = '.o' @@ -351,7 +354,8 @@ n.newline() if host != 'mingw': n.comment('Regenerate build files if build script changes.') n.rule('configure', - command=options.with_python + ' configure.py $configure_args', + command='$configure_env %s configure.py $configure_args' % + options.with_python, generator=True) n.build('build.ninja', 'configure', implicit=['configure.py', 'misc/ninja_syntax.py']) -- cgit v0.12 From 33098cffda17f788e2cc06cd8470e4218dcd2267 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 4 May 2012 14:20:33 -0700 Subject: Do not access os.environ directly. --- configure.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/configure.py b/configure.py index a719536..adea5d1 100755 --- a/configure.py +++ b/configure.py @@ -73,8 +73,9 @@ n.newline() n.comment('The arguments passed to configure.py, for rerunning it.') n.variable('configure_args', ' '.join(sys.argv[1:])) env_keys = set(['CXX', 'AR', 'CFLAGS', 'LDFLAGS']) -configure_env = [k + '=' + os.environ[k] for k in os.environ if k in env_keys] -n.variable('configure_env', ' '.join(configure_env)) +configure_env = dict((k, os.environ[k]) for k in os.environ if k in env_keys) +n.variable('configure_env', + ' '.join([k + '=' + configure_env[k] for k in configure_env])) n.newline() objext = '.o' @@ -101,8 +102,8 @@ if platform == 'windows': n.variable('cxx', 'cl') n.variable('ar', 'link') else: - n.variable('cxx', os.environ.get('CXX', 'g++')) - n.variable('ar', os.environ.get('AR', 'ar')) + n.variable('cxx', configure_env.get('CXX', 'g++')) + n.variable('ar', configure_env.get('AR', 'ar')) if platform == 'windows': cflags = ['/nologo', '/Zi', '/W4', '/WX', '/wd4530', '/wd4100', '/wd4706', @@ -142,11 +143,11 @@ else: elif options.profile == 'pprof': libs.append('-lprofiler') -if 'CFLAGS' in os.environ: - cflags.append(os.environ['CFLAGS']) +if 'CFLAGS' in configure_env: + cflags.append(configure_env['CFLAGS']) n.variable('cflags', ' '.join(cflags)) -if 'LDFLAGS' in os.environ: - ldflags.append(os.environ['LDFLAGS']) +if 'LDFLAGS' in configure_env: + ldflags.append(configure_env['LDFLAGS']) n.variable('ldflags', ' '.join(ldflags)) n.newline() -- cgit v0.12