Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: blimp/tools/bundle-engine.py

Issue 2028353003: Support for bundling Chromium unittests into a tarball. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates based on review feedback. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/engine/BUILD.gn ('k') | blimp/tools/create-bundle.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 '''Bundles the Blimp Engine and its runtime dependencies into a tarball.
7
8 The created bundle can be passed as input to docker build. E.g.
9 docker build - < ../../out-linux/Debug/blimp_engine_deps.tar.gz
10 '''
11
12
13 import argparse
14 import os
15 import subprocess
16 import sys
17
18 def ReadDependencies(manifest):
19 """Read the manifest and return the list of dependencies.
20 :raises IOError: if the manifest could not be read.
21 """
22 deps = []
23 with open(manifest) as f:
24 for line in f.readlines():
25 # Strip comments.
26 dep = line.partition('#')[0].strip()
27 # Ignore empty strings.
28 if dep:
29 deps.append(dep)
30 return deps
31
32 def main():
33 parser = argparse.ArgumentParser(description=__doc__)
34 parser.add_argument('--build-dir',
35 help=('build output directory (e.g. out/Debug)'),
36 required=True,
37 metavar='DIR')
38 parser.add_argument('--dockerfile',
39 help=('Dockerfile to add to the bundle'),
40 required=True,
41 metavar='FILE')
42 parser.add_argument('--startup-script',
43 help=('Engine startup script to add to the bundle'),
44 required=True,
45 metavar='FILE')
46 parser.add_argument('--manifest',
47 help=('engine manifest'),
48 required=True)
49 parser.add_argument('--output',
50 help=('name and path of bundle to create'),
51 required=True,
52 metavar='FILE')
53 args = parser.parse_args()
54
55 deps = ReadDependencies(args.manifest)
56
57 dockerfile_dirname, dockerfile_basename = os.path.split(args.dockerfile)
58 startup_script_dirname, startup_script_basename = os.path.split(
59 args.startup_script)
60
61 try:
62 env = os.environ.copy()
63 # Use fastest possible mode when gzipping.
64 env["GZIP"] = "-1"
65 subprocess.check_output(
66 ["tar",
67 "-zcf", args.output,
68 # Ensure tarball content group permissions are appropriately set for
69 # use as part of a "docker build". That is group readable with
70 # executable files also being group executable.
71 "--mode=g+rX",
72 "-C", dockerfile_dirname, dockerfile_basename,
73 "-C", startup_script_dirname, startup_script_basename,
74 "-C", args.build_dir] + deps,
75 # Redirect stderr to stdout, so that its output is captured.
76 stderr=subprocess.STDOUT,
77 env=env)
78 except subprocess.CalledProcessError as e:
79 print >> sys.stderr, "Failed to create tarball:"
80 print >> sys.stderr, e.output
81 sys.exit(1)
82
83 if __name__ == "__main__":
84 main()
OLDNEW
« no previous file with comments | « blimp/engine/BUILD.gn ('k') | blimp/tools/create-bundle.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698