summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authoragrieve <agrieve@chromium.org>2016-03-23 10:26:34 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-23 17:27:52 +0000
commit070509bda8b8b74d8963907bd5f79909da043c34 (patch)
tree6de99b7c0dafae61562f06f0e97099371ca1ae2b /build
parentf93357a327af2f6c15917b78de3fba559c2a60cd (diff)
downloadchromium_src-070509bda8b8b74d8963907bd5f79909da043c34.zip
chromium_src-070509bda8b8b74d8963907bd5f79909da043c34.tar.gz
chromium_src-070509bda8b8b74d8963907bd5f79909da043c34.tar.bz2
Reland of Android: Run lint using a cache in the output directory (fix-up)
No longer trying to guess name of cached .bin file. Previous commit forgot to set --cache-dir for GN. BUG=583661,597251 Review URL: https://codereview.chromium.org/1828693002 Cr-Commit-Position: refs/heads/master@{#382871}
Diffstat (limited to 'build')
-rw-r--r--build/android/BUILD.gn34
-rw-r--r--build/android/android_lint_cache.gyp9
-rwxr-xr-xbuild/android/gyp/lint.py28
-rw-r--r--build/android/lint_action.gypi6
-rw-r--r--build/config/android/internal_rules.gni68
5 files changed, 68 insertions, 77 deletions
diff --git a/build/android/BUILD.gn b/build/android/BUILD.gn
index 01deb14..73b25cd 100644
--- a/build/android/BUILD.gn
+++ b/build/android/BUILD.gn
@@ -10,37 +10,9 @@ sun_tools_jar_path = "$root_gen_dir/sun_tools_jar/tools.jar"
# Create or update the API versions cache if necessary by running a
# functionally empty lint task. This prevents racy creation of the
# cache while linting java targets in android_lint.
-action("prepare_android_lint_cache") {
- _cache_dir = "${root_out_dir}/android_lint_cache"
- depfile = "${_cache_dir}/prepare_android_lint_cache.d"
- _manifest_file = "//build/android/AndroidManifest.xml"
- _result_file = "${_cache_dir}/result.xml"
- script = "//build/android/gyp/lint.py"
-
- inputs = [
- "${android_sdk_root}/platform-tools/api/api-versions.xml",
- ]
- outputs = [
- depfile,
- ]
- args = [
- "--build-tools-version",
- android_sdk_build_tools_version,
- "--cache-dir",
- rebase_path(_cache_dir, root_build_dir),
- "--depfile",
- rebase_path(depfile, root_build_dir),
- "--lint-path",
- "$rebased_android_sdk_root/tools/lint",
- "--manifest-path",
- rebase_path(_manifest_file, root_build_dir),
- "--product-dir",
- ".",
- "--result-path",
- rebase_path(_result_file, root_build_dir),
- "--silent",
- "--enable",
- ]
+android_lint("prepare_android_lint_cache") {
+ android_manifest = "//build/android/AndroidManifest.xml"
+ create_cache = true
}
action("find_sun_tools_jar") {
diff --git a/build/android/android_lint_cache.gyp b/build/android/android_lint_cache.gyp
index a8b514e..8c5175d 100644
--- a/build/android/android_lint_cache.gyp
+++ b/build/android/android_lint_cache.gyp
@@ -17,26 +17,29 @@
'variables': {
'android_lint_cache_stamp': '<(PRODUCT_DIR)/android_lint_cache/android_lint_cache.stamp',
'android_manifest_path': '<(DEPTH)/build/android/AndroidManifest.xml',
- 'cache_file': '<(PRODUCT_DIR)/android_lint_cache/.android/cache/api-versions-6-23.0.1.bin',
'result_path': '<(PRODUCT_DIR)/android_lint_cache/result.xml',
+ 'platform_xml_path': '<(android_sdk_root)/platform-tools/api/api-versions.xml',
},
'inputs': [
+ '<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/lint.py',
'<(android_manifest_path)',
+ '<(platform_xml_path)',
],
'outputs': [
- '<(cache_file)',
+ '<(android_lint_cache_stamp)',
'<(result_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/lint.py',
'--lint-path', '<(android_sdk_root)/tools/lint',
'--cache-dir', '<(PRODUCT_DIR)/android_lint_cache',
- '--build-tools-version', '<(android_sdk_build_tools_version)',
+ '--platform-xml-path', '<(platform_xml_path)',
'--manifest-path', '<(android_manifest_path)',
'--product-dir', '<(PRODUCT_DIR)',
'--result-path', '<(result_path)',
'--stamp', '<(android_lint_cache_stamp)',
+ '--create-cache',
'--silent',
'--enable'
],
diff --git a/build/android/gyp/lint.py b/build/android/gyp/lint.py
index 2df89e1..20484f7 100755
--- a/build/android/gyp/lint.py
+++ b/build/android/gyp/lint.py
@@ -130,11 +130,16 @@ def _OnStaleMd5(changes, lint_path, config_path, processed_config_path,
os.remove(result_path)
env = {}
+ stderr_filter = None
if cache_dir:
+ # When _JAVA_OPTIONS is set, java prints to stderr:
+ # Picked up _JAVA_OPTIONS: ...
env['_JAVA_OPTIONS'] = '-Duser.home=%s' % _RelativizePath(cache_dir)
+ stderr_filter = lambda l: '' if '_JAVA_OPTIONS' in l else l
try:
- build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None)
+ build_utils.CheckOutput(cmd, cwd=_SRC_ROOT, env=env or None,
+ stderr_filter=stderr_filter)
except build_utils.CalledProcessError:
# There is a problem with lint usage
if not os.path.exists(result_path):
@@ -203,12 +208,14 @@ def main():
help='Path to product dir.')
parser.add_argument('--result-path', required=True,
help='Path to XML lint result file.')
-
- parser.add_argument('--build-tools-version',
- help='Version of the build tools in the Android SDK.')
- parser.add_argument('--cache-dir',
+ parser.add_argument('--cache-dir', required=True,
help='Path to the directory in which the android cache '
'directory tree should be stored.')
+ parser.add_argument('--platform-xml-path', required=True,
+ help='Path to api-platforms.xml')
+ parser.add_argument('--create-cache', action='store_true',
+ help='Mark the lint cache file as an output rather than '
+ 'an input.')
parser.add_argument('--can-fail-build', action='store_true',
help='If set, script will exit with nonzero exit status'
' if lint errors are present')
@@ -222,8 +229,6 @@ def main():
help='Paths to java files.')
parser.add_argument('--manifest-path',
help='Path to AndroidManifest.xml')
- parser.add_argument('--platform-xml-path',
- help='Path to api-platforms.xml')
parser.add_argument('--processed-config-path',
help='Path to processed lint suppressions file.')
parser.add_argument('--resource-dir',
@@ -252,6 +257,7 @@ def main():
input_paths = [
args.lint_path,
+ args.platform_xml_path,
]
if args.config_path:
input_paths.append(args.config_path)
@@ -259,8 +265,6 @@ def main():
input_paths.append(args.jar_path)
if args.manifest_path:
input_paths.append(args.manifest_path)
- if args.platform_xml_path:
- input_paths.append(args.platform_xml_path)
if args.resource_dir:
input_paths.extend(build_utils.FindInDirectory(args.resource_dir, '*'))
if sources:
@@ -271,12 +275,6 @@ def main():
input_strings.append(args.processed_config_path)
output_paths = [ args.result_path ]
- if args.cache_dir:
- if not args.build_tools_version:
- parser.error('--cache-dir specified without --build-tools-version')
- output_paths.append(os.path.join(
- args.cache_dir, '.android', 'cache',
- 'api-versions-6-%s.bin' % args.build_tools_version))
build_utils.CallAndWriteDepfileIfStale(
lambda changes: _OnStaleMd5(changes, args.lint_path,
diff --git a/build/android/lint_action.gypi b/build/android/lint_action.gypi
index 35b7d49..3826662 100644
--- a/build/android/lint_action.gypi
+++ b/build/android/lint_action.gypi
@@ -16,16 +16,20 @@
'additional_args': [],
}]
],
+ 'android_lint_cache_stamp': '<(PRODUCT_DIR)/android_lint_cache/android_lint_cache.stamp',
'android_manifest_path%': '<(DEPTH)/build/android/AndroidManifest.xml',
'resource_dir%': '<(DEPTH)/build/android/ant/empty/res',
'suppressions_file%': '<(DEPTH)/build/android/lint/suppressions.xml',
+ 'platform_xml_path': '<(android_sdk_root)/platform-tools/api/api-versions.xml',
},
'inputs': [
'<(DEPTH)/build/android/gyp/util/build_utils.py',
'<(DEPTH)/build/android/gyp/lint.py',
+ '<(android_lint_cache_stamp)',
'<(android_manifest_path)',
'<(lint_jar_path)',
'<(suppressions_file)',
+ '<(platform_xml_path)',
],
'action': [
'python', '<(DEPTH)/build/android/gyp/lint.py',
@@ -33,7 +37,7 @@
'--config-path=<(suppressions_file)',
'--processed-config-path=<(config_path)',
'--cache-dir', '<(PRODUCT_DIR)/android_lint_cache',
- '--build-tools-version', '<(android_sdk_build_tools_version)',
+ '--platform-xml-path', '<(platform_xml_path)',
'--manifest-path=<(android_manifest_path)',
'--result-path=<(result_path)',
'--resource-dir=<(resource_dir)',
diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni
index 79805d1..6c421df 100644
--- a/build/config/android/internal_rules.gni
+++ b/build/config/android/internal_rules.gni
@@ -24,13 +24,6 @@ if (is_debug) {
}
template("android_lint") {
- set_sources_assignment_filter([])
-
- jar_path = invoker.jar_path
- android_manifest = invoker.android_manifest
- java_files = invoker.java_files
- base_path = "$target_gen_dir/$target_name"
-
action(target_name) {
deps = []
forward_variables_from(invoker,
@@ -40,41 +33,62 @@ template("android_lint") {
"public_deps",
"testonly",
])
+ _cache_dir = "$root_build_dir/android_lint_cache"
+ _result_path = "$target_gen_dir/$target_name/result.xml"
+ _config_path = "$target_gen_dir/$target_name/config.xml"
+ _suppressions_file = "//build/android/lint/suppressions.xml"
+ _platform_xml_path =
+ "${android_sdk_root}/platform-tools/api/api-versions.xml"
+
script = "//build/android/gyp/lint.py"
- result_path = base_path + "/result.xml"
- config_path = base_path + "/config.xml"
- suppressions_file = "//build/android/lint/suppressions.xml"
+ depfile = "$target_gen_dir/$target_name.d"
inputs = [
- suppressions_file,
- android_manifest,
- jar_path,
- ] + java_files
+ _platform_xml_path,
+ _suppressions_file,
+ invoker.android_manifest,
+ ]
outputs = [
- config_path,
- result_path,
+ depfile,
+ _config_path,
+ _result_path,
]
- deps += [ "//build/android:prepare_android_lint_cache" ]
-
- rebased_java_files = rebase_path(java_files, root_build_dir)
-
args = [
"--lint-path=$rebased_android_sdk_root/tools/lint",
+ "--cache-dir",
+ rebase_path(_cache_dir, root_build_dir),
+ "--platform-xml-path",
+ rebase_path(_platform_xml_path, root_build_dir),
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
"--config-path",
- rebase_path(suppressions_file, root_build_dir),
+ rebase_path(_suppressions_file, root_build_dir),
"--manifest-path",
- rebase_path(android_manifest, root_build_dir),
+ rebase_path(invoker.android_manifest, root_build_dir),
"--product-dir=.",
- "--jar-path",
- rebase_path(jar_path, root_build_dir),
"--processed-config-path",
- rebase_path(config_path, root_build_dir),
+ rebase_path(_config_path, root_build_dir),
"--result-path",
- rebase_path(result_path, root_build_dir),
- "--java-files=$rebased_java_files",
+ rebase_path(_result_path, root_build_dir),
"--enable",
]
+
+ if (defined(invoker.create_cache) && invoker.create_cache) {
+ args += [
+ "--create-cache",
+ "--silent",
+ ]
+ } else {
+ inputs += [ invoker.jar_path ] + invoker.java_files
+ deps += [ "//build/android:prepare_android_lint_cache" ]
+ _rebased_java_files = rebase_path(invoker.java_files, root_build_dir)
+ args += [
+ "--jar-path",
+ rebase_path(invoker.jar_path, root_build_dir),
+ "--java-files=$_rebased_java_files",
+ ]
+ }
}
}