diff --git a/js/src/js-confdefs.h.in b/js/src/js-confdefs.h.in index e4908a94a812..b46357b5528c 100644 --- a/js/src/js-confdefs.h.in +++ b/js/src/js-confdefs.h.in @@ -6,7 +6,8 @@ #ifndef js_confdefs_h #define js_confdefs_h -@ALLDEFINES@ +// Expands to all the defines from configure. +#undef ALLDEFINES #include "js/RequiredDefines.h" diff --git a/js/src/moz.build b/js/src/moz.build index 591d7a6a3ee5..b783f22349e2 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -61,10 +61,12 @@ TEST_DIRS += ['jsapi-tests', 'tests', 'gdb'] CONFIGURE_SUBST_FILES += [ 'devtools/rootAnalysis/Makefile', - 'js-confdefs.h', 'js-config', 'js.pc', ] +CONFIGURE_DEFINE_FILES += [ + 'js-confdefs.h', +] if not CONFIG['JS_STANDALONE']: CONFIGURE_SUBST_FILES += [ diff --git a/moz.build b/moz.build index 485ef5f5d512..3c6d856edec1 100644 --- a/moz.build +++ b/moz.build @@ -23,9 +23,11 @@ DIRS += [ if not CONFIG['JS_STANDALONE']: CONFIGURE_SUBST_FILES += [ - 'mozilla-config.h', 'tools/update-packaging/Makefile', ] + CONFIGURE_DEFINE_FILES += [ + 'mozilla-config.h', + ] DIRS += [ 'build', diff --git a/mozilla-config.h.in b/mozilla-config.h.in index 8d2c857a65d2..7484180b0db6 100644 --- a/mozilla-config.h.in +++ b/mozilla-config.h.in @@ -13,7 +13,8 @@ #endif #endif -@ALLDEFINES@ +// Expands to all the defines from configure. +#undef ALLDEFINES /* * The c99 defining the limit macros (UINT32_MAX for example), says: diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 723a2ad1067a..a6e134c0570e 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -382,6 +382,9 @@ def _create_config_header(self, obj): "#define NAME ORIGINAL_VALUE" is turned into "#define NAME VALUE" "#undef UNKNOWN_NAME" is turned into "/* #undef UNKNOWN_NAME */" Whitespaces are preserved. + + As a special rule, "#undef ALLDEFINES" is turned into "#define NAME + VALUE" for all the defined variables. ''' with self._write_file(obj.output_path) as fh, \ open(obj.input_path, 'rU') as input: @@ -393,7 +396,18 @@ def _create_config_header(self, obj): name = m.group('name') value = m.group('value') if name: - if name in obj.config.defines: + 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 obj.config.defines.iteritems() + if name not in obj.config.non_global_defines)) + l = l[:m.start('cmd') - 1] \ + + defines + l[m.end('name'):] + elif name in obj.config.defines: if cmd == 'define' and value: l = l[:m.start('value')] \ + str(obj.config.defines[name]) \ diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py index 9f379657dd47..8d31acb27aa3 100644 --- a/python/mozbuild/mozbuild/backend/configenvironment.py +++ b/python/mozbuild/mozbuild/backend/configenvironment.py @@ -81,24 +81,20 @@ class ConfigEnvironment(object): - defines is a list of (name, value) tuples. In autoconf, these are set with AC_DEFINE and AC_DEFINE_UNQUOTED - non_global_defines are a list of names appearing in defines above - that are not meant to be exported in ACDEFINES and ALLDEFINES (see - below) + that are not meant to be exported in ACDEFINES (see below) - substs is a list of (name, value) tuples. In autoconf, these are set with AC_SUBST. - ConfigEnvironment automatically defines two additional substs variables + ConfigEnvironment automatically defines one additional substs variable from all the defines not appearing in non_global_defines: - ACDEFINES contains the defines in the form -DNAME=VALUE, for use on preprocessor command lines. The order in which defines were given when creating the ConfigEnvironment is preserved. - - ALLDEFINES contains the defines in the form #define NAME VALUE, in - sorted order, for use in config files, for an automatic listing of - defines. and two other additional subst variables from all the other substs: - ALLSUBSTS contains the substs in the form NAME = VALUE, in sorted - order, for use in autoconf.mk. It includes ACDEFINES, but doesn't - include ALLDEFINES. Only substs with a VALUE are included, such that - the resulting file doesn't change when new empty substs are added. + order, for use in autoconf.mk. It includes ACDEFINES + Only substs with a VALUE are included, such that the resulting file + doesn't change when new empty substs are added. This results in less invalidation of build dependencies in the case of autoconf.mk.. - ALLEMPTYSUBSTS contains the substs with an empty value, in the form @@ -117,6 +113,7 @@ def __init__(self, topsrcdir, topobjdir, defines=[], non_global_defines=[], source = mozpath.join(topobjdir, 'config.status') self.source = source self.defines = ReadOnlyDict(defines) + self.non_global_defines = non_global_defines self.substs = dict(substs) self.topsrcdir = mozpath.abspath(topsrcdir) self.topobjdir = mozpath.abspath(topobjdir) @@ -146,8 +143,6 @@ def serialize(obj): serialize(self.substs[name])) for name in self.substs if self.substs[name]])) self.substs['ALLEMPTYSUBSTS'] = '\n'.join(sorted(['%s =' % name for name in self.substs if not self.substs[name]])) - self.substs['ALLDEFINES'] = '\n'.join(sorted(['#define %s %s' % (name, - self.defines[name]) for name in global_defines])) self.substs = ReadOnlyDict(self.substs) diff --git a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py index 474a9196c48a..89b5397c5837 100644 --- a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py +++ b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py @@ -35,8 +35,8 @@ def __init__(self, *args, **kwargs): class TestEnvironment(unittest.TestCase): def test_auto_substs(self): - '''Test the automatically set values of ACDEFINES, ALLDEFINES, - ALLSUBSTS and ALLEMPTYSUBSTS. + '''Test the automatically set values of ACDEFINES, ALLSUBSTS + and ALLEMPTYSUBSTS. ''' env = ConfigEnvironment('.', '.', defines = [ ('foo', 'bar'), ('baz', 'qux 42'), @@ -45,16 +45,10 @@ def test_auto_substs(self): substs = [ ('FOO', 'bar'), ('FOOBAR', ''), ('ABC', 'def'), ('bar', 'baz qux'), ('zzz', '"abc def"'), ('qux', '') ]) - # non_global_defines should be filtered out in ACDEFINES and - # ALLDEFINES. + # non_global_defines should be filtered out in ACDEFINES. # Original order of the defines need to be respected in ACDEFINES self.assertEqual(env.substs['ACDEFINES'], """-Dfoo=bar -Dbaz='qux 42' -Dabc='d'\\''e'\\''f'""") - # ALLDEFINES, on the other hand, needs to be sorted - self.assertEqual(env.substs['ALLDEFINES'], '''#define abc d'e'f -#define baz qux 42 -#define foo bar''') - # Likewise for ALLSUBSTS, which also mustn't contain ALLDEFINES - # but contain ACDEFINES + # Likewise for ALLSUBSTS, which also must contain ACDEFINES self.assertEqual(env.substs['ALLSUBSTS'], '''ABC = def ACDEFINES = -Dfoo=bar -Dbaz='qux 42' -Dabc='d'\\''e'\\''f' FOO = bar