Skip to content

Commit

Permalink
Separate transition for instrumentation_test_apk
Browse files Browse the repository at this point in the history
Summary: In subsequent diffs we are going to make these transitions do different things, so separate them here as a no-op.

Reviewed By: ianlevesque

Differential Revision: D37554149

fbshipit-source-id: 79334f4993fde99ebf3fc24edf336b8b3144da09
  • Loading branch information
IanChilds authored and facebook-github-bot committed Oct 6, 2022
1 parent ab59a81 commit e1d6599
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions prelude/android/android.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ load(":android_prebuilt_aar.bzl", "android_prebuilt_aar_impl")
load(":android_resource.bzl", "android_resource_impl")
load(":android_toolchain.bzl", "AndroidPlatformInfo", "AndroidToolchainInfo")
load(":apk_genrule.bzl", "apk_genrule_impl")
load(":configuration.bzl", "cpu_split_transition", "cpu_transition")
load(":configuration.bzl", "cpu_split_transition", "cpu_split_transition_instrumentation_test_apk", "cpu_transition")
load(":gen_aidl.bzl", "gen_aidl_impl")
load(":prebuilt_native_library.bzl", "prebuilt_native_library_impl")
load(":robolectric_test.bzl", "robolectric_test_impl")
Expand Down Expand Up @@ -112,7 +112,7 @@ extra_attributes = {
"android_instrumentation_apk": {
"aapt_mode": attrs.enum(AaptMode, default = "aapt1"), # Match default in V1
"cpu_filters": attrs.list(attrs.enum(TargetCpuType), default = []),
"deps": attrs.list(_transition_dep_wrapper(attrs.split_transition_dep(cfg = cpu_split_transition)), default = []),
"deps": attrs.list(_transition_dep_wrapper(attrs.split_transition_dep(cfg = cpu_split_transition_instrumentation_test_apk)), default = []),
"dex_tool": attrs.string(default = "d8"), # Match default in V1
"manifest": attrs.option(attrs.one_of(_transition_dep_wrapper(attrs.transition_dep(cfg = cpu_transition)), attrs.source()), default = None),
"min_sdk_version": attrs.option(attrs.int(), default = None),
Expand Down
30 changes: 28 additions & 2 deletions prelude/android/configuration.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@ for min_sdk in get_min_sdk_version_range():
constraint_value_name = get_min_sdk_version_constraint_value_name(min_sdk)
_REFS[constraint_value_name] = "fbsource//xplat/buck2/platform/android:{}".format(constraint_value_name)

def _cpu_split_transition_instrumentation_test_apk_impl(
platform: PlatformInfo.type,
refs: struct.type,
attrs: struct.type) -> {str.type: PlatformInfo.type}:
cpu_filters = attrs.cpu_filters or CPU_FILTER_TO_ABI_DIRECTORY.keys()

return _cpu_split_transition(platform, refs, cpu_filters, attrs.min_sdk_version)

def _cpu_split_transition_impl(
platform: PlatformInfo.type,
refs: struct.type,
attrs: struct.type) -> {str.type: PlatformInfo.type}:
cpu_filters = attrs.cpu_filters or CPU_FILTER_TO_ABI_DIRECTORY.keys()

return _cpu_split_transition(platform, refs, cpu_filters, attrs.min_sdk_version)

def _cpu_split_transition(
platform: PlatformInfo.type,
refs: struct.type,
cpu_filters: [str.type],
min_sdk_version: [int.type, None]) -> {str.type: PlatformInfo.type}:
cpu = refs.cpu
x86 = refs.x86[ConstraintValueInfo]
x86_64 = refs.x86_64[ConstraintValueInfo]
Expand All @@ -44,8 +60,8 @@ def _cpu_split_transition_impl(
if constraint_setting_label != cpu[ConstraintSettingInfo].label
}

if attrs.min_sdk_version:
base_constraints[refs.min_sdk_version[ConstraintSettingInfo].label] = _get_min_sdk_constraint_value(attrs.min_sdk_version, refs)
if min_sdk_version:
base_constraints[refs.min_sdk_version[ConstraintSettingInfo].label] = _get_min_sdk_constraint_value(min_sdk_version, refs)

new_configs = {}
for platform_name, cpu_constraint in cpu_name_to_cpu_constraint.items():
Expand Down Expand Up @@ -77,6 +93,16 @@ cpu_split_transition = transition(
split = True,
)

cpu_split_transition_instrumentation_test_apk = transition(
impl = _cpu_split_transition_instrumentation_test_apk_impl,
refs = _REFS,
attrs = [
"cpu_filters",
"min_sdk_version",
],
split = True,
)

# If our deps have been split-transitioned by CPU then we are already analyzing the dependency
# graph using the resulting configurations. If there are any other attributes on the same target
# that also need to analyze the dependency graph, then we want to use one of the configurations
Expand Down

0 comments on commit e1d6599

Please sign in to comment.