diff options
author | Yifan Hong <elsk@google.com> | 2024-03-07 17:25:20 -0800 |
---|---|---|
committer | Yifan Hong <elsk@google.com> | 2024-03-15 20:45:21 +0000 |
commit | d80c1e1641f83373082c529739f9ff12aeabca79 (patch) | |
tree | 3b3f5a1bd3eb7bd983f4eb81a99c240f2da2b4d9 | |
parent | c3f8d7d9252dbdb5edd20ee29d6815770826d194 (diff) | |
download | build-d80c1e1641f83373082c529739f9ff12aeabca79.tar.gz |
kleaf: Mark _downloaded / _download_or_build targets deprecated.
Redirect users to use the single target under @gki_prebuilts.
This breaks the dependency of common_kernels on kernel_prebuilt_utils,
so there is one less thing to clean up.
These targets are also un-usable unless the @kleaf
module specifies the following in the Module.bazel
file:
use_repo(kernel_prebuilt_ext, "gki_prebuilts")
However, with bzlmod, the repository `gki_prebuilts` may
or may not be defined depending on whether
kernel_prebuilt_ext.declare_kernel_prebuilts are called or not.
Test: TH
Test: bazel build --use_prebuilt_gki=P71660124 //common:kernel_aarch64_download_or_build
without bzlmod
Bug: 291918087
Change-Id: I239cf5f2234f2c74b4a0b2b9146ecbc985272eee
-rw-r--r-- | kleaf/common_kernels.bzl | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/kleaf/common_kernels.bzl b/kleaf/common_kernels.bzl index 73a0e18..f40fe9c 100644 --- a/kleaf/common_kernels.bzl +++ b/kleaf/common_kernels.bzl @@ -25,7 +25,6 @@ load("//build/kernel/kleaf/artifact_tests:kernel_test.bzl", "initramfs_modules_o load( "//build/kernel/kleaf/impl:constants.bzl", "MODULE_OUTS_FILE_OUTPUT_GROUP", - "MODULE_OUTS_FILE_SUFFIX", "TOOLCHAIN_VERSION_FILENAME", ) load("//build/kernel/kleaf/impl:gki_artifacts.bzl", "gki_artifacts", "gki_artifacts_prebuilts") @@ -50,7 +49,6 @@ load( "kernel_build", "kernel_build_config", "kernel_compile_commands", - "kernel_filegroup", "kernel_images", "kernel_kythe", "kernel_modules_install", @@ -582,7 +580,7 @@ KLEAF_REDECLARE_KERNEL_DIR_UNDER_DYNAMIC_KLEAF_REPO_WORKSPACE_ROOT=1 flat = True, ) - _define_prebuilts(target_configs = target_configs, visibility = visibility) + _define_prebuilts(visibility = visibility) def _get_target_config( name, @@ -955,7 +953,8 @@ def _define_common_kernel( flat = True, ) -def _define_prebuilts(target_configs, **kwargs): +# TODO(b/291918087): Delete once users have migrated to @gki_prebuilts +def _define_prebuilts(**kwargs): # Legacy flag for backwards compatibility # TODO(https://github.com/bazelbuild/bazel/issues/13463): alias to bool_flag does not # work. Hence we use a composite flag here. @@ -989,55 +988,33 @@ def _define_prebuilts(target_configs, **kwargs): name = value["target"] main_target_outs = value["outs"] # outs of target named {name} gki_prebuilts_outs = value["gki_prebuilts_outs"] # outputs of _gki_prebuilts + deprecate_msg = "Use @{}//{} directly".format(repo_name, name) + not_available_msg = "This will no longer be available. File a bug if you rely on this target." native.filegroup( name = name + "_downloaded", srcs = ["@{}//{}".format(repo_name, filename) for filename in main_target_outs], tags = ["manual"], + deprecation = deprecate_msg, ) native.filegroup( name = name + "_module_outs_file", srcs = [":" + name], output_group = MODULE_OUTS_FILE_OUTPUT_GROUP, + deprecation = not_available_msg, ) # A kernel_filegroup that: # - If --use_prebuilt_gki_num is set, use downloaded prebuilt of kernel_aarch64 # - Otherwise build kernel_aarch64 from sources. - kernel_filegroup( + native.alias( name = name + "_download_or_build", - srcs = select({ - ":use_prebuilt_gki_set": [":" + name + "_downloaded"], - "//conditions:default": [name], - }), - deps = select({ - ":use_prebuilt_gki_set": [ - name + "_ddk_artifacts_downloaded", - name + "_unstripped_modules_archive_downloaded", - name + "_" + TOOLCHAIN_VERSION_FILENAME + "_downloaded", - ], - "//conditions:default": [ - name + "_ddk_artifacts", - name + "_" + TOOLCHAIN_VERSION_FILENAME, - # unstripped modules come from {name} in srcs, KernelUnstrippedModulesInfo - ], - }), - kernel_uapi_headers = name + "_uapi_headers_download_or_build", - collect_unstripped_modules = _COLLECT_UNSTRIPPED_MODULES, - images = name + "_images_download_or_build", - module_outs_file = select({ - ":use_prebuilt_gki_set": "@{}//{}{}".format(repo_name, name, MODULE_OUTS_FILE_SUFFIX), - "//conditions:default": ":" + name + "_module_outs_file", + actual = select({ + ":use_prebuilt_gki_set": "@{}//{}".format(repo_name, name), + "//conditions:default": name, }), - protected_modules_list = select({ - ":use_prebuilt_gki_set": "@{}//{}".format(repo_name, value["protected_modules"]), - "//conditions:default": target_configs[name].get("protected_modules_list"), - }), - gki_artifacts = name + "_gki_artifacts_download_or_build", - ddk_module_defconfig_fragments = [ - Label("//build/kernel/kleaf/impl/defconfig:signing_modules_disabled"), - ], + deprecation = deprecate_msg, **kwargs ) @@ -1048,6 +1025,7 @@ def _define_prebuilts(target_configs, **kwargs): "//conditions:default": [name + "_boot_img_archive_downloaded"], }), outs = gki_prebuilts_outs, + deprecation = deprecate_msg, ) native.filegroup( @@ -1056,6 +1034,7 @@ def _define_prebuilts(target_configs, **kwargs): ":use_prebuilt_gki_set": [name + "_gki_artifacts_downloaded"], "//conditions:default": [name + "_gki_artifacts"], }), + deprecation = deprecate_msg, **kwargs ) @@ -1070,6 +1049,7 @@ def _define_prebuilts(target_configs, **kwargs): name = name + "_" + target_suffix + "_downloaded", srcs = ["@{}//{}".format(repo_name, filename) for filename in suffixed_target_outs], tags = ["manual"], + deprecation = deprecate_msg, ) # A filegroup that: @@ -1081,6 +1061,7 @@ def _define_prebuilts(target_configs, **kwargs): ":use_prebuilt_gki_set": [":" + name + "_" + target_suffix + "_downloaded"], "//conditions:default": [name + "_" + target_suffix], }), + deprecation = deprecate_msg, **kwargs ) @@ -1094,11 +1075,13 @@ def _define_prebuilts(target_configs, **kwargs): native.filegroup( name = name + "_additional_artifacts_downloaded", srcs = [item + "_downloaded" for item in additional_artifacts_items], + deprecation = not_available_msg, ) native.filegroup( name = name + "_additional_artifacts_download_or_build", srcs = [item + "_download_or_build" for item in additional_artifacts_items], + deprecation = not_available_msg, ) def _define_common_kernels_additional_tests( |