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