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

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

Issue 2345143002: Move language pak files to assets. (Closed)
Patch Set: Move language pak files back to assets rather than res. Created 4 years, 3 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 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 """Writes a build_config file. 7 """Writes a build_config file.
8 8
9 The build_config file for a target is a json file containing information about 9 The build_config file for a target is a json file containing information about
10 how to build that target based on the target's dependencies. This includes 10 how to build that target based on the target's dependencies. This includes
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 '--deps-configs', 226 '--deps-configs',
227 help='List of paths for dependency\'s build_config files. ') 227 help='List of paths for dependency\'s build_config files. ')
228 228
229 # android_resources options 229 # android_resources options
230 parser.add_option('--srcjar', help='Path to target\'s resources srcjar.') 230 parser.add_option('--srcjar', help='Path to target\'s resources srcjar.')
231 parser.add_option('--resources-zip', help='Path to target\'s resources zip.') 231 parser.add_option('--resources-zip', help='Path to target\'s resources zip.')
232 parser.add_option('--r-text', help='Path to target\'s R.txt file.') 232 parser.add_option('--r-text', help='Path to target\'s R.txt file.')
233 parser.add_option('--package-name', 233 parser.add_option('--package-name',
234 help='Java package name for these resources.') 234 help='Java package name for these resources.')
235 parser.add_option('--android-manifest', help='Path to android manifest.') 235 parser.add_option('--android-manifest', help='Path to android manifest.')
236 parser.add_option('--is-locale-resource', action='store_true',
237 help='Whether it is locale resource.')
238 parser.add_option('--resource-dirs', action='append', default=[], 236 parser.add_option('--resource-dirs', action='append', default=[],
239 help='GYP-list of resource dirs') 237 help='GYP-list of resource dirs')
240 238
241 # android_assets options 239 # android_assets options
242 parser.add_option('--asset-sources', help='List of asset sources.') 240 parser.add_option('--asset-sources', help='List of asset sources.')
243 parser.add_option('--asset-renaming-sources', 241 parser.add_option('--asset-renaming-sources',
244 help='List of asset sources with custom destinations.') 242 help='List of asset sources with custom destinations.')
245 parser.add_option('--asset-renaming-destinations', 243 parser.add_option('--asset-renaming-destinations',
246 help='List of asset custom destinations.') 244 help='List of asset custom destinations.')
247 parser.add_option('--disable-asset-compression', action='store_true', 245 parser.add_option('--disable-asset-compression', action='store_true',
248 help='Whether to disable asset compression.') 246 help='Whether to disable asset compression.')
247 parser.add_option('--is-locale-asset', action='store_true',
agrieve 2016/09/21 01:06:42 Idea: If we add the assets target directly to the
estevenson 2016/09/21 19:50:56 Done.
248 help='Whether it is a locale asset.')
249 249
250 # java library options 250 # java library options
251 parser.add_option('--jar-path', help='Path to target\'s jar output.') 251 parser.add_option('--jar-path', help='Path to target\'s jar output.')
252 parser.add_option('--java-sources-file', help='Path to .sources file') 252 parser.add_option('--java-sources-file', help='Path to .sources file')
253 parser.add_option('--bundled-srcjars', 253 parser.add_option('--bundled-srcjars',
254 help='GYP-list of .srcjars that have been included in this java_library.') 254 help='GYP-list of .srcjars that have been included in this java_library.')
255 parser.add_option('--supports-android', action='store_true', 255 parser.add_option('--supports-android', action='store_true',
256 help='Whether this library supports running on the Android platform.') 256 help='Whether this library supports running on the Android platform.')
257 parser.add_option('--requires-android', action='store_true', 257 parser.add_option('--requires-android', action='store_true',
258 help='Whether this library requires running on the Android platform.') 258 help='Whether this library requires running on the Android platform.')
(...skipping 24 matching lines...) Expand all
283 283
284 parser.add_option('--tested-apk-config', 284 parser.add_option('--tested-apk-config',
285 help='Path to the build config of the tested apk (for an instrumentation ' 285 help='Path to the build config of the tested apk (for an instrumentation '
286 'test apk).') 286 'test apk).')
287 parser.add_option('--proguard-enabled', action='store_true', 287 parser.add_option('--proguard-enabled', action='store_true',
288 help='Whether proguard is enabled for this apk.') 288 help='Whether proguard is enabled for this apk.')
289 parser.add_option('--proguard-configs', 289 parser.add_option('--proguard-configs',
290 help='GYP-list of proguard flag files to use in final apk.') 290 help='GYP-list of proguard flag files to use in final apk.')
291 parser.add_option('--proguard-info', 291 parser.add_option('--proguard-info',
292 help='Path to the proguard .info output for this apk.') 292 help='Path to the proguard .info output for this apk.')
293 parser.add_option('--has-alternative-locale-resource', action='store_true', 293 parser.add_option('--has-alternative-locale-asset', action='store_true',
294 help='Whether there is alternative-locale-resource in direct deps') 294 help='Whether there is alternative-locale-asset in direct deps')
295 parser.add_option('--fail', 295 parser.add_option('--fail',
296 help='GYP-list of error message lines to fail with.') 296 help='GYP-list of error message lines to fail with.')
297 297
298 options, args = parser.parse_args(argv) 298 options, args = parser.parse_args(argv)
299 299
300 if args: 300 if args:
301 parser.error('No positional arguments should be given.') 301 parser.error('No positional arguments should be given.')
302 if options.fail: 302 if options.fail:
303 parser.error('\n'.join(build_utils.ParseGnList(options.fail))) 303 parser.error('\n'.join(build_utils.ParseGnList(options.fail)))
304 304
(...skipping 27 matching lines...) Expand all
332 raise Exception( 332 raise Exception(
333 '--supports-android is required when using --requires-android') 333 '--supports-android is required when using --requires-android')
334 334
335 direct_deps_config_paths = build_utils.ParseGnList(options.deps_configs) 335 direct_deps_config_paths = build_utils.ParseGnList(options.deps_configs)
336 direct_deps_config_paths = _FilterDepsPaths(direct_deps_config_paths, 336 direct_deps_config_paths = _FilterDepsPaths(direct_deps_config_paths,
337 options.type) 337 options.type)
338 338
339 deps = Deps(direct_deps_config_paths) 339 deps = Deps(direct_deps_config_paths)
340 all_inputs = deps.AllConfigPaths() 340 all_inputs = deps.AllConfigPaths()
341 341
342 # Remove other locale resources if there is alternative_locale_resource in 342 # Remove other locale assets if there is alternative_locale_asset in
343 # direct deps. 343 # direct deps.
344 if options.has_alternative_locale_resource: 344 if options.has_alternative_locale_asset:
345 alternative = [r['path'] for r in deps.Direct('android_resources') 345 alternative = [r['path'] for r in deps.Direct('android_assets')
346 if r.get('is_locale_resource')] 346 if r.get('is_locale_asset')]
347 # We can only have one locale resources in direct deps. 347 # We can only have one locale assets in direct deps.
348 if len(alternative) != 1: 348 if len(alternative) != 1:
349 raise Exception('The number of locale resource in direct deps is wrong %d' 349 raise Exception('The number of locale assets in direct deps is wrong %d'
350 % len(alternative)) 350 % len(alternative))
351 unwanted = [r['path'] for r in deps.All('android_resources') 351 unwanted = [r['path'] for r in deps.All('android_assets')
352 if r.get('is_locale_resource') and r['path'] not in alternative] 352 if r.get('is_locale_asset') and r['path'] not in alternative]
353 for p in unwanted: 353 for p in unwanted:
354 deps.RemoveNonDirectDep(p) 354 deps.RemoveNonDirectDep(p)
355 355
356 356
357 direct_library_deps = deps.Direct('java_library') 357 direct_library_deps = deps.Direct('java_library')
358 all_library_deps = deps.All('java_library') 358 all_library_deps = deps.All('java_library')
359 359
360 all_resources_deps = deps.All('android_resources') 360 all_resources_deps = deps.All('android_resources')
361 # Resources should be ordered with the highest-level dependency first so that 361 # Resources should be ordered with the highest-level dependency first so that
362 # overrides are done correctly. 362 # overrides are done correctly.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 all_asset_sources.extend(build_utils.ParseGnList(options.asset_sources)) 466 all_asset_sources.extend(build_utils.ParseGnList(options.asset_sources))
467 467
468 deps_info['assets'] = { 468 deps_info['assets'] = {
469 'sources': all_asset_sources 469 'sources': all_asset_sources
470 } 470 }
471 if options.asset_renaming_destinations: 471 if options.asset_renaming_destinations:
472 deps_info['assets']['outputs'] = ( 472 deps_info['assets']['outputs'] = (
473 build_utils.ParseGnList(options.asset_renaming_destinations)) 473 build_utils.ParseGnList(options.asset_renaming_destinations))
474 if options.disable_asset_compression: 474 if options.disable_asset_compression:
475 deps_info['assets']['disable_compression'] = True 475 deps_info['assets']['disable_compression'] = True
476 if options.is_locale_asset:
477 deps_info['is_locale_asset'] = True
476 478
477 if options.type == 'android_resources': 479 if options.type == 'android_resources':
478 deps_info['resources_zip'] = options.resources_zip 480 deps_info['resources_zip'] = options.resources_zip
479 if options.srcjar: 481 if options.srcjar:
480 deps_info['srcjar'] = options.srcjar 482 deps_info['srcjar'] = options.srcjar
481 if options.android_manifest: 483 if options.android_manifest:
482 manifest = AndroidManifest(options.android_manifest) 484 manifest = AndroidManifest(options.android_manifest)
483 deps_info['package_name'] = manifest.GetPackageName() 485 deps_info['package_name'] = manifest.GetPackageName()
484 if options.package_name: 486 if options.package_name:
485 deps_info['package_name'] = options.package_name 487 deps_info['package_name'] = options.package_name
486 if options.r_text: 488 if options.r_text:
487 deps_info['r_text'] = options.r_text 489 deps_info['r_text'] = options.r_text
488 if options.is_locale_resource:
489 deps_info['is_locale_resource'] = True
490 490
491 deps_info['resources_dirs'] = [] 491 deps_info['resources_dirs'] = []
492 if options.resource_dirs: 492 if options.resource_dirs:
493 for gyp_list in options.resource_dirs: 493 for gyp_list in options.resource_dirs:
494 deps_info['resources_dirs'].extend(build_utils.ParseGnList(gyp_list)) 494 deps_info['resources_dirs'].extend(build_utils.ParseGnList(gyp_list))
495 495
496 if options.supports_android and options.type in ('android_apk', 496 if options.supports_android and options.type in ('android_apk',
497 'java_library'): 497 'java_library'):
498 # Lint all resources that are not already linted by a dependent library. 498 # Lint all resources that are not already linted by a dependent library.
499 owned_resource_dirs = set() 499 owned_resource_dirs = set()
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 _MergeAssets(deps.All('android_assets'))) 660 _MergeAssets(deps.All('android_assets')))
661 661
662 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 662 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
663 663
664 if options.depfile: 664 if options.depfile:
665 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) 665 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs)
666 666
667 667
668 if __name__ == '__main__': 668 if __name__ == '__main__':
669 sys.exit(main(sys.argv[1:])) 669 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698