From 80b07c9c32884daf19e311e87665c2bf4e1d4702 Mon Sep 17 00:00:00 2001 From: Tom Renn Date: Wed, 4 Dec 2024 15:25:43 -0800 Subject: [PATCH 1/2] Support relative workspace paths Make it possible for the Android SDK path to exist within the workspace when using the ANDROID_HOME repository environment variable. --- rules/android_sdk_repository/rule.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rules/android_sdk_repository/rule.bzl b/rules/android_sdk_repository/rule.bzl index 4fdf38c62..c453d0b2e 100644 --- a/rules/android_sdk_repository/rule.bzl +++ b/rules/android_sdk_repository/rule.bzl @@ -96,6 +96,8 @@ def _android_sdk_repository_impl(repo_ctx): android_sdk_path = repo_ctx.attr.path if not android_sdk_path: android_sdk_path = repo_ctx.os.environ.get("ANDROID_HOME") + if android_sdk_path.startswith("$WORKSPACE_ROOT"): + android_sdk_path = str(ctx.workspace_root) + android_sdk_path.removeprefix("$WORKSPACE_ROOT") if not android_sdk_path: # Create an empty repository that allows non-Android code to build. repo_ctx.template("BUILD.bazel", _EMPTY_SDK_REPO_TEMPLATE) From 8ba038a9680a34a53252781c8c37a73586e6d4ea Mon Sep 17 00:00:00 2001 From: Tom Renn Date: Wed, 4 Dec 2024 15:25:43 -0800 Subject: [PATCH 2/2] Support relative workspace paths Make it possible for the Android SDK path to exist within the workspace when using the ANDROID_HOME repository environment variable. --- rules/android_sdk_repository/rule.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/android_sdk_repository/rule.bzl b/rules/android_sdk_repository/rule.bzl index c453d0b2e..0aa01cd8f 100644 --- a/rules/android_sdk_repository/rule.bzl +++ b/rules/android_sdk_repository/rule.bzl @@ -97,7 +97,7 @@ def _android_sdk_repository_impl(repo_ctx): if not android_sdk_path: android_sdk_path = repo_ctx.os.environ.get("ANDROID_HOME") if android_sdk_path.startswith("$WORKSPACE_ROOT"): - android_sdk_path = str(ctx.workspace_root) + android_sdk_path.removeprefix("$WORKSPACE_ROOT") + android_sdk_path = str(repo_ctx.workspace_root) + android_sdk_path.removeprefix("$WORKSPACE_ROOT") if not android_sdk_path: # Create an empty repository that allows non-Android code to build. repo_ctx.template("BUILD.bazel", _EMPTY_SDK_REPO_TEMPLATE)