summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2022-08-05 12:30:54 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2022-12-24 12:57:48 +0800
commit13e658a2009bb1b0e2f15a5713af3fca12189b48 (patch)
treea6b291a5fe0387aef6f0d6b95d911f922e4a4a60 /python
parentabf74404c5e564af77e10741b443b42a7d677170 (diff)
downloaduxp-13e658a2009bb1b0e2f15a5713af3fca12189b48.tar.gz
Issue #2065 - Part 2: Expand pattern when track file is created rather than read
This fixes build bustage on Windows when using `mach build faster`. Based on https://bugzilla.mozilla.org/show_bug.cgi?id=1416465
Diffstat (limited to 'python')
-rw-r--r--python/mozbuild/mozbuild/action/process_install_manifest.py4
-rw-r--r--python/mozbuild/mozpack/manifests.py25
-rw-r--r--python/mozbuild/mozpack/test/test_manifests.py23
3 files changed, 44 insertions, 8 deletions
diff --git a/python/mozbuild/mozbuild/action/process_install_manifest.py b/python/mozbuild/mozbuild/action/process_install_manifest.py
index e19fe4edae..47b7aef5ba 100644
--- a/python/mozbuild/mozbuild/action/process_install_manifest.py
+++ b/python/mozbuild/mozbuild/action/process_install_manifest.py
@@ -70,7 +70,9 @@ def process_manifest(destdir, paths, track=None,
remove_empty_directories=remove_empty_directories)
if track:
- manifest.write(path=track)
+ # We should record files that we actually copied.
+ # It is too late to expand wildcards when the track file is read.
+ manifest.write(path=track, expand_pattern=True)
return result
diff --git a/python/mozbuild/mozpack/manifests.py b/python/mozbuild/mozpack/manifests.py
index 93bd6c2cab..b77931101a 100644
--- a/python/mozbuild/mozpack/manifests.py
+++ b/python/mozbuild/mozpack/manifests.py
@@ -228,7 +228,7 @@ class InstallManifest(object):
"""
return json.loads(data)
- def write(self, path=None, fileobj=None):
+ def write(self, path=None, fileobj=None, expand_pattern=False):
"""Serialize this manifest to a file or file object.
If path is specified, that file will be written to. If fileobj is specified,
@@ -242,10 +242,21 @@ class InstallManifest(object):
for dest in sorted(self._dests):
entry = self._dests[dest]
- parts = ['%d' % entry[0], dest]
- parts.extend(entry[1:])
- fh.write('%s\n' % self.FIELD_SEPARATOR.join(
- p.encode('utf-8') for p in parts))
+ if expand_pattern and entry[0] in (self.PATTERN_SYMLINK, self.PATTERN_COPY):
+ type, base, pattern, dest = entry
+ type = self.SYMLINK if type == self.PATTERN_SYMLINK else self.COPY
+ finder = FileFinder(base)
+ paths = [f[0] for f in finder.find(pattern)]
+ for path in paths:
+ source = mozpath.join(base, path)
+ parts = ['%d' % type, mozpath.join(dest, path), source]
+ fh.write('%s\n' % self.FIELD_SEPARATOR.join(
+ p.encode('utf-8') for p in parts))
+ else:
+ parts = ['%d' % entry[0], dest]
+ parts.extend(entry[1:])
+ fh.write('%s\n' % self.FIELD_SEPARATOR.join(
+ p.encode('utf-8') for p in parts))
def add_symlink(self, source, dest):
"""Add a symlink to this manifest.
@@ -289,7 +300,7 @@ class InstallManifest(object):
<base>/foo/bar.h -> <dest>/foo/bar.h
"""
- self._add_entry(mozpath.join(base, pattern, dest),
+ self._add_entry(mozpath.join(dest, pattern),
(self.PATTERN_SYMLINK, base, pattern, dest))
def add_pattern_copy(self, base, pattern, dest):
@@ -297,7 +308,7 @@ class InstallManifest(object):
See ``add_pattern_symlink()`` for usage.
"""
- self._add_entry(mozpath.join(base, pattern, dest),
+ self._add_entry(mozpath.join(dest, pattern),
(self.PATTERN_COPY, base, pattern, dest))
def add_preprocess(self, source, dest, deps, marker='#', defines={},
diff --git a/python/mozbuild/mozpack/test/test_manifests.py b/python/mozbuild/mozpack/test/test_manifests.py
index b785d014a4..7d926a0c8a 100644
--- a/python/mozbuild/mozpack/test/test_manifests.py
+++ b/python/mozbuild/mozpack/test/test_manifests.py
@@ -156,6 +156,29 @@ class TestInstallManifest(TestWithTmpDir):
self.assertIn('s_dest2', m1)
self.assertIn('c_dest2', m1)
+ def test_write_expand_pattern(self):
+ source = self.tmppath('source')
+ os.mkdir(source)
+ os.mkdir('%s/base' % source)
+ os.mkdir('%s/base/foo' % source)
+
+ with open('%s/base/foo/file1' % source, 'a'):
+ pass
+
+ with open('%s/base/foo/file2' % source, 'a'):
+ pass
+
+ m = InstallManifest()
+ m.add_pattern_link('%s/base' % source, '**', 'dest')
+
+ track = self.tmppath('track')
+ m.write(path=track, expand_pattern=True)
+
+ m = InstallManifest(path=track)
+ self.assertEqual([dest for dest in m._dests],
+ ['dest/foo/file1', 'dest/foo/file2'])
+
+
def test_copier_application(self):
dest = self.tmppath('dest')
os.mkdir(dest)