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

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

Issue 2113943002: 🎒 Rework Android resource linting to exclude third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | 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 69acb2bb8a437911f524fcf0f98d42874774399c..edb1f4b4cd55d5b2c3dfa4aa402ffe54cb10b9eb 100755
--- a/build/android/gyp/write_build_config.py
+++ b/build/android/gyp/write_build_config.py
@@ -313,7 +313,6 @@ def main(argv):
direct_library_deps = deps.Direct('java_library')
all_library_deps = deps.All('java_library')
- direct_resources_deps = deps.Direct('android_resources')
all_resources_deps = deps.All('android_resources')
# Resources should be ordered with the highest-level dependency first so that
# overrides are done correctly.
@@ -415,40 +414,32 @@ def main(argv):
deps_info['r_text'] = options.r_text
if options.is_locale_resource:
deps_info['is_locale_resource'] = True
- # Record resources_dirs of this target so dependendent libraries can pick up
- # them and pass to Lint.
- lint_info = deps_info['lint'] = {}
- resource_dirs = []
- lint_info['resources_zips'] = []
- for gyp_list in options.resource_dirs:
- resource_dirs += build_utils.ParseGypList(gyp_list)
- if resource_dirs:
- lint_info['resources_dirs'] = resource_dirs
- # There things become ugly. Resource targets may have resource dependencies
- # as well. Some of these dependencies are resources from other libraries
- # so we should not lint them here (they should be linted within their
- # libraries). But others are just generated resources that also contribute
- # to this library and we should check them. These generated resources has no
- # package_name so we skip all direct deps that has package names.
- for c in direct_resources_deps:
- if 'package_name' not in c:
- lint_info['resources_zips'].append(c['resources_zip'])
+
+ deps_info['resources_dirs'] = []
+ if options.resource_dirs:
+ for gyp_list in options.resource_dirs:
+ deps_info['resources_dirs'].extend(build_utils.ParseGypList(gyp_list))
if options.supports_android and options.type in ('android_apk',
'java_library'):
- # GN's project model doesn't exactly match traditional Android project
- # model: GN splits resources into separate targets, while in Android
- # resources are part of the library/APK. Android Lint expects an Android
- # project - with java sources and resources combined. So we assume that
- # direct resource dependencies of the library/APK are the resources of this
- # library in Android project sense.
- lint_info = config['lint'] = {}
- lint_info['resources_dirs'] = []
- lint_info['resources_zips'] = []
- for c in direct_resources_deps:
- lint_info['resources_dirs'] += c['lint'].get('resources_dirs', [])
- lint_info['resources_zips'] += c['lint'].get('resources_zips', [])
-
+ # Lint all resources that are not already linted by a dependent library.
+ owned_resource_dirs = set()
+ owned_resource_zips = set()
+ for c in all_resources_deps:
+ # Always use resources_dirs in favour of resources_zips so that lint error
+ # messages have paths that are closer to reality (and to avoid needing to
+ # extract during lint).
+ if c['resources_dirs']:
+ owned_resource_dirs.update(c['resources_dirs'])
+ else:
+ owned_resource_zips.add(c['resources_zip'])
+
+ for c in all_library_deps:
+ if c['supports_android']:
+ owned_resource_dirs.difference_update(c['owned_resources_dirs'])
+ owned_resource_zips.difference_update(c['owned_resources_zips'])
+ deps_info['owned_resources_dirs'] = list(owned_resource_dirs)
+ deps_info['owned_resources_zips'] = list(owned_resource_zips)
if options.type in ('android_resources','android_apk', 'resource_rewriter'):
config['resources'] = {}
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698