From 7b730a559b0cd9c43b1863b699d5a68c7abbd7cf Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Wed, 31 Jul 2024 17:34:46 +0100 Subject: [PATCH] repo: Make it work externally Signed-off-by: Ryan Northey --- examples.bzl | 17 +++++++++++++++-- verify_example.sh | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples.bzl b/examples.bzl index e24728d..b337a20 100644 --- a/examples.bzl +++ b/examples.bzl @@ -11,8 +11,21 @@ def envoy_example(name, shared = ":shared_files", common_fun = ":verify-common.s name = "%s_dir" % name, outs = ["%s_dir.tar" % name], cmd = """ - tar chf $@ -C . shared verify-common.sh %s - """ % name, + SHARED_PATHS="$(locations %s)" + SHARED=$$(echo $$SHARED_PATHS | cut -d/ -f1) + # This is a bit hacky and may not work in all bazel situations, but works for now + if [[ $$SHARED == "external" ]]; then + SHARED=$$(echo $$SHARED_PATHS | cut -d/ -f-3) + fi + EXAMPLE_PATHS="$(locations %s_files)" + EXAMPLE=$$(echo $$EXAMPLE_PATHS | cut -d/ -f1) + # This is a bit hacky and may not work in all bazel situations, but works for now + if [[ $$EXAMPLE == "external" ]]; then + EXAMPLE=$$(echo $$EXAMPLE_PATHS | cut -d/ -f-3) + fi + + tar chf $@ -C . $$SHARED $(location %s) $$EXAMPLE + """ % (shared, name, common_fun), tools = [ common_fun, shared, diff --git a/verify_example.sh b/verify_example.sh index 4bb86a9..cb54310 100755 --- a/verify_example.sh +++ b/verify_example.sh @@ -24,7 +24,13 @@ complete () { verify () { tar xf $EXAMPLE_DIR -C $RUNDIR - cd "$RUNDIR/${EXAMPLE_NAME}" + cd "$RUNDIR" + dirlist=$(ls .) + if [[ "$dirlist" == "external" ]]; then + cd "external/envoy_examples/${EXAMPLE_NAME}" + else + cd "${EXAMPLE_NAME}" + fi script -q -c "unbuffer ./verify.sh" "$TMPOUT" >/dev/null }