Skip to content
Commits on Source (36)
last_rc
# TODO: relax this once we have `use_rule_repo`
7.0.0rc7
\ No newline at end of file
registry=https://gitlab.arm.com/api/v4/groups/semantic-release/-/packages/npm/
......@@ -15,6 +15,7 @@ Copyright: 2023 Arm Ltd.
License: MIT
Files:
.npmrc
icon.svg
package.json
package-lock.json
......
# [1.0.0-alpha.7](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2023-12-08)
### Bug Fixes
- be graceful when `uname` is not found ([6f4242c](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/6f4242c19284b424ffd4079c0a02ed6a2bdef103))
- correct `{{basename}}` in `which` ([892c623](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/892c6233cce27d1ff2a6b950d3ddca1e34b807ff))
- fail fast when not three Linux version parts ([e298c3e](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/e298c3e5e0674809bd62def624aaf0104089468e))
- need to foward on `.cmd` not `.com` ([49d7c9f](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/49d7c9fd03763b135cf2e19db16ddfe30e00c8a5))
- pin Bazel version ([585e5f4](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/585e5f4168736c050687be6e59c359ab3a50f8ae))
- **resolved:** propagate `.bat`/`.com` extensions ([b0a4176](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/b0a4176194fcf379e4ab4a8ac9f213f34bc9771c))
- **select:** add `map` to the error string ([727be3b](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/727be3b7570aebda46b78560cd98cbaa74368b99))
- **symlink_target:** propagate `.bat`/`.com` extensions ([78a6265](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/78a62657e5dc911a75418afb28243e0d29f3db93))
- **symlink_target:** use `ctx.executable` ([fdf8d73](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/fdf8d732de0a1137172d0cbd311277834760dbe8))
- **test:** simplify POSIX variable substitution ([82a4eca](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/82a4ecaa71dbd06c98f24ef5fb4dc40ad58a40a6))
### Features
- add `//toolchain/constraint/libc:ucrt` ([4deb57e](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/4deb57e881ad3fd4e43b49bc5a6724ad0db68ffd))
- add `//toolchain/constraint/os:windows` ([064ecaf](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/064ecafcc9b0a1ed3afc3c62c459f0b541438b27))
- add a plain string value to local triplet repository ([e41e05f](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/e41e05ffec1208b535ccfdcb4d70bc5d4c9311af))
- add launcher ([96823ab](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/96823abd1096cb17d81b554072916450f6944fa7))
- add simple Windows OS detection ([a090eab](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/a090eabe2dae4e52eb611c610c617437a31a46f0))
- add Universal C runtime detection ([cd8b097](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/cd8b097bd731403b3502214fffefb15089a975be))
- add Windows version detection ([b2d0c53](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/b2d0c53752ca2488a7ae9c70697591098bdb06b3))
- **local/which:** support Windows ([1398d38](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/1398d3869c59f6500def3894c4065ef2d9a0d9a1))
- **select:** add more selection options ([22e5104](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/22e5104a50b8fcfdffed77a2c8af82bdb79c512f))
- **test:** add Batch script for Windows ([ea1a75d](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/ea1a75db5b906e31646d0e41adad7b8ad8a63381))
- **toolchain_triplet:** add Windows support ([32e2220](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/32e2220df6254455713d331f9cbd4509fb9d9bc8))
# [1.0.0-alpha.6](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2023-11-30)
### Bug Fixes
......
module(
name = "rules_toolchain",
version = "1.0.0-alpha.6",
version = "1.0.0-alpha.7",
bazel_compatibility = [
">=6.4.0",
],
compatibility_level = 1,
)
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "platforms", version = "0.0.7")
triplet = use_repo_rule("//toolchain/local/triplet:repository.bzl", "triplet")
triplet = use_repo_rule("//toolchain/local/triplet:defs.bzl", "toolchain_local_triplet")
triplet(
name = "local",
)
launcher = use_repo_rule("//toolchain/launcher:repository.bzl", "launcher")
launcher(
name = "launcher",
)
{
"lockFileVersion": 3,
"moduleFileHash": "40376b7f2b286e2b47922cf35c49ab73256806d8f016a140a6e0ca8e3fe94475",
"moduleFileHash": "55a8f1e3f74b9d8c0339def09fee2ef9e3ba7d6867977992475a8ff11094305f",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build/"
......@@ -34,12 +34,13 @@
"column": 0
},
"imports": {
"local": "local"
"local": "local",
"launcher": "launcher"
},
"devImports": [],
"tags": [
{
"tagName": "//toolchain/local/triplet:repository.bzl%triplet",
"tagName": "//toolchain/local/triplet:defs.bzl%toolchain_local_triplet",
"attributeValues": {
"name": "local"
},
......@@ -49,6 +50,18 @@
"line": 14,
"column": 8
}
},
{
"tagName": "//toolchain/launcher:repository.bzl%launcher",
"attributeValues": {
"name": "launcher"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 20,
"column": 9
}
}
],
"hasDevUseExtension": false,
......@@ -656,7 +669,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "VGGV2/aS8KP0wlEaxXfdomUzHtZ4Ry+aV/L2Ktp3UCo=",
"bzlTransitiveDigest": "CSJxsw5u8tv972NPHJazAfB/a3Rb8wU8pXWhqZJv+Wk=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -666,6 +679,13 @@
"attributes": {
"name": "_main~_repo_rules~local"
}
},
"launcher": {
"bzlFile": "@@//toolchain/launcher:repository.bzl",
"ruleClassName": "launcher",
"attributes": {
"name": "_main~_repo_rules~launcher"
}
}
}
}
......
......@@ -4,45 +4,20 @@
## Getting Started
### Local Tool
Add the following to `MODULE.bazel`:
```py
which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which")
which = use_repo_rule("@rules_toolchain//toolchain/local/which:defs.bzl", "toolchain_local_which")
which(
name = "echo",
toolchain_type = "//toolchain/echo:type",
)
```
The `echo` tool will be found on the `PATH`.
A repository with the `@echo//:echo` target will be created.
### Downloaded Tool
Use `rules_download` to provide a hermetic, pre-built binary in `MODULE.bazel`
```py
archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive")
archive(
name = "coreutils-arm64-linux-gnu",
srcs = ["coreutils"],
integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=",
strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"],
)
```
A repository with the `@coreutils-arm64-linux-gnu//:coreutils` target will be created.
### Toolchains
Create a `toolchain/echo/BUILD.bazel` with the following:
```py
load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test")
load("@rules_toolchain//toolchain/test:defs.bzl", "toolchain_test")
# The `toolchain/echo:type` for registration
toolchain_type(
......@@ -54,29 +29,55 @@ toolchain_type(
# No `exec_compatible_with` constraints are needed as a local binary is always compatible with the execution platform
toolchain(
name = "local",
toolchain = "@echo",
toolchain = "@echo//:echo",
toolchain_type = ":type",
)
# Create a toolchain binary from the downloaded `coreutils`
toolchain_symlink_target(
name = "coreutils-arm64-linux-gnu",
target = "@coreutils-arm64-linux-gnu//:coreutils",
# Run the resolved toolchain with:
# bazel run -- //toolchain/echo:resolved
alias(
name = "resolved",
actual = "@echo//:resolved",
)
# Create a symlink to the multi-call binary
# Performs a execution test of the binary
# Validates it works on the current platform
toolchain_test(
name = "test",
args = ["Hello, world!"],
stdout = ":hello-world.txt",
toolchains = [":resolved"],
)
```
To create a hermetic toolchain from a built target:
```py
load("@rules_toolchain//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
# Assumes that `:echo` points to a Bazel built `echo` binary
toolchain_symlink_target(
name = "echo-arm64-linux-gnu",
basename = "echo",
target = ":coreutils-arm64-linux-gnu",
name = "built",
target = ":echo"
)
# Register the hermetic toolchain
# Use constraints to signify what host machines the toolchain is compatible with
toolchain(
name = "hermetic",
toolchain = ":built",
toolchain_type = ":type",
)
```
To create a hermetic toolchain from a downloaded target:
```py
# Assume `:echo-arm64-linux-gnu` is a downloaded `echo` binary
toolchain(
name = "arm64-linux",
toolchain = ":echo-arm64-linux-gnu",
toolchain_type = ":type",
# Use constraints to signify what host machines the toolchain is compatible with
exec_compatible_with = [
"@rules_toolchain//toolchain/constraint/cpu:arm64",
"@rules_toolchain//toolchain/constraint/os:linux",
......@@ -84,23 +85,6 @@ toolchain(
# "@rules_toolchain//toolchain/constraint/libc:gnu",
],
)
# Provide a resolved toolchain target
alias(
name = "resolved",
actual = "@echo//:resolved",
)
```
### Run
The `resolved` target allows the toolchain that is compatible with the current machine to be executed:
```py
bazelisk run -- //toolchain/echo:resolved "Hello, world!"
```
If the machine is compatible with the downloaded toolchain constraints, that will be used. Otherwise, it will fallback
to finding the toolchain on the local `PATH`.
[resolved]: https://github.com/bazelbuild/bazel/issues/14009
last_rc
# TODO: relax this once we have `use_rule_repo`
7.0.0rc7
\ No newline at end of file
......@@ -12,14 +12,14 @@ local_path_override(
path = "..",
)
which = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_which")
which = use_repo_rule("@rules_toolchain//toolchain/local/which:defs.bzl", "toolchain_local_which")
which(
name = "echo",
toolchain_type = "//toolchain/echo:type",
)
resolved = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_resolved")
resolved = use_repo_rule("@rules_toolchain//toolchain/resolved:defs.bzl", "toolchain_resolved")
resolved(
name = "resolved",
......@@ -42,7 +42,15 @@ fixture(
name = "fixture-arm-linux-musl",
)
select = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_select")
fixture(
name = "fixture-windows-ucrt",
)
fixture(
name = "fixture-arm64-windows-ucrt",
)
select = use_repo_rule("@rules_toolchain//toolchain/local/select:defs.bzl", "toolchain_local_select")
select(
name = "fixture",
......@@ -50,6 +58,7 @@ select(
"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",
},
)
......
{
"lockFileVersion": 3,
"moduleFileHash": "7c7e76923d2e2442dc1fbaa7b1e37fda17ab54a2eefba7b32eab54747d049bc9",
"moduleFileHash": "33d7bab2dd31ed91bc652763be07b5096e6999fccdf0ed68bad1008aa7b9884c",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build/"
......@@ -13,7 +13,7 @@
"compatibilityMode": "ERROR"
},
"localOverrideHashes": {
"rules_toolchain": "40376b7f2b286e2b47922cf35c49ab73256806d8f016a140a6e0ca8e3fe94475",
"rules_toolchain": "55a8f1e3f74b9d8c0339def09fee2ef9e3ba7d6867977992475a8ff11094305f",
"bazel_tools": "922ea6752dc9105de5af957f7a99a6933c0a6a712d23df6aad16a9c399f7e787"
},
"moduleDepGraph": {
......@@ -42,12 +42,14 @@
"fixture-amd64-linux-gnu": "fixture-amd64-linux-gnu",
"fixture-arm64-linux-gnu": "fixture-arm64-linux-gnu",
"fixture-arm-linux-musl": "fixture-arm-linux-musl",
"fixture-windows-ucrt": "fixture-windows-ucrt",
"fixture-arm64-windows-ucrt": "fixture-arm64-windows-ucrt",
"fixture": "fixture"
},
"devImports": [],
"tags": [
{
"tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_local_which",
"tagName": "@rules_toolchain//toolchain/local/which:defs.bzl%toolchain_local_which",
"attributeValues": {
"toolchain_type": "//toolchain/echo:type",
"name": "echo"
......@@ -60,7 +62,7 @@
}
},
{
"tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_resolved",
"tagName": "@rules_toolchain//toolchain/resolved:defs.bzl%toolchain_resolved",
"attributeValues": {
"toolchain_type": "//toolchain/echo:type",
"name": "resolved"
......@@ -109,19 +111,44 @@
}
},
{
"tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_local_select",
"tagName": "//test/fixture:repository.bzl%fixture",
"attributeValues": {
"name": "fixture-windows-ucrt"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 45,
"column": 8
}
},
{
"tagName": "//test/fixture:repository.bzl%fixture",
"attributeValues": {
"name": "fixture-arm64-windows-ucrt"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 49,
"column": 8
}
},
{
"tagName": "@rules_toolchain//toolchain/local/select:defs.bzl%toolchain_local_select",
"attributeValues": {
"map": {
"amd64-linux-gnu": "@fixture-amd64-linux-gnu",
"arm64-linux-gnu": "@fixture-arm64-linux-gnu",
"arm-linux-musl": "@fixture-arm-linux-musl"
"arm-linux-musl": "@fixture-arm-linux-musl",
"windows-ucrt": "@fixture-windows-ucrt"
},
"name": "fixture"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 47,
"line": 55,
"column": 7
}
}
......@@ -135,7 +162,7 @@
"usingModule": "<root>",
"location": {
"file": "@@//:MODULE.bazel",
"line": 56,
"line": 65,
"column": 23
},
"imports": {
......@@ -152,7 +179,7 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 57,
"line": 66,
"column": 15
}
}
......@@ -217,12 +244,13 @@
"column": 0
},
"imports": {
"local": "local"
"local": "local",
"launcher": "launcher"
},
"devImports": [],
"tags": [
{
"tagName": "//toolchain/local/triplet:repository.bzl%triplet",
"tagName": "//toolchain/local/triplet:defs.bzl%toolchain_local_triplet",
"attributeValues": {
"name": "local"
},
......@@ -232,6 +260,18 @@
"line": 14,
"column": 8
}
},
{
"tagName": "//toolchain/launcher:repository.bzl%launcher",
"attributeValues": {
"name": "launcher"
},
"devDependency": false,
"location": {
"file": "@@rules_toolchain~override//:MODULE.bazel",
"line": 20,
"column": 9
}
}
],
"hasDevUseExtension": false,
......@@ -808,7 +848,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "/R69egUTLvkHkALvRLGxIJMgJWsQ0N6s2oGkMp4YL30=",
"bzlTransitiveDigest": "H6a/EFhNB57YKE/R9dWOnzyt7/yZUN4dwbh4eVfSEko=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -849,6 +889,20 @@
"name": "_main~_repo_rules~fixture-arm-linux-musl"
}
},
"fixture-windows-ucrt": {
"bzlFile": "@@//test/fixture:repository.bzl",
"ruleClassName": "fixture",
"attributes": {
"name": "_main~_repo_rules~fixture-windows-ucrt"
}
},
"fixture-arm64-windows-ucrt": {
"bzlFile": "@@//test/fixture:repository.bzl",
"ruleClassName": "fixture",
"attributes": {
"name": "_main~_repo_rules~fixture-arm64-windows-ucrt"
}
},
"fixture": {
"bzlFile": "@@rules_toolchain~override//toolchain/local/select:repository.bzl",
"ruleClassName": "select",
......@@ -856,7 +910,8 @@
"map": {
"amd64-linux-gnu": "@fixture-amd64-linux-gnu",
"arm64-linux-gnu": "@fixture-arm64-linux-gnu",
"arm-linux-musl": "@fixture-arm-linux-musl"
"arm-linux-musl": "@fixture-arm-linux-musl",
"windows-ucrt": "@fixture-windows-ucrt"
},
"name": "_main~_repo_rules~fixture"
}
......@@ -1468,7 +1523,7 @@
},
"@@rules_toolchain~override//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "VGGV2/aS8KP0wlEaxXfdomUzHtZ4Ry+aV/L2Ktp3UCo=",
"bzlTransitiveDigest": "CSJxsw5u8tv972NPHJazAfB/a3Rb8wU8pXWhqZJv+Wk=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -1478,13 +1533,20 @@
"attributes": {
"name": "rules_toolchain~override~_repo_rules~local"
}
},
"launcher": {
"bzlFile": "@@rules_toolchain~override//toolchain/launcher:repository.bzl",
"ruleClassName": "launcher",
"attributes": {
"name": "rules_toolchain~override~_repo_rules~launcher"
}
}
}
}
},
"@@rules_toolchain~override//toolchain/export:defs.bzl%toolchain_export": {
"general": {
"bzlTransitiveDigest": "GaX6IuOvOKsD8efBm9Fy5gFKF6piHEW7gvUENxCsD9M=",
"bzlTransitiveDigest": "BzNop8Xd2QfFtwy+F4thyq9O+CpaFjHeMWKDF15GMaM=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......
load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test")
load("@rules_toolchain//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
load("@rules_toolchain//toolchain/test:defs.bzl", "toolchain_test")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
toolchain_type(
......@@ -6,20 +7,24 @@ toolchain_type(
visibility = ["//visibility:public"],
)
toolchain_symlink_target(
name = "hermetic",
target = ":echo.sh",
)
toolchain(
name = "local",
toolchain = "@echo//:echo",
toolchain_type = ":type",
)
alias(
name = "echo",
actual = "hermetic",
toolchain_symlink_target(
name = "script",
target = select({
"@rules_toolchain//toolchain/constraint/os:windows": ":echo.bat",
"//conditions:default": ":echo.sh",
}),
)
toolchain(
name = "hermetic",
toolchain = ":script",
toolchain_type = ":type",
)
alias(
......
@echo.%*
\ No newline at end of file
This diff is collapsed.
......@@ -6,3 +6,8 @@ constraint_value(
name = "gnu",
constraint_setting = ":libc",
)
constraint_value(
name = "ucrt",
constraint_setting = ":libc",
)
load(":versions.bzl", "VERSIONS")
package(default_visibility = ["//visibility:public"])
constraint_setting(name = "ucrt")
[
constraint_value(
name = version,
constraint_setting = ":ucrt",
)
for version in VERSIONS
]
load("@local//:triplet.bzl", "TRIPLET")
visibility("//toolchain/...")
LOCAL = TRIPLET.libc.version and TRIPLET.libc.version.value
# TODO: figure out a way to generate Universal CRT versions
VERSIONS = tuple([LOCAL] if LOCAL != None else [])
package(default_visibility = ["//visibility:public"])
# TODO: add more OS aliases when we are ready to support them.
[
alias(
name = v,
actual = "@platforms//os:{}".format(v),
)
for v in (
"linux",
)
]
alias(
name = "linux",
actual = "@platforms//os:linux",
)
alias(
name = "windows",
actual = "@platforms//os:windows",
)
load(":versions.bzl", "VERSIONS")
package(default_visibility = ["//visibility:public"])
constraint_setting(name = "windows")
[
constraint_value(
name = version,
constraint_setting = ":windows",
)
for version in VERSIONS
]
load("@local//:triplet.bzl", "TRIPLET")
visibility("//toolchain/...")
LOCAL = TRIPLET.os.version and TRIPLET.os.version.value
# TODO: figure out a way to generate Windows versions
VERSIONS = tuple([LOCAL] if LOCAL != None else [])