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_coreutils
1 result
Show changes
Commits on Source (16)
Showing
with 1081 additions and 1916 deletions
include:
- component: "${CI_SERVER_HOST}/ci/component/bazelisk/bazelisk@v1.0.0-beta.2"
- component: "${CI_SERVER_HOST}/ci/component/bazelisk/bazelisk@v1.0.0-beta.3"
default:
tags:
......
# [1.0.0-alpha.8](https://git.gitlab.arm.com/bazel/rules_coreutils/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2024-04-03)
### Bug Fixes
- correct coreutils archive extension ([b073c6b](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/b073c6b25209db51067b7c9bf35e18d7f0bfa1b7))
- correct Windows `coreutils` link ([86300e5](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/86300e57ad999a4e40c30d04bb78071f01a7ef8b))
- make redirection scripts public ([001dd36](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/001dd36641bdbca48782e5a2e94ee5fc78256123))
### Features
- add `sha1sum` rule ([a4f0476](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/a4f0476e9c6309b4bc8b6dc71be949df3c65ced8))
- add `sha256sum` rule ([c9154db](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/c9154dbdc78bb374fbafe543996424498f6de19a))
- add `sha3sum` rule ([5537e8e](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/5537e8e9764f3a27c3bcc2b32e3250c4e1935467))
- add `sha512sum` rule ([1c4d632](https://git.gitlab.arm.com/bazel/rules_coreutils/commit/1c4d63275839827dfeaa5065088f5e25f30e5981))
# [1.0.0-alpha.7](https://git.gitlab.arm.com/bazel/rules_coreutils/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2024-02-14)
### Bug Fixes
......
module(
name = "rules_coreutils",
version = "1.0.0-alpha.7",
version = "1.0.0-alpha.8",
bazel_compatibility = [
">=7.0.0",
],
......@@ -12,60 +12,28 @@ bazel_dep(name = "download_utils", version = "1.0.0-beta.1")
archive = use_repo_rule("@download_utils//download/archive:defs.bzl", "download_archive")
archive(
name = "coreutils-arm64-linux-gnu",
srcs = ["entrypoint"],
integrity = "sha256-8wMVMgAgf8JQ2+2LdoewkyDo416VEsf9RlMJl4jiBjk=",
links = {
"coreutils": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-aarch64-unknown-linux-gnu",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-aarch64-unknown-linux-gnu.tar.gz"],
)
archive(
name = "coreutils-amd64-linux-gnu",
srcs = ["entrypoint"],
integrity = "sha256-u7OMW43Y46aXRRIKULfKdfUW51WJn6G70s5Xxwb6/1g=",
links = {
"coreutils": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-x86_64-unknown-linux-gnu",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-x86_64-unknown-linux-gnu.tar.gz"],
)
archive(
name = "coreutils-amd64-windows-msvc",
srcs = ["entrypoint"],
integrity = "sha256-aglIj5JvFGLm2ABwRzWAsZRTTD3X444V3GxHM9pGJS4=",
links = {
"coreutils.exe": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-x86_64-pc-windows-msvc",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-x86_64-pc-windows-msvc.zip"],
)
archive(
name = "coreutils-arm64-macos-darwin",
srcs = ["entrypoint"],
integrity = "sha256-KP90sjKxtXDbLC+o5f4+gQnvP3Tr7O0RopME4g9QF5E=",
links = {
"coreutils": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-aarch64-apple-darwin",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-aarch64-apple-darwin.tar.gz"],
)
archive(
name = "coreutils-amd64-macos-darwin",
srcs = ["entrypoint"],
integrity = "sha256-SswetVAuK/hMK1r9uBvNnKj5JpSgD0bzkbsHTxOabCo=",
links = {
"coreutils": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-x86_64-apple-darwin",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-x86_64-apple-darwin.tar.gz"],
)
[
archive(
name = "coreutils-{}".format(triplet),
srcs = ["entrypoint"],
integrity = integrity,
links = {
"coreutils.exe" if "windows" in triplet else "coreutils": "entrypoint",
},
strip_prefix = "coreutils-0.0.23-{}".format(slug),
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.23/coreutils-0.0.23-{}.{}".format(
slug,
"zip" if "windows" in triplet else "tar.gz",
)],
)
for triplet, slug, integrity in (
("arm64-linux-gnu", "aarch64-unknown-linux-gnu", "sha256-8wMVMgAgf8JQ2+2LdoewkyDo416VEsf9RlMJl4jiBjk="),
("amd64-linux-gnu", "x86_64-unknown-linux-gnu", "sha256-u7OMW43Y46aXRRIKULfKdfUW51WJn6G70s5Xxwb6/1g="),
("amd64-windows-msvc", "x86_64-pc-windows-msvc", "sha256-aglIj5JvFGLm2ABwRzWAsZRTTD3X444V3GxHM9pGJS4="),
("arm64-macos-darwin", "aarch64-apple-darwin", "sha256-KP90sjKxtXDbLC+o5f4+gQnvP3Tr7O0RopME4g9QF5E="),
("amd64-macos-darwin", "x86_64-apple-darwin", "sha256-SswetVAuK/hMK1r9uBvNnKj5JpSgD0bzkbsHTxOabCo="),
)
]
select = use_repo_rule("@toolchain_utils//toolchain/local/select:defs.bzl", "toolchain_local_select")
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -40,7 +40,7 @@ export = use_extension("@toolchain_utils//toolchain/export:defs.bzl", "toolchain
use_repo(export, "coreutils")
some_repo_rule(
coreutils = "@coreutils",
coreutils = "@coreutils//:entrypoint",
)
```
......@@ -52,6 +52,10 @@ The resolved toolchains are runnable:
bazel run -- @rules_coreutils//coreutils/toolchain:resolved
```
## Hermeticity
The module is fully hermetic. No Bash is required on Windows.
## Implementations
Various implementations of the core utilties are resolved depending on the platform.
......
exports_files(
[
"stdout.tmpl.sh",
"stdout.tmpl.bat",
],
visibility = ["//visibility:public"],
)
alias(
name = "stdout",
actual = select({
"@toolchain_utils//toolchain/constraint/os:windows": "stdout.tmpl.bat",
"//conditions:default": "stdout.tmpl.sh",
}),
visibility = ["//visibility:public"],
)
@echo off
:: Enable Batch extensions
verify other 2>nul
setlocal EnableExtensions
if errorlevel 1 (
echo "Failed to enable extensions"
exit /b 120
)
:: Enable delayed expansion of variables with `!VAR!`
verify other 2>nul
setlocal EnableDelayedExpansion
if errorlevel 1 (
echo "Failed to enable extensions"
exit /b 120
)
:: Bazel substitutions
for /f %%a in ("{{stdout}}") do set "STDOUT=%%~fa"
:: Convert executable to backslash path
set EXE=%1
set EXE=%EXE:/=\%
set ARGS=%*
set ARGS=!ARGS:%1=%EXE%!
:: Redirect the command
%ARGS% >"%STDOUT%"
if %%ERRORLEVEL%% neq 1 exit /b %%ERRORLEVEL%%
#! /usr/bin/env sh
# Strict shell
set -o errexit
set -o nounset
# Substitutions
STDOUT="{{stdout}}"
readonly STDOUT
# Run the command
"${@}" >"${STDOUT}"
load(":rule.bzl", _sha1sum = "sha1sum")
visibility("public")
coreutils_sha1sum = _sha1sum
visibility("//coreutils/...")
ATTRS = {
"srcs": attr.label_list(
doc = "Create SHA1 sum for each file.",
allow_files = True,
allow_empty = False,
mandatory = True,
),
"_template": attr.label(
default = "//coreutils/redirect:stdout",
allow_single_file = True,
),
}
def implementation(ctx):
toolchain = ctx.toolchains["//coreutils/toolchain/sha1sum:type"]
output = ctx.actions.declare_file(ctx.label.name)
rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension))
ctx.actions.expand_template(
template = ctx.file._template,
output = rendered,
is_executable = True,
substitutions = {
"{{stdout}}": output.path,
},
)
args = ctx.actions.args()
args.add(toolchain.executable.path)
args.add_all(ctx.files.srcs)
ctx.actions.run(
inputs = ctx.files.srcs,
tools = [toolchain.executable],
executable = rendered,
arguments = [args],
outputs = [output],
mnemonic = "Sha1Sum",
progress_message = "sha1sum",
toolchain = "//coreutils/toolchain/sha1sum:type",
)
default = DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles([output]),
)
return [default]
coreutils_sha1sum = rule(
doc = "Calculates SHA1 sums for a collection of files.",
attrs = ATTRS,
implementation = implementation,
toolchains = ["//coreutils/toolchain/sha1sum:type"],
)
sha1sum = coreutils_sha1sum
load(":rule.bzl", _sha256sum = "sha256sum")
visibility("public")
coreutils_sha256sum = _sha256sum
visibility("//coreutils/...")
ATTRS = {
"srcs": attr.label_list(
doc = "Create SHA256 sum for each file.",
allow_files = True,
allow_empty = False,
mandatory = True,
),
"_template": attr.label(
default = "//coreutils/redirect:stdout",
allow_single_file = True,
),
}
def implementation(ctx):
toolchain = ctx.toolchains["//coreutils/toolchain/sha256sum:type"]
output = ctx.actions.declare_file(ctx.label.name)
rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension))
ctx.actions.expand_template(
template = ctx.file._template,
output = rendered,
is_executable = True,
substitutions = {
"{{stdout}}": output.path,
},
)
args = ctx.actions.args()
args.add(toolchain.executable.path)
args.add_all(ctx.files.srcs)
ctx.actions.run(
inputs = ctx.files.srcs,
tools = [toolchain.executable],
executable = rendered,
arguments = [args],
outputs = [output],
mnemonic = "Sha1Sum",
progress_message = "sha256sum",
toolchain = "//coreutils/toolchain/sha256sum:type",
)
default = DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles([output]),
)
return [default]
coreutils_sha256sum = rule(
doc = "Calculates SHA256 sums for a collection of files.",
attrs = ATTRS,
implementation = implementation,
toolchains = ["//coreutils/toolchain/sha256sum:type"],
)
sha256sum = coreutils_sha256sum
load(":rule.bzl", _sha3sum = "sha3sum")
visibility("public")
coreutils_sha3sum = _sha3sum
visibility("//coreutils/...")
ATTRS = {
"srcs": attr.label_list(
doc = "Create SHA3 sum for each file.",
allow_files = True,
allow_empty = False,
mandatory = True,
),
"_template": attr.label(
default = "//coreutils/redirect:stdout",
allow_single_file = True,
),
}
def implementation(ctx):
toolchain = ctx.toolchains["//coreutils/toolchain/sha3sum:type"]
output = ctx.actions.declare_file(ctx.label.name)
rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension))
ctx.actions.expand_template(
template = ctx.file._template,
output = rendered,
is_executable = True,
substitutions = {
"{{stdout}}": output.path,
},
)
args = ctx.actions.args()
args.add(toolchain.executable.path)
args.add_all(ctx.files.srcs)
ctx.actions.run(
inputs = ctx.files.srcs,
tools = [toolchain.executable],
executable = rendered,
arguments = [args],
outputs = [output],
mnemonic = "Sha1Sum",
progress_message = "sha3sum",
toolchain = "//coreutils/toolchain/sha3sum:type",
)
default = DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles([output]),
)
return [default]
coreutils_sha3sum = rule(
doc = "Calculates SHA3 sums for a collection of files.",
attrs = ATTRS,
implementation = implementation,
toolchains = ["//coreutils/toolchain/sha3sum:type"],
)
sha3sum = coreutils_sha3sum
load(":rule.bzl", _sha512sum = "sha512sum")
visibility("public")
coreutils_sha512sum = _sha512sum
visibility("//coreutils/...")
ATTRS = {
"srcs": attr.label_list(
doc = "Create SHA512 sum for each file.",
allow_files = True,
allow_empty = False,
mandatory = True,
),
"_template": attr.label(
default = "//coreutils/redirect:stdout",
allow_single_file = True,
),
}
def implementation(ctx):
toolchain = ctx.toolchains["//coreutils/toolchain/sha512sum:type"]
output = ctx.actions.declare_file(ctx.label.name)
rendered = ctx.actions.declare_file("{}.{}".format(ctx.label.name, ctx.file._template.extension))
ctx.actions.expand_template(
template = ctx.file._template,
output = rendered,
is_executable = True,
substitutions = {
"{{stdout}}": output.path,
},
)
args = ctx.actions.args()
args.add(toolchain.executable.path)
args.add_all(ctx.files.srcs)
ctx.actions.run(
inputs = ctx.files.srcs,
tools = [toolchain.executable],
executable = rendered,
arguments = [args],
outputs = [output],
mnemonic = "Sha1Sum",
progress_message = "sha512sum",
toolchain = "//coreutils/toolchain/sha512sum:type",
)
default = DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles([output]),
)
return [default]
coreutils_sha512sum = rule(
doc = "Calculates SHA512 sums for a collection of files.",
attrs = ATTRS,
implementation = implementation,
toolchains = ["//coreutils/toolchain/sha512sum:type"],
)
sha512sum = coreutils_sha512sum