Bug 1259806 - Remove toolkit/components/ctypes/tests/Makefile.in; r=ted
authorMike Shal <mshal@mozilla.com>
Fri, 25 Mar 2016 14:25:17 -0400
changeset 291286 ec809e68ba7e040911dbebd1f0bd4d4081e3f56f
parent 291285 e7da19944c6ce85c09fe96fbc1acc1b58abd3c9c
child 291287 37ee5a42ddb506b6ecdf4d0119e96003db734a1d
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1259806
milestone48.0a1
Bug 1259806 - Remove toolkit/components/ctypes/tests/Makefile.in; r=ted MozReview-Commit-ID: EVCZVXukFQf
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/common.py
python/mozbuild/mozbuild/test/frontend/data/test-install-shared-lib/moz.build
python/mozbuild/mozbuild/test/frontend/test_emitter.py
toolkit/components/ctypes/tests/Makefile.in
toolkit/components/ctypes/tests/moz.build
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -364,17 +364,17 @@ class TreeMetadataEmitter(LoggingMixin):
         # context more or less truthful about where the external library is.
         context = Context(config=self.config)
         context.add_source(mozpath.join(self.config.topsrcdir, dir, 'dummy'))
         if force_static:
             return ExternalStaticLibrary(context, name)
         else:
             return ExternalSharedLibrary(context, name)
 
-    def _handle_linkables(self, context, passthru):
+    def _handle_linkables(self, context, passthru, generated_files):
         has_linkables = False
 
         for kind, cls in [('PROGRAM', Program), ('HOST_PROGRAM', HostProgram)]:
             program = context.get(kind)
             if program:
                 if program in self._binaries:
                     raise SandboxValidationError(
                         'Cannot use "%s" as %s name, '
@@ -555,16 +555,17 @@ class TreeMetadataEmitter(LoggingMixin):
                         symbols_file.full_path), context)
                 shared_args['symbols_file'] = True
 
             if shared_lib:
                 lib = SharedLibrary(context, libname, **shared_args)
                 self._libs[libname].append(lib)
                 self._linkage.append((context, lib, 'USE_LIBS'))
                 has_linkables = True
+                generated_files.add(lib.lib_name)
                 if is_component and not context['NO_COMPONENTS_MANIFEST']:
                     yield ChromeManifestEntry(context,
                         'components/components.manifest',
                         ManifestBinaryComponent('components', lib.lib_name))
                 if symbols_file:
                     script = mozpath.join(
                         mozpath.dirname(mozpath.dirname(__file__)),
                         'action', 'generate_symbols_file.py')
@@ -816,17 +817,17 @@ class TreeMetadataEmitter(LoggingMixin):
         for local_include in context.get('LOCAL_INCLUDES', []):
             if (not isinstance(local_include, ObjDirPath) and
                     not os.path.exists(local_include.full_path)):
                 raise SandboxValidationError('Path specified in LOCAL_INCLUDES '
                     'does not exist: %s (resolved to %s)' % (local_include,
                     local_include.full_path), context)
             yield LocalInclude(context, local_include)
 
-        for obj in self._handle_linkables(context, passthru):
+        for obj in self._handle_linkables(context, passthru, generated_files):
             yield obj
 
         generated_files.update(['%s%s' % (k, self.config.substs.get('BIN_SUFFIX', '')) for k in self._binaries.keys()])
 
         components = []
         for var, cls in (
             ('BRANDING_FILES', BrandingFiles),
             ('EXPORTS', Exports),
--- a/python/mozbuild/mozbuild/test/common.py
+++ b/python/mozbuild/mozbuild/test/common.py
@@ -26,16 +26,18 @@ class MockConfig(object):
         self.topsrcdir = mozpath.abspath(topsrcdir)
         self.topobjdir = mozpath.abspath('/path/to/topobjdir')
 
         self.substs = ReadOnlyDict({
             'MOZ_FOO': 'foo',
             'MOZ_BAR': 'bar',
             'MOZ_TRUE': '1',
             'MOZ_FALSE': '',
+            'DLL_PREFIX': 'lib',
+            'DLL_SUFFIX': '.so'
         }, **extra_substs)
 
         self.substs_unicode = ReadOnlyDict({k.decode('utf-8'): v.decode('utf-8',
             'replace') for k, v in self.substs.items()})
 
         self.defines = self.substs
 
         self.external_source_dir = None
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/frontend/data/test-install-shared-lib/moz.build
@@ -0,0 +1,12 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+@template
+def SharedLibrary(name):
+    LIBRARY_NAME = name
+    FORCE_SHARED_LIB = True
+
+DIST_INSTALL = False
+SharedLibrary('foo')
+
+TEST_HARNESS_FILES.foo.bar += ['!%sfoo%s' % (CONFIG['DLL_PREFIX'], CONFIG['DLL_SUFFIX'])]
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -982,11 +982,22 @@ class TestEmitterBasic(unittest.TestCase
         self.assertIsInstance(objs[0].entry, manifest.ManifestBinaryComponent)
         self.assertEqual(objs[0].entry.base, 'dist/bin/components')
         self.assertEqual(objs[0].entry.relpath, objs[1].lib_name)
         self.assertIsInstance(objs[1], SharedLibrary)
         self.assertEqual(objs[1].basename, 'foo')
         self.assertIsInstance(objs[2], SharedLibrary)
         self.assertEqual(objs[2].basename, 'bar')
 
+    def test_install_shared_lib(self):
+        """Test that we can install a shared library with TEST_HARNESS_FILES"""
+        reader = self.reader('test-install-shared-lib')
+        objs = self.read_topsrcdir(reader)
+        self.assertIsInstance(objs[0], TestHarnessFiles)
+        self.assertIsInstance(objs[1], VariablePassthru)
+        self.assertIsInstance(objs[2], SharedLibrary)
+        for path, files in objs[0].files.walk():
+            for f in files:
+                self.assertEqual(str(f), '!libfoo.so')
+                self.assertEqual(path, 'foo/bar')
 
 if __name__ == '__main__':
     main()
deleted file mode 100644
--- a/toolkit/components/ctypes/tests/Makefile.in
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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/.
-
-LIB_1_FILES = $(SHARED_LIBRARY)
-LIB_1_DEST = $(DEPTH)/_tests/xpcshell/$(relativesrcdir)/unit
-INSTALL_TARGETS += LIB_1
-
-LIB_3_FILES = $(SHARED_LIBRARY)
-LIB_3_DEST = $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)/chrome
-INSTALL_TARGETS += LIB_3
--- a/toolkit/components/ctypes/tests/moz.build
+++ b/toolkit/components/ctypes/tests/moz.build
@@ -18,8 +18,13 @@ UNIFIED_SOURCES += [
 SharedLibrary('jsctypes-test')
 
 LOCAL_INCLUDES += [
     '/js/src/ctypes',
 ]
 
 if CONFIG['GNU_CXX']:
     CXXFLAGS += ['-Wshadow']
+
+if CONFIG['COMPILE_ENVIRONMENT']:
+    shared_library = '!%sjsctypes-test%s' % (CONFIG['DLL_PREFIX'], CONFIG['DLL_SUFFIX'])
+    TEST_HARNESS_FILES.xpcshell.toolkit.components.ctypes.tests.unit += [shared_library]
+    TEST_HARNESS_FILES.testing.mochitest.chrome.toolkit.components.ctypes.tests.chrome += [shared_library]