regenerate-meson: improve search for sdbus++ tool
Improve search for sdbus++-gen-meson so that this works both
within SDK (where sdbus++-gen-meson is in the path) and from
submodule.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ifea44b67a8e8563c2f2612981bbb5605e7ed2e53
diff --git a/gen/regenerate-meson b/gen/regenerate-meson
index b9cb192..6c32c46 100755
--- a/gen/regenerate-meson
+++ b/gen/regenerate-meson
@@ -1,3 +1,23 @@
-#!/bin/sh
-${SDBUSPP_GEN_MESON:=../subprojects/sdbusplus/tools/sdbus++-gen-meson} \
- --directory .. --command meson --output .
+#!/bin/bash
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+
+# Find sdbus++-gen-meson
+# 1. Check $SDBUSPP_GEN_MESON
+# 2. Check in $PATH
+# 3. Check in subprojects/sdbusplus
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$(which sdbus++-gen-meson 2> /dev/null)"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$REPO_ROOT/subprojects/sdbusplus/tools/sdbus++-gen-meson"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ echo "Cannot find sdbus++-gen-meson ($SDBUSPP_GEN_MESON)."
+ exit 1
+fi
+
+$SDBUSPP_GEN_MESON \
+ --command meson \
+ --directory $REPO_ROOT \
+ --output $REPO_ROOT/gen