michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # This script creates a zip file, but will also strip any binaries michael@0: # it finds before adding them to the zip. michael@0: michael@0: from mozpack.files import FileFinder michael@0: from mozpack.copier import Jarrer michael@0: from mozpack.errors import errors michael@0: michael@0: import argparse michael@0: import buildconfig michael@0: import mozpack.path as mozpath michael@0: import os michael@0: import sys michael@0: import tempfile michael@0: michael@0: def main(args): michael@0: parser = argparse.ArgumentParser() michael@0: parser.add_argument("--base-dir", michael@0: default=os.path.join(buildconfig.topobjdir, michael@0: "dist", "bin"), michael@0: help="Store paths relative to this directory") michael@0: parser.add_argument("zip", help="Path to zip file to write") michael@0: parser.add_argument("input", nargs="+", michael@0: help="Path to files to add to zip") michael@0: args = parser.parse_args(args) michael@0: michael@0: jarrer = Jarrer(optimize=False) michael@0: michael@0: with errors.accumulate(): michael@0: finder = FileFinder(args.base_dir) michael@0: for i in args.input: michael@0: path = mozpath.relpath(i, args.base_dir) michael@0: for p, f in finder.find(path): michael@0: jarrer.add(p, f) michael@0: jarrer.copy(args.zip) michael@0: michael@0: michael@0: if __name__ == '__main__': michael@0: main(sys.argv[1:])