| 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 | |
| 10 import argparse | |
| 11 import fnmatch | |
| 12 import os | |
| 13 import subprocess | |
| 14 import sys | |
| 15 | |
| 16 # Returns True if |entry| matches any of the patterns in |blacklist|. | |
| 17 def IsBlacklisted(entry, blacklist): | |
| 18 return any([next_pat for next_pat in blacklist | |
| 19 if fnmatch.fnmatch(entry, next_pat)]) | |
| 20 | |
| 21 def main(): | |
| 22 parser = argparse.ArgumentParser(description=__doc__) | |
| 23 parser.add_argument('--build-dir', | |
| 24 help=('build output directory (e.g. out/Debug)'), | |
| 25 required=True, | |
| 26 metavar='DIR') | |
| 27 parser.add_argument('--target', | |
| 28 help=('build target of engine'), | |
| 29 required=True) | |
| 30 parser.add_argument('--output', | |
| 31 help=('name and path of manifest file to create'), | |
| 32 required=True, | |
| 33 metavar='FILE') | |
| 34 args = parser.parse_args() | |
| 35 | |
| 36 try: | |
| 37 deps = subprocess.check_output(['gn', 'desc', args.build_dir, args.target, | |
| 38 'runtime_deps']).split() | |
| 39 except subprocess.CalledProcessError as e: | |
| 40 print "Error: " + ' '.join(e.cmd) | |
| 41 print e.output | |
| 42 exit(1) | |
| 43 | |
| 44 command_line = ' '.join([os.path.basename(sys.argv[0])] + sys.argv[1:]) | |
| 45 header = [ | |
| 46 '# Runtime dependencies for the Blimp Engine', | |
| 47 '#', | |
| 48 '# This file was generated by running:', | |
| 49 '# ' + command_line + '', | |
| 50 '#', | |
| 51 '# Note: Any unnecessary dependencies should be added to', | |
| 52 '# manifest-blacklist.txt and this file should be regenerated.', | |
| 53 '', | |
| 54 ] | |
| 55 | |
| 56 blacklist_patterns = [] | |
| 57 with open(os.path.join(os.sys.path[0], 'manifest-blacklist.txt'), 'r') \ | |
| 58 as blacklist_file: | |
| 59 blacklist_patterns = \ | |
| 60 [entry.partition('#')[0].strip() for entry \ | |
| 61 in blacklist_file.readlines()] | |
| 62 | |
| 63 with open(args.output, 'w') as manifest: | |
| 64 manifest.write('\n'.join(header)) | |
| 65 manifest.write('\n'.join([dep for dep in deps | |
| 66 if not IsBlacklisted(dep, blacklist_patterns)])) | |
| 67 | |
| 68 print 'Created ' + args.output | |
| 69 | |
| 70 if __name__ == "__main__": | |
| 71 main() | |
| OLD | NEW |