2 # Copyright (c) 2013 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.
6 """Logic to generate lists of DEPS used by various parts of
7 the android_webview continuous integration (buildbot) infrastructure.
9 Note: The root Chromium project (which is not explicitly listed here)
10 has a couple of third_party libraries checked in directly into it. This means
11 that the list of third parties present in this file is not a comprehensive
12 list of third party android_webview dependencies.
22 class DepsWhitelist(object):
24 # If a new DEPS entry is needed for the AOSP bot to compile please add it
26 # This is a staging area for deps that are accepted by the android_webview
27 # team and are in the process of having the required branches being created
28 # in the Android tree.
29 self._compile_but_not_snapshot_dependencies = [
32 # Dependencies that need to be merged into the Android tree.
33 self._snapshot_into_android_dependencies = [
38 'third_party/brotli/src',
39 ('third_party/eyesfree/src/android/java/src/com/googlecode/eyesfree/'
41 'third_party/freetype',
43 'third_party/leveldatabase/src',
44 'third_party/libjingle/source/talk',
45 'third_party/libphonenumber/src/phonenumbers',
46 'third_party/libphonenumber/src/resources',
47 'third_party/libsrtp',
50 'third_party/mesa/src',
51 'third_party/openssl',
52 'third_party/opus/src',
54 'third_party/sfntly/cpp/src',
55 'third_party/skia/gyp',
56 'third_party/skia/include',
57 'third_party/skia/src',
58 'third_party/smhasher/src',
60 'third_party/yasm/source/patched-yasm',
66 # Dependencies required to build android_webview.
67 self._compile_dependencies = (self._snapshot_into_android_dependencies +
68 self._compile_but_not_snapshot_dependencies)
70 # Dependencies required to run android_webview tests but not required to
72 self._test_data_dependencies = [
73 'chrome/test/data/perf/third_party/octane',
77 def _read_deps_file(deps_file_path):
78 class FileImplStub(object):
79 """Stub for the File syntax."""
80 def __init__(self, file_location):
95 def from_stub(__, _=None):
96 """Stub for the From syntax."""
99 class VarImpl(object):
100 def __init__(self, custom_vars, local_scope):
101 self._custom_vars = custom_vars
102 self._local_scope = local_scope
104 def Lookup(self, var_name):
105 """Implements the Var syntax."""
106 if var_name in self._custom_vars:
107 return self._custom_vars[var_name]
108 elif var_name in self._local_scope.get("vars", {}):
109 return self._local_scope["vars"][var_name]
110 raise Exception("Var is not defined: %s" % var_name)
113 var = VarImpl({}, local_scope)
115 'File': FileImplStub,
120 execfile(deps_file_path, global_scope, local_scope)
121 deps = local_scope.get('deps', {})
122 deps_os = local_scope.get('deps_os', {})
123 for os_specific_deps in deps_os.itervalues():
124 deps.update(os_specific_deps)
127 def _make_gclient_blacklist(self, deps_file_path, whitelisted_deps):
128 """Calculates the list of deps that need to be excluded from the deps_file
129 so that the only deps left are the one in the whitelist."""
130 all_deps = self._read_deps_file(deps_file_path)
131 # The list of deps read from the DEPS file are prefixed with the source
132 # tree root, which is 'src' for Chromium.
133 def prepend_root(path):
134 return os.path.join('src', path)
135 whitelisted_deps = map(prepend_root, whitelisted_deps)
136 deps_blacklist = set(all_deps).difference(set(whitelisted_deps))
137 return dict(map(lambda(x): (x, None), deps_blacklist))
139 def get_deps_for_android_build(self, deps_file_path):
140 """This is used to calculate the custom_deps list for the Android bot.
142 if not deps_file_path:
143 raise Exception('You need to specify a DEPS file path.')
144 return self._make_gclient_blacklist(deps_file_path,
145 self._compile_dependencies)
147 def get_deps_for_android_build_and_test(self, deps_file_path):
148 """This is used to calculate the custom_deps list for the Android perf bot.
150 if not deps_file_path:
151 raise Exception('You need to specify a DEPS file path.')
152 return self._make_gclient_blacklist(deps_file_path,
153 self._compile_dependencies +
154 self._test_data_dependencies)
156 def get_deps_for_android_merge(self, _):
157 """Calculates the list of deps that need to be merged into the Android tree
158 in order to build the C++ and Java android_webview code."""
159 return self._snapshot_into_android_dependencies
161 def get_deps_for_license_check(self, _):
162 """Calculates the list of deps that need to be checked for Android license
164 return self._compile_dependencies
166 def execute_method(self, method_name, deps_file_path):
168 'android_build': self.get_deps_for_android_build,
169 'android_build_and_test':
170 self.get_deps_for_android_build_and_test,
171 'android_merge': self.get_deps_for_android_merge,
172 'license_check': self.get_deps_for_license_check
174 if not method_name in methods:
175 raise Exception('Method name %s is not valid. Valid choices are %s' %
176 (method_name, methods.keys()))
177 return methods[method_name](deps_file_path)
180 parser = argparse.ArgumentParser()
181 parser.add_argument('--method', help='Method to use to fetch from whitelist.',
183 parser.add_argument('--path-to-deps', help='Path to DEPS file.')
184 parser.add_argument('--output-json', help='Name of file to write output to.')
185 parser.add_argument('verbose', action='store_true', default=False)
186 opts = parser.parse_args()
188 logging.getLogger().setLevel(logging.DEBUG if opts.verbose else logging.WARN)
190 deps_whitelist = DepsWhitelist()
191 blacklist = deps_whitelist.execute_method(opts.method, opts.path_to_deps)
193 if (opts.output_json):
195 'blacklist' : blacklist
197 with open(opts.output_json, 'w') as output_json_file:
198 json.dump(output_dict, output_json_file)
205 if __name__ == '__main__':