Commit 7b39bed1 authored by Peter Wen's avatar Peter Wen Committed by Commit Bot

Android: Generate project.xml for lint

Use --project to pass in a generated project.xml file for each lint
target instead of passing each argument through the command line. This
allows the lint checks to function more correctly and thoroughly than
before.

Currently lint does not fully support srcjars (fix is in ToT but not yet
in our lint version), so we extract generated sources and generated
resources in a consistent temporary location under their lint target's
gen dir, removing them if lint succeeds and leaving them in place if
lint fails in order to make it easier to debug lint failures.

Clean up and remove various options that are no longer used or needed.
e.g. display lint errors directly rather than parsing an xml file from
lint's results.

Simplify suppressions file comments and remove unnecessary ones. Ignore
common failures for translations since we have a dedicated translation
team.

Remove an unused dimens and fix a few issues. Suppress additional issues
found by this lint improvement.

Bug: 1082743
Change-Id: I67147e582bd904308fe6a5fc5a11baebd60db41b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212550
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772301}
parent 7829cbdd
This diff is collapsed.
This diff is collapsed.
...@@ -867,8 +867,6 @@ template("test_runner_script") { ...@@ -867,8 +867,6 @@ template("test_runner_script") {
} }
if (enable_java_templates) { if (enable_java_templates) {
android_sdk_jar = "$android_sdk/android.jar"
template("android_lint") { template("android_lint") {
action_with_pydeps(target_name) { action_with_pydeps(target_name) {
forward_variables_from(invoker, forward_variables_from(invoker,
...@@ -878,59 +876,45 @@ if (enable_java_templates) { ...@@ -878,59 +876,45 @@ if (enable_java_templates) {
"public_deps", "public_deps",
"testonly", "testonly",
]) ])
_suppressions_file = "//build/android/lint/suppressions.xml"
if (defined(invoker.lint_suppressions_file)) { if (defined(invoker.lint_suppressions_file)) {
lint_suppressions_file = invoker.lint_suppressions_file _suppressions_file = invoker.lint_suppressions_file
} else if (!defined(lint_suppressions_file)) { } else if (defined(lint_suppressions_file)) {
# WebRTC defines its own lint_suppressions_file: # WebRTC defines its own lint_suppressions_file:
# //tools_webrtc/android/suppressions.xml # //tools_webrtc/android/suppressions.xml
lint_suppressions_file = "//build/android/lint/suppressions.xml" _suppressions_file = lint_suppressions_file
} }
_min_sdk_version = default_min_sdk_version _min_sdk_version = default_min_sdk_version
if (defined(invoker.min_sdk_version)) { if (defined(invoker.min_sdk_version)) {
_min_sdk_version = invoker.min_sdk_version _min_sdk_version = invoker.min_sdk_version
} }
_lint_path = "$lint_android_sdk_root/cmdline-tools/latest/bin/lint"
_lint_binary_path = "$lint_android_sdk_root/cmdline-tools/latest/bin/lint"
_cache_dir = "$root_build_dir/android_lint_cache" _cache_dir = "$root_build_dir/android_lint_cache"
_result_path = "$target_out_dir/$target_name/result.xml"
_config_path = "$target_out_dir/$target_name/config.xml" # Save these generated xml files in a consistent location for debugging.
_stamp_path = "$target_out_dir/$target_name/build.lint.stamp" _lint_gen_dir = "$target_gen_dir/$target_name"
_suppressions_file = lint_suppressions_file
_platform_xml_path =
"$lint_android_sdk_root/platform-tools/api/api-versions.xml"
script = "//build/android/gyp/lint.py" script = "//build/android/gyp/lint.py"
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
inputs = [ inputs = [
_lint_path, _lint_binary_path,
_platform_xml_path,
_suppressions_file, _suppressions_file,
] ]
# _result_path is also an output, but do not list it in order to avoid it
# being uploaded to swarming as part of isolates. This happens as a
# side-effect of lint targets being listed as "data_deps" in order to
# have them run concurrently with other targets.
outputs = [ _stamp_path ]
args = [ args = [
"--depfile", "--depfile",
rebase_path(depfile, root_build_dir), rebase_path(depfile, root_build_dir),
"--lint-path", "--lint-binary-path",
rebase_path(_lint_path, root_build_dir), rebase_path(_lint_binary_path, root_build_dir),
"--cache-dir", "--cache-dir",
rebase_path(_cache_dir, root_build_dir), rebase_path(_cache_dir, root_build_dir),
"--platform-xml-path",
rebase_path(_platform_xml_path, root_build_dir),
"--android-sdk-version=${lint_android_sdk_version}",
"--config-path", "--config-path",
rebase_path(_suppressions_file, root_build_dir), rebase_path(_suppressions_file, root_build_dir),
"--product-dir=.", "--lint-gen-dir",
"--result-path", rebase_path(_lint_gen_dir, root_build_dir),
rebase_path(_result_path, root_build_dir), "--android-sdk-version=${lint_android_sdk_version}",
"--stamp",
rebase_path(_stamp_path, root_build_dir),
"--include-unexpected-failures",
"--min-sdk-version=$_min_sdk_version", "--min-sdk-version=$_min_sdk_version",
"--android-sdk-root", "--android-sdk-root",
rebase_path(lint_android_sdk_root, root_build_dir), rebase_path(lint_android_sdk_root, root_build_dir),
...@@ -941,11 +925,24 @@ if (enable_java_templates) { ...@@ -941,11 +925,24 @@ if (enable_java_templates) {
args += [ "--testonly" ] args += [ "--testonly" ]
} }
if (defined(invoker.manifest_package)) {
args += [ "--manifest-package=${invoker.manifest_package}" ]
}
if (java_warnings_as_errors) {
args += [ "--can-fail-build" ]
}
_stamp_path = "$target_out_dir/$target_name/build.lint.stamp"
if (defined(invoker.create_cache) && invoker.create_cache) { if (defined(invoker.create_cache) && invoker.create_cache) {
args += [ "--silent" ] args += [ "--silent" ]
# Putting the stamp file in the cache dir allows us to depend on ninja
# to create the cache dir for us.
_stamp_path = "$_cache_dir/build.lint.stamp"
} else { } else {
inputs += [ invoker.build_config ]
deps += [ "//build/android:prepare_android_lint_cache" ] deps += [ "//build/android:prepare_android_lint_cache" ]
inputs += [ invoker.build_config ]
_rebased_build_config = _rebased_build_config =
rebase_path(invoker.build_config, root_build_dir) rebase_path(invoker.build_config, root_build_dir)
args += [ args += [
...@@ -955,14 +952,13 @@ if (enable_java_templates) { ...@@ -955,14 +952,13 @@ if (enable_java_templates) {
"--resource-sources=@FileArg($_rebased_build_config:deps_info:lint_resource_sources)", "--resource-sources=@FileArg($_rebased_build_config:deps_info:lint_resource_sources)",
"--resource-zips=@FileArg($_rebased_build_config:deps_info:lint_resource_zips)", "--resource-zips=@FileArg($_rebased_build_config:deps_info:lint_resource_zips)",
] ]
if (java_warnings_as_errors) {
args += [ "--can-fail-build" ]
}
} }
if (defined(invoker.manifest_package)) { outputs = [ _stamp_path ]
args += [ "--manifest-package=${invoker.manifest_package}" ] args += [
} "--stamp",
rebase_path(_stamp_path, root_build_dir),
]
} }
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
<dimen name="location_bar_action_icon_width">40dp</dimen> <dimen name="location_bar_action_icon_width">40dp</dimen>
<dimen name="location_bar_url_action_offset">0dp</dimen> <dimen name="location_bar_url_action_offset">0dp</dimen>
<dimen name="omnibox_suggestion_start_offset_without_icon">@dimen/location_bar_icon_width</dimen> <dimen name="omnibox_suggestion_start_offset_without_icon">@dimen/location_bar_icon_width</dimen>
<dimen name="omnibox_suggestion_start_offset_with_icon">@dimen/omnibox_suggestion_start_offset_without_icon</dimen>
<dimen name="omnibox_suggestion_icon_area_size">40dp</dimen> <dimen name="omnibox_suggestion_icon_area_size">40dp</dimen>
<dimen name="omnibox_suggestion_36dp_icon_margin_start">0dp</dimen> <dimen name="omnibox_suggestion_36dp_icon_margin_start">0dp</dimen>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.toolbar.bottom; package org.chromium.chrome.browser.toolbar.bottom;
import android.annotation.SuppressLint;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener; import android.view.View.OnLongClickListener;
...@@ -75,6 +76,7 @@ public class BottomControlsCoordinator { ...@@ -75,6 +76,7 @@ public class BottomControlsCoordinator {
* whether the bar should be focused, and the second is the OmniboxFocusReason. * whether the bar should be focused, and the second is the OmniboxFocusReason.
* @param overviewModeBehaviorSupplier Supplier for the overview mode manager. * @param overviewModeBehaviorSupplier Supplier for the overview mode manager.
*/ */
@SuppressLint("CutPasteId") // Not actually cut and paste since it's View vs ViewGroup.
public BottomControlsCoordinator(ChromeFullscreenManager fullscreenManager, ViewStub stub, public BottomControlsCoordinator(ChromeFullscreenManager fullscreenManager, ViewStub stub,
ActivityTabProvider tabProvider, OnLongClickListener tabSwitcherLongclickListener, ActivityTabProvider tabProvider, OnLongClickListener tabSwitcherLongclickListener,
ThemeColorProvider themeColorProvider, ThemeColorProvider themeColorProvider,
......
...@@ -7,7 +7,6 @@ package org.chromium.components.browser_ui.widget; ...@@ -7,7 +7,6 @@ package org.chromium.components.browser_ui.widget;
import android.content.Context; import android.content.Context;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
import android.util.LayoutDirection;
import android.view.View; import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
...@@ -525,7 +524,7 @@ public class WrappingLayoutTest { ...@@ -525,7 +524,7 @@ public class WrappingLayoutTest {
ViewExpectation expectationB, ViewExpectation expectationC) { ViewExpectation expectationB, ViewExpectation expectationC) {
WrappingLayoutSubclass layout = WrappingLayoutSubclass.create( WrappingLayoutSubclass layout = WrappingLayoutSubclass.create(
mContext, leftTopPadding, bottomRightPadding, spacing); mContext, leftTopPadding, bottomRightPadding, spacing);
layout.setLayoutDirection(LayoutDirection.RTL); layout.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
layout.addTestViews(margin); layout.addTestViews(margin);
layout.layoutAtSize(width, height, specWidth, specHeight, 0, 0); layout.layoutAtSize(width, height, specWidth, specHeight, 0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment