bug 1419055 - Fix FasterMake backend handling of FINAL_TARGET_FILES with wildcards in filename. r=nalexander
authorTed Mielczarek <ted@mielczarek.org>
Mon, 20 Nov 2017 11:35:39 -0500
changeset 392938 bca7bf9ad9bf54e1c0e96c2dd8be27f61c50cfbd
parent 392937 eb9c29a3067df17a9fe2d23a541154cccb613018
child 392939 0cfaf6902748f13a602ec69c5cd6f56b7713a4e5
push id32946
push userccoroiu@mozilla.com
push dateTue, 21 Nov 2017 23:34:39 +0000
treeherdermozilla-central@b96f00947898 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1419055
milestone59.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 1419055 - Fix FasterMake backend handling of FINAL_TARGET_FILES with wildcards in filename. r=nalexander This patch fixes a bug in the FasterMake backend and adds a new test_fastermake.py file to add a test for the behavior. The FasterMake backend didn't handle wildcards in file names present in FINAL_TARGET_FILES properly. For an entry like: FINAL_TARGET_FILES.foo += ['*.xyz'] It would wind up trying to install the files to `dist/bin/foo/*.xyz/`, a path with a literal asterisk in it. The code seems to have been written assuming that wildcards would only be present in directory components of the path. This change fixes this specific case, although it's possible that it still doesn't handle all permutations of wildcards properly. MozReview-Commit-ID: rk2tSyDyIu
python/mozbuild/mozbuild/backend/fastermake.py
python/mozbuild/mozbuild/test/backend/data/final-target-files-wildcard/bar.xyz
python/mozbuild/mozbuild/test/backend/data/final-target-files-wildcard/foo.xyz
python/mozbuild/mozbuild/test/backend/data/final-target-files-wildcard/moz.build
python/mozbuild/mozbuild/test/backend/test_fastermake.py
python/mozbuild/mozbuild/test/python.ini
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -70,21 +70,26 @@ class FasterMakeBackend(CommonBackend, P
                                              defines=defines)
                     elif '*' in f:
                         def _prefix(s):
                             for p in mozpath.split(s):
                                 if '*' not in p:
                                     yield p + '/'
                         prefix = ''.join(_prefix(f.full_path))
 
+                        if '*' in f.target_basename:
+                            target = path
+                        else:
+                            target = mozpath.join(path, f.target_basename)
+                        mozpath.join(path, f.target_basename)
                         self._install_manifests[obj.install_target] \
                             .add_pattern_link(
                                 prefix,
                                 f.full_path[len(prefix):],
-                                mozpath.join(path, f.target_basename))
+                                target)
                     else:
                         self._install_manifests[obj.install_target].add_link(
                             f.full_path,
                             mozpath.join(path, f.target_basename)
                         )
                     if isinstance(f, ObjDirPath):
                         dep_target = 'install-%s' % obj.install_target
                         self._dependencies[dep_target].append(
new file mode 100644
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/backend/data/final-target-files-wildcard/moz.build
@@ -0,0 +1,5 @@
+# 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/.
+
+FINAL_TARGET_FILES.foo += ['*.xyz']
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/test/backend/test_fastermake.py
@@ -0,0 +1,46 @@
+# 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/.
+
+from __future__ import unicode_literals
+
+import cPickle as pickle
+import json
+import os
+import unittest
+
+from mozpack.copier import FileRegistry
+from mozpack.manifests import InstallManifest
+from mozunit import main
+
+from mozbuild.backend.fastermake import FasterMakeBackend
+
+from mozbuild.test.backend.common import BackendTester
+
+import mozpack.path as mozpath
+
+
+class TestFasterMakeBackend(BackendTester):
+    def test_basic(self):
+        """Ensure the FasterMakeBackend works without error."""
+        env = self._consume('stub0', FasterMakeBackend)
+        self.assertTrue(os.path.exists(mozpath.join(env.topobjdir,
+            'backend.FasterMakeBackend')))
+        self.assertTrue(os.path.exists(mozpath.join(env.topobjdir,
+            'backend.FasterMakeBackend.in')))
+
+    def test_final_target_files_wildcard(self):
+        """Ensure that wildcards in FINAL_TARGET_FILES work properly."""
+        env = self._consume('final-target-files-wildcard', FasterMakeBackend)
+        m = InstallManifest(path=mozpath.join(env.topobjdir,
+            'faster', 'install_dist_bin'))
+        self.assertEqual(len(m), 1)
+        reg = FileRegistry()
+        m.populate_registry(reg)
+        expected = [('foo/bar.xyz', 'bar.xyz'), ('foo/foo.xyz', 'foo.xyz')]
+        actual = [(path, mozpath.relpath(f.path, env.topsrcdir)) for (path, f) in reg]
+        self.assertEqual(expected, actual)
+
+
+if __name__ == '__main__':
+    main()
--- a/python/mozbuild/mozbuild/test/python.ini
+++ b/python/mozbuild/mozbuild/test/python.ini
@@ -1,14 +1,15 @@
 [action/test_buildlist.py]
 [action/test_generate_browsersearch.py]
 [action/test_langpack_manifest.py]
 [action/test_package_fennec_apk.py]
 [backend/test_build.py]
 [backend/test_configenvironment.py]
+[backend/test_fastermake.py]
 [backend/test_partialconfigenvironment.py]
 [backend/test_recursivemake.py]
 [backend/test_test_manifest.py]
 [backend/test_visualstudio.py]
 [codecoverage/test_lcov_rewrite.py]
 [compilation/test_warnings.py]
 [configure/lint.py]
 [configure/test_checks_configure.py]