This commit is contained in:
Paolo Tranquilli 2024-06-05 14:46:59 +02:00
Родитель 44a56c420f
Коммит 61847bc58b
16 изменённых файлов: 73 добавлений и 27 удалений

2
.gitattributes поставляемый
Просмотреть файл

@ -83,7 +83,7 @@
/csharp/paket.main_extension.bzl linguist-generated=true
# ripunzip tool
/misc/bazel/internal/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text
/misc/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text
# swift prebuilt resources
/swift/third_party/resource-dir/*.zip filter=lfs diff=lfs merge=lfs -text

Просмотреть файл

@ -118,19 +118,19 @@ lfs_files = use_repo_rule("//misc/bazel:lfs.bzl", "lfs_files")
lfs_files(
name = "ripunzip-linux",
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-linux"],
srcs = ["//misc/ripunzip:ripunzip-linux"],
executable = True,
)
lfs_files(
name = "ripunzip-windows",
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-windows.exe"],
srcs = ["//misc/ripunzip:ripunzip-windows.exe"],
executable = True,
)
lfs_files(
name = "ripunzip-macos",
srcs = ["//misc/bazel/internal/ripunzip:ripunzip-macos"],
srcs = ["//misc/ripunzip:ripunzip-macos"],
executable = True,
)

Просмотреть файл

@ -7,3 +7,10 @@ buildifier(
],
lint_mode = "fix",
)
sh_library(
name = "sh_runfiles",
srcs = ["runfiles.sh"],
visibility = ["//visibility:public"],
deps = ["@bazel_tools//tools/bash/runfiles"],
)

Просмотреть файл

@ -1,8 +0,0 @@
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
native_binary(
name = "ripunzip",
src = select({"@platforms//os:" + os: "@ripunzip-" + os for os in ("linux", "windows", "macos")}),
out = "ripunzip.exe",
visibility = ["//visibility:public"],
)

Просмотреть файл

@ -1,2 +0,0 @@
These LFS files are distributions of [ripunzip](https://github.com/google/ripunzip), compiled with this [workflow](https://github.com/github/codeql/actions/workflows/build-ripunzip.yml).
A [copy](./LICENSE.txt) of the ripunzip license is included.

Просмотреть файл

@ -364,7 +364,7 @@ def codeql_pack(
internal("script"),
] + ([
internal("zip-manifest"),
Label("//misc/bazel/internal/ripunzip"),
Label("//misc/ripunzip"),
] if zips else []),
deps = ["@rules_python//python/runfiles"],
args = [
@ -373,7 +373,7 @@ def codeql_pack(
"--destdir",
install_dest,
] + ([
"--ripunzip=$(rlocationpath %s)" % Label("//misc/bazel/internal/ripunzip"),
"--ripunzip=$(rlocationpath %s)" % Label("//misc/ripunzip"),
"--zip-manifest=$(rlocationpath %s)" % internal("zip-manifest"),
] if zips else []),
visibility = visibility,

10
misc/bazel/runfiles.sh Normal file
Просмотреть файл

@ -0,0 +1,10 @@
# --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

13
misc/ripunzip/BUILD.bazel Normal file
Просмотреть файл

@ -0,0 +1,13 @@
alias(
name = "ripunzip",
actual = select({"@platforms//os:" + os: "@ripunzip-" + os for os in ("linux", "windows", "macos")}),
visibility = ["//visibility:public"],
)
sh_binary(
name = "install",
srcs = ["install.sh"],
args = ["$(rlocationpath :ripunzip)"],
data = [":ripunzip"],
deps = ["//misc/bazel:sh_runfiles"],
)

Просмотреть файл

11
misc/ripunzip/README.md Normal file
Просмотреть файл

@ -0,0 +1,11 @@
These LFS files are distributions of [ripunzip](https://github.com/google/ripunzip), compiled with this [workflow](https://github.com/github/codeql/actions/workflows/build-ripunzip.yml).
A [copy](./LICENSE.txt) of the ripunzip license is included.
`ripunzip` can easily be made available on the system by running
```bash
bazel run //misc/ripunzip:install
```
By default, it will be installed in `~/.local/bin`. The target can be changed with
```bash
bazel run //misc/ripunzip:install -- /path/to/installation/dir
```

24
misc/ripunzip/install.sh Executable file
Просмотреть файл

@ -0,0 +1,24 @@
#!/bin/bash
set -eu
. misc/bazel/runfiles.sh
dest="${2:-$HOME/.local/bin}"
if [ ! -d "$dest" ]; then
echo "$dest: not a directory. Provide a valid installation target." >&2
exit 1
fi
source="$(rlocation "$1")"
dest+="/ripunzip"
if [[ "$source" = *.exe ]]; then
dest+=".exe"
fi
cp "$source" "$dest"
echo "installed $("$dest" --version) in $(dirname "$dest")"

2
swift/third_party/resource-dir/BUILD.bazel поставляемый
Просмотреть файл

@ -21,7 +21,7 @@ alias(
"@swift_toolchain_" + os,
],
target_compatible_with = ["@platforms//os:" + os],
deps = ["@bazel_tools//tools/bash/runfiles"],
deps = ["//misc/bazel:sh_runfiles"],
)
for os in ("linux", "macos")
]

11
swift/third_party/resource-dir/update.sh поставляемый Executable file → Normal file
Просмотреть файл

@ -1,12 +1,3 @@
# --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---
. misc/bazel/runfiles.sh
cp "$(rlocation "$1")" "$(rlocation "$2")"