Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • bazel/toolchain_utils
1 result
Show changes
Commits on Source (10)
7.2.0
7.4.0
# [1.0.0-beta.18](https://git.gitlab.arm.com/bazel/toolchain_utils/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2024-11-20)
### Bug Fixes
- bump to `7.1.0+` due to `rctx.getenv` ([3228e10](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/3228e1007aa69e9e6d41dc8cea0f57e3246b2501))
- **toolchain_local_select:** use `label_keyed_string_dict` for `map` attribute ([1d48d2e](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/1d48d2e43ff1cbe1d2746aa7c7b7b86363fad2a0))
### BREAKING CHANGES
- **toolchain_local_select:** `toolchain_local_select#map` is now flipped taking the labels as they keys rather than as the values.
Previous releases had the following setup:
```py
download_file(
name = "abc-arm64-linux-gnu",
output = "abc",
)
download_file(
name = "abc-arm64-linux-musl",
output = "abc",
)
toolchain_local_select(
name = "abc",
map = {
"arm64-linux-gnu": "@abc-arm64-linux-gnu",
"arm64-linux-musl": "@abc-arm64-linux-musl",
},
)
```
This prevented eagarly overfetching all the repositories that would be
selected. As of Bazel 7.4.0+[1], it no longer overfetches so the `map`
attribute has been switched to a `label_keyed_string_dict`:
```py
toolchain_local_select(
name = "abc",
map = {
"@abc-arm64-linux-gnu": "arm64-linux-gnu",
"@abc-arm64-linux-musl": "arm64-linux-musl",
},
)
```
The repository rule will _only_ fetch the repostory label that has been selected due
to the triplet value matching.
Whilst this is a breaking change, it will introduce a regression on Bazel 7.3 and below
which will overfetch the repositories. It is _highly_ recommended to use Bazel 7.4 and above.
[1]: https://github.com/bazelbuild/bazel/commit/6fabb1fc6869a204373e5ee0adde696a659415dd
# [1.0.0-beta.17](https://git.gitlab.arm.com/bazel/toolchain_utils/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2024-10-28)
### Bug Fixes
......
# Contributing
# Getting Started
[Install][bazelisk-install] `bazelisk` and run the tests:
```sh
$ bazelisk test //...
$ (cd e2e; bazelisk test //...)
```
[bazelisk-install]: https://github.com/bazelbuild/bazelisk?tab=readme-ov-file#installation
# Workflow
- Follow the [contributions guide] to be granted forking permissions.
- [Fork] the project
- Implement the change
- [Create merge request] from fork
# Release
`semantic-release` performs automatic releases of the project.
Release channels for `alpha`, `beta` and `stable` releases are used.
The [upstream configuration usage guide][semrel-release-channels-usage] provides information on how to perform a
release.
[semrel-release-channels-usage]: https://gitlab.arm.com/semantic-release/config-release-channels/-/blob/main/README.md?ref_type=heads#usage
[contributions guide]: https://gitlab.arm.com/documentation/contributions#contributions
[Fork]: https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html#create-a-fork
[Create merge request]: https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html#merge-changes-back-upstream
module(
name = "toolchain_utils",
version = "1.0.0-beta.17",
version = "1.0.0-beta.18",
bazel_compatibility = [
">=7.0.0",
">=7.1.0",
],
compatibility_level = 1,
)
......
......@@ -36,8 +36,8 @@
"https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5",
"https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430",
"https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74",
"https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe",
"https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362",
"https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1",
"https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35",
"https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0",
......@@ -58,27 +58,27 @@
"https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459",
"https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0",
"https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27",
"https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72",
"https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c"
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79",
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d"
},
"selectedYankedVersions": {},
"moduleExtensions": {
"@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=",
"usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=",
"usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"local_config_apple_cc": {
"local_config_apple_cc_toolchains": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
"ruleClassName": "_apple_cc_autoconf",
"ruleClassName": "_apple_cc_autoconf_toolchains",
"attributes": {}
},
"local_config_apple_cc_toolchains": {
"local_config_apple_cc": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
"ruleClassName": "_apple_cc_autoconf_toolchains",
"ruleClassName": "_apple_cc_autoconf",
"attributes": {}
}
},
......@@ -94,7 +94,7 @@
"@@platforms//host:extension.bzl%host_platform": {
"general": {
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
"usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=",
"usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
......
7.2.0
7.4.0
......@@ -57,18 +57,23 @@ fixture(
name = "fixture-amd64-macos-darwin",
)
fixture(
name = "fixture-never",
)
select = use_repo_rule("@toolchain_utils//toolchain/local/select:defs.bzl", "toolchain_local_select")
select(
name = "fixture",
map = {
"amd64-linux-gnu": "@fixture-amd64-linux-gnu",
"arm64-linux-gnu": "@fixture-arm64-linux-gnu",
"arm-linux-musl": "@fixture-arm-linux-musl",
"windows-ucrt": "@fixture-windows-ucrt",
"windows-cygwin": "@fixture-windows-cygwin",
"arm64-macos-darwin": "@fixture-arm64-macos-darwin",
"amd64-macos-darwin": "@fixture-amd64-macos-darwin",
"@fixture-amd64-linux-gnu": "amd64-linux-gnu",
"@fixture-arm64-linux-gnu": "arm64-linux-gnu",
"@fixture-arm-linux-musl": "arm-linux-musl",
"@fixture-windows-ucrt": "windows-ucrt",
"@fixture-windows-cygwin": "windows-cygwin",
"@fixture-arm64-macos-darwin": "arm64-macos-darwin",
"@fixture-amd64-macos-darwin": "amd64-macos-darwin",
"@fixture-never": "never",
},
)
......
......@@ -36,8 +36,8 @@
"https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5",
"https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430",
"https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74",
"https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe",
"https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362",
"https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1",
"https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7",
"https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35",
"https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0",
......@@ -58,27 +58,27 @@
"https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459",
"https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0",
"https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27",
"https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72",
"https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c"
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79",
"https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d"
},
"selectedYankedVersions": {},
"moduleExtensions": {
"@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=",
"usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=",
"usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
"generatedRepoSpecs": {
"local_config_apple_cc": {
"local_config_apple_cc_toolchains": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
"ruleClassName": "_apple_cc_autoconf",
"ruleClassName": "_apple_cc_autoconf_toolchains",
"attributes": {}
},
"local_config_apple_cc_toolchains": {
"local_config_apple_cc": {
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
"ruleClassName": "_apple_cc_autoconf_toolchains",
"ruleClassName": "_apple_cc_autoconf",
"attributes": {}
}
},
......@@ -94,7 +94,7 @@
"@@platforms//host:extension.bzl%host_platform": {
"general": {
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
"usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=",
"usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=",
"recordedFileInputs": {},
"recordedDirentsInputs": {},
"envVariables": {},
......
......@@ -15,6 +15,10 @@ ATTRS = {
}
def implementation(rctx):
version = tuple([int(v) for v in native.bazel_version.split(".")[:2]])
if rctx.name.endswith("never") and version >= (7, 4):
fail("The `{}` repository should not be fetched. This is a case where Bazel is over-fetching.")
map = {l: "{}/{}".format(l.package, l.name) for l in rctx.attr.srcs}
for label, path in map.items():
......
load("//toolchain/repository:root.bzl", "root")
load("//toolchain:separator.bzl", "SEPARATOR")
load(":resolve.bzl", resolve = "key")
load(":resolve.bzl", resolve = "value")
visibility("//toolchain/...")
DOC = "Selects and symlinks a repository based on the local machine triplet."
ATTRS = {
"map": attr.string_dict(
doc = """Local triplet to repository mappings:
"map": attr.label_keyed_string_dict(
doc = """A map of repository labels against the host triplet:
```
toolchian_local_select(
```py
toolchain_local_select(
name = "abc",
map = {
"arm64-linux-gnu": "@abc-arm64-linux-gnu",
"arm64-linux-musl": "@abc-arm64-linux-musl",
"@abc-arm64-linux-gnu": "arm64-linux-gnu",
"@abc-arm64-linux-musl": "arm64-linux-musl",
},
)
```
""",
mandatory = True,
allow_empty = False,
......@@ -33,16 +33,11 @@ toolchian_local_select(
),
}
def canonical(rctx, label):
prefix = SEPARATOR.join(rctx.name.split(SEPARATOR)[:-1])
return Label("@@{}{}{}".format(prefix, SEPARATOR, label.removeprefix("@")))
def implementation(rctx):
label = resolve(rctx.attr.map, no_match_error = rctx.attr.no_match_error)
canon = canonical(rctx, label)
path = root(rctx, canon)
path = root(rctx, label)
if not path:
fail("Missing `{}` for `{}`".format(canon, rctx.name))
fail("Missing `{}` for `{}`".format(label, rctx.name))
rctx.delete(".")
rctx.symlink(path, ".")
......
......@@ -97,10 +97,12 @@ def implementation(ctx):
runfiles = runfiles,
)
path = rule(
toolchain_symlink_path = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
provides = [DefaultInfo],
executable = True,
)
path = toolchain_symlink_path
......@@ -61,9 +61,11 @@ def implementation(ctx):
runfiles = runfiles,
)
target = rule(
toolchain_symlink_target = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
executable = True,
)
target = toolchain_symlink_target
visibility("//toolchain/...")
DOC = """Performs a simple test that a toolchain resolved to an executable.
- Resolves the provided toolchain binary
- Executes with the provided arguments
- Captures `stdout` and `stderr`
- Can do optional `diff` checking of the output
A common use case is to check that a toolchain can output some help text:
```
toolchain_test(
name = "test",
args = ["--help"],
toolchains = [":resolved"],
)
```
"""
ATTRS = {
"stdout": attr.label(
doc = """The expected standard output.
......@@ -73,23 +91,7 @@ def implementation(ctx):
)
toolchain_test = rule(
doc = """Performs a simple test that a toolchain resolved to an executable.
- Resolves the provided toolchain binary
- Executes with the provided arguments
- Captures `stdout` and `stderr`
- Can do optional `diff` checking of the output
A common use case is to check that a toolchain can output some help text:
```
toolchain_test(
name = "test",
args = ["--help"],
toolchains = [":resolved"],
)
```
""",
doc = DOC,
attrs = ATTRS,
implementation = implementation,
test = True,
......
......@@ -2,6 +2,17 @@ load(":TripletInfo.bzl", "TripletInfo")
visibility("//toolchain/...")
DOC = """Provides a machine triplet.
A simple rule that provides a `ToolchainTripletInfo` provider.
The resulting provider can be used in other rules to understand triplet values.
Running the target with `bazel run` will result in the triplet being printed.
The triplet runnable output is particularly useful for the resolved host triplet at `@toolchain_utils//toolchain/triplet:host`
"""
ATTRS = {
"value": attr.string(
doc = "A triplet value that overrides `name`.",
......@@ -44,17 +55,8 @@ def implementation(ctx):
return [triplet, default]
triplet = rule(
doc = """Provides a machine triplet.
A simple rule that provides a `ToolchainTripletInfo` provider.
The resulting provider can be used in other rules to understand triplet values.
Running the target with `bazel run` will result in the triplet being printed.
The triplet runnable output is particularly useful for the resolved host triplet at `@toolchain_utils//toolchain/triplet:host`
""",
toolchain_triplet = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
provides = [
......@@ -63,3 +65,5 @@ The triplet runnable output is particularly useful for the resolved host triplet
],
executable = True,
)
triplet = toolchain_triplet