Skip to content

Commit

Permalink
Reland "[buck2][apk_genrule] Passthrough native_libs to aab apk_genru…
Browse files Browse the repository at this point in the history
…le" (2nd attempt)

Summary:
D69821223 was reverted in D69897660 because we weren't properly capturing all the subtargets in an apk_genrule. This diff is the same as D69821223 with support for the missing subtargets.

Original Summary
----
Relands D69639800 with an improved test case and fixes for the Redex test

> From D68046119,
>  It's annoying to have to grab the android_binary rule before building a targeted native library. Allow that to be passed through the apk_genrule.
> The diff here applies the same to the aab path (which is now being set for m4a release builds)

Reviewed By: IanChilds

Differential Revision: D69906589

fbshipit-source-id: d7197e9df12caf04076aa9d8091522bfc4fb287e
  • Loading branch information
thevinster authored and facebook-github-bot committed Feb 20, 2025
1 parent 0fa32fb commit 7bb7705
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion prelude/android/apk_genrule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def apk_genrule_impl(ctx: AnalysisContext) -> list[Provider]:
input_android_apk_under_test_info = None
input_unstripped_shared_libraries = None
input_android_apk_subtargets = None
input_android_aab_subtargets = None
if ctx.attrs.apk != None:
# TODO(T104150125) The underlying APK should not have exopackage enabled
input_android_apk_info = ctx.attrs.apk[AndroidApkInfo]
Expand All @@ -42,6 +43,7 @@ def apk_genrule_impl(ctx: AnalysisContext) -> list[Provider]:
input_apk = input_android_aab_info.aab
input_manifest = input_android_aab_info.manifest
input_materialized_artifacts = input_android_aab_info.materialized_artifacts
input_android_aab_subtargets = ctx.attrs.aab[DefaultInfo].sub_targets

env_vars = {
"AAB": cmd_args(input_apk),
Expand Down Expand Up @@ -96,11 +98,22 @@ def apk_genrule_impl(ctx: AnalysisContext) -> list[Provider]:
"aab": [DefaultInfo(
default_outputs = [genrule_default_output],
)],
"native_libs": [input_android_aab_subtargets["native_libs"][DefaultInfo]],
},
),
] + filter(lambda x: not isinstance(x, DefaultInfo), genrule_providers)
else:
default_providers = genrule_providers
sub_targets = {k: [v[DefaultInfo]] for k, v in genrule_default_info[0].sub_targets.items()}
sub_targets.update({
"native_libs": [input_android_aab_subtargets["native_libs"][DefaultInfo]],
})
default_providers = [
DefaultInfo(
default_output = genrule_default_output,
other_outputs = genrule_default_info[0].other_outputs,
sub_targets = sub_targets,
),
] + filter(lambda x: not isinstance(x, DefaultInfo), genrule_providers)

else:
sub_targets = {k: [v[DefaultInfo]] for k, v in genrule_default_info[0].sub_targets.items()}
Expand Down

0 comments on commit 7bb7705

Please sign in to comment.