2021-12-09 00:47:45 +00:00
|
|
|
"Macros for loading dependencies and registering toolchains"
|
|
|
|
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
2022-06-10 19:51:13 +00:00
|
|
|
|
|
|
|
# Note: we don't use "maybe" because renovate doesn't understand the syntax, see
|
|
|
|
# https://github.com/renovatebot/renovate/pull/16003/
|
2022-04-23 19:06:40 +00:00
|
|
|
load("//lib/private:jq_toolchain.bzl", "JQ_PLATFORMS", "jq_host_alias_repo", "jq_platform_repo", "jq_toolchains_repo", _DEFAULT_JQ_VERSION = "DEFAULT_JQ_VERSION")
|
|
|
|
load("//lib/private:yq_toolchain.bzl", "YQ_PLATFORMS", "yq_host_alias_repo", "yq_platform_repo", "yq_toolchains_repo", _DEFAULT_YQ_VERSION = "DEFAULT_YQ_VERSION")
|
2021-12-09 00:47:45 +00:00
|
|
|
|
|
|
|
def aspect_bazel_lib_dependencies():
|
|
|
|
"Load dependencies required by aspect rules"
|
2022-06-10 19:51:13 +00:00
|
|
|
if not native.existing_rule("bazel_skylib"):
|
|
|
|
http_archive(
|
|
|
|
name = "bazel_skylib",
|
|
|
|
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
|
|
|
|
urls = [
|
|
|
|
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
|
|
|
|
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
|
|
|
|
],
|
|
|
|
)
|
2021-12-09 00:47:45 +00:00
|
|
|
|
2022-04-23 19:06:40 +00:00
|
|
|
# Re-export the default versions
|
|
|
|
DEFAULT_JQ_VERSION = _DEFAULT_JQ_VERSION
|
|
|
|
DEFAULT_YQ_VERSION = _DEFAULT_YQ_VERSION
|
|
|
|
|
2022-04-27 04:07:17 +00:00
|
|
|
def register_jq_toolchains(name = "jq", version = DEFAULT_JQ_VERSION, register = True):
|
2021-12-09 00:47:45 +00:00
|
|
|
"""Registers jq toolchain and repositories
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: override the prefix for the generated toolchain repositories
|
2022-04-23 19:06:40 +00:00
|
|
|
version: the version of jq to execute (see https://github.com/stedolan/jq/releases)
|
2022-04-27 04:07:17 +00:00
|
|
|
register: whether to call through to native.register_toolchains.
|
|
|
|
Should be True for WORKSPACE users, but false when used under bzlmod extension
|
2021-12-09 00:47:45 +00:00
|
|
|
"""
|
2022-04-22 00:45:33 +00:00
|
|
|
for [platform, meta] in JQ_PLATFORMS.items():
|
2021-12-09 00:47:45 +00:00
|
|
|
jq_platform_repo(
|
2022-04-22 01:35:10 +00:00
|
|
|
name = "%s_%s" % (name, platform),
|
2021-12-09 00:47:45 +00:00
|
|
|
platform = platform,
|
2022-04-22 00:45:33 +00:00
|
|
|
version = version,
|
2021-12-09 00:47:45 +00:00
|
|
|
)
|
2022-04-27 04:07:17 +00:00
|
|
|
if register:
|
|
|
|
native.register_toolchains("@%s_toolchains//:%s_toolchain" % (name, platform))
|
2021-12-09 00:47:45 +00:00
|
|
|
|
2022-04-27 15:08:28 +00:00
|
|
|
jq_host_alias_repo(name = name)
|
2022-04-22 01:35:10 +00:00
|
|
|
|
2021-12-09 00:47:45 +00:00
|
|
|
jq_toolchains_repo(
|
|
|
|
name = "%s_toolchains" % name,
|
2022-04-22 01:35:10 +00:00
|
|
|
user_repository_name = name,
|
2021-12-09 00:47:45 +00:00
|
|
|
)
|
2022-04-20 04:45:06 +00:00
|
|
|
|
2022-04-27 04:07:17 +00:00
|
|
|
def register_yq_toolchains(name = "yq", version = DEFAULT_YQ_VERSION, register = True):
|
2022-04-20 04:45:06 +00:00
|
|
|
"""Registers yq toolchain and repositories
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: override the prefix for the generated toolchain repositories
|
2022-04-23 19:06:40 +00:00
|
|
|
version: the version of yq to execute (see https://github.com/mikefarah/yq/releases)
|
2022-04-27 04:07:17 +00:00
|
|
|
register: whether to call through to native.register_toolchains.
|
|
|
|
Should be True for WORKSPACE users, but false when used under bzlmod extension
|
2022-04-20 04:45:06 +00:00
|
|
|
"""
|
2022-04-22 00:45:33 +00:00
|
|
|
for [platform, meta] in YQ_PLATFORMS.items():
|
2022-04-20 04:45:06 +00:00
|
|
|
yq_platform_repo(
|
2022-04-22 01:35:10 +00:00
|
|
|
name = "%s_%s" % (name, platform),
|
2022-04-20 04:45:06 +00:00
|
|
|
platform = platform,
|
2022-04-22 00:45:33 +00:00
|
|
|
version = version,
|
2022-04-20 04:45:06 +00:00
|
|
|
)
|
2022-04-27 04:07:17 +00:00
|
|
|
if register:
|
|
|
|
native.register_toolchains("@%s_toolchains//:%s_toolchain" % (name, platform))
|
2022-04-20 04:45:06 +00:00
|
|
|
|
2022-04-27 15:08:28 +00:00
|
|
|
yq_host_alias_repo(name = name)
|
2022-04-22 01:35:10 +00:00
|
|
|
|
2022-04-20 04:45:06 +00:00
|
|
|
yq_toolchains_repo(
|
|
|
|
name = "%s_toolchains" % name,
|
2022-04-22 01:35:10 +00:00
|
|
|
user_repository_name = name,
|
2022-04-20 04:45:06 +00:00
|
|
|
)
|