Bug 1319345 - Change how application.ini and application.ini.h are generated. r?mshal draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 02 Nov 2016 17:16:56 +0900
changeset 442607 0726f5897e45dc9d4b81cb5fffd1822d96053e38
parent 442283 e8bf500b9d663ee1557eaa7a6baffd58be48c679
child 442608 42993a0ea548c261ac62c88274aeb775f66b7a25
child 442633 bbdc4cf09e3791595fc3ca40a34d30747c061936
push id36756
push userbmo:mh+mozilla@glandium.org
push dateTue, 22 Nov 2016 22:21:56 +0000
reviewersmshal
bugs1319345
milestone53.0a1
Bug 1319345 - Change how application.ini and application.ini.h are generated. r?mshal The current way they are generated makes it so that it's not trivial for the backends to figure that one depends on the other. While we should eventually make things such that using FINAL_TARGET_PP_FILES works for that, it's currently simpler to just use GENERATED_FILES.
build/application.ini
build/application.ini.in
build/moz.build
python/mozbuild/mozbuild/action/preprocessor.py
rename from build/application.ini
rename to build/application.ini.in
--- a/build/moz.build
+++ b/build/moz.build
@@ -13,34 +13,17 @@ SPHINX_TREES['buildsystem'] = 'docs'
 if CONFIG['OS_ARCH'] == 'WINNT':
     DIRS += ['win32']
 else:
     DIRS += ['unix']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     DIRS += ['annotationProcessors']
 
-for var in ('GRE_MILESTONE', 'MOZ_APP_VERSION', 'MOZ_APP_BASENAME',
-            'MOZ_APP_VENDOR', 'MOZ_APP_ID', 'MAR_CHANNEL_ID',
-            'ACCEPTED_MAR_CHANNEL_IDS', 'MOZ_APP_REMOTINGNAME'):
-    DEFINES[var] = CONFIG[var]
-
-if CONFIG['MOZ_APP_DISPLAYNAME'] != CONFIG['MOZ_APP_BASENAME']:
-    DEFINES['MOZ_APP_DISPLAYNAME'] = CONFIG['MOZ_APP_DISPLAYNAME']
-
-if CONFIG['MOZ_BUILD_APP'] == 'browser':
-    DEFINES['MOZ_BUILD_APP_IS_BROWSER'] = True
-
-if CONFIG['MOZ_APP_PROFILE']:
-    DEFINES['MOZ_APP_PROFILE'] = CONFIG['MOZ_APP_PROFILE']
-
-for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR',
-            'MOZ_APP_STATIC_INI'):
-    if CONFIG[var]:
-        DEFINES[var] = True
+DEFINES['ACCEPTED_MAR_CHANNEL_IDS'] = CONFIG['ACCEPTED_MAR_CHANNEL_IDS']
 
 if CONFIG['MOZ_BUILD_APP'] == 'browser':
     PYTHON_UNIT_TESTS += [
         'compare-mozconfig/compare-mozconfigs-wrapper.py',
     ]
 
 if CONFIG['ENABLE_TESTS'] or CONFIG['MOZ_DMD']:
     FINAL_TARGET_FILES += ['/tools/rb/fix_stack_using_bpsyms.py']
@@ -58,27 +41,55 @@ FINAL_TARGET_FILES += ['/.gdbinit']
 FINAL_TARGET_PP_FILES += ['.gdbinit_python.in']
 OBJDIR_FILES += ['!/dist/bin/.gdbinit_python']
 
 # Install the clang-cl runtime library for ASAN next to the binaries we produce.
 if CONFIG['MOZ_ASAN'] and CONFIG['CLANG_CL']:
     FINAL_TARGET_FILES += ['%' + CONFIG['MOZ_CLANG_RT_ASAN_LIB_PATH']]
 
 if CONFIG['MOZ_APP_BASENAME']:
-    FINAL_TARGET_PP_FILES += ['application.ini']
+    appini_defines = {
+        'TOPOBJDIR': TOPOBJDIR,
+    }
+
+    for var in ('GRE_MILESTONE', 'MOZ_APP_VERSION', 'MOZ_APP_BASENAME',
+                'MOZ_APP_VENDOR', 'MOZ_APP_ID', 'MAR_CHANNEL_ID',
+                'MOZ_APP_REMOTINGNAME'):
+        appini_defines[var] = CONFIG[var]
+
+    if CONFIG['MOZ_APP_DISPLAYNAME'] != CONFIG['MOZ_APP_BASENAME']:
+        appini_defines['MOZ_APP_DISPLAYNAME'] = CONFIG['MOZ_APP_DISPLAYNAME']
+
+    if CONFIG['MOZ_BUILD_APP'] == 'browser':
+        appini_defines['MOZ_BUILD_APP_IS_BROWSER'] = True
+
+    if CONFIG['MOZ_APP_PROFILE']:
+        appini_defines['MOZ_APP_PROFILE'] = CONFIG['MOZ_APP_PROFILE']
+
+    for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR',
+                'MOZ_APP_STATIC_INI'):
+        if CONFIG[var]:
+            appini_defines[var] = True
+
+    GENERATED_FILES += ['application.ini']
+
+    appini = GENERATED_FILES['application.ini']
+    appini.script = '../python/mozbuild/mozbuild/action/preprocessor.py:generate'
+    appini.inputs = ['application.ini.in']
+    appini.flags = ['-D%s=%s' % (k, '1' if v is True else v)
+                    for k, v in appini_defines.iteritems()]
+    FINAL_TARGET_FILES += ['!application.ini']
     if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' and CONFIG['MOZ_UPDATER']:
         FINAL_TARGET_PP_FILES += ['update-settings.ini']
 
     if CONFIG['MOZ_APP_STATIC_INI']:
         GENERATED_FILES += ['application.ini.h']
         appini = GENERATED_FILES['application.ini.h']
         appini.script = 'appini_header.py'
-        appini.inputs = ['!/dist/bin/application.ini']
-
-DEFINES['TOPOBJDIR'] = TOPOBJDIR
+        appini.inputs = ['!application.ini']
 
 # NOTE: Keep .gdbinit in the topsrcdir for people who run gdb from the topsrcdir.
 OBJDIR_FILES += ['/.gdbinit']
 
 # Put a .lldbinit in the bin directory and the objdir, to be picked up
 # automatically by LLDB when we debug executables using either of those two
 # directories as the current working directory.  The .lldbinit file will
 # load $(topsrcdir)/.lldbinit, which is where the actual debugging commands are.
--- a/python/mozbuild/mozbuild/action/preprocessor.py
+++ b/python/mozbuild/mozbuild/action/preprocessor.py
@@ -4,15 +4,21 @@
 
 from __future__ import absolute_import
 
 import sys
 
 from mozbuild.preprocessor import Preprocessor
 
 
+def generate(output, *args):
+    pp = Preprocessor()
+    pp.out = output
+    pp.handleCommandLine(list(args), True)
+    return set(pp.includes)
+
 def main(args):
-  pp = Preprocessor()
-  pp.handleCommandLine(args, True)
+    pp = Preprocessor()
+    pp.handleCommandLine(args, True)
 
 
 if __name__ == "__main__":
   main(sys.argv[1:])