Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: build/android/gyp/apkbuilder.py

Issue 2841883002: Android: Fix incremental builds not noticing when assets change (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Adds the code parts to a resource APK.""" 7 """Adds the code parts to a resource APK."""
8 8
9 import argparse 9 import argparse
10 import itertools 10 import itertools
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 src_path=path, 182 src_path=path,
183 compress=compress) 183 compress=compress)
184 184
185 185
186 def main(args): 186 def main(args):
187 args = build_utils.ExpandFileArgs(args) 187 args = build_utils.ExpandFileArgs(args)
188 options = _ParseArgs(args) 188 options = _ParseArgs(args)
189 189
190 native_libs = sorted(options.native_libs) 190 native_libs = sorted(options.native_libs)
191 191
192 input_paths = [options.resource_apk, __file__] + native_libs 192 input_paths = [options.resource_apk, __file__]
193 # Include native libs in the depfile_deps since GN doesn't know about the 193 # Include native libs in the depfile_deps since GN doesn't know about the
194 # dependencies when is_component_build=true. 194 # dependencies when is_component_build=true.
195 depfile_deps = list(native_libs) 195 depfile_deps = list(native_libs)
196 196
197 secondary_native_libs = [] 197 secondary_native_libs = []
198 if options.secondary_native_libs: 198 if options.secondary_native_libs:
199 secondary_native_libs = sorted(options.secondary_native_libs) 199 secondary_native_libs = sorted(options.secondary_native_libs)
200 input_paths += secondary_native_libs
201 depfile_deps += secondary_native_libs 200 depfile_deps += secondary_native_libs
202 201
203 if options.dex_file: 202 if options.dex_file:
204 input_paths.append(options.dex_file) 203 input_paths.append(options.dex_file)
205 204
206 input_strings = [options.android_abi, 205 input_strings = [options.android_abi,
207 options.native_lib_placeholders, 206 options.native_lib_placeholders,
208 options.uncompress_shared_libraries] 207 options.uncompress_shared_libraries]
209 208
210 if options.secondary_android_abi: 209 if options.secondary_android_abi:
211 input_strings.append(options.secondary_android_abi) 210 input_strings.append(options.secondary_android_abi)
212 211
213 if options.java_resources: 212 if options.java_resources:
214 input_paths.extend(options.java_resources) 213 # Included via .build_config, so need to write it to depfile.
214 depfile_deps.extend(options.java_resources)
215 215
216 _assets = _ExpandPaths(options.assets) 216 _assets = _ExpandPaths(options.assets)
217 _uncompressed_assets = _ExpandPaths(options.uncompressed_assets) 217 _uncompressed_assets = _ExpandPaths(options.uncompressed_assets)
218 218
219 for src_path, dest_path in itertools.chain(_assets, _uncompressed_assets): 219 for src_path, dest_path in itertools.chain(_assets, _uncompressed_assets):
220 input_paths.append(src_path) 220 # Included via .build_config, so need to write it to depfile.
221 depfile_deps.append(src_path)
221 input_strings.append(dest_path) 222 input_strings.append(dest_path)
222 223
223 def on_stale_md5(): 224 def on_stale_md5():
224 tmp_apk = options.output_apk + '.tmp' 225 tmp_apk = options.output_apk + '.tmp'
225 try: 226 try:
226 # TODO(agrieve): It would be more efficient to combine this step 227 # TODO(agrieve): It would be more efficient to combine this step
227 # with finalize_apk(), which sometimes aligns and uncompresses the 228 # with finalize_apk(), which sometimes aligns and uncompresses the
228 # native libraries. 229 # native libraries.
229 with zipfile.ZipFile(options.resource_apk) as resource_apk, \ 230 with zipfile.ZipFile(options.resource_apk) as resource_apk, \
230 zipfile.ZipFile(tmp_apk, 'w', zipfile.ZIP_DEFLATED) as out_apk: 231 zipfile.ZipFile(tmp_apk, 'w', zipfile.ZIP_DEFLATED) as out_apk:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 out_apk, apk_path, data=java_resource_jar.read(apk_path)) 303 out_apk, apk_path, data=java_resource_jar.read(apk_path))
303 304
304 shutil.move(tmp_apk, options.output_apk) 305 shutil.move(tmp_apk, options.output_apk)
305 finally: 306 finally:
306 if os.path.exists(tmp_apk): 307 if os.path.exists(tmp_apk):
307 os.unlink(tmp_apk) 308 os.unlink(tmp_apk)
308 309
309 build_utils.CallAndWriteDepfileIfStale( 310 build_utils.CallAndWriteDepfileIfStale(
310 on_stale_md5, 311 on_stale_md5,
311 options, 312 options,
312 input_paths=input_paths, 313 input_paths=input_paths + depfile_deps,
313 input_strings=input_strings, 314 input_strings=input_strings,
314 output_paths=[options.output_apk], 315 output_paths=[options.output_apk],
315 depfile_deps=depfile_deps) 316 depfile_deps=depfile_deps)
316 317
317 318
318 if __name__ == '__main__': 319 if __name__ == '__main__':
319 main(sys.argv[1:]) 320 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698