Bug 1319345 - Change how application.ini and application.ini.h are generated. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 02 Nov 2016 17:16:56 +0900
changeset 323943 d4006c73e308002cfefc45512dff41d92da2e0a7
parent 323942 861e47bdfa2bb1aa73042d4e252f0365e6b4975c
child 323944 4215cd6d8d55af24fc88999ade03261fa7ce56da
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +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_UNITTEST_MANIFESTS += [
         'compare-mozconfig/python.ini',
     ]
 
 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:])