Skip to content

Commit

Permalink
Traverse Kotlin toolchain edge rather than _toolchain attr in mobile-…
Browse files Browse the repository at this point in the history
…install

PiperOrigin-RevId: 683794734
Change-Id: I46a40f12ccc510530fd56fea2d52434995f77496
  • Loading branch information
nreid260 authored and copybara-github committed Oct 8, 2024
1 parent 2a39234 commit de5b947
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions mobile_install/adapters/android_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ load(
"providers",
)
load("//mobile_install:resources.bzl", "get_assets_dir")
load("//mobile_install:tools.bzl", "TOOLCHAIN_TYPES")
load("//mobile_install:transform.bzl", "dex", "filter_jars")
load("//providers:providers.bzl", "AndroidIdeInfo")
load("//rules:visibility.bzl", "PROJECT_VISIBILITY")
Expand All @@ -36,8 +37,6 @@ def _aspect_attrs():
return [
"_aidl_lib",
"_android_sdk",
# Access the kt toolchain to get kotlin std and runtime libs.
"_toolchain",
"deps",
"exports",
]
Expand All @@ -52,10 +51,16 @@ def _adapt(target, ctx):
Returns:
A list of providers.
"""
kt_toolchain = [ctx.rule.attr._toolchain] if hasattr(ctx.rule.attr, "_toolchain") else []

if ctx.rule.attr.neverlink:
return []

toolchains = [
ctx.rule.toolchains[toolchain_type]
for toolchain_type in TOOLCHAIN_TYPES
if (toolchain_type in ctx.rule.toolchains)
]

aidl_lib = []
if target[AndroidIdeInfo].idl_generated_java_files:
aidl_lib = [ctx.rule.attr._aidl_lib]
Expand Down Expand Up @@ -94,7 +99,7 @@ def _adapt(target, ctx):
ctx.rule.attr.deps,
ctx.rule.attr.exports,
aidl_lib,
kt_toolchain,
toolchains,
),
),
providers.make_mi_android_resources_info(
Expand All @@ -111,7 +116,7 @@ def _adapt(target, ctx):
ctx.rule.attr.deps,
ctx.rule.attr.exports,
aidl_lib,
kt_toolchain,
toolchains,
),
),
]
Expand Down

0 comments on commit de5b947

Please sign in to comment.