Skip to content

Commit

Permalink
[Scripts] Add script for simple zaptool startup (project-chip#8292)
Browse files Browse the repository at this point in the history
* Add script for starting zaptool easily

* run_zaptool script: exit on setup failure

* run_zaptool script: Added copyrights, formatting

* Restyled by whitespace

* Restyled by shellharden

* Restyled by shfmt

* run_zaptool script: Changes for compatibility with macOS, replacing configure.sh

* Restyled by prettier-markdown

* Restyled by shellharden

* Restyled by shfmt

* run_zaptool script: fix CWD cornercase

* Restyled by shfmt

* Update scripts/tools/zap/run_zaptool.sh

Co-authored-by: Łukasz Duda <lukasz.duda@nordicsemi.no>

* Revert "Update scripts/tools/zap/run_zaptool.sh"

This reverts commit 6eab9fd.

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Łukasz Duda <lukasz.duda@nordicsemi.no>
  • Loading branch information
3 people authored and Nikita committed Sep 23, 2021
1 parent 70115bf commit 120333b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
22 changes: 0 additions & 22 deletions scripts/tools/zap/configure.sh

This file was deleted.

53 changes: 53 additions & 0 deletions scripts/tools/zap/run_zaptool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

#
# Copyright (c) 2021 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

function _get_fullpath() {
cd "$(dirname "$1")" && echo "$PWD/$(basename "$1")"
}

set -e

[[ "$1" == "--help" ]] && {
echo "Usage: $0 [ZAP-file-path]" >&2
exit 0
}

SCRIPT_PATH="$(_get_fullpath "$0")"
CHIP_ROOT="${SCRIPT_PATH%/scripts/tools/zap/run_zaptool.sh}"
[[ -n "$1" ]] && ZAP_ARGS=(-i "$(_get_fullpath "$1")") || ZAP_ARGS=()

(

cd "$CHIP_ROOT" &&
git submodule update --init third_party/zap/repo

cd "third_party/zap/repo"
if ! npm list installed-check &>/dev/null; then
npm install installed-check
fi

if ! ./node_modules/.bin/installed-check -c &>/dev/null; then
npm install
fi

node src-script/zap-start.js --logToStdout \
--gen "$CHIP_ROOT/src/app/zap-templates/app-templates.json" \
--zcl "$CHIP_ROOT/src/app/zap-templates/zcl/zcl.json" \
"${ZAP_ARGS[@]}"

)
8 changes: 7 additions & 1 deletion src/app/zap-templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ This directory contains generation templates for ZAP, ZCL Advanced Platform.
Run ZAP with UI to configure endpoints and clusters

```
./scripts/tools/zap/configure.sh
./scripts/tools/zap/run_zaptool.sh
```

or

```
./scripts/tools/zap/run_zaptool.sh <path to *.zap file>
```

### How to generate files for all applications
Expand Down

0 comments on commit 120333b

Please sign in to comment.