OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 '''Generates a list of runtime Blimp Engine runtime dependencies. | 6 '''Generates a list of Blimp engine target runtime dependencies. |
7 ''' | 7 ''' |
8 | 8 |
9 | 9 |
10 import argparse | 10 import argparse |
11 import fnmatch | 11 import fnmatch |
12 import os | 12 import os |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 # Returns True if |entry| matches any of the patterns in |blacklist|. | 16 # Returns True if |entry| matches any of the patterns in |blacklist|. |
17 def IsBlacklisted(entry, blacklist): | 17 def IsBlacklisted(entry, blacklist): |
18 return any([next_pat for next_pat in blacklist | 18 return any([next_pat for next_pat in blacklist |
19 if fnmatch.fnmatch(entry, next_pat)]) | 19 if fnmatch.fnmatch(entry, next_pat)]) |
20 | 20 |
21 def main(): | 21 def main(): |
22 parser = argparse.ArgumentParser(description=__doc__) | 22 parser = argparse.ArgumentParser(description=__doc__) |
23 parser.add_argument('--build-dir', | 23 parser.add_argument('--build-dir', |
24 help=('build output directory (e.g. out/Debug)'), | 24 help=('build output directory (e.g. out/Debug)'), |
25 required=True, | 25 required=True, |
26 metavar='DIR') | 26 metavar='DIR') |
27 parser.add_argument('--target', | 27 parser.add_argument('--target', |
28 help=('build target of engine'), | 28 help=('build target of engine'), |
29 required=True) | 29 required=True) |
30 parser.add_argument('--output', | 30 parser.add_argument('--output', |
31 help=('name and path of manifest file to create'), | 31 help=('name and path of manifest file to create'), |
32 required=True, | 32 required=True, |
33 metavar='FILE') | 33 metavar='FILE') |
34 parser.add_argument('--blacklist', | |
35 help=('name and path of the blacklist file to use'), | |
36 required=True) | |
34 args = parser.parse_args() | 37 args = parser.parse_args() |
35 | 38 |
36 try: | 39 try: |
37 deps = subprocess.check_output(['gn', 'desc', args.build_dir, args.target, | 40 deps = subprocess.check_output(['gn', 'desc', args.build_dir, args.target, |
38 'runtime_deps']).split() | 41 'runtime_deps']).split() |
39 except subprocess.CalledProcessError as e: | 42 except subprocess.CalledProcessError as e: |
40 print "Error: " + ' '.join(e.cmd) | 43 print "Error: " + ' '.join(e.cmd) |
41 print e.output | 44 print e.output |
42 exit(1) | 45 exit(1) |
43 | 46 |
44 command_line = ' '.join([os.path.basename(sys.argv[0])] + sys.argv[1:]) | 47 command_line = ' '.join([os.path.basename(sys.argv[0])] + sys.argv[1:]) |
45 header = [ | 48 header = [ |
46 '# Runtime dependencies for the Blimp Engine', | 49 '# Runtime dependencies for the Blimp Engine', |
47 '#', | 50 '#', |
48 '# This file was generated by running:', | 51 '# This file was generated by running:', |
49 '# ' + command_line + '', | 52 '# ' + command_line + '', |
50 '#', | 53 '#', |
51 '# Note: Any unnecessary dependencies should be added to', | 54 '# Note: Any unnecessary dependencies should be added to provided', |
52 '# manifest-blacklist.txt and this file should be regenerated.', | 55 '# manifest-blacklist and this file should be regenerated.', |
53 '', | 56 '', |
54 ] | 57 ] |
55 | 58 |
56 blacklist_patterns = [] | 59 blacklist_patterns = [] |
57 with open(os.path.join(os.sys.path[0], 'manifest-blacklist.txt'), 'r') \ | 60 with open(args.blacklist, 'r') as blacklist_file: |
nyquist
2016/05/05 22:31:49
os.sys.path[0] is the script path. Does removing t
Jess
2016/05/09 23:42:55
My thought was to ensure that path behavior was co
| |
58 as blacklist_file: | |
59 blacklist_patterns = \ | 61 blacklist_patterns = \ |
60 [entry.partition('#')[0].strip() for entry \ | 62 [entry.partition('#')[0].strip() for entry \ |
61 in blacklist_file.readlines()] | 63 in blacklist_file.readlines()] |
62 | 64 |
63 with open(args.output, 'w') as manifest: | 65 with open(args.output, 'w') as manifest: |
64 manifest.write('\n'.join(header)) | 66 manifest.write('\n'.join(header)) |
65 manifest.write('\n'.join([dep for dep in deps | 67 manifest.write('\n'.join([dep for dep in deps |
66 if not IsBlacklisted(dep, blacklist_patterns)])) | 68 if not IsBlacklisted(dep, blacklist_patterns)])) |
67 | 69 |
68 print 'Created ' + args.output | 70 print 'Created ' + args.output |
69 | 71 |
70 if __name__ == "__main__": | 72 if __name__ == "__main__": |
71 main() | 73 main() |
OLD | NEW |