Index: build/android/gyp/write_build_config.py |
diff --git a/build/android/gyp/write_build_config.py b/build/android/gyp/write_build_config.py |
index f84958c1661dabb91503e001a404b6ca5631de28..dc1172e9220990bef318127f6990ebf8495641cb 100755 |
--- a/build/android/gyp/write_build_config.py |
+++ b/build/android/gyp/write_build_config.py |
@@ -101,6 +101,7 @@ class Deps(object): |
GetDepConfig(p) for p in direct_deps_config_paths] |
self.all_deps_configs = [ |
GetDepConfig(p) for p in self.all_deps_config_paths] |
+ self.direct_deps_config_paths = direct_deps_config_paths |
def All(self, wanted_type=None): |
if type is None: |
@@ -115,6 +116,12 @@ class Deps(object): |
def AllConfigPaths(self): |
return self.all_deps_config_paths |
+ def RemoveNoneDirectDep(self, path): |
agrieve
2015/12/30 15:22:15
nit: RemoveNoneDirectDep -> RemoveNonDirectDep
michaelbai
2015/12/30 19:29:48
Done.
|
+ if path in self.direct_deps_config_paths: |
+ raise Exception('Can not remove direct dep') |
agrieve
2015/12/30 15:22:15
nit: Can not -> Cannot (although assert() might be
michaelbai
2015/12/30 19:29:48
Done.
|
+ self.all_deps_config_paths.remove(path) |
+ self.all_deps_configs = [ |
agrieve
2015/12/30 15:22:15
nit: GetDepConfig() caches, so you can just do:
michaelbai
2015/12/30 19:29:48
Done.
|
+ GetDepConfig(p) for p in self.all_deps_config_paths] |
def _MergeAssets(all_assets): |
"""Merges all assets from the given deps. |
@@ -180,6 +187,8 @@ def main(argv): |
parser.add_option('--package-name', |
help='Java package name for these resources.') |
parser.add_option('--android-manifest', help='Path to android manifest.') |
+ parser.add_option('--is-locale-resource', action='store_true', |
+ help='Whether it is locale resource.') |
# android_assets options |
parser.add_option('--asset-sources', help='List of asset sources.') |
@@ -216,6 +225,8 @@ def main(argv): |
help='Whether proguard is enabled for this apk.') |
parser.add_option('--proguard-info', |
help='Path to the proguard .info output for this apk.') |
+ parser.add_option('--has-alternative-locale-resource', action='store_true', |
+ help='Whether there is alternative-locale-resource in direct deps') |
options, args = parser.parse_args(argv) |
@@ -265,6 +276,21 @@ def main(argv): |
deps = Deps(direct_deps_config_paths) |
+ # Remove other locale resources if there is alternative_locale_resource in |
+ # direct deps. |
+ if options.has_alternative_locale_resource: |
+ alternative = [ r['path'] for r in deps.Direct('android_resources') |
agrieve
2015/12/30 15:22:15
nit: whitespace is off here. should be:
- No spac
michaelbai
2015/12/30 19:29:48
Done.
|
+ if r.get('is_locale_resource') ] |
+ # We can only have one locale resources in direct deps. |
+ if len(alternative) != 1: |
+ raise Exception('The number of locale resource in direct deps is wrong %d' |
+ % len(alternative)) |
+ unwanted = [ r['path'] for r in deps.All('android_resources') |
agrieve
2015/12/30 15:22:14
same here
michaelbai
2015/12/30 19:29:48
Done.
|
+ if r.get('is_locale_resource') and r['path'] not in alternative ] |
+ for p in unwanted: |
+ deps.RemoveNoneDirectDep(p) |
+ |
+ |
direct_library_deps = deps.Direct('java_library') |
all_library_deps = deps.All('java_library') |
@@ -362,6 +388,8 @@ def main(argv): |
deps_info['package_name'] = options.package_name |
if options.r_text: |
deps_info['r_text'] = options.r_text |
+ if options.is_locale_resource: |
+ deps_info['is_locale_resource'] = True |
if options.type in ('android_resources','android_apk', 'resource_rewriter'): |
config['resources'] = {} |