From b9a2848f7004efb4108e3db2a4758afc36dddef2 Mon Sep 17 00:00:00 2001 From: Adrian Gielniewski Date: Thu, 20 Mar 2025 15:37:44 +0100 Subject: [PATCH 1/2] [nrf noup] Check if ZAP file was found Log error and return if ZAP file was not found Signed-off-by: Adrian Gielniewski --- scripts/west/zap_gui.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/west/zap_gui.py b/scripts/west/zap_gui.py index d719401ff9..5e12561ad5 100644 --- a/scripts/west/zap_gui.py +++ b/scripts/west/zap_gui.py @@ -50,6 +50,10 @@ def do_run(self, args, unknown_args): zap_file_path = args.zap_file or find_zap() zcl_json_path = Path(args.zcl_json).absolute() if args.zcl_json else default_zcl_path + if zap_file_path is None: + log.err("ZAP file not found!") + return + if args.clusters: # If the user provided the clusters and the zcl.json file provided by -j argument does not exist # we will create a new zcl.json file according to the base zcl.json file in default_zcl_path. From 4efa1621a2b60a0dbf84dbb5bce01398da973435 Mon Sep 17 00:00:00 2001 From: Adrian Gielniewski Date: Thu, 20 Mar 2025 15:50:46 +0100 Subject: [PATCH 2/2] [nrf noup] Add zap-install command Add west command to install ZAP Signed-off-by: Adrian Gielniewski --- scripts/west/west-commands.yml | 5 +++++ scripts/west/zap_install.py | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 scripts/west/zap_install.py diff --git a/scripts/west/west-commands.yml b/scripts/west/west-commands.yml index ddff0dabfe..72205b28d2 100644 --- a/scripts/west/west-commands.yml +++ b/scripts/west/west-commands.yml @@ -1,5 +1,10 @@ # Keep the help strings in sync with the values in the .py files! west-commands: + - file: scripts/west/zap_install.py + commands: + - name: zap-install + class: ZapInstall + help: Install Matter ZCL Advanced Platform (ZAP) GUI - file: scripts/west/zap_generate.py commands: - name: zap-generate diff --git a/scripts/west/zap_install.py b/scripts/west/zap_install.py new file mode 100644 index 0000000000..0fa423fe8e --- /dev/null +++ b/scripts/west/zap_install.py @@ -0,0 +1,35 @@ +# Copyright (c) 2025 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + +import argparse +from textwrap import dedent +from west.commands import WestCommand +from zap_common import existing_dir_path, ZapInstaller, DEFAULT_MATTER_PATH + + +class ZapInstall(WestCommand): + + def __init__(self): + super().__init__( + 'zap-install', + 'Install Matter ZCL Advanced Platform (ZAP) GUI', + dedent(''' + Install Matter ZCL Advanced Platform (ZAP) GUI. + + The ZAP GUI in a node.js tool for configuring the data model + of a Matter application, which defines clusters, commands, + attributes and events enabled for the given application.''')) + + def do_add_parser(self, parser_adder): + parser = parser_adder.add_parser(self.name, + help=self.help, + formatter_class=argparse.RawDescriptionHelpFormatter, + description=self.description) + parser.add_argument('-m', '--matter-path', type=existing_dir_path, + default=DEFAULT_MATTER_PATH, help=f'Path to Matter SDK. Default is set to {DEFAULT_MATTER_PATH}') + return parser + + def do_run(self, args, unknown_args): + zap_installer = ZapInstaller(args.matter_path) + zap_installer.update_zap_if_needed()