Bug 1229245 - Use a FinalTargetFiles-like object for TESTING_JS_MODULES. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Sat, 28 Nov 2015 11:48:50 +0900
changeset 274891 3a46c6381b0d
parent 274890 e43cd6da7458
child 274892 76c20ad43874
push id29739
push usercbook@mozilla.com
push date2015-12-01 14:26 +0000
treeherdermozilla-central@974fe614d529 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1229245
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 1229245 - Use a FinalTargetFiles-like object for TESTING_JS_MODULES. r=gps
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/frontend/emitter.py
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -52,17 +52,16 @@ from ..frontend.data import (
     HostDefines,
     HostLibrary,
     HostProgram,
     HostSimpleProgram,
     HostSources,
     InstallationTarget,
     JARManifest,
     JavaJarData,
-    JavaScriptModules,
     Library,
     LocalInclude,
     PerSourceFlag,
     Program,
     SharedLibrary,
     SimpleProgram,
     Sources,
     StaticLibrary,
@@ -557,19 +556,16 @@ class RecursiveMakeBackend(CommonBackend
             self._process_local_include(obj.path, backend_file)
 
         elif isinstance(obj, PerSourceFlag):
             self._process_per_source_flag(obj, backend_file)
 
         elif isinstance(obj, InstallationTarget):
             self._process_installation_target(obj, backend_file)
 
-        elif isinstance(obj, JavaScriptModules):
-            self._process_javascript_modules(obj, backend_file)
-
         elif isinstance(obj, ContextWrapped):
             # Process a rich build system object from the front-end
             # as-is.  Please follow precedent and handle CamelCaseData
             # in a function named _process_camel_case_data.  At some
             # point in the future, this unwrapping process may be
             # automated.
             if isinstance(obj.wrapped, JavaJarData):
                 self._process_java_jar_data(obj.wrapped, backend_file)
@@ -1022,28 +1018,16 @@ INSTALL_TARGETS += %(prefix)s
         if obj.target and not obj.is_custom():
             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 != 'testing':
-            raise Exception('Unsupported JavaScriptModules instance: %s' % obj.flavor)
-
-        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))
-
     def _handle_idl_manager(self, manager):
         build_files = self._install_manifests['xpidl']
 
         for p in ('Makefile', 'backend.mk', '.deps/.mkdir.done'):
             build_files.add_optional_exists(p)
 
         for idl in manager.idls.values():
             self._install_manifests['dist_idl'].add_symlink(idl['source'],
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -996,26 +996,20 @@ 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'),
 
-    '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.
-
-        ``TESTING_JS_MODULES.foo += ['module.jsm']``.
+    'TESTING_FILES': (HierarchicalStringList, list,
+        """List of files to be installed in the _tests directory.
+
+        This works similarly to FINAL_TARGET_FILES.
         """, None),
 
     'FINAL_LIBRARY': (unicode, unicode,
         """Library in which the objects of the current directory will be linked.
 
         This variable contains the name of a library, defined elsewhere with
         ``LIBRARY_NAME``, in which the objects of the current directory will be
         linked.
@@ -1969,16 +1963,28 @@ SPECIAL_VARIABLES = {
 
     '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.
         """),
 
+    'TESTING_JS_MODULES': (lambda context: context['TESTING_FILES'].modules, 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.
+
+        ``TESTING_JS_MODULES.foo += ['module.jsm']``.
+        """),
+
 }
 
 # Deprecation hints.
 DEPRECATION_HINTS = {
     'CPP_UNIT_TESTS': '''
         Please use'
 
             CppUnitTests(['foo', 'bar'])
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -647,31 +647,16 @@ class JARManifest(ContextDerived):
     )
 
     def __init__(self, context, path):
         ContextDerived.__init__(self, context)
 
         self.path = path
 
 
-class JavaScriptModules(ContextDerived):
-    """Describes a JavaScript module."""
-
-    __slots__ = (
-        'modules',
-        'flavor',
-    )
-
-    def __init__(self, context, modules, flavor):
-        super(JavaScriptModules, self).__init__(context)
-
-        self.modules = modules
-        self.flavor = flavor
-
-
 class ContextWrapped(ContextDerived):
     """Generic context derived container object for a wrapped rich object.
 
     Use this wrapper class to shuttle a rich build system object
     completely defined in moz.build files through the tree metadata
     emitter to the build backend for processing as-is.
     """
 
@@ -836,16 +821,22 @@ class FinalTargetPreprocessedFiles(Conte
     """
     __slots__ = ('files', 'target')
 
     def __init__(self, sandbox, files):
         ContextDerived.__init__(self, sandbox)
         self.files = files
 
 
+class TestingFiles(FinalTargetFiles):
+    @property
+    def install_target(self):
+        return '_tests'
+
+
 class GeneratedFile(ContextDerived):
     """Represents a generated file."""
 
     __slots__ = (
         'script',
         'method',
         'output',
         'inputs',
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -48,30 +48,30 @@ from .data import (
     HostDefines,
     HostLibrary,
     HostProgram,
     HostSimpleProgram,
     HostSources,
     InstallationTarget,
     IPDLFile,
     JARManifest,
-    JavaScriptModules,
     Library,
     Linkable,
     LinkageWrongKindError,
     LocalInclude,
     PerSourceFlag,
     PreprocessedTestWebIDLFile,
     PreprocessedWebIDLFile,
     Program,
     SharedLibrary,
     SimpleProgram,
     Sources,
     StaticLibrary,
     TestHarnessFiles,
+    TestingFiles,
     TestWebIDLFile,
     TestManifest,
     UnifiedSources,
     VariablePassthru,
     WebIDLFile,
     XPIDLFile,
 )
 from mozpack.chrome.manifest import (
@@ -624,20 +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)
 
-        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),
             ('PREPROCESSED_TEST_WEBIDL_FILES', PreprocessedTestWebIDLFile),
             ('PREPROCESSED_WEBIDL_FILES', PreprocessedWebIDLFile),
             ('TEST_WEBIDL_FILES', TestWebIDLFile),
             ('WEBIDL_FILES', WebIDLFile),
@@ -654,21 +650,22 @@ class TreeMetadataEmitter(LoggingMixin):
                     'does not exist: %s (resolved to %s)' % (local_include,
                     local_include.full_path), context)
             yield LocalInclude(context, local_include)
 
         components = []
         for var, cls in (
             ('FINAL_TARGET_FILES', FinalTargetFiles),
             ('FINAL_TARGET_PP_FILES', FinalTargetPreprocessedFiles),
+            ('TESTING_FILES', TestingFiles),
         ):
             all_files = context.get(var)
             if not all_files:
                 continue
-            if dist_install is False:
+            if dist_install is False and var != 'TESTING_FILES':
                 raise SandboxValidationError(
                     '%s cannot be used with DIST_INSTALL = False' % var,
                     context)
             has_prefs = False
             has_resources = False
             for base, files in all_files.walk():
                 if base == 'components':
                     components.extend(files)