summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-04-11 13:23:47 -0700
committerYifan Hong <elsk@google.com>2024-04-12 19:34:38 +0000
commit24b1693b9b599d9d1a4823a6dd92767456dbad49 (patch)
treeb7a00a5c5e92c3bf3c12cdc8e324d4e34d48c7e7
parentc083d3fa19f9397890866a9964805e7b59c0b885 (diff)
downloadbuild-24b1693b9b599d9d1a4823a6dd92767456dbad49.tar.gz
kleaf: [REFACTOR] Clean up kernel_prebuilt_repo (outs)
Drop outs and use outs_mapping everywhere. This removes branching in code. Always specifies mandatory so it is more explicit. Bug: 291918087 Change-Id: I40ccc7be3a32b7b01f86dbccb12724448ddeaf25
-rw-r--r--kleaf/common_kernels.bzl6
-rw-r--r--kleaf/impl/kernel_prebuilt_repo.bzl5
-rw-r--r--kleaf/impl/kernel_prebuilt_utils.bzl60
3 files changed, 34 insertions, 37 deletions
diff --git a/kleaf/common_kernels.bzl b/kleaf/common_kernels.bzl
index de21987..c096abb 100644
--- a/kleaf/common_kernels.bzl
+++ b/kleaf/common_kernels.bzl
@@ -1027,13 +1027,9 @@ def _define_prebuilts(**kwargs):
for config in value["download_configs"]:
target_suffix = config["target_suffix"]
- # outs of target named {name}_{target_suffix}
- suffixed_target_outs = list(config.get("outs", []))
- suffixed_target_outs += list(config.get("outs_mapping", {}).keys())
-
native.filegroup(
name = name + "_" + target_suffix + "_downloaded",
- srcs = ["@{}//{}".format(repo_name, filename) for filename in suffixed_target_outs],
+ srcs = ["@{}//{}".format(repo_name, filename) for filename in config["outs_mapping"]],
tags = ["manual"],
deprecation = deprecate_msg,
)
diff --git a/kleaf/impl/kernel_prebuilt_repo.bzl b/kleaf/impl/kernel_prebuilt_repo.bzl
index a39a039..f7f1242 100644
--- a/kleaf/impl/kernel_prebuilt_repo.bzl
+++ b/kleaf/impl/kernel_prebuilt_repo.bzl
@@ -105,10 +105,7 @@ def _infer_download_config(target):
mandatory[protected_modules] = False
for config in chosen_mapping["download_configs"]:
- config_mandatory = config.get("mandatory", True)
- for out in config.get("outs", []):
- download_config[out] = out
- mandatory[out] = config_mandatory
+ config_mandatory = config["mandatory"]
for out, remote_filename_fmt in config.get("outs_mapping", {}).items():
download_config[out] = remote_filename_fmt
mandatory[out] = config_mandatory
diff --git a/kleaf/impl/kernel_prebuilt_utils.bzl b/kleaf/impl/kernel_prebuilt_utils.bzl
index 8caf254..7110a9e 100644
--- a/kleaf/impl/kernel_prebuilt_utils.bzl
+++ b/kleaf/impl/kernel_prebuilt_utils.bzl
@@ -43,44 +43,49 @@ CI_TARGET_MAPPING = {
"protected_modules": "gki_aarch64_protected_modules",
"gki_prebuilts_outs": GKI_ARTIFACTS_AARCH64_OUTS,
"download_configs": [
- # - mandatory: If False, download errors are ignored. Default is True
+ # - mandatory: If False, download errors are ignored.
+ # - outs_mapping: local_filename -> remote_artifact_fmt
{
"target_suffix": "uapi_headers",
- "outs": [
- "kernel-uapi-headers.tar.gz",
- ],
+ "mandatory": True,
+ "outs_mapping": {
+ "kernel-uapi-headers.tar.gz": "kernel-uapi-headers.tar.gz",
+ },
},
{
"target_suffix": "unstripped_modules_archive",
- "outs": [
- UNSTRIPPED_MODULES_ARCHIVE,
- ],
+ "mandatory": True,
+ "outs_mapping": {
+ UNSTRIPPED_MODULES_ARCHIVE: UNSTRIPPED_MODULES_ARCHIVE,
+ },
},
{
"target_suffix": "headers",
- "outs": [
- "kernel-headers.tar.gz",
- ],
+ "mandatory": True,
+ "outs_mapping": {
+ "kernel-headers.tar.gz": "kernel-headers.tar.gz",
+ },
},
{
"target_suffix": "images",
+ "mandatory": True,
# TODO(b/297934577): Update GKI prebuilts to download system_dlkm.<fs>.img
- "outs": SYSTEM_DLKM_COMMON_OUTS,
+ "outs_mapping": {item: item for item in SYSTEM_DLKM_COMMON_OUTS},
},
{
"target_suffix": "toolchain_version",
- "outs": [
- TOOLCHAIN_VERSION_FILENAME,
- ],
+ "mandatory": True,
+ "outs_mapping": {
+ TOOLCHAIN_VERSION_FILENAME: TOOLCHAIN_VERSION_FILENAME,
+ },
},
{
"target_suffix": "boot_img_archive",
- # We only download GKI for arm64, not riscv64 or x86_64
- # TODO(b/206079661): Allow downloaded prebuilts for risc64/x86_64/debug targets.
- "outs": [
- "boot-img.tar.gz",
+ "mandatory": True,
+ "outs_mapping": {
+ "boot-img.tar.gz": "boot-img.tar.gz",
# The others can be found by extracting the archive, see gki_artifacts_prebuilts
- ],
+ },
},
{
"target_suffix": "boot_img_archive_signed",
@@ -88,8 +93,6 @@ CI_TARGET_MAPPING = {
# exist for unsigned builds. A build error will be emitted by gki_artifacts_prebuilts
# if --use_signed_prebuilts and --use_gki_prebuilts=<an unsigned build number>.
"mandatory": False,
- # We only download GKI for arm64, not riscv64 or x86_64
- # TODO(b/206079661): Allow downloaded prebuilts for risc64/x86_64/debug targets.
"outs_mapping": {
# The basename is kept boot-img.tar.gz so it works with
# gki_artifacts_prebuilts. It is placed under the signed/
@@ -101,17 +104,18 @@ CI_TARGET_MAPPING = {
},
{
"target_suffix": "ddk_artifacts",
- "outs": [
- "kernel_aarch64" + FILEGROUP_DEF_ARCHIVE_SUFFIX,
- ],
+ "mandatory": True,
+ "outs_mapping": {
+ "kernel_aarch64" + FILEGROUP_DEF_ARCHIVE_SUFFIX: "kernel_aarch64" + FILEGROUP_DEF_ARCHIVE_SUFFIX,
+ },
},
{
"target_suffix": "kmi_symbol_list",
"mandatory": False,
- "outs": [
- "abi_symbollist",
- "abi_symbollist.report",
- ],
+ "outs_mapping": {
+ "abi_symbollist": "abi_symbollist",
+ "abi_symbollist.report": "abi_symbollist.report",
+ },
},
],
},