Skip to content

Commit

Permalink
Add --zap ZAP to run_zaptool.sh to specify an arbitrary location …
Browse files Browse the repository at this point in the history
…to `zap` (project-chip#35549).

    * 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`.
  • Loading branch information
gerickson committed Sep 13, 2024
1 parent 236908d commit 3c63ad3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/code_generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
27 changes: 26 additions & 1 deletion scripts/tools/zap/run_zaptool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# limitations under the License.
#

readonly ZAP_CMD_DEFAULT="zap"

ZAP_CMD="$ZAP_CMD_DEFAULT"
ZAP_FILE=""

function _get_fullpath() {
Expand All @@ -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:-<null>}\")."
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:-<null>}\")."
echo ""
echo " If set, this overrides the '--zap' option."
echo ""
fi

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3c63ad3

Please sign in to comment.