Bug 1402012 - Use PartialConfigEnvironment in process_define_files.py; r?glandium
This removes the dependency on config.status for CONFIGURE_DEFINE_FILES.
Instead, each file depends on the specific configure values that it
uses.
MozReview-Commit-ID: H4oLmJei1KR
--- a/python/mozbuild/mozbuild/action/process_define_files.py
+++ b/python/mozbuild/mozbuild/action/process_define_files.py
@@ -3,18 +3,18 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import argparse
import os
import re
import sys
-from buildconfig import topobjdir
-from mozbuild.backend.configenvironment import ConfigEnvironment
+from buildconfig import topsrcdir, topobjdir
+from mozbuild.backend.configenvironment import PartialConfigEnvironment
from mozbuild.util import FileAvoidWrite
import mozpack.path as mozpath
def process_define_file(output, input):
'''Creates the given config header. A config header is generated by
taking the corresponding source file and replacing some #define/#undef
occurences:
@@ -25,43 +25,40 @@ def process_define_file(output, input):
Whitespaces are preserved.
As a special rule, "#undef ALLDEFINES" is turned into "#define NAME
VALUE" for all the defined variables.
'''
path = os.path.abspath(input)
- config = ConfigEnvironment.from_config_status(
- mozpath.join(topobjdir, 'config.status'))
+ config = PartialConfigEnvironment(topobjdir)
if mozpath.basedir(path,
- [mozpath.join(config.topsrcdir, 'js/src')]) and \
+ [mozpath.join(topsrcdir, 'js/src')]) and \
not config.substs.get('JS_STANDALONE'):
- config = ConfigEnvironment.from_config_status(
- mozpath.join(topobjdir, 'js', 'src', 'config.status'))
+ config = PartialConfigEnvironment(mozpath.join(topobjdir, 'js', 'src'))
with open(path, 'rU') as input:
r = re.compile('^\s*#\s*(?P<cmd>[a-z]+)(?:\s+(?P<name>\S+)(?:\s+(?P<value>\S+))?)?', re.U)
for l in input:
m = r.match(l)
if m:
cmd = m.group('cmd')
name = m.group('name')
value = m.group('value')
- if name:
+ if name and cmd != 'endif':
if name == 'ALLDEFINES':
if cmd == 'define':
raise Exception(
'`#define ALLDEFINES` is not allowed in a '
'CONFIGURE_DEFINE_FILE')
defines = '\n'.join(sorted(
'#define %s %s' % (name, val)
- for name, val in config.defines.iteritems()
- if name not in config.non_global_defines))
+ for name, val in config.defines['ALLDEFINES'].iteritems()))
l = l[:m.start('cmd') - 1] \
+ defines + l[m.end('name'):]
elif name in config.defines:
if cmd == 'define' and value:
l = l[:m.start('value')] \
+ str(config.defines[name]) \
+ l[m.end('value'):]
elif cmd == 'undef':
@@ -71,17 +68,19 @@ def process_define_file(output, input):
+ ' ' \
+ str(config.defines[name]) \
+ l[m.end('name'):]
elif cmd == 'undef':
l = '/* ' + l[:m.end('name')] + ' */' + l[m.end('name'):]
output.write(l)
- return {path, config.source}
+ deps = {path}
+ deps.update(config.get_dependencies())
+ return deps
def main(argv):
parser = argparse.ArgumentParser(
description='Process define files.')
parser.add_argument('input', help='Input define file.')