Skip to content
Commits on Source (7)
# [1.0.0-alpha.2](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2023-11-16)
### Bug Fixes
- **resolved:** forward on `basename` attribute ([e71e807](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/e71e807b6ded13a3baf2d430900f675a1f8849fd))
- **test:** correctly output `stderr` from toolchain executable on error ([22cd108](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/22cd108126e8917d7142d7f447fdc61f69ea2521))
### Features
- **local_which:** make local binaries non-mandatory ([5d9a292](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/5d9a292cfd4a7f9dd5b952ca33c34b01da0fc796))
# 1.0.0-alpha.1 (2023-11-15)
### Bug Fixes
......
module(
name = "rules_toolchain",
version = "1.0.0-alpha.1",
version = "1.0.0-alpha.2",
bazel_compatibility = [
">=6.4.0",
],
......
......@@ -777,7 +777,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "da/DoHSQBm39DhgiqteTa0XULbwxsr8VGJ6XQ/cPUmw=",
"bzlTransitiveDigest": "/xroDvlQ7p867k7lShdRN/8y8PAICvIR2NWA0F7JzLg=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......
......@@ -9,7 +9,7 @@
"@semantic-release/bzlmod": "https://gitlab.arm.com/semantic-release/bzlmod/-/releases/v1.0.3/downloads/package.tar.gz",
"@semantic-release/changelog": "^6",
"@semantic-release/commit-analyzer": "^11",
"@semantic-release/config-gitlab-bzlmod": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.0.5/downloads/package.tar.gz",
"@semantic-release/config-gitlab-bzlmod": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.0.6/downloads/package.tar.gz",
"@semantic-release/config-release-channels": "https://gitlab.arm.com/semantic-release/config-release-channels/-/releases/v1.0.1/downloads/package.tar.gz",
"@semantic-release/error": "^4",
"@semantic-release/exec": "^6",
......@@ -366,9 +366,9 @@
}
},
"node_modules/@semantic-release/config-gitlab-bzlmod": {
"version": "1.0.5",
"resolved": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.0.5/downloads/package.tar.gz",
"integrity": "sha512-crGLBTi9zN0X6Y1ZY9eaaNB3tNGrlx53NMseaGUMIbidlqWJm0rtNI7fRWW6aaI04//iNNpbrp3lyb1zI+34kQ==",
"version": "1.0.6",
"resolved": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.0.6/downloads/package.tar.gz",
"integrity": "sha512-y/LRDh7DxjUYCs54OYQ7nREM+v63PhAak9KnOPGSE57nI+sEPAWnMlSnt+zrmXKEhTU+I12EAsmqs6rjNg/6zQ==",
"dev": true,
"license": "MIT",
"peerDependencies": {
......
......@@ -12,5 +12,6 @@ toolchain_symlink_path(
resolved(
name = "resolved",
toolchain = "{{toolchain_type}}",
basename = "{{basename}}",
toolchain_type = "{{toolchain_type}}",
)
load("//toolchain:resolved.bzl", _ATTRS = "ATTRS")
visibility("//toolchain/...")
DOC = """Creates a repository that provides a binary target wrapping a local binary found on `PATH`.
......@@ -17,7 +19,7 @@ toolchain(
```
"""
ATTRS = {
ATTRS = _ATTRS | {
"program": attr.string(
doc = "The name of the binary to find on `PATH`.",
),
......@@ -27,9 +29,9 @@ ATTRS = {
"variable": attr.string(
doc = "The variable name for Make or the execution environment.",
),
"toolchain_type": attr.label(
doc = "The toolchain type for the binary.",
mandatory = True,
"mandatory": attr.bool(
doc = "Determines if the tool must exist locally",
default = False,
),
"resolved": attr.label(
doc = "The tepmlate that is expanded into the `resolved.bzl`.",
......@@ -41,6 +43,13 @@ ATTRS = {
default = ":BUILD.tmpl.bazel",
allow_single_file = True,
),
"stub": attr.label(
doc = "An executable to use when the local binary is not found on `PATH`.",
default = ":stub.sh",
allow_single_file = True,
executable = True,
cfg = "exec",
),
}
def implementation(rctx):
......@@ -48,10 +57,13 @@ def implementation(rctx):
path = rctx.which(program)
if not path:
fail("Cannot find `{}` on `PATH`".format(program))
if rctx.attr.mandatory:
fail("Cannot find `{}` on `PATH`".format(program))
path = rctx.path(rctx.attr.stub)
rctx.template("resolved.bzl", rctx.attr.resolved, {
"{{toolchain_type}}": str(rctx.attr.toolchain_type),
"{{basename}}": str(rctx.attr.basename),
}, executable = False)
rctx.template("BUILD.bazel", rctx.attr.build, {
......
......@@ -17,7 +17,7 @@ ATTRS = {
"basename": attr.string(
doc = "The basename for the symlink, which defaults to `name`",
),
"toolchain": attr.label(
"toolchain_type": attr.label(
doc = "The toolchain type to resolve and forward on providers.",
mandatory = True,
),
......@@ -25,7 +25,7 @@ ATTRS = {
def implementation(ctx):
basename = ctx.attr.basename or ctx.label.name
toolchain = ctx.toolchains[ctx.attr.toolchain.label]
toolchain = ctx.toolchains[ctx.attr.toolchain_type.label]
executable = ctx.actions.declare_file(basename)
ctx.actions.symlink(
......@@ -82,7 +82,7 @@ def macro(*, toolchain_type):
resolved(
name = "resolved",
toolchain = ":type",
toolchain_type = ":type",
)
```
......
......@@ -2,6 +2,7 @@ load("//:resolved.bzl", "resolved")
resolved(
name = "resolved",
toolchain = "{{toolchain_type}}",
basename = "{{basename}}",
toolchain_type = "{{toolchain_type}}",
visibility = ["//visibility:public"],
)
load("//toolchain:resolved.bzl", _ATTRS = "ATTRS")
visibility("//toolchain/...")
DOC = """Creates a repository that provides a toolchain resolution rule.
......@@ -14,11 +16,7 @@ toolchain_resolved(
[quirk]: https://github.com/bazelbuild/bazel/issues/14009
"""
ATTRS = {
"toolchain_type": attr.label(
doc = "The toolchain type to resolve.",
mandatory = True,
),
ATTRS = _ATTRS | {
"resolved": attr.label(
doc = "The template that is expanded into the `resolved.bzl`.",
default = Label(":resolved.tmpl.bzl"),
......@@ -34,6 +32,7 @@ ATTRS = {
def implementation(rctx):
substitutions = {
"{{toolchain_type}}": str(rctx.attr.toolchain_type),
"{{basename}}": str(rctx.attr.basename),
}
rctx.template("resolved.bzl", rctx.attr.resolved, substitutions, executable = False)
rctx.template("BUILD.bazel", rctx.attr.build, substitutions, executable = False)
......
......@@ -24,7 +24,7 @@ if ! "${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt; then
echo >&2 "stderr:"
while IFS= read -r LINE; do
echo >&2 "${LINE}"
done <stdout.txt
done <stderr.txt
exit 2
fi
......