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_download
1 result
Show changes
Commits on Source (8)
Showing
with 263 additions and 309 deletions
# [1.0.0-alpha.2](https://git.gitlab.arm.com/bazel/rules_download/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2023-12-08)
### Features
- add Windows support ([1c275c2](https://git.gitlab.arm.com/bazel/rules_download/commit/1c275c20cd80f8cc17ede2adb7dc41e03c359a5c))
# 1.0.0-alpha.1 (2023-12-01)
### Bug Fixes
......
module(
name = "rules_download",
version = "1.0.0-alpha.1",
version = "1.0.0-alpha.2",
bazel_compatibility = [
">=6.4.0",
],
......
......@@ -8,14 +8,14 @@ Use the repository rules in `MODULE.bazel` to download artifacts:
```py
# Download an archive and unpack it
download_archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive")
download_archive = use_repo_rule("@rules_download//download/archive:defs.bzl", "download_archive")
download_archive(
name = "archive",
urls = ["https://some.thing/archive.tar"],
)
# Download a single file and possibly make it executable
download_file = use_repo_rule("@rules_download//download:defs.bzl", "download_file")
download_file = use_repo_rule("@rules_download//download/file:defs.bzl", "download_file")
download_file(
name = "file",
output = "executable",
......@@ -24,7 +24,7 @@ download_file(
)
# Download a Debian package, unpack it then unpack the `data.tar.{xz,zst}`
download_deb = use_repo_rule("@rules_download//download:defs.bzl", "download_deb")
download_deb = use_repo_rule("@rules_download//download/deb:defs.bzl", "download_deb")
download_deb(
name = "deb",
integrity = "sha256-vMiq8kFBwoSrVEE+Tcs08RvaiNp6MsboWlXS7p1clO0=",
......@@ -66,7 +66,7 @@ Hermetic commands can be ran against the unpacked repository. Hermetic binaries
### Sources
By default, the `BUILD.bazel` file exports all files downloaded. This can be controlled with the `srcs` attribute to
customise the files that are exposed the Bazel build.
customise the files that are exposed to the Bazel build.
[sri]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
[commands]: lib/commands.bzl
......
load("//download/archive:repository.bzl", _archive = "archive")
load("//download/file:repository.bzl", _file = "file")
load("//download/deb:repository.bzl", _deb = "deb")
visibility("public")
download_archive = _archive
download_file = _file
download_deb = _deb
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_user_netrc", "use_netrc")
load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download_and_extract.bzl", "download_and_extract", _DOWNLOAD_AND_EXTRACT = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
visibility("//download/...")
ATTRS = _COMMANDS | {
"urls": attr.string_list(
doc = "URLs to download the file.",
mandatory = True,
),
"integrity": attr.string(
doc = "The archive subresource integrity.",
mandatory = False,
),
"strip_prefix": attr.string(
doc = "A prefix to remove from each file in the archive.",
),
"patches": attr.label_list(
doc = "Patches to apply to the downloaded archive.",
allow_files = [".patch"],
),
"srcs": attr.string_list(
doc = "Globs for source files in the unpacked repository.",
default = ["**"],
),
"template": attr.label(
doc = "The `BUILD.bazel` template.",
default = ":BUILD.tmpl.bazel",
allow_single_file = True,
),
}
DOC = """
"""
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD
def implementation(rctx):
canonical = {a: getattr(rctx.attr, a) for a in ATTRS} | {"name": rctx.name}
netrc = read_user_netrc(rctx)
auth = use_netrc(netrc, rctx.attr.urls, {})
chksum = rctx.download_and_extract(
url = [u.replace("%workspace%", str(rctx.workspace_root)) for u in rctx.attr.urls],
integrity = rctx.attr.integrity,
stripPrefix = rctx.attr.strip_prefix,
auth = auth,
)
canonical["integrity"] = chksum.integrity
bld = rctx.path("BUILD.bazel")
if not bld.exists and rctx.attr.template:
rctx.template(bld, rctx.attr.template, {"{{srcs}}": repr(rctx.attr.srcs)}, executable = False)
for patch in rctx.attr.patches:
rctx.patch(patch, strip = 1)
canonical |= download_and_extract(rctx)
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= commands(rctx)
return canonical
archive = repository_rule(
doc = DOC,
implementation = implementation,
attrs = ATTRS,
)
filegroup(
name = "srcs",
srcs = glob({{srcs}}),
visibility = ["//visibility:public"],
)
exports_files(
glob({{srcs}}),
visibility = ["//visibility:public"],
)
load("//download/deb:repository.bzl", _deb = "deb")
visibility("public")
download_deb = _deb
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_user_netrc", "use_netrc")
load("//download/archive:repository.bzl", _ARCHIVE = "ATTRS")
load("//lib:commands.bzl", "commands")
load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download_and_extract.bzl", "download_and_extract", _DOWNLOAD_AND_EXTRACT = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
visibility("//download/...")
ATTRS = _ARCHIVE
DOC = """
"""
def data(path, compressions = ("xz", "zst")):
for compression in compressions:
child = path.get_child("data.tar.{}".format(compression))
if child.exists:
return child
fail("Cannot find data archive in `{}`: {}".format(path, ",".join(path.readdir())))
ATTRS = _COMMANDS | _DOWNLOAD_AND_EXTRACT | _PATCH | _BUILD
def implementation(rctx):
canonical = {a: getattr(rctx.attr, a) for a in ATTRS} | {"name": rctx.name}
netrc = read_user_netrc(rctx)
auth = use_netrc(netrc, rctx.attr.urls, {})
deb = rctx.path(".deb")
chksum = rctx.download_and_extract(
url = [u.replace("%workspace%", str(rctx.workspace_root)) for u in rctx.attr.urls],
integrity = rctx.attr.integrity,
auth = auth,
output = deb,
)
canonical["integrity"] = chksum.integrity
rctx.extract(
archive = data(deb),
stripPrefix = rctx.attr.strip_prefix,
)
rctx.delete(deb)
bld = rctx.path("BUILD.bazel")
if not bld.exists and rctx.attr.template:
rctx.template(bld, rctx.attr.template, {"{{srcs}}": repr(rctx.attr.srcs)}, executable = False)
for patch in rctx.attr.patches:
rctx.patch(patch, strip = 1)
canonical |= download_and_extract(rctx, nested = ("data.tar.xz", "data.tar.zst"))
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= commands(rctx)
return canonical
deb = repository_rule(
doc = "Downloads a `.deb` and unpacks the contained `data.tar.xz` into the repository.",
doc = DOC,
implementation = implementation,
attrs = ATTRS,
)
exports_files({{files}})
exports_files({{srcs}})
load("//download/file:repository.bzl", _file = "file")
visibility("public")
download_file = _file
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "read_user_netrc", "use_netrc")
load("//lib:commands.bzl", "commands", _COMMANDS = "ATTRS")
load("//lib:download.bzl", "download", _DOWNLOAD = "ATTRS")
load("//lib:patch.bzl", "patch", _PATCH = "ATTRS")
load("//lib:build.bzl", "build", _BUILD = "ATTRS")
visibility("//download/...")
ATTRS = _COMMANDS | {
"urls": attr.string_list(
doc = "URLs to download the file.",
mandatory = True,
),
"integrity": attr.string(
doc = "The archive subresource integrity.",
mandatory = False,
),
"output": attr.string(
doc = "The output filename for the downloaded file",
mandatory = True,
),
"patches": attr.label_list(
doc = "Patches to apply to the repository after creation.",
allow_files = [".patch"],
),
"template": attr.label(
DOC = """
"""
ATTRS = _COMMANDS | _DOWNLOAD | _PATCH | _BUILD | {
"build": attr.label(
doc = "The template for the `BUILD.bazel` file.",
default = ":BUILD.tmpl.bazel",
),
"executable": attr.bool(
doc = "Mark the downloaded file as executable.",
default = False,
),
}
def implementation(rctx):
canonical = {a: getattr(rctx.attr, a) for a in ATTRS} | {"name": rctx.name}
netrc = read_user_netrc(rctx)
auth = use_netrc(netrc, rctx.attr.urls, {})
chksum = rctx.download(
url = [u.replace("%workspace%", str(rctx.workspace_root)) for u in rctx.attr.urls],
integrity = rctx.attr.integrity,
auth = auth,
output = rctx.attr.output,
executable = rctx.attr.executable,
)
canonical["integrity"] = chksum.integrity
rctx.template("BUILD.bazel", rctx.attr.template, {"{{files}}": repr([rctx.attr.output])}, executable = False)
for patch in rctx.attr.patches:
rctx.patch(patch, strip = 1)
canonical |= download(rctx)
canonical |= build(rctx)
canonical |= patch(rctx)
canonical |= commands(rctx)
return canonical
file = repository_rule(
doc = DOC,
implementation = implementation,
attrs = ATTRS,
)
# Authentication
common --credential_helper=gitlab.arm.com=%workspace%/.credentials.sh
# Enable `bzlmod`
common --enable_bzlmod
common --registry https://bcr.bazel.build
common --registry=https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.6/downloads
common --registry=https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads
# Build cache
build --experimental_guard_against_concurrent_changes
......
#! /bin/sh
# https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md
# https://github.com/docker/docker-credential-helpers
# Strict shell
set -o errexit -o nounset
# Validate the command
if test ${#} != 1; then
printf >&2 'Error: unexpected number of arguments: %s\n' "${#}"
exit 1
elif test "${1}" != "get"; then
printf >&2 'Error: unexpected credentials command: %s\n' "${1}"
exit 1
fi
# Read in the JSON
while IFS= read -r LINE; do
printf >&2 'Error: unexpected newline on stdin: %s\n' "${LINE}"
exit 2
done
JSON="${LINE}"
readonly JSON
# "Process" the JSON
URI="${JSON}"
URI="${URI#*{}"
URI="${URI#*\"uri\"}"
URI="${URI#*:}"
URI="${URI#*\"}"
URI="${URI%\}*}"
URI="${URI%\"*}"
readonly URI
printf >&2 'URI: %s\n' "${URI}"
# Grab the host
HOST="${URI}"
HOST="${HOST#https://}"
HOST="${HOST#http://}"
HOST="${HOST%%/*}"
readonly HOST
printf >&2 'HOST: %s\n' "${HOST}"
# Attempt to parse the `.netrc`
if test -f "${HOME}/.netrc"; then
while IFS= read -r LINE <&3; do
# shellcheck disable=SC2249
case "${LINE}" in
"machine "*"${HOST}")
while IFS= read -r LINE <&3; do
case "${LINE}" in
"machine "*)
break
;;
"password "*)
printf >&2 'Using network run commands\n'
printf '{"headers":{"Authorization": ["Bearer %s"]}}\n' "${LINE##password }"
exit 0
;;
esac
done
;;
esac
done 3<"${HOME}/.netrc"
fi
if ! test -z ${BZLMOD_TOKEN+x}; then
printf >&2 'Using Bazel Module Token\n'
printf '{"headers":{"PRIVATE-TOKEN": ["%s"]}}\n' "${BZLMOD_TOKEN}"
exit 0
fi
if ! test -z ${GITLAB_TOKEN+x}; then
printf >&2 'Using GitLab Token\n'
printf '{"headers":{"PRIVATE-TOKEN": ["%s"]}}\n' "${GITLAB_TOKEN}"
exit 0
fi
if ! test -z ${CI_JOB_TOKEN+x}; then
printf >&2 'Using CI Job Token\n'
printf '{"headers":{"JOB-TOKEN": ["%s"]}}\n' "${CI_JOB_TOKEN}"
exit 0
fi
printf >&2 'No authentication found\n'
printf '{}\n'
exit 0
......@@ -11,9 +11,9 @@ local_path_override(
path = "..",
)
bazel_dep(name = "rules_toolchain", version = "1.0.0-alpha.6")
bazel_dep(name = "rules_toolchain", version = "1.0.0-alpha.7")
archive = use_repo_rule("@rules_download//download:defs.bzl", "download_archive")
archive = use_repo_rule("@rules_download//download/archive:defs.bzl", "download_archive")
archive(
name = "archive",
......@@ -21,13 +21,8 @@ archive(
"symlink": [
"$(location @coreutils)",
"ln",
"-s",
"fixture.txt",
"symlink.txt",
],
"Hello, world!": [
"$(location //archive:posix.sh)",
"hello-world.txt",
"hardlink.txt",
],
},
integrity = "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -35,13 +30,12 @@ archive(
"//archive:fixture.patch",
],
tools = [
"//archive:posix.sh",
"@coreutils",
],
urls = ["file://%workspace%/archive.tar.xz"],
)
file = use_repo_rule("@rules_download//download:defs.bzl", "download_file")
file = use_repo_rule("@rules_download//download/file:defs.bzl", "download_file")
file(
name = "file",
......@@ -53,7 +47,7 @@ file(
urls = ["file://%workspace%/fixture.txt"],
)
deb = use_repo_rule("@rules_download//download:defs.bzl", "download_deb")
deb = use_repo_rule("@rules_download//download/deb:defs.bzl", "download_deb")
deb(
name = "deb",
......@@ -66,26 +60,43 @@ deb(
archive(
name = "coreutils-arm64-linux-gnu",
build = "//coreutils:BUILD.tmpl.bazel",
integrity = "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=",
strip_prefix = "coreutils-0.0.21-aarch64-unknown-linux-gnu",
template = "//coreutils:BUILD.tmpl.bazel",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"],
)
archive(
name = "coreutils-amd64-linux-gnu",
build = "//coreutils:BUILD.tmpl.bazel",
integrity = "sha256-8zd3E3oh4kLUVnIl2grQyY+RekwvlQVlmZP5ftclnkg=",
strip_prefix = "coreutils-0.0.21-x86_64-unknown-linux-gnu",
template = "//coreutils:BUILD.tmpl.bazel",
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-unknown-linux-gnu.tar.gz"],
)
select = use_repo_rule("@rules_toolchain//toolchain:defs.bzl", "toolchain_local_select")
archive(
name = "coreutils-amd64-windows-msvc",
build = "//coreutils:BUILD.tmpl.bazel",
commands = {
"mklink": [
"$(location //coreutils:mklink.bat)",
"coreutils.exe",
"coreutils",
],
},
integrity = "sha256-MnwdLPwZ+S5/cYPRym8lhcyvazAuhzJaZCmBLAW5+80=",
strip_prefix = "coreutils-0.0.21-x86_64-pc-windows-msvc",
tools = ["//coreutils:mklink.bat"],
urls = ["https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-pc-windows-msvc.zip"],
)
select = use_repo_rule("@rules_toolchain//toolchain/local/select:defs.bzl", "toolchain_local_select")
select(
name = "coreutils",
map = {
"arm64-linux-gnu": "@coreutils-arm64-linux-gnu",
"amd64-linux-gnu": "@coreutils-amd64-linux-gnu",
"amd64-windows": "@coreutils-amd64-windows-msvc",
},
)
{
"lockFileVersion": 3,
"moduleFileHash": "c98bed9985e834a886ad4ab6e142a15cd0360bb5b540196b2e7b2255bc7539ed",
"moduleFileHash": "a34c0b63dce3db2326406704501bec857b10fd3f1ab2c2c2e417da842b36547f",
"flags": {
"cmdRegistries": [
"https://bcr.bazel.build",
"https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.6/downloads"
"https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads"
],
"cmdModuleOverrides": {},
"allowedYankedVersions": [],
......@@ -41,24 +41,20 @@
"deb": "deb",
"coreutils-arm64-linux-gnu": "coreutils-arm64-linux-gnu",
"coreutils-amd64-linux-gnu": "coreutils-amd64-linux-gnu",
"coreutils-amd64-windows-msvc": "coreutils-amd64-windows-msvc",
"coreutils": "coreutils"
},
"devImports": [],
"tags": [
{
"tagName": "@rules_download//download:defs.bzl%download_archive",
"tagName": "@rules_download//download/archive:defs.bzl%download_archive",
"attributeValues": {
"commands": {
"symlink": [
"$(location @coreutils)",
"ln",
"-s",
"fixture.txt",
"symlink.txt"
],
"Hello, world!": [
"$(location //archive:posix.sh)",
"hello-world.txt"
"hardlink.txt"
]
},
"integrity": "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -66,7 +62,6 @@
"//archive:fixture.patch"
],
"tools": [
"//archive:posix.sh",
"@coreutils"
],
"urls": [
......@@ -82,7 +77,7 @@
}
},
{
"tagName": "@rules_download//download:defs.bzl%download_file",
"tagName": "@rules_download//download/file:defs.bzl%download_file",
"attributeValues": {
"integrity": "sha256-2QFMRiSESqW6wxR3PWtomtRn+k4dGlChuKmdWpX3L/U=",
"output": "fixture.txt",
......@@ -97,12 +92,12 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 46,
"line": 40,
"column": 5
}
},
{
"tagName": "@rules_download//download:defs.bzl%download_deb",
"tagName": "@rules_download//download/deb:defs.bzl%download_deb",
"attributeValues": {
"integrity": "sha256-vMiq8kFBwoSrVEE+Tcs08RvaiNp6MsboWlXS7p1clO0=",
"patches": [
......@@ -116,16 +111,16 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 58,
"line": 52,
"column": 4
}
},
{
"tagName": "@rules_download//download:defs.bzl%download_archive",
"tagName": "@rules_download//download/archive:defs.bzl%download_archive",
"attributeValues": {
"build": "//coreutils:BUILD.tmpl.bazel",
"integrity": "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=",
"strip_prefix": "coreutils-0.0.21-aarch64-unknown-linux-gnu",
"template": "//coreutils:BUILD.tmpl.bazel",
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"
],
......@@ -134,16 +129,16 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 67,
"line": 61,
"column": 8
}
},
{
"tagName": "@rules_download//download:defs.bzl%download_archive",
"tagName": "@rules_download//download/archive:defs.bzl%download_archive",
"attributeValues": {
"build": "//coreutils:BUILD.tmpl.bazel",
"integrity": "sha256-8zd3E3oh4kLUVnIl2grQyY+RekwvlQVlmZP5ftclnkg=",
"strip_prefix": "coreutils-0.0.21-x86_64-unknown-linux-gnu",
"template": "//coreutils:BUILD.tmpl.bazel",
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-unknown-linux-gnu.tar.gz"
],
......@@ -152,23 +147,52 @@
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 75,
"line": 69,
"column": 8
}
},
{
"tagName": "@rules_toolchain//toolchain:defs.bzl%toolchain_local_select",
"tagName": "@rules_download//download/archive:defs.bzl%download_archive",
"attributeValues": {
"build": "//coreutils:BUILD.tmpl.bazel",
"commands": {
"mklink": [
"$(location //coreutils:mklink.bat)",
"coreutils.exe",
"coreutils"
]
},
"integrity": "sha256-MnwdLPwZ+S5/cYPRym8lhcyvazAuhzJaZCmBLAW5+80=",
"strip_prefix": "coreutils-0.0.21-x86_64-pc-windows-msvc",
"tools": [
"//coreutils:mklink.bat"
],
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-pc-windows-msvc.zip"
],
"name": "coreutils-amd64-windows-msvc"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 77,
"column": 8
}
},
{
"tagName": "@rules_toolchain//toolchain/local/select:defs.bzl%toolchain_local_select",
"attributeValues": {
"map": {
"arm64-linux-gnu": "@coreutils-arm64-linux-gnu",
"amd64-linux-gnu": "@coreutils-amd64-linux-gnu"
"amd64-linux-gnu": "@coreutils-amd64-linux-gnu",
"amd64-windows": "@coreutils-amd64-windows-msvc"
},
"name": "coreutils"
},
"devDependency": false,
"location": {
"file": "@@//:MODULE.bazel",
"line": 85,
"line": 95,
"column": 7
}
}
......@@ -179,7 +203,7 @@
],
"deps": {
"rules_download": "rules_download@_",
"rules_toolchain": "rules_toolchain@1.0.0-alpha.6",
"rules_toolchain": "rules_toolchain@1.0.0-alpha.7",
"bazel_tools": "bazel_tools@_",
"local_config_platform": "local_config_platform@_"
}
......@@ -197,10 +221,10 @@
"local_config_platform": "local_config_platform@_"
}
},
"rules_toolchain@1.0.0-alpha.6": {
"rules_toolchain@1.0.0-alpha.7": {
"name": "rules_toolchain",
"version": "1.0.0-alpha.6",
"key": "rules_toolchain@1.0.0-alpha.6",
"version": "1.0.0-alpha.7",
"key": "rules_toolchain@1.0.0-alpha.7",
"repoName": "rules_toolchain",
"executionPlatformsToRegister": [],
"toolchainsToRegister": [],
......@@ -208,28 +232,41 @@
{
"extensionBzlFile": "//:MODULE.bazel",
"extensionName": "_repo_rules",
"usingModule": "rules_toolchain@1.0.0-alpha.6",
"usingModule": "rules_toolchain@1.0.0-alpha.7",
"location": {
"file": "https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.6/downloads/modules/rules_toolchain/1.0.0-alpha.6/MODULE.bazel",
"file": "https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads/modules/rules_toolchain/1.0.0-alpha.7/MODULE.bazel",
"line": 0,
"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"
},
"devDependency": false,
"location": {
"file": "https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.6/downloads/modules/rules_toolchain/1.0.0-alpha.6/MODULE.bazel",
"line": 14,
"file": "https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads/modules/rules_toolchain/1.0.0-alpha.7/MODULE.bazel",
"line": 15,
"column": 8
}
},
{
"tagName": "//toolchain/launcher:repository.bzl%launcher",
"attributeValues": {
"name": "launcher"
},
"devDependency": false,
"location": {
"file": "https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads/modules/rules_toolchain/1.0.0-alpha.7/MODULE.bazel",
"line": 21,
"column": 9
}
}
],
"hasDevUseExtension": false,
......@@ -246,12 +283,12 @@
"bzlFile": "@bazel_tools//tools/build_defs/repo:http.bzl",
"ruleClassName": "http_archive",
"attributes": {
"name": "rules_toolchain~1.0.0-alpha.6",
"name": "rules_toolchain~1.0.0-alpha.7",
"urls": [
"https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.6/downloads/src.tar.gz"
"https://gitlab.arm.com/bazel/rules_toolchain/-/releases/v1.0.0-alpha.7/downloads/src.tar.gz"
],
"integrity": "sha512-RV4aLbaSBS8VuA9JR7RhJ+6Ny+Eej8dkCUyY3cBpE9PMCrkbHuvhflMWOK0TqxRNTvO6NxguZ4bF0tvr4HGEew==",
"strip_prefix": "rules_toolchain-v1.0.0-alpha.6",
"integrity": "sha512-a+uRKHkB5UMbweDFAoL9lDBQAHg98/LDU9LgTu16WMSOCJynbJxWrEpjrNSrD2EM1DeZVjNbe/ZeIhOJXhx+XA==",
"strip_prefix": "rules_toolchain-v1.0.0-alpha.7",
"remote_patches": {},
"remote_patch_strip": 0
}
......@@ -851,7 +888,7 @@
"moduleExtensions": {
"//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "GCKKnN7t3GZuia4vflzwjBxUGsnXtaiNg14ezmer5C0=",
"bzlTransitiveDigest": "MD6B4Z6FQIQiobtHHkoG8Ore0k3X37moHGyWsvSpNSY=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
......@@ -863,13 +900,8 @@
"symlink": [
"$(location @coreutils)",
"ln",
"-s",
"fixture.txt",
"symlink.txt"
],
"Hello, world!": [
"$(location //archive:posix.sh)",
"hello-world.txt"
"hardlink.txt"
]
},
"integrity": "sha256-PWscbDJ+esMLMe4/ix5LTP+lsR1piMNe7r9eHsx/KOg=",
......@@ -877,7 +909,6 @@
"@@//archive:fixture.patch"
],
"tools": [
"@@//archive:posix.sh",
"@@_main~_repo_rules~coreutils//:coreutils"
],
"urls": [
......@@ -919,9 +950,9 @@
"bzlFile": "@@rules_download~override//download/archive:repository.bzl",
"ruleClassName": "archive",
"attributes": {
"build": "@@//coreutils:BUILD.tmpl.bazel",
"integrity": "sha256-mlmkbeabyu4+5+cFiUSL6Ki4KFNqWu48gTjFc3NS43g=",
"strip_prefix": "coreutils-0.0.21-aarch64-unknown-linux-gnu",
"template": "@@//coreutils:BUILD.tmpl.bazel",
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-aarch64-unknown-linux-gnu.tar.gz"
],
......@@ -932,28 +963,75 @@
"bzlFile": "@@rules_download~override//download/archive:repository.bzl",
"ruleClassName": "archive",
"attributes": {
"build": "@@//coreutils:BUILD.tmpl.bazel",
"integrity": "sha256-8zd3E3oh4kLUVnIl2grQyY+RekwvlQVlmZP5ftclnkg=",
"strip_prefix": "coreutils-0.0.21-x86_64-unknown-linux-gnu",
"template": "@@//coreutils:BUILD.tmpl.bazel",
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-unknown-linux-gnu.tar.gz"
],
"name": "_main~_repo_rules~coreutils-amd64-linux-gnu"
}
},
"coreutils-amd64-windows-msvc": {
"bzlFile": "@@rules_download~override//download/archive:repository.bzl",
"ruleClassName": "archive",
"attributes": {
"build": "@@//coreutils:BUILD.tmpl.bazel",
"commands": {
"mklink": [
"$(location //coreutils:mklink.bat)",
"coreutils.exe",
"coreutils"
]
},
"integrity": "sha256-MnwdLPwZ+S5/cYPRym8lhcyvazAuhzJaZCmBLAW5+80=",
"strip_prefix": "coreutils-0.0.21-x86_64-pc-windows-msvc",
"tools": [
"@@//coreutils:mklink.bat"
],
"urls": [
"https://github.com/uutils/coreutils/releases/download/0.0.21/coreutils-0.0.21-x86_64-pc-windows-msvc.zip"
],
"name": "_main~_repo_rules~coreutils-amd64-windows-msvc"
}
},
"coreutils": {
"bzlFile": "@@rules_toolchain~1.0.0-alpha.6//toolchain/local/select:repository.bzl",
"bzlFile": "@@rules_toolchain~1.0.0-alpha.7//toolchain/local/select:repository.bzl",
"ruleClassName": "select",
"attributes": {
"map": {
"arm64-linux-gnu": "@coreutils-arm64-linux-gnu",
"amd64-linux-gnu": "@coreutils-amd64-linux-gnu"
"amd64-linux-gnu": "@coreutils-amd64-linux-gnu",
"amd64-windows": "@coreutils-amd64-windows-msvc"
},
"name": "_main~_repo_rules~coreutils"
}
}
}
}
},
"@@rules_toolchain~1.0.0-alpha.7//:MODULE.bazel%_repo_rules": {
"general": {
"bzlTransitiveDigest": "CSJxsw5u8tv972NPHJazAfB/a3Rb8wU8pXWhqZJv+Wk=",
"accumulatedFileDigests": {},
"envVariables": {},
"generatedRepoSpecs": {
"local": {
"bzlFile": "@@rules_toolchain~1.0.0-alpha.7//toolchain/local/triplet:repository.bzl",
"ruleClassName": "triplet",
"attributes": {
"name": "rules_toolchain~1.0.0-alpha.7~_repo_rules~local"
}
},
"launcher": {
"bzlFile": "@@rules_toolchain~1.0.0-alpha.7//toolchain/launcher:repository.bzl",
"ruleClassName": "launcher",
"attributes": {
"name": "rules_toolchain~1.0.0-alpha.7~_repo_rules~launcher"
}
}
}
}
}
}
}
......@@ -10,13 +10,6 @@ diff_test(
diff_test(
name = "symlink",
size = "small",
file1 = "@archive//:symlink.txt",
file1 = "@archive//:hardlink.txt",
file2 = ":fixture.txt",
)
diff_test(
name = "hello-world",
size = "small",
file1 = "@archive//:hello-world.txt",
file2 = ":hello-world.txt",
)
#! /bin/sh
# e: quit on command errors
# u: quit on undefined variables
set -eu
echo "Hello, world!" >"${1}"
@echo off
:: Enable Batch extensions
verify other 2>nul
setlocal EnableExtensions
if errorlevel 1 (
echo "Failed to enable extensions"
exit /b 120
)
:: Process arguments
set "LINKNAME=%~1"
set "FILEPATH=%~2"
:: Hardlink
mklink /h "%FILEPATH%" "%LINKNAME%"
\ No newline at end of file
visibility("//download/...")
ATTRS = {
"build": attr.label(
doc = "The template for the `BUILD.bazel` file.",
default = ":BUILD.tmpl.bazel",
),
}
def build(rctx):
"""
A mixin for `download` repository rules that patches files after download.
Args:
rctx: The download repository context.
Returns:
A map of canonical arguments
"""
substitutions = {}
if hasattr(rctx.attr, "output"):
substitutions["{{srcs}}"] = repr([rctx.attr.output])
elif hasattr(rctx.attr, "srcs"):
substitutions["{{srcs}}"] = repr(rctx.attr.srcs)
else:
fail("No supported attributes")
rctx.template("BUILD.bazel", rctx.attr.build, substitutions, executable = False)
return {}