From a068855d27b42b2c17d38b3a8a9d30d672163aee Mon Sep 17 00:00:00 2001 From: Grant Erickson Date: Fri, 13 Sep 2024 15:48:49 -0700 Subject: [PATCH] Add `--zap ZAP` to `run_zaptool.sh` to specify an arbitrary location to `zap` (#35549). (#35582) * scripts/tools/zap/run_zaptool.sh * Display the value of 'ZAP_CMD' to standard output. * Add support for the `--zap` command line option to specify the `zap` executable to run. * Added usage documentation about `ZAP_DEVELOPMENT_PATH` and `ZAP_INSTALL_PATH`. * docs/code_generation.md: Added documentation about the `--zap ZAP` option to `run_zaptool.sh`. --- docs/code_generation.md | 2 +- scripts/tools/zap/run_zaptool.sh | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/code_generation.md b/docs/code_generation.md index e12bf40f100cff..bf5b6f3036963a 100644 --- a/docs/code_generation.md +++ b/docs/code_generation.md @@ -66,7 +66,7 @@ Since this is tedious to type, the SDK provides a `scripts/tools/zap/run_zaptool.sh` script to automate this: ```bash -# Ensure zap is in $PATH or set $ZAP_INSTALL_PATH or $ZAP_DEVELOPMENT_PATH +# Ensure `zap` is in $PATH, specify the `--zap ZAP` option to `run_zaptool.sh` to specify the path to `zap`, set $ZAP_INSTALL_PATH, or set $ZAP_DEVELOPMENT_PATH ./scripts/tools/zap/run_zaptool.sh examples/lighting-app/lighting-common/lighting-app.zap ``` diff --git a/scripts/tools/zap/run_zaptool.sh b/scripts/tools/zap/run_zaptool.sh index 4caf9d5610076f..52efc26abeaaee 100755 --- a/scripts/tools/zap/run_zaptool.sh +++ b/scripts/tools/zap/run_zaptool.sh @@ -16,6 +16,9 @@ # limitations under the License. # +readonly ZAP_CMD_DEFAULT="zap" + +ZAP_CMD="$ZAP_CMD_DEFAULT" ZAP_FILE="" function _get_fullpath() { @@ -39,6 +42,22 @@ function _print_usage() { echo " General Options:" echo "" echo " -h, --help Display this help, then exit." + echo " --zap ZAP Use the zap program ZAP as the zap executable " + echo " to run (default: $ZAP_CMD_DEFAULT)." + echo "" + echo " Some influential environment variables:" + echo "" + echo " ZAP_DEVELOPMENT_PATH The path to a zap development environment. This " + echo " is likely a zap checkout, used for local " + echo " development (current: \"${ZAP_DEVELOPMENT_PATH:-}\")." + echo "" + echo " If set, this overrides both the '--zap' option " + echo " and the 'ZAP_INTALL_PATH' environment variable." + echo " ZAP_INSTALL_PATH The path where the 'zap' executable exists. " + echo " This may be used if 'zap' is NOT in the current " + echo " PATH (current: \"${ZAP_INSTALL_PATH:-}\")." + echo "" + echo " If set, this overrides the '--zap' option." echo "" fi @@ -59,6 +78,11 @@ while [ "${#}" -gt 0 ]; do _print_usage 0 ;; + --zap) + ZAP_CMD="${2}" + shift 2 + ;; + -*) echo "ERROR: Unknown or invalid option: '${1}'" >&2 _print_usage 1 @@ -101,13 +125,14 @@ elif [ -n "$ZAP_INSTALL_PATH" ]; then fi WORKING_DIR="$CHIP_ROOT" else - ZAP_CMD="zap" + [ -z "$ZAP_CMD" ] && ZAP_CMD="$ZAP_CMD_DEFAULT" WORKING_DIR="$CHIP_ROOT" fi ( cd "$WORKING_DIR" + echo "CMD: $ZAP_CMD" echo "ARGS: $ZAP_ARGS" if [[ "${ZAP_ARGS[*]}" == *"/all-clusters-app.zap"* ]]; then