Skip to content

Commit

Permalink
bazel/unpacker: Fix empty placeholder (#2390)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Nov 4, 2024
1 parent 55782b2 commit 227cf35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 4 additions & 1 deletion bazel/tarball/BUILD
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
exports_files(["unpack.sh"])
exports_files([
"PLACEHOLDER.TXT",
"unpack.sh",
])
16 changes: 15 additions & 1 deletion bazel/tarball/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ def unpacker(
zstd = None,
visibility = ["//visibility:public"],
):

native.genrule(
name = "placeholder",
outs = ["PLACEHOLDER.TXT"],
cmd = """
touch $@
""",
)

native.filegroup(
name = "true",
srcs = [],
Expand All @@ -15,9 +24,14 @@ def unpacker(
srcs = [],
)

native.filegroup(
name = "empty",
srcs = [":placeholder"],
)

native.label_flag(
name = "target",
build_setting_default = ":false",
build_setting_default = ":empty",
visibility = ["//visibility:public"],
)

Expand Down
2 changes: 1 addition & 1 deletion bazel/tarball/unpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TARGET="${TARGET:-}"
OVERWRITE="${OVERWRITE:-}"
EXTRACT_PATH="$1"

if [[ -z "$TARGET" ]]; then
if [[ -z "$TARGET" || "$TARGET" == "PLACEHOLDER.TXT" ]]; then
echo "TARGET must be provided using a bazel flag." >&2
exit 1
fi
Expand Down

0 comments on commit 227cf35

Please sign in to comment.