Bug 1641693 - Replace a bunch of uses of `GENERATED_FILES` with the `GeneratedFile` template r=necko-reviewers,geckoview-reviewers,aklotz,dragana,froydnj
authorRicky Stewart <rstewart@mozilla.com>
Mon, 01 Jun 2020 16:00:28 +0000
changeset 533326 aa85ec8bc0721238f2c3a88342dfeca418b036fd
parent 533325 05154441b0f4adf797324d5ef3c79d7f50fac4fb
child 533327 bd587844f8820742827af14859e6f3643e16ee34
push id37469
push userapavel@mozilla.com
push dateMon, 01 Jun 2020 21:42:28 +0000
treeherdermozilla-central@bc973d369db5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnecko-reviewers, geckoview-reviewers, aklotz, dragana, froydnj
bugs1641693
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641693 - Replace a bunch of uses of `GENERATED_FILES` with the `GeneratedFile` template r=necko-reviewers,geckoview-reviewers,aklotz,dragana,froydnj Also update documentation to suggest using the `GeneratedFile` template rather than directly referencing `GENERATED_FILES` where possible. Differential Revision: https://phabricator.services.mozilla.com/D77496
accessible/mac/moz.build
config/moz.build
layout/style/test/moz.build
media/libdav1d/asm/moz.build
media/mp4parse-rust/moz.build
modules/libpref/moz.build
mozglue/dllservices/moz.build
netwerk/dns/tests/unit/data/moz.build
python/mozbuild/mozbuild/frontend/context.py
toolkit/components/normandy/test/browser/moz.build
toolkit/mozapps/extensions/test/browser/moz.build
widget/android/bindings/moz.build
--- a/accessible/mac/moz.build
+++ b/accessible/mac/moz.build
@@ -42,22 +42,18 @@ LOCAL_INCLUDES += [
     '/accessible/ipc/other',
     '/accessible/xul',
     '/layout/generic',
     '/layout/xul',
     '/widget',
     '/widget/cocoa',
 ]
 
-GENERATED_FILES += [
-    'MacSelectorMap.h',
-    'MacSelectorMap.mm',
-]
-
-GENERATED_FILES['MacSelectorMap.mm'].script = '/accessible/mac/SelectorMapGen.py:gen_mm'
-GENERATED_FILES['MacSelectorMap.mm'].inputs = ['MOXAccessibleProtocol.h']
-
-GENERATED_FILES['MacSelectorMap.h'].script = '/accessible/mac/SelectorMapGen.py:gen_h'
-GENERATED_FILES['MacSelectorMap.h'].inputs = ['MOXAccessibleProtocol.h']
+GeneratedFile('MacSelectorMap.h',
+              script='/accessible/mac/SelectorMapGen.py', entry_point='gen_h',
+              inputs=['MOXAccessibleProtocol.h'])
+GeneratedFile('MacSelectorMap.mm',
+              script='/accessible/mac/SelectorMapGen.py', entry_point='gen_mm',
+              inputs=['MOXAccessibleProtocol.h'])
 
 FINAL_LIBRARY = 'xul'
 
 include('/ipc/chromium/chromium-config.mozbuild')
--- a/config/moz.build
+++ b/config/moz.build
@@ -50,21 +50,19 @@ if CONFIG['WRAP_STL_INCLUDES']:
         # GeneratedFile.__init__ in python/mozbuild/mozbuild/frontend/data.py
         # might need to be updated accordingly as well.
         template_file = SRCDIR + '/%s-stl-wrapper.template.h' % stl_compiler
         output_dir = '../dist/stl_wrappers'
         # We have to use a sentinel file as the first file because the
         # file_generate action will create it for us, but we want to create all
         # the files in gen_wrappers()
         outputs = tuple(['stl.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers])
-        GENERATED_FILES += [outputs]
-        stl = GENERATED_FILES[outputs]
-        stl.script = 'make-stl-wrappers.py:gen_wrappers'
-        stl.flags = [output_dir, stl_compiler, template_file]
-        stl.flags.extend(stl_headers)
+        GeneratedFile(
+            *outputs, script='make-stl-wrappers.py', entry_point='gen_wrappers',
+            flags=[output_dir, stl_compiler, template_file] + stl_headers)
 
     # Wrap <windows.h> to make it easier to use correctly
     # NOTE: If we aren't wrapping STL includes, we're building part of the browser
     # which won't need this wrapper, such as L10N. Just don't try to generate the
     # wrapper in that case.
     if CONFIG['OS_TARGET'] == 'WINNT':
         GeneratedFile('../dist/stl_wrappers/windows.h',
                       script='make-windows-h-wrapper.py',
@@ -73,14 +71,11 @@ if CONFIG['WRAP_STL_INCLUDES']:
                                 'windows-h-unicode.decls.h',
                                 'windows-h-wrapper.template.h'],
                       flags=[stl_compiler])
 
 if CONFIG['WRAP_SYSTEM_INCLUDES']:
     include('system-headers.mozbuild')
     output_dir = '../dist/system_wrappers'
     outputs = tuple(['system-header.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers + system_headers])
-    GENERATED_FILES += [outputs]
-    system = GENERATED_FILES[outputs]
-    system.script = 'make-system-wrappers.py:gen_wrappers'
-    system.flags = [output_dir]
-    system.flags.extend(stl_headers)
-    system.flags.extend(system_headers)
+    GeneratedFile(*outputs, script='make-system-wrappers.py',
+                  entry_point='gen_wrappers',
+                  flags = [output_dir] + stl_headers + system_headers)
--- a/layout/style/test/moz.build
+++ b/layout/style/test/moz.build
@@ -132,15 +132,13 @@ TEST_HARNESS_FILES.testing.mochitest.tes
     '/layout/reftests/svg/as-image/svg-image-visited-1d.html',
     '/layout/reftests/svg/pseudo-classes-02-ref.svg',
     '/layout/reftests/svg/pseudo-classes-02.svg',
 ]
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
 
 if CONFIG['COMPILE_ENVIRONMENT']:
-    GENERATED_FILES += ['css_properties.js']
-    GENERATED_FILES['css_properties.js'].script = 'gen-css-properties.py'
-    GENERATED_FILES['css_properties.js'].inputs = [
-        'css_properties_like_longhand.js',
-        '!host_ListCSSProperties%s' % CONFIG['HOST_BIN_SUFFIX'],
-    ]
+    GeneratedFile('css_properties.js', script='gen-css-properties.py',
+                  inputs=[
+                      'css_properties_like_longhand.js',
+                      '!host_ListCSSProperties%s' % CONFIG['HOST_BIN_SUFFIX']])
     TEST_HARNESS_FILES.testing.mochitest.tests.layout.style.test += ['!css_properties.js']
--- a/media/libdav1d/asm/moz.build
+++ b/media/libdav1d/asm/moz.build
@@ -110,43 +110,31 @@ if CONFIG['CPU_ARCH'] in ('x86', 'x86_64
         'film_grain_init_tmpl.c',
         'ipred_init_tmpl.c',
         'itx_init_tmpl.c',
         'loopfilter_init_tmpl.c',
         'looprestoration_init_tmpl.c',
         'mc_init_tmpl.c',
     ]
 
-    GENERATED_FILES += [
-        '16bd_%s' % p for p in bitdepth_basenames
-    ]
-
-    SOURCES += [
-        '!16bd_%s' % p for p in bitdepth_basenames
-    ]
 
     for f in bitdepth_basenames:
-        a = GENERATED_FILES['16bd_%s' % f]
-        a.script = '../generate_source.py:add_define'
-        a.inputs = [relative_path + f]
-        a.flags = ['BITDEPTH', '16']
-
-    GENERATED_FILES += [
-        '8bd_%s' % p for p in bitdepth_basenames
-    ]
+        SOURCES += [
+            '!16bd_%s' % f
+        ]
+        GeneratedFile('16bd_%s' % f, script='../generate_source.py',
+                      entry_point='add_define', inputs=[relative_path + f],
+                      flags=['BITDEPTH', '16'])
+        SOURCES += [
+            '!8bd_%s' % f
+        ]
+        GeneratedFile('8bd_%s' % f, script='../generate_source.py',
+                      entry_point='add_define', inputs=[relative_path + f],
+                      flags=['BITDEPTH', '8'])
 
-    SOURCES += [
-        '!8bd_%s' % p for p in bitdepth_basenames
-    ]
-
-    for f in bitdepth_basenames:
-        a = GENERATED_FILES['8bd_%s' % f]
-        a.script = '../generate_source.py:add_define'
-        a.inputs = [relative_path + f]
-        a.flags = ['BITDEPTH', '8']
 elif CONFIG['CPU_ARCH'] == 'arm' or CONFIG['CPU_ARCH'] == 'aarch64':
     SOURCES += [
         '../../../third_party/dav1d/src/arm/cpu.c',
     ]
     EXPORTS += [
         '../../../third_party/dav1d/src/arm/cpu.h',
         '../../../third_party/dav1d/src/arm/msac.h',
     ]
@@ -157,43 +145,29 @@ elif CONFIG['CPU_ARCH'] == 'arm' or CONF
         'cdef_init_tmpl.c',
         'ipred_init_tmpl.c',
         'itx_init_tmpl.c',
         'loopfilter_init_tmpl.c',
         'looprestoration_init_tmpl.c',
         'mc_init_tmpl.c',
     ]
 
-    GENERATED_FILES += [
-        '16bd_%s' % p for p in bitdepth_basenames
-    ]
-
-    SOURCES += [
-        '!16bd_%s' % p for p in bitdepth_basenames
-    ]
-
     for f in bitdepth_basenames:
-        a = GENERATED_FILES['16bd_%s' % f]
-        a.script = '../generate_source.py:add_define'
-        a.inputs = [relative_path + f]
-        a.flags = ['BITDEPTH', '16']
-
-    GENERATED_FILES += [
-        '8bd_%s' % p for p in bitdepth_basenames
-    ]
-
-    SOURCES += [
-        '!8bd_%s' % p for p in bitdepth_basenames
-    ]
-
-    for f in bitdepth_basenames:
-        a = GENERATED_FILES['8bd_%s' % f]
-        a.script = '../generate_source.py:add_define'
-        a.inputs = [relative_path + f]
-        a.flags = ['BITDEPTH', '8']
+        SOURCES += [
+            '!16bd_%s' % f
+        ]
+        GeneratedFile('16bd_%s' % f, script='../generate_source.py',
+                      entry_point='add_define', inputs=[relative_path + f],
+                      flags=['BITDEPTH', '16'])
+        SOURCES += [
+            '!8bd_%s' % f
+        ]
+        GeneratedFile('8bd_%s' % f, script='../generate_source.py',
+                      entry_point='add_define', inputs=[relative_path + f],
+                      flags=['BITDEPTH', '8'])
 
     # BITDEPTH .S files
     if CONFIG['CPU_ARCH'] == 'aarch64':
         SOURCES += [
             '../../../third_party/dav1d/src/arm/64/cdef.S',
             '../../../third_party/dav1d/src/arm/64/cdef16.S',
             '../../../third_party/dav1d/src/arm/64/cdef_tmpl.S',
             '../../../third_party/dav1d/src/arm/64/ipred.S',
--- a/media/mp4parse-rust/moz.build
+++ b/media/mp4parse-rust/moz.build
@@ -4,24 +4,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 EXPORTS += [
     'mp4parse.h',
 ]
 
 if CONFIG['COMPILE_ENVIRONMENT']:
-
-    GENERATED_FILES += [
-        'mp4parse_ffi_generated.h',
-    ]
+    GeneratedFile('mp4parse_ffi_generated.h',
+                  script='/build/RunCbindgen.py', entry_point='generate',
+                  inputs=['/third_party/rust/mp4parse_capi'])
 
     EXPORTS += [ # Should this be namespaced? EXPORTS.mozilla.media
         '!mp4parse_ffi_generated.h',
     ]
 
-    ffi_generated = GENERATED_FILES['mp4parse_ffi_generated.h']
-    ffi_generated.script = '/build/RunCbindgen.py:generate'
-    ffi_generated.inputs = [
-        '/third_party/rust/mp4parse_capi',
-    ]
-
 FINAL_LIBRARY = 'xul'
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -116,21 +116,18 @@ EXPORTS.mozilla += sorted(['!' + g for g
 
 UNIFIED_SOURCES += [
     'Preferences.cpp',
     'SharedPrefMap.cpp',
 ]
 
 gen_all_tuple = tuple(gen_h + gen_cpp + gen_rs)
 
-GENERATED_FILES += [gen_all_tuple]
-
-static_pref_list = GENERATED_FILES[gen_all_tuple]
-static_pref_list.script = 'init/generate_static_pref_list.py:emit_code'
-static_pref_list.inputs = ['init/StaticPrefList.yaml']
+GeneratedFile(*gen_all_tuple, script='init/generate_static_pref_list.py',
+              entry_point='emit_code', inputs=['init/StaticPrefList.yaml'])
 
 PYTHON_UNITTEST_MANIFESTS += [
     'test/python.ini',
 ]
 
 XPCOM_MANIFESTS += [
     'components.conf',
 ]
--- a/mozglue/dllservices/moz.build
+++ b/mozglue/dllservices/moz.build
@@ -42,17 +42,15 @@ EXPORTS.mozilla.glue += [
     'WindowsDllServices.h',
 ]
 
 # Generate DLL Blocklists
 blocklist_header_types = ['A11y', 'Launcher', 'Legacy', 'Test']
 blocklist_file_leaf_tpl = 'WindowsDllBlocklist{0}Defs.h'
 blocklist_files = tuple([blocklist_file_leaf_tpl.format(type)
                          for type in blocklist_header_types])
-GENERATED_FILES += [
-    blocklist_files
-]
-blocklist_defs = GENERATED_FILES[blocklist_files]
-blocklist_defs.script = 'gen_dll_blocklist_defs.py:gen_blocklists'
-blocklist_defs.inputs = ['WindowsDllBlocklistDefs.in']
+
+GeneratedFile(*blocklist_files, script='gen_dll_blocklist_defs.py',
+              entry_point='gen_blocklists',
+              inputs=['WindowsDllBlocklistDefs.in'])
 EXPORTS.mozilla += ['!' + hdr for hdr in blocklist_files]
 
 FINAL_LIBRARY = 'mozglue'
--- a/netwerk/dns/tests/unit/data/moz.build
+++ b/netwerk/dns/tests/unit/data/moz.build
@@ -1,14 +1,10 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-GENERATED_FILES = ['fake_remote_dafsa.bin']
-
-fake_remote_dafsa = GENERATED_FILES['fake_remote_dafsa.bin']
-fake_remote_dafsa.script = '../../../prepare_tlds.py'
-fake_remote_dafsa.inputs = ['fake_public_suffix_list.dat']
-fake_remote_dafsa.flags = ['bin']
+GeneratedFile('fake_remote_dafsa.bin', script='../../../prepare_tlds.py',
+              inputs=['fake_public_suffix_list.dat'], flags = ['bin'])
 
 TEST_HARNESS_FILES.xpcshell.netwerk.dns.tests.unit.data += ['!fake_remote_dafsa.bin']
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -1418,16 +1418,22 @@ VARIABLES = {
         """
         ),
 
     'GENERATED_FILES': (
         GeneratedFilesList,
         list,
         """Generic generated files.
 
+        Unless you have a reason not to, use the GeneratedFile template rather
+        than referencing GENERATED_FILES directly. The GeneratedFile template
+        has all the same arguments as the attributes listed below (``script``,
+        ``inputs``, ``flags``, ``force``), plus an additional ``entry_point``
+        argument to specify a particular function to run in the given script.
+
         This variable contains a list of files for the build system to
         generate at export time. The generation method may be declared
         with optional ``script``, ``inputs``, ``flags``, and ``force``
         attributes on individual entries.
         If the optional ``script`` attribute is not present on an entry, it
         is assumed that rules for generating the file are present in
         the associated Makefile.in.
 
--- a/toolkit/components/normandy/test/browser/moz.build
+++ b/toolkit/components/normandy/test/browser/moz.build
@@ -1,8 +1,10 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 BROWSER_CHROME_MANIFESTS += [
   'browser.ini',
 ]
 
@@ -13,13 +15,11 @@ addons = [
 ]
 
 output_dir = OBJDIR_FILES._tests.testing.mochitest.browser.toolkit.components.normandy.test.browser.addons
 
 for addon in addons:
     indir = 'addons/%s' % addon
     xpi = '%s.xpi' % indir
 
-    GENERATED_FILES += [xpi]
-    GENERATED_FILES[xpi].script = '../create_xpi.py'
-    GENERATED_FILES[xpi].inputs = [indir]
+    GeneratedFile(xpi, script='../create_xpi.py', inputs=[indir])
 
     output_dir += ['!%s' % xpi]
--- a/toolkit/mozapps/extensions/test/browser/moz.build
+++ b/toolkit/mozapps/extensions/test/browser/moz.build
@@ -19,14 +19,12 @@ addons = [
 
 output_dir = OBJDIR_FILES._tests.testing.mochitest.browser.toolkit.mozapps.extensions.test.browser.addons
 
 for addon in addons:
     for file_type in ['xpi', 'zip']:
         indir = 'addons/%s' % addon
         path = '%s.%s' % (indir, file_type)
 
-        GENERATED_FILES += [path]
-        GENERATED_FILES[path].script = '../create_xpi.py'
-        GENERATED_FILES[path].inputs = [indir]
+        GeneratedFile(path, script='../create_xpi.py', inputs=[indir])
 
         output_dir += ['!%s' % path]
 
--- a/widget/android/bindings/moz.build
+++ b/widget/android/bindings/moz.build
@@ -32,17 +32,17 @@ EXPORTS += ['!%s.h' % stem for stem in g
 # The recursive make backend treats the first output specially: it's passed as
 # an open FileAvoidWrite to the invoked script.  That doesn't work well with
 # the Gradle task that generates all of the outputs, so we add a dummy first
 # output.
 t = tuple(['sdk_bindings'] +
           ['%s.cpp' % stem for stem in generated] +
           ['%s.h' % stem for stem in generated])
 
-GENERATED_FILES += [t]
-GENERATED_FILES[t].script = '/mobile/android/gradle.py:generate_sdk_bindings'
-GENERATED_FILES[t].inputs += ['%s-classes.txt' % stem for stem in generated]
+GeneratedFile(*t, script='/mobile/android/gradle.py',
+              entry_point='generate_sdk_bindings',
+              inputs=['%s-classes.txt' % stem for stem in generated])
 
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/widget/android',
 ]