3 # Copyright (c) 2014 Intel Corporation. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
8 Parses a gyp JSON dependency dict generated by gyp's dump_dependency_json
9 generator and prints the Chromium targets (ie. the ones not in gyp files in
10 src/xwalk) required for building the ones passed on the command-line.
12 The output can then be passed, for example, to ninja.
21 def ParseDependency(dep):
23 Given a dependency like '/path/to/foo.gyp:somedep#target', returns a tuple
24 ('/path/to/foo.gyp', 'somedep').
26 path = dep[:dep.find(':')]
27 name = dep[dep.find(':')+1:dep.find('#')]
31 def GetDependencies(deps_dict, root):
33 dependencies = copy.deepcopy(deps_dict[root])
35 dep = dependencies.pop()
36 target_path, target_name = ParseDependency(dep)
37 if target_name in targets:
39 if ("xwalk/" not in target_path) and ("tizen_src/ewk/" not in target_path):
40 targets.add(target_name)
41 dependencies += deps_dict[dep]
47 print('Usage: %s <deps.json> <target 1> [... <target N>]' % sys.argv[0])
48 print('<deps.json> points to deps.json generated by gyp with '
49 'GYP_GENERATORS=dump_dependency_json.')
50 print('Each target is a target name whose dependencies will be '
54 dump_json_path = sys.argv[1]
55 if not os.path.isfile(dump_json_path):
56 print('"%s" not found.' % dump_json_path)
57 print('Run gyp with GYP_GENERATORS=dump_dependency_json first.')
60 deps_dict = json.load(open(dump_json_path))
61 targets = sys.argv[2:]
64 for target in targets:
67 if dep.endswith(':%s#target' % target):
72 print('Error: "%s" is not a valid target.' % target)
76 for dependency in roots:
77 target_deps |= GetDependencies(deps_dict, dependency)
79 print ' '.join(list(target_deps))
83 if __name__ == '__main__':