Skip to content

Commit a068855

Browse files
authored
Add --zap ZAP to run_zaptool.sh to specify an arbitrary location to zap (project-chip#35549). (project-chip#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`.
1 parent f78dad4 commit a068855

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

docs/code_generation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Since this is tedious to type, the SDK provides a
6666
`scripts/tools/zap/run_zaptool.sh` script to automate this:
6767

6868
```bash
69-
# Ensure zap is in $PATH or set $ZAP_INSTALL_PATH or $ZAP_DEVELOPMENT_PATH
69+
# 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
7070
./scripts/tools/zap/run_zaptool.sh examples/lighting-app/lighting-common/lighting-app.zap
7171
```
7272

scripts/tools/zap/run_zaptool.sh

+26-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# limitations under the License.
1717
#
1818

19+
readonly ZAP_CMD_DEFAULT="zap"
20+
21+
ZAP_CMD="$ZAP_CMD_DEFAULT"
1922
ZAP_FILE=""
2023

2124
function _get_fullpath() {
@@ -39,6 +42,22 @@ function _print_usage() {
3942
echo " General Options:"
4043
echo ""
4144
echo " -h, --help Display this help, then exit."
45+
echo " --zap ZAP Use the zap program ZAP as the zap executable "
46+
echo " to run (default: $ZAP_CMD_DEFAULT)."
47+
echo ""
48+
echo " Some influential environment variables:"
49+
echo ""
50+
echo " ZAP_DEVELOPMENT_PATH The path to a zap development environment. This "
51+
echo " is likely a zap checkout, used for local "
52+
echo " development (current: \"${ZAP_DEVELOPMENT_PATH:-<null>}\")."
53+
echo ""
54+
echo " If set, this overrides both the '--zap' option "
55+
echo " and the 'ZAP_INTALL_PATH' environment variable."
56+
echo " ZAP_INSTALL_PATH The path where the 'zap' executable exists. "
57+
echo " This may be used if 'zap' is NOT in the current "
58+
echo " PATH (current: \"${ZAP_INSTALL_PATH:-<null>}\")."
59+
echo ""
60+
echo " If set, this overrides the '--zap' option."
4261
echo ""
4362
fi
4463

@@ -59,6 +78,11 @@ while [ "${#}" -gt 0 ]; do
5978
_print_usage 0
6079
;;
6180

81+
--zap)
82+
ZAP_CMD="${2}"
83+
shift 2
84+
;;
85+
6286
-*)
6387
echo "ERROR: Unknown or invalid option: '${1}'" >&2
6488
_print_usage 1
@@ -101,13 +125,14 @@ elif [ -n "$ZAP_INSTALL_PATH" ]; then
101125
fi
102126
WORKING_DIR="$CHIP_ROOT"
103127
else
104-
ZAP_CMD="zap"
128+
[ -z "$ZAP_CMD" ] && ZAP_CMD="$ZAP_CMD_DEFAULT"
105129
WORKING_DIR="$CHIP_ROOT"
106130
fi
107131

108132
(
109133
cd "$WORKING_DIR"
110134

135+
echo "CMD: $ZAP_CMD"
111136
echo "ARGS: $ZAP_ARGS"
112137

113138
if [[ "${ZAP_ARGS[*]}" == *"/all-clusters-app.zap"* ]]; then

0 commit comments

Comments
 (0)