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 target runtime dependencies.''' |
7 | |
8 | 7 |
9 import argparse | 8 import argparse |
10 import fnmatch | 9 import fnmatch |
11 import os | |
12 | |
13 | 10 |
14 # Returns True if |entry| matches any of the patterns in |blacklist|. | 11 # Returns True if |entry| matches any of the patterns in |blacklist|. |
15 def IsBlacklisted(entry, blacklist): | 12 def IsBlacklisted(entry, blacklist): |
16 return any([next_pat for next_pat in blacklist | 13 return any([next_pat for next_pat in blacklist |
17 if fnmatch.fnmatch(entry, next_pat)]) | 14 if fnmatch.fnmatch(entry, next_pat)]) |
18 | 15 |
19 def main(): | 16 def main(): |
20 parser = argparse.ArgumentParser(description=__doc__) | 17 parser = argparse.ArgumentParser(description=__doc__) |
21 parser.add_argument('--runtime-deps-file', | 18 parser.add_argument('--runtime-deps-file', |
22 help=('name and path of runtime deps file, ' | 19 help=('name and path of runtime deps file, ' |
23 'if available'), | 20 'if available'), |
24 required=True, | 21 required=True, |
25 metavar='FILE') | 22 metavar='FILE') |
26 parser.add_argument('--output', | 23 parser.add_argument('--output', |
27 help=('name and path of manifest file to create ' | 24 help=('name and path of manifest file to create ' |
28 '(required)'), | 25 '(required)'), |
29 required=True, | 26 required=True, |
30 metavar='FILE') | 27 metavar='FILE') |
| 28 parser.add_argument('--blacklist', |
| 29 help=('name and path of the blacklist file to use'), |
| 30 required=True) |
31 args = parser.parse_args() | 31 args = parser.parse_args() |
32 | 32 |
33 with open(args.runtime_deps_file) as f: | 33 with open(args.runtime_deps_file) as f: |
34 deps = f.read().splitlines() | 34 deps = f.read().splitlines() |
35 | 35 |
36 header = [ | 36 header = [ |
37 '# Runtime dependencies for the Blimp Engine', | 37 '# Runtime dependencies for: ' + args.runtime_deps_file, |
38 '#', | 38 '#', |
39 '# Note: Any unnecessary dependencies should be added to', | 39 '# Note: Any unnecessary dependencies should be added to', |
40 '# manifest-blacklist.txt and this file should be regenerated.', | 40 '# the appropriate blacklist and this file should be regenerated.', |
41 '', | 41 '', |
42 ] | 42 ] |
43 | 43 |
44 blacklist_patterns = [] | 44 blacklist_patterns = [] |
45 with open(os.path.join(os.sys.path[0], 'manifest-blacklist.txt'), 'r') \ | 45 with open(args.blacklist, 'r') as blacklist_file: |
46 as blacklist_file: | |
47 blacklist_patterns = \ | 46 blacklist_patterns = \ |
48 [entry.partition('#')[0].strip() for entry \ | 47 [entry.partition('#')[0].strip() for entry \ |
49 in blacklist_file.readlines()] | 48 in blacklist_file.readlines()] |
50 | 49 |
51 with open(args.output, 'w') as manifest: | 50 with open(args.output, 'w') as manifest: |
52 manifest.write('\n'.join(header)) | 51 manifest.write('\n'.join(header)) |
53 manifest.write('\n'.join([dep for dep in deps | 52 manifest.write('\n'.join([dep for dep in deps |
54 if not IsBlacklisted(dep, blacklist_patterns)])) | 53 if not IsBlacklisted(dep, blacklist_patterns)])) |
55 manifest.write('\n') | 54 manifest.write('\n') |
56 | 55 |
57 print 'Created ' + args.output | 56 print 'Created ' + args.output |
58 | 57 |
59 if __name__ == "__main__": | 58 if __name__ == "__main__": |
60 main() | 59 main() |
OLD | NEW |