2022-04-28 21:18:06 +00:00
|
|
|
"A repository that exposes information about the host platform"
|
|
|
|
|
2022-09-16 18:51:48 +00:00
|
|
|
load("@bazel_skylib//lib:versions.bzl", "versions")
|
2022-04-28 21:18:06 +00:00
|
|
|
load(":repo_utils.bzl", "repo_utils")
|
|
|
|
|
2022-09-20 22:23:56 +00:00
|
|
|
def _host_repo_impl(rctx):
|
2022-04-28 21:18:06 +00:00
|
|
|
# Base BUILD file for this repository
|
2022-04-29 07:49:15 +00:00
|
|
|
rctx.file("BUILD.bazel", """# @generated by @aspect_bazel_lib//lib/private:host_repo.bzl
|
2023-02-17 18:12:41 +00:00
|
|
|
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
|
2022-04-28 21:18:06 +00:00
|
|
|
bzl_library(
|
|
|
|
name = "defs",
|
|
|
|
srcs = ["defs.bzl"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
""")
|
|
|
|
|
|
|
|
# defs.bzl file for this repository
|
2022-04-29 07:49:15 +00:00
|
|
|
rctx.file("defs.bzl", content = """# @generated by @aspect_bazel_lib//lib/private:host_repo.bzl
|
2022-04-28 21:18:06 +00:00
|
|
|
# Information about the host platform
|
|
|
|
host = struct(
|
2022-09-16 18:51:48 +00:00
|
|
|
bazel_version = "{bazel_version}",
|
2022-04-28 21:18:06 +00:00
|
|
|
is_darwin = {is_darwin},
|
|
|
|
is_linux = {is_linux},
|
|
|
|
is_windows = {is_windows},
|
|
|
|
os = "{os}",
|
|
|
|
platform = "{platform}",
|
|
|
|
)
|
|
|
|
""".format(
|
2022-09-16 18:51:48 +00:00
|
|
|
bazel_version = versions.get(),
|
2022-04-28 21:18:06 +00:00
|
|
|
is_darwin = repo_utils.is_darwin(rctx),
|
|
|
|
is_linux = repo_utils.is_linux(rctx),
|
|
|
|
is_windows = repo_utils.is_windows(rctx),
|
|
|
|
os = repo_utils.os(rctx),
|
|
|
|
platform = repo_utils.platform(rctx),
|
|
|
|
))
|
|
|
|
|
|
|
|
host_repo = repository_rule(
|
2022-09-20 22:23:56 +00:00
|
|
|
implementation = _host_repo_impl,
|
2022-10-26 22:05:27 +00:00
|
|
|
# always invalidate this repository since so that the bazel_version is
|
|
|
|
# always updated on every invocation of bazel
|
|
|
|
local = True,
|
2022-04-28 21:18:06 +00:00
|
|
|
doc = "Exposes information about the host platform",
|
|
|
|
)
|