Bug 902825 - Rename ALLDEFINES to GLOBAL_DEFINES; r?glandium draft
authorMike Shal <mshal@mozilla.com>
Thu, 05 Oct 2017 13:36:59 -0400
changeset 675772 5557533d7153c812458556b5b86cca6b9d9d12d2
parent 675771 af91cb485b6d815ba117e2b3c02c3c8fe8256be2
child 675773 93b87c6825c3e1c6831dc4f7e6590e677ed9dd56
push id83240
push userbmo:mshal@mozilla.com
push dateThu, 05 Oct 2017 21:34:38 +0000
reviewersglandium
bugs902825
milestone58.0a1
Bug 902825 - Rename ALLDEFINES to GLOBAL_DEFINES; r?glandium The name change makes it more obvious that this isn't all of the defines in the buildconfig, but rather only those that are global. There are certain cases, such as in the packager, where we explicitly want all of the defines instead of just the global defines. In this case we need to use the defines dict from the MozbuildObject, since the defines in the PartialConfigEnvironment aren't a true dict and conflict with python's internal dict() conversion. Using the full set of defines rather than the global-only defines will allow us to remove an explicit NECKO_WIFI define in another commit. MozReview-Commit-ID: IsHQGFETbdW
build/autoconf/config.status.m4
js/src/builtin/embedjs.py
js/src/js-confdefs.h.in
mozilla-config.h.in
python/mozbuild/mozbuild/action/generate_symbols_file.py
python/mozbuild/mozbuild/action/process_define_files.py
python/mozbuild/mozbuild/backend/configenvironment.py
python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py
toolkit/mozapps/installer/find-dupes.py
toolkit/mozapps/installer/packager.py
--- a/build/autoconf/config.status.m4
+++ b/build/autoconf/config.status.m4
@@ -140,17 +140,17 @@ dnl Add in the output from the subconfig
 for ac_subst_arg in $_subconfigure_ac_subst_args; do
   variable='$'$ac_subst_arg
   echo "    (''' $ac_subst_arg ''', r''' `eval echo $variable` ''')," >> $CONFIG_STATUS
 done
 
 cat >> $CONFIG_STATUS <<\EOF
 ]
 
-dnl List of AC_DEFINEs that aren't to be exposed in ALLDEFINES
+dnl List of AC_DEFINEs that aren't to be exposed in GLOBAL_DEFINES
 non_global_config = [
 EOF
 
 if test -n "$_NON_GLOBAL_ACDEFINES"; then
   for var in $_NON_GLOBAL_ACDEFINES; do
     echo "    '$var'," >> $CONFIG_STATUS
   done
 fi
--- a/js/src/builtin/embedjs.py
+++ b/js/src/builtin/embedjs.py
@@ -127,17 +127,17 @@ def messages(jsmsg):
       defines.append("#define %s %i" % (match.group(1), len(defines)))
     else:
       # Make sure that MSG_DEF isn't preceded by whitespace
       assert not line.strip().startswith("MSG_DEF")
   return '\n'.join(defines)
 
 def get_config_defines(buildconfig):
   # Collect defines equivalent to ACDEFINES and add MOZ_DEBUG_DEFINES.
-  env = buildconfig.defines['ALLDEFINES']
+  env = buildconfig.defines['GLOBAL_DEFINES']
   for define in buildconfig.substs['MOZ_DEBUG_DEFINES']:
     env[define] = 1
   return env
 
 def process_inputs(namespace, c_out, msg_file, inputs):
   deps = [path for path in inputs if path.endswith(".h") or path.endswith(".h.js")]
   sources = [path for path in inputs if path.endswith(".js") and not path.endswith(".h.js")]
   assert len(deps) + len(sources) == len(inputs)
--- a/js/src/js-confdefs.h.in
+++ b/js/src/js-confdefs.h.in
@@ -2,13 +2,13 @@
  * -include, to avoid long list of -D defines on the compile command-line.
  * Do not edit.
  */
 
 #ifndef js_confdefs_h
 #define js_confdefs_h
 
 // Expands to all the defines from configure.
-#undef ALLDEFINES
+#undef GLOBAL_DEFINES
 
 #include "js/RequiredDefines.h"
 
 #endif /* js_confdefs_h */
--- a/mozilla-config.h.in
+++ b/mozilla-config.h.in
@@ -9,17 +9,17 @@
 #if defined(__clang__)
 #pragma clang diagnostic push
 #if __has_warning("-Wreserved-id-macro")
 #pragma clang diagnostic ignored "-Wreserved-id-macro"
 #endif
 #endif
 
 /* Expands to all the defines from configure. */
-#undef ALLDEFINES
+#undef GLOBAL_DEFINES
 
 /*
  * The c99 defining the limit macros (UINT32_MAX for example), says:
  *
  *   C++ implementations should define these macros only when
  *   __STDC_LIMIT_MACROS is defined before <stdint.h> is included.
  *
  * The same also occurs with __STDC_CONSTANT_MACROS for the constant macros
--- a/python/mozbuild/mozbuild/action/generate_symbols_file.py
+++ b/python/mozbuild/mozbuild/action/generate_symbols_file.py
@@ -17,17 +17,17 @@ def generate_symbols_file(output, *args)
     parser = argparse.ArgumentParser()
     parser.add_argument('input')
     parser.add_argument('-D', action=DefinesAction)
     parser.add_argument('-U', action='append', default=[])
     args = parser.parse_args(args)
     input = os.path.abspath(args.input)
 
     pp = Preprocessor()
-    pp.context.update(buildconfig.defines['ALLDEFINES'])
+    pp.context.update(buildconfig.defines['GLOBAL_DEFINES'])
     if args.D:
         pp.context.update(args.D)
     for undefine in args.U:
         if undefine in pp.context:
             del pp.context[undefine]
     # Hack until MOZ_DEBUG_FLAGS are simply part of buildconfig.defines
     if buildconfig.substs['MOZ_DEBUG']:
         pp.context['DEBUG'] = '1'
--- a/python/mozbuild/mozbuild/action/process_define_files.py
+++ b/python/mozbuild/mozbuild/action/process_define_files.py
@@ -19,18 +19,18 @@ def process_define_file(output, input):
     taking the corresponding source file and replacing some #define/#undef
     occurences:
         "#undef NAME" is turned into "#define NAME VALUE"
         "#define NAME" is unchanged
         "#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.
+    As a special rule, "#undef GLOBAL_DEFINES" is turned into "#define NAME
+    VALUE" for all the global defined variables.
     '''
 
     path = os.path.abspath(input)
 
     config = PartialConfigEnvironment(topobjdir)
 
     if mozpath.basedir(path,
                        [mozpath.join(topsrcdir, 'js/src')]) and \
@@ -41,24 +41,24 @@ def process_define_file(output, 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 and cmd != 'endif':
-                    if name == 'ALLDEFINES':
+                    if name == 'GLOBAL_DEFINES':
                         if cmd == 'define':
                             raise Exception(
-                                '`#define ALLDEFINES` is not allowed in a '
+                                '`#define GLOBAL_DEFINES` is not allowed in a '
                                 'CONFIGURE_DEFINE_FILE')
                         defines = '\n'.join(sorted(
                             '#define %s %s' % (name, val)
-                            for name, val in config.defines['ALLDEFINES'].iteritems()))
+                            for name, val in config.defines['GLOBAL_DEFINES'].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':
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -327,17 +327,17 @@ class PartialConfigEnvironment(object):
 
     The PartialConfigEnvironment automatically defines one additional subst variable
     from all the defines not appearing in non_global_config:
       - 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.
 
     and one additional define from all the defines as a dictionary:
-      - ALLDEFINES contains all of the global defines as a dictionary. This is
+      - GLOBAL_DEFINES contains all of the global defines as a dictionary. This is
       intended to be used instead of the defines structure from config.status so
       that scripts can depend directly on its value.
     """
     def __init__(self, topobjdir):
         config_statusd = mozpath.join(topobjdir, 'config.statusd')
         self.substs = PartialConfigDict(config_statusd, 'substs', environ_override=True)
         self.defines = PartialConfigDict(config_statusd, 'defines')
         self.topobjdir = topobjdir
@@ -353,15 +353,15 @@ class PartialConfigEnvironment(object):
         acdefines = ' '.join(['-D%s=%s' % (name,
             shell_quote(config['defines'][name]).replace('$', '$$'))
             for name in sorted(global_defines)])
         substs['ACDEFINES'] = acdefines
 
         all_defines = OrderedDict()
         for k in global_defines:
             all_defines[k] = config['defines'][k]
-        defines['ALLDEFINES'] = all_defines
+        defines['GLOBAL_DEFINES'] = all_defines
 
         self.substs._fill_group(substs)
         self.defines._fill_group(defines)
 
     def get_dependencies(self):
         return ['$(wildcard %s)' % f for f in self.substs._files | self.defines._files]
--- a/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py
+++ b/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py
@@ -37,22 +37,22 @@ class TestPartial(unittest.TestCase):
         os.environ.update(self._old_env)
 
     def _objdir(self):
         objdir = mkdtemp()
         self.addCleanup(rmtree, objdir)
         return objdir
 
     def test_auto_substs(self):
-        '''Test the automatically set values of ACDEFINES, and ALLDEFINES
+        '''Test the automatically set values of ACDEFINES, and GLOBAL_DEFINES
         '''
         env = PartialConfigEnvironment(self._objdir())
         env.write_vars(config)
         self.assertEqual(env.substs['ACDEFINES'], '-DMOZ_BAR=2 -DMOZ_FOO=1')
-        self.assertEqual(env.defines['ALLDEFINES'], {
+        self.assertEqual(env.defines['GLOBAL_DEFINES'], {
             'MOZ_BAR': '2',
             'MOZ_FOO': '1',
         })
 
     def test_remove_subst(self):
         '''Test removing a subst from the config. The file should be overwritten with 'None'
         '''
         env = PartialConfigEnvironment(self._objdir())
--- a/toolkit/mozapps/installer/find-dupes.py
+++ b/toolkit/mozapps/installer/find-dupes.py
@@ -97,17 +97,17 @@ def main():
     parser.add_argument('directory',
                         help='The directory to check for duplicates in')
 
     args = parser.parse_args()
 
     allowed_dupes = []
     for filename in args.dupes_files:
         pp = Preprocessor()
-        pp.context.update(buildconfig.defines['ALLDEFINES'])
+        pp.context.update(buildconfig.config.defines)
         if args.D:
             pp.context.update(args.D)
         for undefine in args.U:
             if undefine in pp.context:
                 del pp.context[undefine]
         pp.out = StringIO()
         pp.do_filter('substitution')
         pp.do_include(filename)
--- a/toolkit/mozapps/installer/packager.py
+++ b/toolkit/mozapps/installer/packager.py
@@ -221,17 +221,17 @@ def main():
                         help='Manifest file name')
     parser.add_argument('source', help='Source directory')
     parser.add_argument('destination', help='Destination directory')
     parser.add_argument('--non-resource', nargs='+', metavar='PATTERN',
                         default=[],
                         help='Extra files not to be considered as resources')
     args = parser.parse_args()
 
-    defines = dict(buildconfig.defines['ALLDEFINES'])
+    defines = dict(buildconfig.config.defines)
     if args.ignore_errors:
         errors.ignore_errors()
 
     if args.defines:
         for name, value in [split_define(d) for d in args.defines]:
             defines[name] = value
 
     compress = {