Skip to content
Commits on Source (9)
......@@ -16,6 +16,9 @@ common --show_timestamps
# Do not wrap any output
common --terminal_columns=0
# Print relative paths where possible to reduce noise
common --attempt_to_print_relative_paths
# Output as much information in the CI log about failures as possible
build --verbose_failures
......@@ -26,5 +29,36 @@ test --test_output=errors
test --test_verbose_timeout_warnings
# These locations are cached on the CI
build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk
build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo
build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk
build:local --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo
# Use remote cache/execution for our builds
build:remote --remote_executor=${CI_REMOTE_EXECUTOR}
build:remote --remote_cache=${CI_REMOTE_CACHE}
build:remote --remote_timeout=3600
build:remote --remote_header=${CI_REMOTE_HEADER}
build:remote --experimental_remote_cache_compression
build:remote --jobs=${CI_REMOTE_JOBS}
# Upload results to the Build Event Service
build:remote --bes_results_url=${CI_BES_RESULTS_URL}
build:remote --bes_backend=${CI_BES_BACKEND}
# Add build metadata
build:remote --build_metadata=REPO_URL=${CI_PROJECT_URL}
build:remote --build_metadata=BRANCH_NAME=${CI_COMMIT_REF_NAME}
build:remote --build_metadata=COMMIT_SHA=${CI_COMMIT_SHA}
build:remote --build_metadata=HOST=${CI_SERVER_HOST}
build:remote --build_metadata=ROLE=CI
build:remote --build_metadata=USER=gitlab-ci
# Provide detailed timing information to the remote executor
build:remote --noslim_profile
build:remote --experimental_profile_include_target_label
build:remote --experimental_profile_include_primary_output
# Eliminate duplicate references in the Build Event Stream
build:remote --nolegacy_important_outputs
# TODO: remove this when `bazel/ape` binaries work on remote execution `arm64` instances
build:remote --host_platform=@toolchain_utils//toolchain/platform:amd64-linux-gnu
include:
- component: "${CI_SERVER_HOST}/ci/component/bazelisk/bazelisk@v1.0.0-beta.3"
inputs:
variables: |
CI_PROJECT_DIR
CI_PROJECT_ID
CI_REMOTE_EXECUTOR
CI_REMOTE_CACHE
CI_REMOTE_HEADER
CI_REMOTE_JOBS
CI_BES_RESULTS_URL
CI_BES_BACKEND
CI_PROJECT_URL
CI_COMMIT_REF_NAME
CI_COMMIT_SHA
CI_SERVER_HOST
default:
tags:
......@@ -10,8 +24,13 @@ test:
parallel:
matrix:
- ROOT:
- .
- e2e
- .
- e2e
CONFIG:
- local
- remote
script:
- cd "${ROOT}"; bazelisk test --config="${CONFIG}" //...
# TODO: switch this out for `rules_semantic_release`
semantic-release:
......
# [1.0.0-beta.7](https://git.gitlab.arm.com/bazel/toolchain_utils/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2024-05-03)
### Bug Fixes
- **symlink/target:** add `files_to_run` property on `ToolchainInfo` provider ([2966744](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/2966744e1328bef9143dbb5c9c1d32fc756e0219))
- **symlink/target:** add target to runfiles ([4ec2331](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/4ec23317cba14be99c3eec807e9b3873fc5636b0))
- **symlink/target:** merge all data runfiles ([753b43a](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/753b43a44ff14e768dd98f9fd9234d4f30eb3d0d))
- **toolchain/test:** break `diff` loop correctly ([d57cc71](https://git.gitlab.arm.com/bazel/toolchain_utils/commit/d57cc71913ae936d26ed4a385ad3eb24bde6e8d9))
### BREAKING CHANGES
- **symlink/target:** `toolchain_symlink_path` no longer provides `ToolchainInfo`/`TemplateVariableInfo`.
It is required to use `toolchain_symlink_target` to the `toolchain_symlink_path`.
This is due to `toolchain_symlink_target` needing to export the `DefaultInfo.file_to_run` from the
symlinked target. That is not possible with a filesystem path.
This should not affect most users as `toolchain_symlink_path` is mainly used in `toolchain_local_which`.
If `toolchain_symlink_path` is being used, then to gain the previous functionality, create a
`toolchain_symlink_target` to the `toolchain_symlink_path` label.
# [1.0.0-beta.6](https://git.gitlab.arm.com/bazel/toolchain_utils/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2024-04-24)
### Bug Fixes
......
module(
name = "toolchain_utils",
version = "1.0.0-beta.6",
version = "1.0.0-beta.7",
bazel_compatibility = [
">=7.0.0",
],
......
......@@ -16,6 +16,9 @@ common --show_timestamps
# Do not wrap any output
common --terminal_columns=0
# Print relative paths where possible to reduce noise
common --attempt_to_print_relative_paths
# Output as much information in the CI log about failures as possible
build --verbose_failures
......@@ -26,5 +29,36 @@ test --test_output=errors
test --test_verbose_timeout_warnings
# These locations are cached on the CI
build --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk
build --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo
build:local --disk_cache=${CI_PROJECT_DIR}/.cache/bazel/disk
build:local --repository_cache=${CI_PROJECT_DIR}/.cache/bazel/repo
# Use remote cache/execution for our builds
build:remote --remote_executor=${CI_REMOTE_EXECUTOR}
build:remote --remote_cache=${CI_REMOTE_CACHE}
build:remote --remote_timeout=3600
build:remote --remote_header=${CI_REMOTE_HEADER}
build:remote --experimental_remote_cache_compression
build:remote --jobs=${CI_REMOTE_JOBS}
# Upload results to the Build Event Service
build:remote --bes_results_url=${CI_BES_RESULTS_URL}
build:remote --bes_backend=${CI_BES_BACKEND}
# Add build metadata
build:remote --build_metadata=REPO_URL=${CI_PROJECT_URL}
build:remote --build_metadata=BRANCH_NAME=${CI_COMMIT_REF_NAME}
build:remote --build_metadata=COMMIT_SHA=${CI_COMMIT_SHA}
build:remote --build_metadata=HOST=${CI_SERVER_HOST}
build:remote --build_metadata=ROLE=CI
build:remote --build_metadata=USER=gitlab-ci
# Provide detailed timing information to the remote executor
build:remote --noslim_profile
build:remote --experimental_profile_include_target_label
build:remote --experimental_profile_include_primary_output
# Eliminate duplicate references in the Build Event Stream
build:remote --nolegacy_important_outputs
# TODO: remove this when `bazel/ape` binaries work on remote execution `arm64` instances
build:remote --host_platform=@toolchain_utils//toolchain/platform:amd64-linux-gnu
......@@ -5,7 +5,6 @@ module(
],
)
bazel_dep(name = "rules_diff", version = "1.0.0-alpha.3")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "toolchain_utils", version = "0.0.0")
local_path_override(
......
This diff is collapsed.
alias(
name = "template",
actual = select({
"@toolchain_utils//toolchain/constraint/os:windows": ":nt.tmpl.bat",
"//conditions:default": ":posix.tmpl.sh",
}),
visibility = ["//visibility:public"],
)
load(":rule.bzl", _test = "test")
visibility("public")
diff_file_test = _test
@echo off
:: Enable Batch extensions
verify other 2>nul
setlocal EnableExtensions
if errorlevel 1 (
echo>&2.Failed to enable extensions
exit /b 120
)
:: Bazel substitutions
call :rlocation A "{{a}}"
if errorlevel 1 (
echo>&2.Failed to resolve runfile
exit /b 2
)
call :rlocation B "{{b}}"
if errorlevel 1 (
echo>&2.Failed to resolve runfile
exit /b 2
)
:: Provided on all Windows installations
set "DIFF=%SYSTEMROOT%\\system32\\fc.exe"
:: Perform the difference
"%DIFF%" "%A%" "%B%"
exit /b %ERRORLEVEL%
:rlocation - resolve run files
:: %1 - return code variable
:: %2 - runfile path
setlocal
set "FILEPATH=%2%"
for /f usebackq %%a in ('%FILEPATH%') do set "FILEPATH=%%~a"
if [%RUNFILES_MANIFEST_ONLY%] neq [1] (
echo>&2.Only runfile manifests are supported
exit /b 2
)
for /f "tokens=1,2* usebackq" %%a in ("%RUNFILES_MANIFEST_FILE%") do (
if "_main/%FILEPATH%" == "%%a" (
set "FILEPATH=%%~fb"
)
if "%FILEPATH%" == "../%%a" (
set "FILEPATH=%%~fb"
)
)
if not exist "%FILEPATH%" (
echo>&2.Failed to resolve runfile: %FILEPATH%
exit /b 2
)
endlocal & set "%~1=%FILEPATH%"
goto :eof
#!/usr/bin/env sh
# Strict shell
set -o errexit
set -o nounset
# Bazel substitutions
A="{{a}}"
B="{{b}}"
readonly A B
# Test environment
JUNIT="${XML_OUTPUT_FILE-junit.xml}"
readonly JUNIT
diff() (
INDEX="${1}"
FILEPATH="${2}"
EXPECTED="${3}"
while true; do
FAILS=0
IFS= read -r L <&3 || FAILS=$((FAILS + 1))
IFS= read -r R <&4 || FAILS=$((FAILS + 1))
if test "${FAILS}" -eq 1; then
printf >&2 'not ok %i - %s had a different number of lines to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}"
printf ' <testcase name="%s">\n' "${FILEPATH}"
printf ' <failure type="Difference">%s contained different line counts:\n' "${FILEPATH}"
printf '%s %s\n' '---' "${FILEPATH}"
printf '%s %s\n' '+++' "${EXPECTED}"
printf '@@ -1 +1 @@\n'
printf '%s%s\n' '-' "${A-}"
printf '%s%s\n' '+' "${B-}"
printf '</failure>\n'
printf ' </testcase>\n'
exit
elif test "${FAILS}" -eq 2; then
break
elif test "${L}" != "${R}"; then
printf >&2 'not ok %i: %s had different content to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}"
printf ' <testcase name="%s">\n' "${FILEPATH}"
printf ' <failure type="Difference">%s contained different content:\n' "${FILEPATH}"
printf '%s %s\n' '---' "${FILEPATH}"
printf '%s %s\n' '+++' "${EXPECTED}"
printf '@@ -1 +1 @@\n'
printf '%s%s\n' '-' "${L}"
printf '%s%s\n' '+' "${R}"
printf '</failure>\n'
printf ' </testcase>\n'
exit
fi
done 3<"${FILEPATH}" 4<"${EXPECTED}"
printf >&2 'ok %s - %s was equal to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}"
printf ' <testcase name="%s"/>\n' "${FILEPATH}"
)
junit() (
COUNT="${#}"
TESTS=$((COUNT / 2))
readonly COUNT TESTS
printf '<testsuite tests="%s">\n' "${TESTS}"
printf >&2 '1..%i\n' "${TESTS}"
INDEX=1
while ! test -z ${2+x}; do
FILEPATH="${1}"
EXPECTED="${2}"
shift 2
diff "${INDEX}" "${FILEPATH}" "${EXPECTED}"
INDEX=$((INDEX + 1))
done
printf '</testsuite>\n'
)
junit "${A}" "${B}" >"${JUNIT}"
while IFS= read -r LINE; do
if test -z "${LINE#*</failure>*}"; then
exit 1
fi
done <"${JUNIT}"
visibility("//...")
DOC = """Performs a difference between two files and fails if any are found.
```py
diff_file_test(
name = "test",
a = ":some-file.txt",
b = ":some-file.txt",
size = "small",
)
```
"""
ATTRS = {
"a": attr.label(
doc = "A file to compare.",
allow_single_file = True,
mandatory = True,
),
"b": attr.label(
doc = "Another file to compare.",
allow_single_file = True,
mandatory = True,
),
"template": attr.label(
doc = "The script template to be rendered into the test executable.",
allow_single_file = True,
default = ":template",
),
}
def implementation(ctx):
rendered = ctx.actions.declare_file("{}.rendered.{}".format(ctx.label.name, ctx.file.template.extension))
ctx.actions.expand_template(
output = rendered,
template = ctx.file.template,
is_executable = True,
substitutions = {
"{{a}}": ctx.file.a.short_path,
"{{b}}": ctx.file.b.short_path,
},
)
files = depset([rendered])
runfiles = ctx.runfiles(files = [ctx.file.a, ctx.file.b])
return DefaultInfo(
executable = rendered,
files = files,
runfiles = runfiles,
)
diff_file_test = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
test = True,
)
test = diff_file_test
load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test")
load("//diff/file/test:defs.bzl", "diff_file_test")
diff_file_test(
name = "hello-world",
......
load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test")
load("//diff/file/test:defs.bzl", "diff_file_test")
diff_file_test(
name = "hello-world",
......
load("@toolchain_utils//toolchain/triplet:local.bzl", "TRIPLET")
load("@rules_diff//diff/file/test:defs.bzl", "diff_file_test")
load("//diff/file/test:defs.bzl", "diff_file_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(
......
load("@toolchain_utils//toolchain/symlink/path:defs.bzl", "toolchain_symlink_path")
load("@toolchain_utils//toolchain/symlink/target:defs.bzl", "toolchain_symlink_target")
package(default_visibility = ["//visibility:public"])
exports_files(["entrypoint"])
exports_files(
["entrypoint"],
visibility = ["//visibility:public"],
)
toolchain_symlink_path(
name = "symlink",
path = "{{path}}",
tags = ["no-remote"],
)
toolchain_symlink_target(
name = "{{target}}",
basename = "{{basename}}",
path = "{{path}}",
tags = ["no-remote"],
target = ":symlink",
variable = "{{variable}}",
visibility = ["//visibility:public"],
)
......@@ -2,14 +2,12 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
visibility("//toolchain/...")
DOC = """Creates a executable symlink to a binary path.
DOC = """Creates an executable symlink to a binary path.
This rule can be used to symlink a executable file outside of the workspace.
The external executable become part of the Bazel target graph.
It exports the necessary providers for the target to be easily ingested by the native `toolchain` rule.
```
toolchain_type(
name = "type",
......@@ -20,9 +18,14 @@ toolchain_symlink_path(
path = "/usr/bin/gcc",
)
toolchain_symlink_target(
name = "gcc",
target = "gcc-local",
)
toolchain(
name = "local",
toolchain = ":gcc-local",
toolchain = ":gcc",
toolchain_type = ":type",
)
```
......@@ -85,32 +88,19 @@ def implementation(ctx):
target_path = ctx.attr.path,
)
variables = platform_common.TemplateVariableInfo({
variable: executable.path,
})
runfiles = ctx.runfiles([executable])
runfiles.merge_all([d[DefaultInfo].default_runfiles for d in ctx.attr.data])
default = DefaultInfo(
return DefaultInfo(
executable = executable,
files = depset([executable]),
runfiles = ctx.runfiles(ctx.attr.data + [executable]),
runfiles = runfiles,
)
toolchain = platform_common.ToolchainInfo(
variables = variables,
default = default,
executable = executable,
)
return [variables, toolchain, default]
path = rule(
doc = DOC,
attrs = ATTRS,
implementation = implementation,
provides = [
platform_common.TemplateVariableInfo,
platform_common.ToolchainInfo,
DefaultInfo,
],
provides = [DefaultInfo],
executable = True,
)
......@@ -50,10 +50,6 @@ ATTRS = {
"variable": attr.string(
doc = "The variable name for Make or the execution environment. Defaults to `basename.upper()`",
),
"data": attr.label_list(
doc = "Extra files that are needed at runtime.",
allow_files = True,
),
"_windows": attr.label(
providers = [platform_common.ConstraintValueInfo],
default = "//toolchain/constraint/os:windows",
......@@ -85,7 +81,7 @@ def implementation(ctx):
variable: executable.path,
})
runfiles = ctx.runfiles(ctx.attr.data + [executable])
runfiles = ctx.runfiles([executable, ctx.executable.target])
runfiles = runfiles.merge(ctx.attr.target.default_runfiles)
default = DefaultInfo(
......@@ -96,8 +92,9 @@ def implementation(ctx):
toolchain = platform_common.ToolchainInfo(
variables = variables,
default = default,
executable = executable,
default = ctx.attr.target[DefaultInfo],
executable = ctx.executable.target,
files_to_run = ctx.attr.target.files_to_run,
)
return [variables, toolchain, default]
......
......@@ -95,7 +95,7 @@ diff() (
printf ' </testcase>\n'
exit
elif test "${FAILS}" -eq 2; then
exit
break
elif test "${A}" != "${B}"; then
printf >&2 'not ok %i: %s had different content to %s\n' "${INDEX}" "${FILEPATH}" "${EXPECTED}"
printf ' <testcase name="%s">\n' "${FILEPATH}"
......