diff --git a/python/mozbuild/mozbuild/action/generate_suggestedsites.py b/python/mozbuild/mozbuild/action/generate_suggestedsites.py index 96d824cc28a9..2279cdd2b45f 100644 --- a/python/mozbuild/mozbuild/action/generate_suggestedsites.py +++ b/python/mozbuild/mozbuild/action/generate_suggestedsites.py @@ -102,7 +102,7 @@ def main(args): if not opts.resources: continue resources = os.path.abspath(opts.resources) - finder = FileFinder(resources) + finder = FileFinder(resources, find_executables=False) matches = [p for p, _ in finder.find(drawables_template.format(name=name))] if not matches: raise Exception("Could not find drawable in '{resources}' for '{name}'" diff --git a/python/mozbuild/mozbuild/action/zip.py b/python/mozbuild/mozbuild/action/zip.py index 143d7766e6c0..2d95e91ecf5f 100644 --- a/python/mozbuild/mozbuild/action/zip.py +++ b/python/mozbuild/mozbuild/action/zip.py @@ -28,7 +28,7 @@ def main(args): jarrer = Jarrer(optimize=False) with errors.accumulate(): - finder = FileFinder(args.C) + finder = FileFinder(args.C, find_executables=False) for path in args.input: for p, f in finder.find(path): jarrer.add(p, f) diff --git a/python/mozbuild/mozbuild/backend/android_eclipse.py b/python/mozbuild/mozbuild/backend/android_eclipse.py index f17eb8d34ef3..1dbcf91fabf6 100644 --- a/python/mozbuild/mozbuild/backend/android_eclipse.py +++ b/python/mozbuild/mozbuild/backend/android_eclipse.py @@ -247,7 +247,7 @@ class AndroidEclipseBackend(CommonBackend): defines['MOZ_ANDROID_MIN_SDK_VERSION'] = self.environment.defines['MOZ_ANDROID_MIN_SDK_VERSION'] copier = FileCopier() - finder = FileFinder(template_directory) + finder = FileFinder(template_directory, find_executables=False) for input_filename, f in itertools.chain(finder.find('**'), finder.find('.**')): if input_filename == 'AndroidManifest.xml' and not data.is_library: # Main projects supply their own manifests. diff --git a/python/mozbuild/mozbuild/codecoverage/packager.py b/python/mozbuild/mozbuild/codecoverage/packager.py index 3a4f359f6a0e..16f269fe96aa 100644 --- a/python/mozbuild/mozbuild/codecoverage/packager.py +++ b/python/mozbuild/mozbuild/codecoverage/packager.py @@ -15,7 +15,7 @@ def package_gcno_tree(root, output_file): if isinstance(root, unicode): root = root.encode('utf-8') - finder = FileFinder(root) + finder = FileFinder(root, find_executables=False) jarrer = Jarrer(optimize=False) for p, f in finder.find("**/*.gcno"): jarrer.add(p, f) diff --git a/python/mozbuild/mozbuild/test/backend/test_build.py b/python/mozbuild/mozbuild/test/backend/test_build.py index d3f5fb6a9d92..77c0a0adeb7c 100644 --- a/python/mozbuild/mozbuild/test/backend/test_build.py +++ b/python/mozbuild/mozbuild/test/backend/test_build.py @@ -152,7 +152,7 @@ class TestBuild(unittest.TestCase): # of the difference in type. result = { p: f.open().read().decode('utf-8') - for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist')) + for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist'), find_executables=False) } self.assertTrue(len(result)) self.assertEqual(result, { diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py index 64902e195cbc..34cb8d80e9fa 100644 --- a/python/mozbuild/mozpack/files.py +++ b/python/mozbuild/mozpack/files.py @@ -841,7 +841,7 @@ class FileFinder(BaseFinder): ''' Helper to get appropriate BaseFile instances from the file system. ''' - def __init__(self, base, find_executables=True, ignore=(), + def __init__(self, base, ignore=(), find_dotfiles=False, **kargs): ''' Create a FileFinder for files under the given base directory. @@ -856,6 +856,8 @@ class FileFinder(BaseFinder): to a directory, all files under that directory will be ignored. If an entry corresponds to a file, that particular file will be ignored. ''' + assert 'find_executables' in kargs + find_executables = kargs.pop('find_executables') BaseFinder.__init__(self, base, **kargs) self.find_dotfiles = find_dotfiles self.find_executables = find_executables diff --git a/python/mozbuild/mozpack/packager/unpack.py b/python/mozbuild/mozpack/packager/unpack.py index fa2b474e71ee..008ac93a1399 100644 --- a/python/mozbuild/mozpack/packager/unpack.py +++ b/python/mozbuild/mozpack/packager/unpack.py @@ -47,7 +47,7 @@ class UnpackFinder(BaseFinder): if isinstance(source, BaseFinder): self._finder = source else: - self._finder = FileFinder(source) + self._finder = FileFinder(source, find_executables=False) self.base = self._finder.base self.files = FileRegistry() self.kind = 'flat' diff --git a/python/mozbuild/mozpack/test/test_files.py b/python/mozbuild/mozpack/test/test_files.py index 6fd617828858..7a0526d0ac95 100644 --- a/python/mozbuild/mozpack/test/test_files.py +++ b/python/mozbuild/mozpack/test/test_files.py @@ -924,13 +924,13 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir): def test_file_finder(self): self.prepare_match_test(with_dotfiles=True) - self.finder = FileFinder(self.tmpdir) + self.finder = FileFinder(self.tmpdir, find_executables=False) self.do_match_test() self.do_finder_test(self.finder) def test_get(self): self.prepare_match_test() - finder = FileFinder(self.tmpdir) + finder = FileFinder(self.tmpdir, find_executables=False) self.assertIsNone(finder.get('does-not-exist')) res = finder.get('bar') @@ -946,7 +946,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir): # Present to ensure prefix matching doesn't exclude. self.add('foo/quxz') - self.finder = FileFinder(self.tmpdir, ignore=['foo/qux']) + self.finder = FileFinder(self.tmpdir, ignore=['foo/qux'], find_executables=False) self.do_check('**', ['bar', 'foo/bar', 'foo/baz', 'foo/quxz', 'fooz']) self.do_check('foo/*', ['foo/bar', 'foo/baz', 'foo/quxz']) @@ -964,7 +964,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir): # Be sure prefix match doesn't get ignored. self.add('barz') - self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar']) + self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'], find_executables=False) self.do_check('**', ['barz', 'foo/baz', 'foo/qux/1', 'foo/qux/2/test', 'foo/qux/2/test2', 'foo/qux/bar']) self.do_check('foo/**', ['foo/baz', 'foo/qux/1', 'foo/qux/2/test', @@ -976,14 +976,14 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir): self.add('foo/quxz') - self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*']) + self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'], find_executables=False) self.do_check('**', ['foo/bar', 'foo/baz', 'foo/quxz', 'bar']) self.do_check('foo/**', ['foo/bar', 'foo/baz', 'foo/quxz']) def test_dotfiles(self): """Finder can find files beginning with . is configured.""" self.prepare_match_test(with_dotfiles=True) - self.finder = FileFinder(self.tmpdir, find_dotfiles=True) + self.finder = FileFinder(self.tmpdir, find_dotfiles=True, find_executables=False) self.do_check('**', ['bar', 'foo/.foo', 'foo/.bar/foo', 'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2']) @@ -991,7 +991,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir): def test_dotfiles_plus_ignore(self): self.prepare_match_test(with_dotfiles=True) self.finder = FileFinder(self.tmpdir, find_dotfiles=True, - ignore=['foo/.bar/**']) + ignore=['foo/.bar/**'], find_executables=False) self.do_check('foo/**', ['foo/.foo', 'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2']) @@ -1060,8 +1060,8 @@ class TestComposedFinder(MatchTestTemplate, TestWithTmpDir): open(self.tmppath('a/foo/qux/hoge'), 'wb').write('hoge') open(self.tmppath('a/foo/qux/bar'), 'wb').write('not the right content') self.finder = ComposedFinder({ - '': FileFinder(self.tmppath('a')), - 'foo/qux': FileFinder(self.tmppath('b')), + '': FileFinder(self.tmppath('a'), find_executables=False), + 'foo/qux': FileFinder(self.tmppath('b'), find_executables=False), }) self.do_match_test() diff --git a/python/mozbuild/mozpack/test/test_mozjar.py b/python/mozbuild/mozpack/test/test_mozjar.py index 948403006907..e0a8e6668452 100644 --- a/python/mozbuild/mozpack/test/test_mozjar.py +++ b/python/mozbuild/mozpack/test/test_mozjar.py @@ -245,7 +245,7 @@ class TestJar(unittest.TestCase): def test_add_from_finder(self): s = MockDest() with JarWriter(fileobj=s, optimize=self.optimize) as jar: - finder = FileFinder(test_data_path) + finder = FileFinder(test_data_path, find_executables=False) for p, f in finder.find('test_data'): jar.add('test_data', f) diff --git a/python/mozbuild/mozpack/test/test_unify.py b/python/mozbuild/mozpack/test/test_unify.py index a2bbb44702a2..11cdc50412b2 100644 --- a/python/mozbuild/mozpack/test/test_unify.py +++ b/python/mozbuild/mozpack/test/test_unify.py @@ -46,8 +46,8 @@ class TestUnifiedFinder(TestUnified): self.create_one('b', 'test/foo', 'b\nc\na\n') self.create_both('test/bar', 'a\nb\nc\n') - finder = UnifiedFinder(FileFinder(self.tmppath('a')), - FileFinder(self.tmppath('b')), + finder = UnifiedFinder(FileFinder(self.tmppath('a'), find_executables=False), + FileFinder(self.tmppath('b'), find_executables=False), sorted=['test']) self.assertEqual(sorted([(f, c.open().read()) for f, c in finder.find('foo')]), @@ -63,8 +63,8 @@ class TestUnifiedFinder(TestUnified): class TestUnifiedBuildFinder(TestUnified): def test_unified_build_finder(self): - finder = UnifiedBuildFinder(FileFinder(self.tmppath('a')), - FileFinder(self.tmppath('b'))) + finder = UnifiedBuildFinder(FileFinder(self.tmppath('a'), find_executables=False), + FileFinder(self.tmppath('b'), find_executables=False)) # Test chrome.manifest unification self.create_both('chrome.manifest', 'a\nb\nc\n') diff --git a/toolkit/mozapps/installer/packager.py b/toolkit/mozapps/installer/packager.py index f2dc3fac661e..ab83576b7831 100644 --- a/toolkit/mozapps/installer/packager.py +++ b/toolkit/mozapps/installer/packager.py @@ -342,11 +342,14 @@ def main(): 'js-compare-ast.js') ] if args.unify: - finder = UnifiedBuildFinder(FileFinder(args.source), - FileFinder(args.unify), + finder = UnifiedBuildFinder(FileFinder(args.source, + find_executables=True), + FileFinder(args.unify, + find_executables=True), **finder_args) else: - finder = FileFinder(args.source, **finder_args) + finder = FileFinder(args.source, find_executables=True, + **finder_args) if 'NO_PKG_FILES' in os.environ: sinkformatter = NoPkgFilesRemover(formatter, args.manifest is not None) diff --git a/toolkit/mozapps/installer/strip.py b/toolkit/mozapps/installer/strip.py index bb83025da552..d6e81f280bfa 100644 --- a/toolkit/mozapps/installer/strip.py +++ b/toolkit/mozapps/installer/strip.py @@ -15,7 +15,7 @@ def strip(dir): # The FileFinder will give use ExecutableFile instances for files # that can be stripped, and copying ExecutableFiles defaults to # stripping them unless buildconfig.substs['PKG_SKIP_STRIP'] is set. - for p, f in FileFinder(dir): + for p, f in FileFinder(dir, find_executables=True): copier.add(p, f) copier.copy(dir)