Skip to content

Commit

Permalink
Add a dedicated configuration file to generate 'src/app/encoder.cpp' …
Browse files Browse the repository at this point in the history
…and 'src/app/chip-zcl-zpro-codec-api.h' (project-chip#4212)

Problem

So far `src/app/chip-zcl-zpro-codec-api.h` and `src/app/encoder.cpp` has been generated
using times to times by manually adding the related templates to to the `chip-templates.json` and
removing it before checking-in the code since this code does not really belongs to application folders.

It is error prone. An in fact I broken it with project-chip#4155 since attributes appears multiple times because of
the second endpoint.

This PR splits the `zap-templates` folder in two, with one folder for the examples and one fodler for
chip related code.

Summary of changes
 * Split `zap-templates` folder in two
 * Split `helper-chip.js` into multiple helpers and move those helpers where they belongs
 * Add a new `scripts/tools/zap_generate_chip.sh` script to generate the `src/app` content
 * Add `scripts/tools/zap_generate_chip.sh` to `scripts/tools/zap_regen_all.py`
 * Create a partial for the licensing `header` instead of relying on js for it
 * Fix the attribute issue mentioned above
 * Remove `asChipUnderlyingType` since it relies on `asUnderlyingZclType` and we should be able to fix the issue directly once project-chip#4192 lands and it really does not introduce any problem to remove it
  • Loading branch information
vivien-apple authored and kpschoedel committed Jan 8, 2021
1 parent 36dde42 commit f926510
Show file tree
Hide file tree
Showing 93 changed files with 476 additions and 417 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/all-clusters-common/gen/enums.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/af-structs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/att-storage.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/attribute-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/attribute-size.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/attribute-type.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/callback.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/cluster-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/lighting-common/gen/command-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down Expand Up @@ -46,6 +45,7 @@

// Commands for cluster: Basic
#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00)
#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00)

// Commands for cluster: Identify
#define ZCL_IDENTIFY_COMMAND_ID (0x00)
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/enums.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/gen_config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/lighting-common/gen/print-cluster.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/af-structs.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/att-storage.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/attribute-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/attribute-size.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/attribute-type.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/call-command-handler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/call-command-handler.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/callback-stub.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/callback.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/client-command-macro.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/cluster-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/lock-common/gen/command-id.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down Expand Up @@ -46,6 +45,7 @@

// Commands for cluster: Basic
#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00)
#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00)

// Commands for cluster: Identify
#define ZCL_IDENTIFY_COMMAND_ID (0x00)
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/enums.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/gen_config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/lock-common/gen/print-cluster.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down Expand Up @@ -46,6 +45,7 @@

// Commands for cluster: Basic
#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00)
#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00)

// Commands for cluster: Identify
#define ZCL_IDENTIFY_COMMAND_ID (0x00)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
2 changes: 1 addition & 1 deletion scripts/tools/zap_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

cd ./third_party/zap/repo/

node ./src-script/zap-start.js --logToStdout --gen ../../../src/app/zap-templates/chip-templates.json
node ./src-script/zap-start.js --logToStdout --gen ../../../src/app/zap-templates/app-templates.json
7 changes: 6 additions & 1 deletion scripts/tools/zap_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ if [ ! -d "$OUTPUT_DIRECTORY" ]; then
fi

cd ./third_party/zap/repo/
node ./src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/chip-templates.json -i "$FILE_PATH" -o "$OUTPUT_DIRECTORY"
node ./src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/app-templates.json -i "$FILE_PATH" -o "$OUTPUT_DIRECTORY"

# Check if clang-format is available
if command -v clang-format &>/dev/null; then
clang-format -i "$OUTPUT_DIRECTORY"*
fi
20 changes: 20 additions & 0 deletions scripts/tools/zap_generate_chip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

#
# Copyright (c) 2020 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.
#

cd ./third_party/zap/repo/
node ./src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/chip-templates.json -i ../../../examples/all-clusters-app/all-clusters-common/all-clusters-app.zap -o ../../../
2 changes: 2 additions & 0 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
print('This script must be called from the root of the chip directory')
exit(1)

os.system("./scripts/tools/zap_generate_chip.sh")

for path in Path('./examples').rglob('*.zap'):
os.system("./scripts/tools/zap_generate.sh " + str(path))
1 change: 0 additions & 1 deletion src/app/chip-zcl-zpro-codec-api.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
1 change: 0 additions & 1 deletion src/app/encoder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
*
* Copyright (c) 2020 Project CHIP Authors
Expand Down
5 changes: 3 additions & 2 deletions src/app/zap-templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ Run ZAP with UI to configure endpoints and clusters

```
cd ./third_party/zap/repo/
node src-script/zap-start.js --logToStdout --gen ../../../src/app/zap-templates/chip-templates.json
node src-script/zap-start.js --logToStdout --gen ../../../src/app/zap-templates/app/templates.json
```

Generate files in headless mode

```
cd ./third_party/zap/repo/
node src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/chip-templates.json -i <path to *.zap file> -o <Path to /gen/ folder>
node src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/app-templates.json -i <path to *.zap file> -o <Path to /gen/ folder>
node src-script/zap-generate.js -z ./zcl-builtin/silabs/zcl.json -g ../../../src/app/zap-templates/chip-templates.json -i <path to *.zap file> -o ../../../
```

For more information please see the documentation under `docs/` in
Expand Down
Loading

0 comments on commit f926510

Please sign in to comment.