Skip to content

Commit cc0e0db

Browse files
committed
Fix android_configure.bzl for Windows
1 parent e4172c8 commit cc0e0db

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

third_party/android/android_configure.bzl

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,37 @@ load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
66
_ANDROID_SDK_HOME = "ANDROID_HOME"
77
_ANDROID_NDK_HOME = "ANDROID_NDK_HOME"
88

9-
_ANDROID_SDK_REPO_TEMPLATE = """
10-
android_sdk_repository(
9+
_ANDROID_REPOS_TEMPLATE = """android_sdk_repository(
1110
name="androidsdk",
12-
path="%s",
11+
path={sdk_home},
1312
)
14-
"""
15-
16-
_ANDROID_NDK_REPO_TEMPLATE = """
1713
android_ndk_repository(
1814
name="androidndk",
19-
path="%s",
15+
path={ndk_home},
2016
)
2117
"""
2218

2319
def _android_autoconf_impl(repository_ctx):
2420
"""Implementation of the android_autoconf repo rule"""
2521
sdk_home = repository_ctx.os.environ.get(_ANDROID_SDK_HOME)
2622
ndk_home = repository_ctx.os.environ.get(_ANDROID_NDK_HOME)
27-
sdk_rule = ""
28-
ndk_rule = ""
2923

30-
if all([sdk_home, ndk_home]):
31-
sdk_rule = _ANDROID_SDK_REPO_TEMPLATE % (sdk_home)
32-
ndk_rule = _ANDROID_NDK_REPO_TEMPLATE % (ndk_home)
24+
if sdk_home and ndk_home:
25+
repos = _ANDROID_REPOS_TEMPLATE.format(
26+
sdk_home = repr(sdk_home),
27+
ndk_home = repr(ndk_home),
28+
)
3329
else:
34-
sdk_rule = "pass"
30+
repos = "pass"
3531

3632
repository_ctx.file("BUILD.bazel", "")
3733
repository_ctx.file("android_configure.bzl", """
3834
load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository")
3935
load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")
4036
4137
def android_workspace():
42-
{}
43-
{}
44-
""".format(sdk_rule, ndk_rule))
38+
{repos}
39+
""".format(repos = repos))
4540

4641
android_configure = repository_rule(
4742
implementation = _android_autoconf_impl,

0 commit comments

Comments
 (0)