diff options
author | xyzzyz <xyzzyz@chromium.org> | 2016-02-03 16:49:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-04 00:50:30 +0000 |
commit | ec5af95c1086f8b675e67fbc278b83114c22f55c (patch) | |
tree | d7b82d3447550f48802733aa101b46183d42d2f0 | |
parent | c55a231a0021c476aec4b684dd88145870d6c03d (diff) | |
download | chromium_src-ec5af95c1086f8b675e67fbc278b83114c22f55c.zip chromium_src-ec5af95c1086f8b675e67fbc278b83114c22f55c.tar.gz chromium_src-ec5af95c1086f8b675e67fbc278b83114c22f55c.tar.bz2 |
Compress Blimp engine bundle using gzip in blimp_engine_bundle target.
Fastest compression mode is used, which takes on average around 12 seconds on my workstation.
BUG=582519
Review URL: https://codereview.chromium.org/1641343002
Cr-Commit-Position: refs/heads/master@{#373401}
-rw-r--r-- | blimp/engine/BUILD.gn | 2 | ||||
-rwxr-xr-x | blimp/tools/bundle-engine.py | 36 |
2 files changed, 23 insertions, 15 deletions
diff --git a/blimp/engine/BUILD.gn b/blimp/engine/BUILD.gn index 7752536..313d0b4 100644 --- a/blimp/engine/BUILD.gn +++ b/blimp/engine/BUILD.gn @@ -247,7 +247,7 @@ if (is_linux) { _rebased_dockerfile = rebase_path("//blimp/engine/Dockerfile") _rebased_startup_script = rebase_path("//blimp/engine/start_engine.sh") _rebased_manifest = rebase_path("//blimp/engine/engine-manifest.txt") - _bundle = "$root_out_dir/blimp_engine_bundle.tar" + _bundle = "$root_out_dir/blimp_engine_bundle.tar.gz" # Detail the target & "source"-file dependencies, and output, for GN. deps = [ diff --git a/blimp/tools/bundle-engine.py b/blimp/tools/bundle-engine.py index 9fd266e..4c3aa04 100755 --- a/blimp/tools/bundle-engine.py +++ b/blimp/tools/bundle-engine.py @@ -6,7 +6,7 @@ '''Bundles the Blimp Engine and its runtime dependencies into a tarball. The created bundle can be passed as input to docker build. E.g. - docker build - < ../../out-linux/Debug/blimp_engine_deps.tar + docker build - < ../../out-linux/Debug/blimp_engine_deps.tar.gz ''' @@ -15,7 +15,6 @@ import errno import os import subprocess import sys -import tarfile def ReadDependencies(manifest): """Read the manifest and return the list of dependencies. @@ -56,18 +55,27 @@ def main(): deps = ReadDependencies(args.manifest) - # Add the deps to the tarball along with the Dockerfile. - with tarfile.open(args.output, 'w') as tarball: - tarball.add(args.dockerfile, arcname='Dockerfile') - tarball.add(args.startup_script, arcname='start_engine.sh') - os.chdir(args.build_dir) - for dep in deps: - try: - tarball.add(dep) - except OSError as e: - if e.errno == errno.ENOENT: - print >> sys.stderr, dep + " not found (did you build the engine?)" - exit(1) + dockerfile_dirname, dockerfile_basename = os.path.split(args.dockerfile) + startup_script_dirname, startup_script_basename = os.path.split( + args.startup_script) + + try: + env = os.environ.copy() + # Use fastest possible mode when gzipping. + env["GZIP"] = "-1" + subprocess.check_output( + ["tar", + "-zcf", args.output, + "-C", dockerfile_dirname, dockerfile_basename, + "-C", startup_script_dirname, startup_script_basename, + "-C", args.build_dir] + deps, + # Redirect stderr to stdout, so that its output is captured. + stderr=subprocess.STDOUT, + env=env) + except subprocess.CalledProcessError as e: + print >> sys.stderr, "Failed to create tarball:" + print >> sys.stderr, e.output + sys.exit(1) if __name__ == "__main__": main() |