Skip to content
Commits on Source (9)
......@@ -15,6 +15,7 @@ Copyright: 2023 Arm Ltd.
License: MIT
Files:
icon.svg
package.json
package-lock.json
.releaserc.yml
......
# [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
- add missing stub file ([fdcc9c0](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/fdcc9c013c99bf6c0fb8c29270f4412f83400a83))
- upload release files to generic package registry ([d5deccf](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/d5deccfa9dc35482c23b7376fb368f8037d51845))
### Features
- add `export` extension ([35bae07](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/35bae07323b7ac4a9ddeab60909d9c411970fab2))
- **rules_toolchain:** add `:entrypoint` target to local repositories ([a995bd4](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/a995bd4702de985b14cd99ce1f896f1833342b29))
# [1.0.0-alpha.5](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2023-11-16)
### Bug Fixes
......
module(
name = "rules_toolchain",
version = "1.0.0-alpha.5",
version = "1.0.0-alpha.6",
bazel_compatibility = [
">=6.4.0",
],
......
......@@ -670,7 +670,7 @@
}
}
},
"@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": {
"@@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=",
"accumulatedFileDigests": {},
......@@ -693,7 +693,7 @@
}
}
},
"@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
"@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=",
"accumulatedFileDigests": {},
......@@ -716,7 +716,7 @@
}
}
},
"@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": {
"@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": {
"general": {
"bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=",
"accumulatedFileDigests": {},
......@@ -732,9 +732,9 @@
}
}
},
"@rules_java~7.1.0//java:extensions.bzl%toolchains": {
"@@rules_java~7.1.0//java:extensions.bzl%toolchains": {
"general": {
"bzlTransitiveDigest": "EXsxSX2vQjCcI8jYez/O+Yb9H5reAMhLL3WXGPD6Scw=",
"bzlTransitiveDigest": "iUIRqCK7tkhvcDJCAfPPqSd06IHG0a8HQD0xeQyVAqw=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......
......@@ -52,3 +52,10 @@ select(
"arm-linux-musl": "@fixture-arm-linux-musl",
},
)
export = use_extension("@rules_toolchain//toolchain/export:defs.bzl", "toolchain_export")
export.symlink(
name = "export",
target = "@fixture",
)
use_repo(export, "export")
{
"lockFileVersion": 3,
"moduleFileHash": "a4f83750c39dd1dd3c7f4cb6e91173765b61fec4346ea33df2f4a7cb7e60c729",
"moduleFileHash": "7c7e76923d2e2442dc1fbaa7b1e37fda17ab54a2eefba7b32eab54747d049bc9",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build/"
......@@ -128,6 +128,37 @@
],
"hasDevUseExtension": false,
"hasNonDevUseExtension": true
},
{
"extensionBzlFile": "@rules_toolchain//toolchain/export:defs.bzl",
"extensionName": "toolchain_export",
"usingModule": "<root>",
"location": {
"file": "@@//:MODULE.bazel",
"line": 56,
"column": 23
},
"imports": {
"export": "export"
},
"devImports": [],
"tags": [
{
"tagName": "symlink",
"attributeValues": {
"name": "export",
"target": "@fixture"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 57,
"column": 15
}
}
],
"hasDevUseExtension": false,
"hasNonDevUseExtension": true
}
],
"deps": {
......@@ -777,7 +808,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "/xroDvlQ7p867k7lShdRN/8y8PAICvIR2NWA0F7JzLg=",
"bzlTransitiveDigest": "/R69egUTLvkHkALvRLGxIJMgJWsQ0N6s2oGkMp4YL30=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -833,7 +864,7 @@
}
}
},
"@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": {
"@@apple_support~1.5.0//crosstool:setup.bzl%apple_cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "pMLFCYaRPkgXPQ8vtuNkMfiHfPmRBy6QJfnid4sWfv0=",
"accumulatedFileDigests": {},
......@@ -856,7 +887,7 @@
}
}
},
"@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
"@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
"general": {
"bzlTransitiveDigest": "O9sf6ilKWU9Veed02jG9o2HM/xgV/UAyciuFBuxrFRY=",
"accumulatedFileDigests": {},
......@@ -879,7 +910,7 @@
}
}
},
"@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": {
"@@bazel_tools//tools/sh:sh_configure.bzl%sh_configure_extension": {
"general": {
"bzlTransitiveDigest": "hp4NgmNjEg5+xgvzfh6L83bt9/aiiWETuNpwNuF1MSU=",
"accumulatedFileDigests": {},
......@@ -895,9 +926,9 @@
}
}
},
"@rules_java~7.1.0//java:extensions.bzl%toolchains": {
"@@rules_java~7.1.0//java:extensions.bzl%toolchains": {
"general": {
"bzlTransitiveDigest": "EXsxSX2vQjCcI8jYez/O+Yb9H5reAMhLL3WXGPD6Scw=",
"bzlTransitiveDigest": "iUIRqCK7tkhvcDJCAfPPqSd06IHG0a8HQD0xeQyVAqw=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -1435,7 +1466,7 @@
}
}
},
"@rules_toolchain~override//:MODULE.bazel%_repo_rules": {
"@@rules_toolchain~override//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "VGGV2/aS8KP0wlEaxXfdomUzHtZ4Ry+aV/L2Ktp3UCo=",
"accumulatedFileDigests": {},
......@@ -1450,6 +1481,23 @@
}
}
}
},
"@@rules_toolchain~override//toolchain/export:defs.bzl%toolchain_export": {
"general": {
"bzlTransitiveDigest": "GaX6IuOvOKsD8efBm9Fy5gFKF6piHEW7gvUENxCsD9M=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
"export": {
"bzlFile": "@@rules_toolchain~override//toolchain/export/symlink:repository.bzl",
"ruleClassName": "symlink",
"attributes": {
"name": "rules_toolchain~override~toolchain_export~export",
"target": "@@_main~_repo_rules~fixture//:fixture"
}
}
}
}
}
}
}
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
diff_test(
name = "hello-world",
size = "small",
file1 = "@export//:test/fixture/hello-world.txt",
file2 = "//test/fixture:hello-world.txt",
)
load("@rules_toolchain//toolchain:defs.bzl", "toolchain_symlink_target", "toolchain_test")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
toolchain_type(
name = "type",
......@@ -32,3 +33,8 @@ toolchain_test(
stdout = ":hello-world.txt",
toolchains = [":resolved"],
)
build_test(
name = "entrypoint",
targets = ["@echo//:entrypoint"],
)
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 512 512">
<path d="M11.77 281.823h488.46v64.736H11.77z" style="fill:#2969b0"/>
<path d="M44.138 346.559h423.724V499.57H44.138z" style="fill:#bfdeff"/>
<path d="M203.034 346.559h105.931v52.966H203.034z" style="fill:#ebebeb"/>
<path d="M463.439 179.715 288.455 78.689c12.751-22.085 25.501-44.171 38.253-66.256 61.094 26.728 110.93 79.308 157.329 131.606-6.866 11.893-13.731 23.785-20.598 35.676z" style="fill:#a8a8a8"/>
<path d="m389.202 136.849-43.773 75.811-39.924 69.161h-67.961l15.996-27.695 84.698-146.703z" style="fill:#ffac3d"/>
<path d="m253.54 254.126-15.996 27.695h-22.116l-91.901-136.239-17.184-9.71L76.506 91.64l53.66-36.194 29.837 44.233 2.554 19.573zm160.38-41.466v69.161H305.505l39.924-69.161z" style="fill:#ebebeb"/>
<path d="M500.23 270.051h-74.54V212.66c0-6.501-5.271-11.77-11.77-11.77h-48.1l27.688-47.959 64.046 36.977a11.758 11.758 0 0 0 8.931 1.176 11.768 11.768 0 0 0 7.147-5.484l20.598-35.678a11.769 11.769 0 0 0-1.389-13.696C445.913 83.333 394.793 29.371 331.424 1.649a11.77 11.77 0 0 0-14.91 4.899l-38.253 66.256c-3.251 5.63-1.322 12.828 4.308 16.078l39.586 22.855-69.394 120.189-78.893-116.953-2.194-16.818a11.772 11.772 0 0 0-1.914-5.059l-29.837-44.232c-3.636-5.39-10.952-6.81-16.339-3.176l-53.66 36.193a11.771 11.771 0 0 0-3.177 16.34l29.837 44.232a11.775 11.775 0 0 0 3.968 3.665l14.769 8.345 77.97 115.587H147.67l-46.458-95.485c-2.845-5.845-9.89-8.277-15.733-5.434-5.845 2.845-8.278 9.888-5.434 15.733l41.447 85.186h-29.78l-18.556-42.205c-2.618-5.951-9.566-8.653-15.512-6.037-5.951 2.617-8.655 9.561-6.038 15.512l14.39 32.732H11.77c-6.499 0-11.77 5.27-11.77 11.77v64.736c0 6.501 5.271 11.77 11.77 11.77h20.598v141.241c0 6.501 5.271 11.77 11.77 11.77h423.724c6.499 0 11.77-5.269 11.77-11.77V358.328h20.598c6.499 0 11.77-5.269 11.77-11.77v-64.736c0-6.502-5.271-11.771-11.77-11.771zm-98.08-45.621v45.621h-76.259l26.338-45.621h49.921zM331.515 27.647c52.385 25.827 96.918 71.78 138.08 117.868l-10.464 18.122-154.598-89.256 26.982-46.734zm41.607 113.514-74.412 128.89h-40.774l5.798-10.038c.005-.008.007-.016.012-.025l78.799-136.482 30.577 17.655zM133.285 139a11.775 11.775 0 0 0-3.968-3.665l-14.769-8.345-21.702-32.175 34.144-23.029 21.702 32.171 2.194 16.818a11.772 11.772 0 0 0 1.914 5.059l86.868 128.772-8.917 15.444h-9.063L133.285 139zm322.807 299.952h-48.846c-6.499 0-11.77 5.269-11.77 11.77 0 6.501 5.271 11.77 11.77 11.77h48.846v25.306H55.908v-25.306h48.846c6.499 0 11.77-5.269 11.77-11.77 0-6.501-5.271-11.77-11.77-11.77H55.908v-80.625h135.356v41.195c0 6.501 5.271 11.77 11.77 11.77h105.931c6.499 0 11.77-5.269 11.77-11.77v-41.195h135.356v80.625zm-241.287-80.625h82.391v29.425h-82.391v-29.425zm273.655-23.54H23.54v-41.195h464.92v41.195z" style="fill:#231f20"/>
<path d="M149.677 438.952H148.5c-6.499 0-11.77 5.269-11.77 11.77 0 6.501 5.271 11.77 11.77 11.77h1.177c6.499 0 11.77-5.269 11.77-11.77 0-6.5-5.271-11.77-11.77-11.77zm212.646 23.54h1.177c6.499 0 11.77-5.269 11.77-11.77 0-6.501-5.271-11.77-11.77-11.77h-1.177c-6.499 0-11.77 5.269-11.77 11.77 0 6.501 5.271 11.77 11.77 11.77z" style="fill:#231f20"/>
</svg>
......@@ -9,7 +9,7 @@
"@semantic-release/bzlmod": "https://gitlab.arm.com/semantic-release/bzlmod/-/releases/v1.1.0/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.1.1/downloads/package.tar.gz",
"@semantic-release/config-gitlab-bzlmod": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.1.3/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.1.1",
"resolved": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.1.1/downloads/package.tar.gz",
"integrity": "sha512-9CstRRf6oOY8pF2HnJD6GE6sMmWfSlRa2BIIpPAbAaONhV57ejWGhvyFwIe1eajJCQPtEU1mi2g6uUoSJKxigg==",
"version": "1.1.3",
"resolved": "https://gitlab.arm.com/semantic-release/config-gitlab-bzlmod/-/releases/v1.1.3/downloads/package.tar.gz",
"integrity": "sha512-zqRVybOCJ50/lLOgs4AmR7JAzSkgH1ooP9NlahOeOrTx4tSQzI1bd17CfSu/NLDCof/BjQDw/eKid5J9Zpnx3Q==",
"dev": true,
"license": "MIT",
"peerDependencies": {
......
load("//toolchain/export:extension.bzl", _export = "export")
visibility("public")
toolchain_export = _export
load("//toolchain/export/symlink:repository.bzl", _ATTRS = "ATTRS", _DOC = "DOC", _symlink = "symlink")
visibility("//toolchain/export/...")
DOC = """An extension to export local repositories to other Bazel modules.
A common pattern for Bazel modules is to download hermetic tooling, often with `rules_download`.
The downloaded repositories are local in scope to the current Bazel module.
The locally downloaded repositories can provide hermetic, executable files that are useful for repository rules.
The hermetic, executable files are often useful for other Bazel modules to perform hermetic repositories.
This module provides a way to "export" those locally visible repositories to other Bazel modules.
For example, a `@python` Bazel module could provide:
```py
download_archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive")
download_archive(
name = "python-amd64-linux-gnu",
...,
)
toolchain_select = use_extension("@rules_toolchain//toolchain:defs.bzl", "toolchain_select")
toolchain_select(
name = "python-local",
map = {
"amd64-linux-gnu": "@python-amd64-linux-gnu",
}
)
export = use_extension("@rules_toolchain//toolchain/export:defs.bzl", "export")
export.symlink(
name = "python",
target = "@python-local",
)
use_repo(export, "python")
some_hermetic_repository_rule(
name = "placeholder",
python = "@python//:entrypoint",
)
```
The _same_ downloaded Python interpreter can be used in another Bazel module:
```py
export = use_extension("@rules_toolchain//toolchain/export:defs.bzl", "export")
use_repo(export, "python")
some_other_hermetic_repository_rule(
name = "placeholder",
python = "@python//:entrypoint",
)
```
The de-facto `:entrypoint` label is often used for the executable file entrypoint that can be used with `rctx.execute`.
The exported repository names are global across the module extension.
"""
symlink = tag_class(
doc = _DOC,
attrs = {
"name": attr.string(doc = "Name of the generated repository.", mandatory = True),
} | _ATTRS,
)
TAGS = {
"symlink": symlink,
}
def implementation(mctx):
for mod in mctx.modules:
for d in mod.tags.symlink:
_symlink(name = d.name, **{a: getattr(d, a) for a in _ATTRS})
export = module_extension(
doc = DOC,
implementation = implementation,
tag_classes = TAGS,
)
visibility("//toolchain/export/...")
DOC = "Symlinks a repository to another."
ATTRS = {
"target": attr.label(
doc = "The repository to symlink to.",
mandatory = True,
),
}
def implementation(rctx):
label = rctx.attr.target
workspace = label.relative(":WORKSPACE")
path = rctx.path(workspace)
if not path.exists:
fail("Failed to find `{}`, can only symlink repository labels.".format(path, label))
target = path.dirname
rctx.delete(".")
rctx.symlink(target, ".")
symlink = repository_rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
configure = True,
local = True,
)
......@@ -3,6 +3,8 @@ load("//:resolved.bzl", "resolved")
package(default_visibility = ["//visibility:public"])
exports_files(["entrypoint"])
toolchain_symlink_path(
name = "{{name}}",
path = "{{path}}",
......
#! /bin/sh
# Strict shell
set -o errexit -o nounset
# Bazel replacements
EXECUTABLE="{{path}}"
readonly EXECUTABLE
# Execute!
"${EXECUTABLE}" "${@}"
......@@ -50,6 +50,13 @@ ATTRS = _ATTRS | {
executable = True,
cfg = "exec",
),
"entrypoint": attr.label(
doc = "An executable entrypoint template for hermetic rulesets.",
default = ":entrypoint.tmpl.sh",
allow_single_file = True,
executable = True,
cfg = "exec",
),
}
def implementation(rctx):
......@@ -66,6 +73,10 @@ def implementation(rctx):
"{{basename}}": str(rctx.attr.basename),
}, executable = False)
rctx.template("entrypoint", rctx.attr.entrypoint, {
"{{path}}": str(path.realpath),
}, executable = True)
rctx.template("BUILD.bazel", rctx.attr.build, {
"{{name}}": rctx.attr.target or program,
"{{program}}": program,
......
#! /bin/sh
cat <<EOF >&2
Usage: ${0} ${@}
This is a stub executable that is provided when the \`${0##*/}\` binary is not found on \${PATH}:
${PATH}
It will always exit with a failure code. Either:
- Install the required binary locally
- Setup a hermetic toolchain for the binary
EOF
exit 126