diff options
author | agrieve <agrieve@chromium.org> | 2016-03-22 15:03:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-22 22:05:20 +0000 |
commit | 99748af41ad073389f3f38274a024a830585609c (patch) | |
tree | a4ec1312ee060fdb587a604cc729ca641a10e420 | |
parent | d22fae34f47ce95aee43167fef1eb3f6cb231a0a (diff) | |
download | chromium_src-99748af41ad073389f3f38274a024a830585609c.zip chromium_src-99748af41ad073389f3f38274a024a830585609c.tar.gz chromium_src-99748af41ad073389f3f38274a024a830585609c.tar.bz2 |
Android: Run lint using a cache in the output directory (fix-up)
Previous commit forgot to set --cache-dir for GN.
BUG=583661
Review URL: https://codereview.chromium.org/1824093002
Cr-Commit-Position: refs/heads/master@{#382699}
-rw-r--r-- | build/android/BUILD.gn | 34 | ||||
-rw-r--r-- | build/android/android_lint_cache.gyp | 1 | ||||
-rwxr-xr-x | build/android/gyp/lint.py | 20 | ||||
-rw-r--r-- | build/config/android/internal_rules.gni | 71 |
4 files changed, 64 insertions, 62 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..20b5f77 100644 --- a/build/android/android_lint_cache.gyp +++ b/build/android/android_lint_cache.gyp @@ -37,6 +37,7 @@ '--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 9814bf0..0aad9c5 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: if can_fail_build: traceback.print_exc() @@ -192,6 +197,9 @@ def main(): parser.add_argument('--cache-dir', help='Path to the directory in which the android cache ' 'directory tree should be stored.') + 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') @@ -257,9 +265,13 @@ def main(): 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)) + _cache_file = os.path.join( + args.cache_dir, '.android', 'cache', + 'api-versions-6-%s.bin' % args.build_tools_version) + if args.create_cache: + output_paths.append(_cache_file) + else: + input_paths.append(_cache_file) build_utils.CallAndWriteDepfileIfStale( lambda changes: _OnStaleMd5(changes, args.lint_path, diff --git a/build/config/android/internal_rules.gni b/build/config/android/internal_rules.gni index 79805d1..72cf046 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,65 @@ 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" + _cache_file = "$_cache_dir/.android/cache/api-versions-6-${android_sdk_build_tools_version}.bin" + 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 + "${android_sdk_root}/platform-tools/api/api-versions.xml", + _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), + "--build-tools-version", + android_sdk_build_tools_version, + "--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) { + outputs += [ _cache_file ] + args += [ + "--create-cache", + "--silent", + ] + } else { + inputs += [ + _cache_file, + 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", + ] + } } } |