summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-03-06 15:15:18 -0800
committerYifan Hong <elsk@google.com>2024-03-07 19:34:35 +0000
commit581012a5e44d116defcaf436ca5edbac02753637 (patch)
treea82f89b9fdfca29439d9dbcad45251cf09b3de5e
parent501c8547778fe0f6e3cfe884d77c78938f0dd9db (diff)
downloadbuild-581012a5e44d116defcaf436ca5edbac02753637.tar.gz
kleaf: Skip declare_host_tools() if using defaults.
If using the default list of host tools, simply skip the declare_host_tools() call. This simplifies the Kleaf's MODULE.bazel, or the root MODULE.bazel when using Kleaf as the root module. Test: TH Bug: 328465178 Change-Id: I8225bdabc378e459f70d10a768aea0d15cb4160b
-rw-r--r--kleaf/bzlmod/bazel.MODULE.bazel1
-rw-r--r--kleaf/impl/declare_host_tools.bzl32
2 files changed, 20 insertions, 13 deletions
diff --git a/kleaf/bzlmod/bazel.MODULE.bazel b/kleaf/bzlmod/bazel.MODULE.bazel
index 7f65f1c..8ea802b 100644
--- a/kleaf/bzlmod/bazel.MODULE.bazel
+++ b/kleaf/bzlmod/bazel.MODULE.bazel
@@ -56,7 +56,6 @@ new_kleaf_local_repository(
kernel_toolchain_ext = use_extension("//build/kernel/kleaf:kernel_toolchain_ext.bzl", "kernel_toolchain_ext")
kernel_toolchain_ext.declare_toolchain_constants(toolchain_constants = "//common:build.config.constants")
-kernel_toolchain_ext.declare_host_tools()
use_repo(kernel_toolchain_ext, "kernel_toolchain_info")
use_repo(kernel_toolchain_ext, "kleaf_clang_toolchain")
use_repo(kernel_toolchain_ext, "kleaf_host_tools")
diff --git a/kleaf/impl/declare_host_tools.bzl b/kleaf/impl/declare_host_tools.bzl
index 649c593..a4b207f 100644
--- a/kleaf/impl/declare_host_tools.bzl
+++ b/kleaf/impl/declare_host_tools.bzl
@@ -19,6 +19,18 @@ visibility([
"//", # for root MODULE.bazel
])
+# Superset of all tools we need from host.
+# For the subset of host tools we typically use for a kernel build,
+# see //build/kernel:hermetic-tools.
+_DEFAULT_HOST_TOOLS = [
+ "bash",
+ "perl",
+ "rsync",
+ "sh",
+ # For BTRFS (b/292212788)
+ "find",
+]
+
def _kleaf_host_tools_repo_impl(repository_ctx):
repository_ctx.file("WORKSPACE", """\
workspace(name = "{}")
@@ -52,6 +64,9 @@ def _declare_repos(module_ctx, tag_name):
for declared in getattr(module.tags, tag_name):
host_tools += declared.host_tools
+ if not host_tools:
+ host_tools = _DEFAULT_HOST_TOOLS
+
kleaf_host_tools_repo(
name = "kleaf_host_tools",
host_tools = host_tools,
@@ -61,18 +76,11 @@ _tag_class = tag_class(
doc = "Declares a list of host tools to be symlinked in the extension `kleaf_host_tools.",
attrs = {
"host_tools": attr.string_list(
- doc = "List of host tools",
- # Superset of all tools we need from host.
- # For the subset of host tools we typically use for a kernel build,
- # see //build/kernel:hermetic-tools.
- default = [
- "bash",
- "perl",
- "rsync",
- "sh",
- # For BTRFS (b/292212788)
- "find",
- ],
+ doc = """List of host tools.
+
+ If `declare_host_tools` is not called anywhere, or only called
+ with empty `host_tools`, the default is `{}`.
+ """.format(repr(_DEFAULT_HOST_TOOLS)),
),
},
)