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/rules_toolchain
1 result
Show changes
Commits on Source (6)
# [1.0.0-alpha.11](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2023-12-13)
### Bug Fixes
- create hardlinks on Windows ([374f38d](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/374f38ddb93b74c48ea00f222c2c871cf7821539))
### Features
- **test:** allow custom exit codes ([d0fc499](https://git.gitlab.arm.com/bazel/rules_toolchain/commit/d0fc4991421a494975cc47a2857e3d78a6d356a1))
# [1.0.0-alpha.10](https://git.gitlab.arm.com/bazel/rules_toolchain/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2023-12-13)
### Features
......
module(
name = "rules_toolchain",
version = "1.0.0-alpha.10",
version = "1.0.0-alpha.11",
bazel_compatibility = [
">=7.0.0",
],
......
......@@ -9,12 +9,12 @@ Add the following to `MODULE.bazel`:
```py
which = use_repo_rule("@rules_toolchain//toolchain/local/which:defs.bzl", "toolchain_local_which")
which(
name = "which",
name = "which-echo",
)
resolved = use_repo_rule("@rules_toolchain//toolchain/resolved:defs.bzl", "toolchain_resolved")
resolved(
name = "resolved",
name = "resolved-echo",
toolchain_type = "//toolchain/echo:type",
)
```
......@@ -34,7 +34,7 @@ toolchain_type(
# No `exec_compatible_with` constraints are needed as a local binary is always compatible with the execution platform
toolchain(
name = "local",
toolchain = "@which//:echo",
toolchain = "@which-echo",
toolchain_type = ":type",
)
......@@ -42,7 +42,7 @@ toolchain(
# bazel run -- //toolchain/echo:resolved
alias(
name = "resolved",
actual = "@resolved",
actual = "@resolved-echo",
)
# Performs a execution test of the binary
......
......@@ -847,7 +847,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "DcS7hkCR97tWU6RFIoqiRZfRyhn8MoWr0X40xcNtOZg=",
"bzlTransitiveDigest": "kjjMoE+YxB2J+WBlqvfU09B8+xYcMDSlMPEltkiJtKc=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......
......@@ -41,5 +41,8 @@ toolchain_test(
build_test(
name = "entrypoint",
target_compatible_with = [
"@rules_toolchain//toolchain/constraint/os:linux",
],
targets = ["@which-echo//:entrypoint"],
)
......@@ -21,6 +21,7 @@ setlocal DisableDelayedExpansion
set "EXECUTABLE={{executable}}"
set "STDOUT={{stdout}}"
set "STDERR={{stderr}}"
set "STATUS={{status}}"
:: Runfiles
if [%RUNFILES_MANIFEST_ONLY%] neq [1] (
......@@ -45,8 +46,8 @@ for /f %%a in ("%EXECUTABLE%") do set EXTENSION=%%~xa
if "%EXTENSION%" == ".bat" set LAUNCHER=call
%LAUNCHER% "%EXECUTABLE%" %* >stdout.txt 2>stderr.txt
set "CODE=%ERRORLEVEL%"
if %CODE% neq 0 (
>&2 echo.Failed to run: %EXECUTABLE% %*
if %CODE% neq %STATUS% (
>&2 echo.Failed to run ^(%STATUS^): %EXECUTABLE% %*
>&2 echo.stdout:
>&2 type stdout.txt
>&2 echo.stderr:
......
......@@ -8,15 +8,18 @@ set -eu
EXECUTABLE="{{executable}}"
STDOUT="{{stdout}}"
STDERR="{{stderr}}"
readonly EXECUTABLE STDOUT STDERR
STATUS="{{status}}"
readonly EXECUTABLE STDOUT STDERR STATUS
# Test environment
JUNIT="${XML_OUTPUT_FILE-junit.xml}"
readonly JUNIT
# Run the toolchain executable and validate the output
if ! "${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt; then
echo >&2 "Failed to run: ${EXECUTABLE} ${*}"
"${EXECUTABLE}" "${@}" >stdout.txt 2>stderr.txt && CODE=$? || CODE=$?
readonly CODE
if test "${STATUS}" != "${CODE}"; then
echo >&2 "Failed to run (${CODE}): ${EXECUTABLE} ${*}"
echo >&2 "stdout:"
while IFS= read -r LINE; do
echo >&2 "${LINE}"
......
......@@ -35,6 +35,10 @@ Can be overridden to a custom script that receives the following replacements:
default = ":template",
allow_single_file = True,
),
"status": attr.int(
doc = "The expected status code from the toolchain binary.",
default = 0,
),
}
def implementation(ctx):
......@@ -48,6 +52,7 @@ def implementation(ctx):
substitutions.add("{{executable}}", str(toolchain.executable.short_path))
substitutions.add("{{stdout}}", str(ctx.file.stdout.short_path))
substitutions.add("{{stderr}}", str(ctx.file.stderr.short_path))
substitutions.add("{{status}}", str(ctx.attr.status))
ctx.actions.expand_template(
template = ctx.file.template,
......