Bug 1229241 - Use FINAL_TARGET{,_PP}_FILES for EXTRA{,_PP}_JS_MODULES. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 28 Nov 2015 11:20:32 +0900
changeset 274876 60c1ec5f83695254cd858913b21bb07ad78bf73e
parent 274875 192e590b1a63cad3fc36b768e3e3b7e3ef73fd1c
child 274877 0aed6d9859486d2704f6ba6200bd6bec9149b33e
push id29739
push usercbook@mozilla.com
push dateTue, 01 Dec 2015 14:26:30 +0000
treeherdermozilla-central@974fe614d529 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1229241
milestone45.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 1229241 - Use FINAL_TARGET{,_PP}_FILES for EXTRA{,_PP}_JS_MODULES. r=gps
python/mozbuild/mozbuild/backend/fastermake.py
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/backend/data/extra-js-modules/moz.build
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -7,17 +7,16 @@ from __future__ import absolute_import, 
 from mozbuild.backend.common import CommonBackend
 from mozbuild.frontend.data import (
     ChromeManifestEntry,
     ContextDerived,
     Defines,
     FinalTargetPreprocessedFiles,
     FinalTargetFiles,
     JARManifest,
-    JavaScriptModules,
     XPIDLFile,
 )
 from mozbuild.jar import JarManifestParser
 from mozbuild.makeutil import Makefile
 from mozbuild.preprocessor import Preprocessor
 from mozbuild.util import OrderedDefaultDict
 from mozpack.manifests import InstallManifest
 import mozpack.path as mozpath
@@ -70,29 +69,16 @@ class FasterMakeBackend(CommonBackend):
             # which is kind of set in stone from the order things are treated
             # in emitter.py.
             assert obj.objdir not in self._seen_directories
 
         elif isinstance(obj, JARManifest) and \
                 obj.install_target.startswith('dist/bin'):
             self._consume_jar_manifest(obj, defines)
 
-        elif isinstance(obj, JavaScriptModules) and \
-                obj.install_target.startswith('dist/bin'):
-            for path, strings in obj.modules.walk():
-                base = mozpath.join('modules', path)
-                for f in strings:
-                    if obj.flavor == 'extra':
-                        self._install_manifests[obj.install_target].add_symlink(
-                            mozpath.join(obj.srcdir, f),
-                            mozpath.join(base, mozpath.basename(f))
-                        )
-                    elif obj.flavor == 'extra_pp':
-                        self._add_preprocess(obj, f, base, defines=defines)
-
         elif isinstance(obj, (FinalTargetFiles,
                               FinalTargetPreprocessedFiles)) and \
                 obj.install_target.startswith('dist/bin'):
             for path, strings in obj.files.walk():
                 for f in strings:
                     if isinstance(obj, FinalTargetPreprocessedFiles):
                         self._add_preprocess(obj, f, path, defines=defines)
                     else:
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -1024,47 +1024,19 @@ INSTALL_TARGETS += %(prefix)s
             backend_file.write('FINAL_TARGET = $(DEPTH)/%s\n' % (obj.target))
         else:
             backend_file.write('FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)\n')
 
         if not obj.enabled:
             backend_file.write('NO_DIST_INSTALL := 1\n')
 
     def _process_javascript_modules(self, obj, backend_file):
-        if obj.flavor not in ('extra', 'extra_pp', 'testing'):
+        if obj.flavor != 'testing':
             raise Exception('Unsupported JavaScriptModules instance: %s' % obj.flavor)
 
-        if obj.flavor == 'extra':
-            for path, strings in obj.modules.walk():
-                if not strings:
-                    continue
-
-                prefix = 'extra_js_%s' % path.replace('/', '_')
-                backend_file.write('%s_FILES := %s\n'
-                                   % (prefix, ' '.join(strings)))
-                backend_file.write('%s_DEST = %s\n' %
-                                   (prefix, mozpath.join('$(FINAL_TARGET)', 'modules', path)))
-                backend_file.write('%s_TARGET := misc\n' % prefix)
-                backend_file.write('INSTALL_TARGETS += %s\n\n' % prefix)
-            return
-
-        if obj.flavor == 'extra_pp':
-            for path, strings in obj.modules.walk():
-                if not strings:
-                    continue
-
-                prefix = 'extra_pp_js_%s' % path.replace('/', '_')
-                backend_file.write('%s := %s\n'
-                                   % (prefix, ' '.join(strings)))
-                backend_file.write('%s_PATH = %s\n' %
-                                   (prefix, mozpath.join('$(FINAL_TARGET)', 'modules', path)))
-                backend_file.write('%s_TARGET := misc\n' % prefix)
-                backend_file.write('PP_TARGETS += %s\n\n' % prefix)
-            return
-
         if not self.environment.substs.get('ENABLE_TESTS', False):
             return
 
         manifest = self._install_manifests['tests']
 
         for source, dest, _ in self._walk_hierarchy(obj, obj.modules):
             manifest.add_symlink(source, mozpath.join('modules', dest))
 
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -996,30 +996,16 @@ VARIABLES = {
         """Disable the wrappers for STL which allow it to work with C++ exceptions
         disabled.
         """, None),
 
     'FINAL_TARGET_PP_FILES': (HierarchicalStringList, list,
         """Like ``FINAL_TARGET_FILES``, with preprocessing.
         """, 'libs'),
 
-    'EXTRA_JS_MODULES': (HierarchicalStringList, list,
-        """Additional JavaScript files to distribute.
-
-        This variable contains a list of files to copy into
-        ``$(FINAL_TARGET)/modules.
-        """, 'misc'),
-
-    'EXTRA_PP_JS_MODULES': (HierarchicalStringList, list,
-        """Additional JavaScript files to distribute.
-
-        This variable contains a list of files to copy into
-        ``$(FINAL_TARGET)/modules``, after preprocessing.
-        """, 'misc'),
-
     'TESTING_JS_MODULES': (HierarchicalStringList, list,
         """JavaScript modules to install in the test-only destination.
 
         Some JavaScript modules (JSMs) are test-only and not distributed
         with Firefox. This variable defines them.
 
         To install modules in a subdirectory, use properties of this
         variable to control the final destination. e.g.
@@ -1969,16 +1955,30 @@ SPECIAL_VARIABLES = {
         subdirectory they should be exported to. For example, to export
         ``foo.res`` to the top-level directory, and ``bar.res`` to ``fonts/``,
         append to ``RESOURCE_FILES`` like so::
 
            RESOURCE_FILES += ['foo.res']
            RESOURCE_FILES.fonts += ['bar.res']
         """),
 
+    'EXTRA_JS_MODULES': (lambda context: context['FINAL_TARGET_FILES'].modules, list,
+        """Additional JavaScript files to distribute.
+
+        This variable contains a list of files to copy into
+        ``$(FINAL_TARGET)/modules.
+        """),
+
+    'EXTRA_PP_JS_MODULES': (lambda context: context['FINAL_TARGET_PP_FILES'].modules, list,
+        """Additional JavaScript files to distribute.
+
+        This variable contains a list of files to copy into
+        ``$(FINAL_TARGET)/modules``, after preprocessing.
+        """),
+
 }
 
 # Deprecation hints.
 DEPRECATION_HINTS = {
     'CPP_UNIT_TESTS': '''
         Please use'
 
             CppUnitTests(['foo', 'bar'])
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -624,24 +624,16 @@ class TreeMetadataEmitter(LoggingMixin):
             yield Defines(context, defines)
 
         host_defines = context.get('HOST_DEFINES')
         if host_defines:
             yield HostDefines(context, host_defines)
 
         self._handle_programs(context)
 
-        extra_js_modules = context.get('EXTRA_JS_MODULES')
-        if extra_js_modules:
-            yield JavaScriptModules(context, extra_js_modules, 'extra')
-
-        extra_pp_js_modules = context.get('EXTRA_PP_JS_MODULES')
-        if extra_pp_js_modules:
-            yield JavaScriptModules(context, extra_pp_js_modules, 'extra_pp')
-
         test_js_modules = context.get('TESTING_JS_MODULES')
         if test_js_modules:
             yield JavaScriptModules(context, test_js_modules, 'testing')
 
         simple_lists = [
             ('GENERATED_EVENTS_WEBIDL_FILES', GeneratedEventWebIDLFile),
             ('GENERATED_WEBIDL_FILES', GeneratedWebIDLFile),
             ('IPDL_SOURCES', IPDLFile),
deleted file mode 100644
--- a/python/mozbuild/mozbuild/test/backend/data/extra-js-modules/moz.build
+++ /dev/null
@@ -1,8 +0,0 @@
-# Any copyright is dedicated to the Public Domain.
-# http://creativecommons.org/publicdomain/zero/1.0/
-
-EXTRA_JS_MODULES += ['module1.js', 'module2.js']
-EXTRA_JS_MODULES.submodule += ['module3.js', 'module4.js']
-
-EXTRA_PP_JS_MODULES += ['pp-module1.js']
-EXTRA_PP_JS_MODULES.ppsub += ['pp-module2.js']
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -691,48 +691,16 @@ class TestRecursiveMakeBackend(BackendTe
 
         with open(os.path.join(env.topobjdir, 'backend.mk'), 'rb') as fh:
             lines = fh.readlines()
 
         lines = [line.rstrip() for line in lines]
 
         self.assertIn('JAR_MANIFEST := %s/jar.mn' % env.topsrcdir, lines)
 
-    def test_extra_js_modules(self):
-        env = self._consume('extra-js-modules', RecursiveMakeBackend)
-
-        with open(os.path.join(env.topobjdir, 'backend.mk'), 'rb') as fh:
-            lines = fh.readlines()
-
-        lines = [line.rstrip() for line in lines]
-        self.maxDiff = None
-        expected = [
-            'extra_js__FILES := module1.js module2.js',
-            'extra_js__DEST = $(FINAL_TARGET)/modules/',
-            'extra_js__TARGET := misc',
-            'INSTALL_TARGETS += extra_js_',
-            'extra_js_submodule_FILES := module3.js module4.js',
-            'extra_js_submodule_DEST = $(FINAL_TARGET)/modules/submodule',
-            'extra_js_submodule_TARGET := misc',
-            'INSTALL_TARGETS += extra_js_submodule',
-            'extra_pp_js_ := pp-module1.js',
-            'extra_pp_js__PATH = $(FINAL_TARGET)/modules/',
-            'extra_pp_js__TARGET := misc',
-            'PP_TARGETS += extra_pp_js_',
-            'extra_pp_js_ppsub := pp-module2.js',
-            'extra_pp_js_ppsub_PATH = $(FINAL_TARGET)/modules/ppsub',
-            'extra_pp_js_ppsub_TARGET := misc',
-            'PP_TARGETS += extra_pp_js_ppsub',
-        ]
-
-        found = [line for line in lines if line.startswith(('extra_',
-                                                            'INSTALL_TARGETS',
-                                                            'PP_TARGETS'))]
-        self.assertEqual(expected, found)
-
     def test_test_manifests_duplicate_support_files(self):
         """Ensure duplicate support-files in test manifests work."""
         env = self._consume('test-manifests-duplicate-support-files',
             RecursiveMakeBackend)
 
         p = os.path.join(env.topobjdir, '_build_manifests', 'install', 'tests')
         m = InstallManifest(p)
         self.assertIn('testing/mochitest/tests/support-file.txt', m)