Skip to content

Commit

Permalink
Bug 1307301 - Don't attempt to compress compressed files when packing…
Browse files Browse the repository at this point in the history
… the symbols archive. r=ted

MozReview-Commit-ID: 542dZflb00G

--HG--
extra : rebase_source : 6b942e687517a3053b349a20475de7cff956327a
  • Loading branch information
chmanchester committed Apr 28, 2017
1 parent b9fb403 commit bdaf34a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ symbolsfullarchive: prepsymbolsarchive
$(call py_action,symbols_archive,$(abspath '$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip') \
$(abspath $(DIST)/crashreporter-symbols) \
--exclude '*test*' \
--exclude '*Test*')
--exclude '*Test*' \
--compress '**/*.sym')

.PHONY: symbolsarchive
symbolsarchive: prepsymbolsarchive
Expand Down
13 changes: 9 additions & 4 deletions python/mozbuild/mozbuild/action/symbols_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,35 @@

from mozpack.files import FileFinder
from mozpack.mozjar import JarWriter
import mozpack.path as mozpath

def make_archive(archive_name, base, exclude, include):
def make_archive(archive_name, base, exclude, include, compress):
finder = FileFinder(base, ignore=exclude)
if not include:
include = ['*']

if not compress:
compress = ['**/*.sym']
archive_basename = os.path.basename(archive_name)
with open(archive_name, 'wb') as fh:
with JarWriter(fileobj=fh, optimize=False, compress_level=5) as writer:
for pat in include:
for p, f in finder.find(pat):
print(' Adding to "%s":\n\t"%s"' % (archive_basename, p))
writer.add(p.encode('utf-8'), f.read(), mode=f.mode, skip_duplicates=True)
should_compress = any(mozpath.match(p, pat) for pat in compress)
writer.add(p.encode('utf-8'), f.read(), mode=f.mode,
compress=should_compress, skip_duplicates=True)

def main(argv):
parser = argparse.ArgumentParser(description='Produce a symbols archive')
parser.add_argument('archive', help='Which archive to generate')
parser.add_argument('base', help='Base directory to package')
parser.add_argument('--exclude', default=[], action='append', help='File patterns to exclude')
parser.add_argument('--include', default=[], action='append', help='File patterns to include')
parser.add_argument('--compress', default=[], action='append', help='File patterns to compress')

args = parser.parse_args(argv)

make_archive(args.archive, args.base, args.exclude, args.include)
make_archive(args.archive, args.base, args.exclude, args.include, args.compress)

if __name__ == '__main__':
main(sys.argv[1:])

0 comments on commit bdaf34a

Please sign in to comment.