2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-30 01:41:21 +00:00
bazel-lib/lib/private/host_repo.bzl
Alex Eagle 1df2becc7a chore: turn on more basic precommit checks
In particular this makes our bazelrc presets more compliant with client codebases, ensuring they can copy these files and not trip on their own pre-commit check
2023-02-17 11:00:00 -08:00

44 lines
1.4 KiB
Python

"A repository that exposes information about the host platform"
load("@bazel_skylib//lib:versions.bzl", "versions")
load(":repo_utils.bzl", "repo_utils")
def _host_repo_impl(rctx):
# Base BUILD file for this repository
rctx.file("BUILD.bazel", """# @generated by @aspect_bazel_lib//lib/private:host_repo.bzl
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "defs",
srcs = ["defs.bzl"],
visibility = ["//visibility:public"],
)
""")
# defs.bzl file for this repository
rctx.file("defs.bzl", content = """# @generated by @aspect_bazel_lib//lib/private:host_repo.bzl
# Information about the host platform
host = struct(
bazel_version = "{bazel_version}",
is_darwin = {is_darwin},
is_linux = {is_linux},
is_windows = {is_windows},
os = "{os}",
platform = "{platform}",
)
""".format(
bazel_version = versions.get(),
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(
implementation = _host_repo_impl,
# always invalidate this repository since so that the bazel_version is
# always updated on every invocation of bazel
local = True,
doc = "Exposes information about the host platform",
)