Skip to content

Commit d95ec95

Browse files
committed
verify: Fix for calling verify_examples externally
Signed-off-by: Ryan Northey <ryan@synca.io>
1 parent 14e1ad4 commit d95ec95

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples.bzl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@ def envoy_example(name, shared = ":shared_files", common_fun = ":verify-common.s
1616
name = "%s_dir" % name,
1717
outs = ["%s_dir.tar" % name],
1818
cmd = """
19-
SHARED_PATHS="$(locations %s)"
20-
SHARED=$$(echo $$SHARED_PATHS | cut -d/ -f1)
19+
read -ra SHARED_PATHS <<< "$(locations %s)"
20+
SHARED_DIR=$$(echo $${SHARED_PATHS[0]} | cut -d/ -f1)
2121
# This is a bit hacky and may not work in all bazel situations, but works for now
22-
if [[ $$SHARED == "external" ]]; then
23-
SHARED=$$(echo $$SHARED_PATHS | cut -d/ -f-3)
22+
if [[ $$SHARED_DIR == "external" ]]; then
23+
SHARED_DIR=$$(echo $${SHARED_PATHS[0]} | cut -d/ -f-3)
2424
fi
25-
EXAMPLE_PATHS="$(locations %s_files)"
26-
EXAMPLE=$$(echo $$EXAMPLE_PATHS | cut -d/ -f1)
25+
EXAMPLE=%s
26+
read -ra EXAMPLE_PATHS <<< "$(locations %s_files)"
27+
EXAMPLE_DIR=$$(echo $${EXAMPLE_PATHS[0]} | cut -d/ -f1)
2728
# This is a bit hacky and may not work in all bazel situations, but works for now
28-
if [[ $$EXAMPLE == "external" ]]; then
29-
EXAMPLE=$$(echo $$EXAMPLE_PATHS | cut -d/ -f-3)
29+
if [[ $$EXAMPLE_DIR == "external" ]]; then
30+
EXAMPLE_DIR=$$(echo $$EXAMPLE_PATHS | cut -d/ -f-3)
3031
fi
31-
tar chf $@ -C . $$SHARED $(location %s) $$EXAMPLE
32-
""" % (shared, name, common_fun),
32+
TARGET_DIR=$$(dirname $$EXAMPLE_DIR)
33+
tar chf $@ -C $$TARGET_DIR --exclude="$$(basename "$@")" .
34+
""" % (shared, name, name, common_fun),
3335
tools = [
3436
common_fun,
3537
shared,

0 commit comments

Comments
 (0)