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