Skip to content

Commit

Permalink
repo/bazel: Make it work externally (#18)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Jul 31, 2024
1 parent 006631c commit cb37c0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 15 additions & 2 deletions examples.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion verify_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit cb37c0c

Please sign in to comment.