Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Android Home support #26

Merged
merged 2 commits into from
Apr 27, 2024
Merged

Conversation

EdbertChan
Copy link
Contributor

Directly inject android_home into lint and reconstructs the absolute path without resorting to using the ANDROID_HOME environment variable outside of Bazel.

This is opposed to [Grab's approach.](https://github.com/grab/grab-bazel-common/blob/02735d57ab96392d9b590398218a6be3e1f[…]3813f/tools/lint/src/main/java/com/grab/lint/LintBaseCommand.kt](https://github.com/grab/grab-bazel-common/blob/02735d57ab96392d9b590398218a6be3e1f3813f/tools/lint/src/main/java/com/grab/lint/LintBaseCommand.kt#L213C28-L213C40) that constructs the field from environment variable.

How to Use:

android_lint_test(
    **android_home = "@androidsdk//:sdk",**
)

This way, we keep the sdk in parity with whatever we have specified in WORKSPACE.

@Bencodes
Copy link
Owner

@EdbertChan mind taking a look at the failing tests?

rules/attrs.bzl Outdated
@@ -34,6 +34,10 @@ ATTRS = dict(
allow_single_file = True,
doc = "Android manifest to run Android Lint against.",
),
android_home = attr.label(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really live at the toolchain level instead of needing to be passed to every single target.

rules/impl.bzl Outdated
@@ -116,6 +116,10 @@ def _run_android_lint(
args.add("--output", output)
outputs.append(output)

label = ctx.attr.android_home.label
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw a null pointer if android_home isn't set.

@EdbertChan EdbertChan force-pushed the android_home_support branch from 985d3bd to 8888f1b Compare April 23, 2024 00:59
@EdbertChan EdbertChan force-pushed the android_home_support branch from 9fdcadc to 69332d6 Compare April 23, 2024 17:24
@Bencodes Bencodes merged commit defcc71 into Bencodes:main Apr 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants