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

Unified Diff: build/android/gyp/write_build_config.py

Issue 1493803003: GN(android): Enhance dependency logic in .build_config files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b8b8ec8c748827569799b6c63ef4e11078b4168a..dff0ae0205dba3e698241bd8d30ca86bd99c85c7 100755
--- a/build/android/gyp/write_build_config.py
+++ b/build/android/gyp/write_build_config.py
@@ -37,6 +37,13 @@ from util import md5_check
import write_ordered_libraries
+
+# Types that should never be used as a dependency of another build config.
+_ROOT_TYPES = ('android_apk', 'deps_dex', 'resource_rewriter')
+# Types that should not allow code deps to pass through.
+_RESOURCE_TYPES = ('android_assets', 'android_resources')
+
+
class AndroidManifest(object):
def __init__(self, path):
self.path = path
@@ -143,6 +150,16 @@ def _MergeAssets(all_assets):
return create_list(compressed), create_list(uncompressed)
+def _FilterUnwantedDepsPaths(dep_paths, target_type):
+ # Don't allow root targets to be considered as a dep.
+ ret = [p for p in dep_paths if GetDepConfig(p)['type'] not in _ROOT_TYPES]
+
+ # Don't allow java libraries to cross through assets/resources.
+ if target_type in _RESOURCE_TYPES:
+ ret = [p for p in ret if GetDepConfig(p)['type'] in _RESOURCE_TYPES]
+ return ret
+
+
def main(argv):
parser = optparse.OptionParser()
build_utils.AddDepfileOption(parser)
@@ -242,8 +259,11 @@ def main(argv):
direct_deps_config_paths = [
c for c in possible_deps_config_paths if not c in unknown_deps]
+ direct_deps_config_paths = _FilterUnwantedDepsPaths(direct_deps_config_paths,
+ options.type)
deps = Deps(direct_deps_config_paths)
+
direct_library_deps = deps.Direct('java_library')
all_library_deps = deps.All('java_library')
@@ -265,12 +285,12 @@ def main(argv):
'name': os.path.basename(options.build_config),
'path': options.build_config,
'type': options.type,
- 'deps_configs': direct_deps_config_paths,
+ 'deps_configs': direct_deps_config_paths
}
}
deps_info = config['deps_info']
- if options.type == 'java_library' and not options.bypass_platform_checks:
+ if (options.type == 'java_library' and not options.bypass_platform_checks):
pkotwicz 2015/12/03 20:13:08 Why did you add the brackets?
agrieve 2015/12/03 20:22:18 Whoops, that's an artifact of me splitting up this
deps_info['requires_android'] = options.requires_android
deps_info['supports_android'] = options.supports_android
@@ -287,7 +307,7 @@ def main(argv):
raise Exception('Not all deps support the Android platform: ' +
str(deps_not_support_android))
- if options.type in ['java_library', 'android_apk']:
+ if options.type in ('java_library', 'android_apk'):
javac_classpath = [c['jar_path'] for c in direct_library_deps]
java_full_classpath = [c['jar_path'] for c in all_library_deps]
deps_info['resources_deps'] = [c['path'] for c in all_resources_deps]
« 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