From bba766b25e22d8d6500d698ccf36f2aff52b35dd Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Fri, 13 Sep 2024 15:24:56 -0400 Subject: [PATCH] Add ability to control data-model-interface usage for cmake-based platforms (#35559) * Add data-mode-enabled/disabled variants to all CMAKE builds. Platforms changed: - esp32 - mbed - nrfconnect - telink - nxp I tested all these except NXP which I could not compile in TOT due to missing vscode configuration. * add options for data model to qpg builds as this can be used to check for size deltas * Fix unit test * Restyle * Fix nxp typo and strip * Update quoting logic * Update config/telink/chip-module/CMakeLists.txt Co-authored-by: Terence Hampson * more update on the 'I' text * Fix nxp build placement of data model interface * Switch to zephyr KConfig for data model interface setting * Use bool for DM enabling in places * Apply review comment * Fix nxp typo --------- Co-authored-by: Andrei Litvin Co-authored-by: Terence Hampson --- build/chip/esp32/esp32_codegen.cmake | 10 +++++ config/common/cmake/chip_gn_args.cmake | 9 ++++- config/esp32/components/chip/CMakeLists.txt | 8 ++++ config/mbed/CMakeLists.txt | 4 ++ config/nrfconnect/chip-module/CMakeLists.txt | 8 ++++ config/nxp/chip-cmake-freertos/CMakeLists.txt | 7 ++++ config/nxp/chip-module/CMakeLists.txt | 8 ++++ config/telink/chip-module/CMakeLists.txt | 7 ++++ config/zephyr/Kconfig | 7 ++++ config/zephyr/chip-module/CMakeLists.txt | 9 ++++- scripts/build/build/targets.py | 12 ++++++ scripts/build/builders/esp32.py | 8 +++- scripts/build/builders/host.py | 2 +- scripts/build/builders/mbed.py | 9 ++++- scripts/build/builders/nrf.py | 22 ++++++----- scripts/build/builders/nxp.py | 38 ++++++++++++------- scripts/build/builders/qpg.py | 8 +++- scripts/build/builders/telink.py | 17 ++++++--- .../build/testdata/all_targets_linux_x64.txt | 12 +++--- 19 files changed, 164 insertions(+), 41 deletions(-) diff --git a/build/chip/esp32/esp32_codegen.cmake b/build/chip/esp32/esp32_codegen.cmake index d83bdb7ccf12c8..7febb089875172 100644 --- a/build/chip/esp32/esp32_codegen.cmake +++ b/build/chip/esp32/esp32_codegen.cmake @@ -17,6 +17,7 @@ macro(chip_app_component_codegen IDL_NAME) include("${CHIP_ROOT}/build/chip/chip_codegen.cmake") + include("${CHIP_ROOT}/src/app/codegen-data-model-provider/model.cmake") # The IDF build system performs a two-pass expansion to determine # component expansion. The first pass runs in script-mode @@ -71,5 +72,14 @@ macro(chip_app_component_zapgen ZAP_NAME) add_dependencies(${COMPONENT_LIB} app-zapgen) target_include_directories(${COMPONENT_LIB} PUBLIC "${APP_TEMPLATE_GEN_DIR}") target_sources(${COMPONENT_LIB} PRIVATE ${APP_TEMPLATE_GEN_FILES}) + + # When data model interface is used, provide a default code-generation data model as + # part of zapgen. See `chip_data_model.cmake` for similar logic + set(CHIP_DATA_MODEL_INTERFACE "disabled" CACHE STRING "Data model interface option to use: enabled or disabled") + + if ("${CHIP_DATA_MODEL_INTERFACE}" STREQUAL "enabled") + target_sources(${COMPONENT_LIB} PRIVATE ${CODEGEN_DATA_MODEL_SOURCES}) + endif() + endif() endmacro() diff --git a/config/common/cmake/chip_gn_args.cmake b/config/common/cmake/chip_gn_args.cmake index 663e7f49977030..8fde49c3438098 100644 --- a/config/common/cmake/chip_gn_args.cmake +++ b/config/common/cmake/chip_gn_args.cmake @@ -171,7 +171,7 @@ macro(matter_common_gn_args) LIB_PW_RPC DEVICE_INFO_EXAMPLE_PROVIDER PROJECT_CONFIG - + DATA_MODEL_INTERFACE ) set(multiValueArgs PROJECT_CONFIG_INC_DIR @@ -203,6 +203,11 @@ macro(matter_common_gn_args) if (ARG_DEVICE_INFO_EXAMPLE_PROVIDER) matter_add_gn_arg_bool ("chip_build_example_providers" ${ARG_DEVICE_INFO_EXAMPLE_PROVIDER}) endif() # ARG_DEVICE_INFO_EXAMPLE_PROVIDER + + if (ARG_DATA_MODEL_INTERFACE) + matter_add_gn_arg_string("chip_use_data_model_interface" "${ARG_DATA_MODEL_INTERFACE}") + endif() + if (ARG_PROJECT_CONFIG) get_filename_component(PROJECT_CONFIG ${ARG_PROJECT_CONFIG} @@ -220,4 +225,4 @@ endmacro() # Generate the temporary GN arguments file from the settings macro(matter_generate_args_tmp_file) file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/args.tmp" CONTENT ${MATTER_GN_ARGS}) -endmacro() \ No newline at end of file +endmacro() diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index 85141d5f962241..161a3ce6e2249c 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -33,6 +33,8 @@ include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake) set(CHIP_REQUIRE_COMPONENTS esp_eth freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash) +set(CHIP_DATA_MODEL_INTERFACE "disabled" CACHE STRING "Data model interface option to use: enabled or disabled") + if(NOT "${IDF_TARGET}" STREQUAL "esp32h2") list(APPEND CHIP_REQUIRE_COMPONENTS mdns) endif() @@ -64,6 +66,12 @@ macro(chip_gn_arg_bool arg boolean) endif() endmacro() +if ("${CHIP_DATA_MODEL_INTERFACE}" STREQUAL "enabled") + chip_gn_arg_append("chip_use_data_model_interface" "\"enabled\"") +else() + chip_gn_arg_append("chip_use_data_model_interface" "\"disabled\"") +endif() + # ESP-IDF lets user set software version string by two ways: # 1. Project's CMakeLists.txt file and 2. Config option # It depends on CONFIG_APP_PROJECT_VER_FROM_CONFIG option diff --git a/config/mbed/CMakeLists.txt b/config/mbed/CMakeLists.txt index 88567b604e3254..37dad135327e07 100644 --- a/config/mbed/CMakeLists.txt +++ b/config/mbed/CMakeLists.txt @@ -112,6 +112,9 @@ if (CONFIG_MBED_BSD_SOCKET_TRACE) matter_add_flags(-DMBED_BSD_SOCKET_TRACE=1) endif() +# Option can be set with `-DCHIP_DATA_MODEL_INTERFACE=enabled` or similar on the command line +set(CHIP_DATA_MODEL_INTERFACE "disabled" CACHE STRING "Data model interface option to use: enabled or disabled") + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -121,6 +124,7 @@ matter_common_gn_args( LIB_TESTS CONFIG_CHIP_BUILD_TESTS LIB_PW_RPC CONFIG_CHIP_PW_RPC PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} + DATA_MODEL_INTERFACE ${CHIP_DATA_MODEL_INTERFACE} ) if (CONFIG_CHIP_PW_RPC) matter_add_gn_arg_import("${GN_ROOT_TARGET}/lib/pw_rpc/pw_rpc.gni") diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index ee169106ffc8f9..98fee746485cc3 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -106,6 +106,13 @@ endif() get_property(CHIP_COMPILER_LAUNCHER GLOBAL PROPERTY RULE_LAUNCH_COMPILE) + +if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE) + set(DATA_MODEL_INTERFACE "enabled") +else() + set(DATA_MODEL_INTERFACE "disabled") +endif() + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -116,6 +123,7 @@ matter_common_gn_args( LIB_TESTS CONFIG_CHIP_BUILD_TESTS PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER + DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE} ) matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR}) matter_add_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER}) diff --git a/config/nxp/chip-cmake-freertos/CMakeLists.txt b/config/nxp/chip-cmake-freertos/CMakeLists.txt index b639e23ff65034..db078e69df4f64 100644 --- a/config/nxp/chip-cmake-freertos/CMakeLists.txt +++ b/config/nxp/chip-cmake-freertos/CMakeLists.txt @@ -40,6 +40,12 @@ matter_add_gn_arg("chip_with_factory_data" ${CONFIG_CHIP_FACTORY_DATA}) matter_add_gn_arg("chip_enable_secure_dac_private_key_storage" ${CONFIG_CHIP_SECURE_DAC_PRIVATE_KEY_STORAGE}) matter_add_gn_arg("chip_enable_secure_whole_factory_data" ${CONFIG_CHIP_ENABLE_SECURE_WHOLE_FACTORY_DATA}) +if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE) + set(DATA_MODEL_INTERFACE "enabled") +else() + set(DATA_MODEL_INTERFACE "disabled") +endif() + matter_common_gn_args( DEBUG CONFIG_DEBUG LIB_SHELL CONFIG_CHIP_LIB_SHELL @@ -47,6 +53,7 @@ matter_common_gn_args( PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS} DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER + DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE} ) matter_generate_args_tmp_file() diff --git a/config/nxp/chip-module/CMakeLists.txt b/config/nxp/chip-module/CMakeLists.txt index 32a85a606c71e0..f5cb1bf88a0fce 100644 --- a/config/nxp/chip-module/CMakeLists.txt +++ b/config/nxp/chip-module/CMakeLists.txt @@ -91,6 +91,13 @@ endif() get_property(CHIP_COMPILER_LAUNCHER GLOBAL PROPERTY RULE_LAUNCH_COMPILE) +if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE) + set(DATA_MODEL_INTERFACE "enabled") +else() + set(DATA_MODEL_INTERFACE "disabled") +endif() + + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -101,6 +108,7 @@ matter_common_gn_args( LIB_TESTS CONFIG_CHIP_BUILD_TESTS PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER + DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE} ) matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR}) matter_add_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER}) diff --git a/config/telink/chip-module/CMakeLists.txt b/config/telink/chip-module/CMakeLists.txt index 7b58f5c4b6fc05..d4c02aa5d621b8 100644 --- a/config/telink/chip-module/CMakeLists.txt +++ b/config/telink/chip-module/CMakeLists.txt @@ -77,6 +77,12 @@ if (CONFIG_CHIP_OPENTHREAD_CONFIG) zephyr_set_openthread_config(${CHIP_OPENTHREAD_CONFIG}) endif() +if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE) + set(DATA_MODEL_INTERFACE "enabled") +else() + set(DATA_MODEL_INTERFACE "disabled") +endif() + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -87,6 +93,7 @@ matter_common_gn_args( LIB_TESTS CONFIG_CHIP_BUILD_TESTS PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} DEVICE_INFO_EXAMPLE_PROVIDER CONFIG_CHIP_EXAMPLE_DEVICE_INFO_PROVIDER + DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE} ) matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR}) matter_add_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER}) diff --git a/config/zephyr/Kconfig b/config/zephyr/Kconfig index 62efe30c07fda4..2a3a2d5495bf96 100644 --- a/config/zephyr/Kconfig +++ b/config/zephyr/Kconfig @@ -574,4 +574,11 @@ config CHIP_BLE_ADVERTISING_DURATION If CHIP_BLE_EXT_ADVERTISING is set to false, the maximum duration time is 15 minutes, else the maximum duration time can be extended to 2880 minutes (48h). +config USE_CHIP_DATA_MODEL_INTERFACE + bool "Use a DataModel::Provider interface for data access" + help + This enables a level of indiraction in the CHIP interaction model engine in + accessing underlying data and executing operations such as + wildcard-expansion, read, write and invoke. + endif diff --git a/config/zephyr/chip-module/CMakeLists.txt b/config/zephyr/chip-module/CMakeLists.txt index 8449398b4f480b..fb94465b772bf6 100644 --- a/config/zephyr/chip-module/CMakeLists.txt +++ b/config/zephyr/chip-module/CMakeLists.txt @@ -70,6 +70,12 @@ if(CONFIG_CHIP) zephyr_set_openthread_config(${CHIP_OPENTHREAD_CONFIG}) endif() + if (CONFIG_USE_CHIP_DATA_MODEL_INTERFACE) + set(DATA_MODEL_INTERFACE "enabled") + else() + set(DATA_MODEL_INTERFACE "disabled") + endif() + # ============================================================================== # Generate configuration for CHIP GN build system # ============================================================================== @@ -78,6 +84,7 @@ if(CONFIG_CHIP) LIB_SHELL CONFIG_CHIP_LIB_SHELL LIB_TESTS CONFIG_CHIP_BUILD_TESTS PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} + DATA_MODEL_INTERFACE ${DATA_MODEL_INTERFACE} ) matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR}) @@ -139,4 +146,4 @@ if(CONFIG_CHIP) GN_DEPENDENCIES kernel ) set_property(GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS chip) -endif() # CONFIG_CHIP \ No newline at end of file +endif() # CONFIG_CHIP diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index ca1110088723df..0464c51f7b0e6b 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -232,6 +232,8 @@ def BuildEsp32Target(): target.AppendModifier('rpc', enable_rpcs=True) target.AppendModifier('ipv6only', enable_ipv4=False) target.AppendModifier('tracing', enable_insights_trace=True).OnlyIfRe("light") + target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', data_model_interface="enabled").ExceptIfRe('-data-model-disabled') return target @@ -331,6 +333,8 @@ def BuildNrfTarget(): ]) target.AppendModifier('rpc', enable_rpcs=True) + target.AppendModifier('data-model-disabled', use_data_model_interface=False).ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', use_data_model_interface=True).ExceptIfRe('-data-model-disabled') return target @@ -416,6 +420,8 @@ def BuildMbedTarget(): '-(release|debug)') target.AppendModifier('debug', profile=MbedProfile.DEBUG).ExceptIfRe( '-(release|develop)') + target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', data_model_interface="enabled").ExceptIfRe('-data-model-disabled') return target @@ -540,6 +546,8 @@ def BuildNxpTarget(): target.AppendModifier(name="wifi", enable_wifi=True).OnlyIfRe('rw61x') target.AppendModifier(name="thread", enable_thread=True).ExceptIfRe('zephyr') target.AppendModifier(name="matter-shell", enable_shell=True).ExceptIfRe('k32w0|k32w1') + target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', data_model_interface="enabled").ExceptIfRe('-data-model-disabled') return target @@ -620,6 +628,8 @@ def BuildQorvoTarget(): ]) target.AppendModifier('updateimage', update_image=True) + target.AppendModifier('data-model-disabled', data_model_interface="disabled").ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', data_model_interface="enabled").ExceptIfRe('-data-model-disabled') return target @@ -781,6 +791,8 @@ def BuildTelinkTarget(): target.AppendModifier('4mb', enable_4mb_flash=True) target.AppendModifier('mars', mars_board_config=True) target.AppendModifier('usb', usb_board_config=True) + target.AppendModifier('data-model-disabled', use_data_model_interface=False).ExceptIfRe('-data-model-enabled') + target.AppendModifier('data-model-enabled', use_data_model_interface=True).ExceptIfRe('-data-model-disabled') return target diff --git a/scripts/build/builders/esp32.py b/scripts/build/builders/esp32.py index 018e20170b194b..a225315fc613c6 100644 --- a/scripts/build/builders/esp32.py +++ b/scripts/build/builders/esp32.py @@ -16,6 +16,7 @@ import os import shlex from enum import Enum, auto +from typing import Optional from .builder import Builder, BuilderOutput @@ -153,7 +154,8 @@ def __init__(self, app: Esp32App = Esp32App.ALL_CLUSTERS, enable_rpcs: bool = False, enable_ipv4: bool = True, - enable_insights_trace: bool = False + enable_insights_trace: bool = False, + data_model_interface: Optional[str] = None, ): super(Esp32Builder, self).__init__(root, runner) self.board = board @@ -161,6 +163,7 @@ def __init__(self, self.enable_rpcs = enable_rpcs self.enable_ipv4 = enable_ipv4 self.enable_insights_trace = enable_insights_trace + self.data_model_interface = data_model_interface if not app.IsCompatible(board): raise Exception( @@ -215,6 +218,9 @@ def generate(self): cmake_flags.append( f"-DCHIP_CODEGEN_PREGEN_DIR={shlex.quote(self.options.pregen_dir)}") + if self.data_model_interface: + cmake_flags.append(f'-DCHIP_DATA_MODEL_INTERFACE={self.data_model_interface}') + cmake_args = ['-C', self.ExamplePath, '-B', shlex.quote(self.output_dir)] + cmake_flags diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index 12d21fbe8ba62e..61fbd006824a39 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -322,7 +322,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_test_event_triggers=None, enable_dnssd_tests: Optional[bool] = None, chip_casting_simplified: Optional[bool] = None, - data_model_interface: Optional[bool] = None, + data_model_interface: Optional[str] = None, chip_data_model_check_die_on_failure: Optional[bool] = None, ): super(HostBuilder, self).__init__( diff --git a/scripts/build/builders/mbed.py b/scripts/build/builders/mbed.py index 6dc47d0aa4aa27..cc4eb83a665621 100644 --- a/scripts/build/builders/mbed.py +++ b/scripts/build/builders/mbed.py @@ -15,6 +15,7 @@ import os import shlex from enum import Enum, auto +from typing import Optional from .builder import Builder, BuilderOutput @@ -101,7 +102,9 @@ def __init__(self, runner, app: MbedApp = MbedApp.LOCK, board: MbedBoard = MbedBoard.CY8CPROTO_062_4343W, - profile: MbedProfile = MbedProfile.RELEASE): + profile: MbedProfile = MbedProfile.RELEASE, + data_model_interface: Optional[str] = None, + ): super(MbedBuilder, self).__init__(root, runner) self.app = app self.board = board @@ -111,6 +114,7 @@ def __init__(self, self.root, 'third_party', 'mbed-os', 'repo') self.mbed_os_posix_socket_path = os.path.join( self.root, 'third_party', 'mbed-os-posix-socket', 'repo') + self.data_model_interface = data_model_interface @property def ExamplePath(self): @@ -131,6 +135,9 @@ def generate(self): flags.append(f"-DMBED_OS_PATH={shlex.quote(self.mbed_os_path)}") flags.append(f"-DMBED_OS_POSIX_SOCKET_PATH={shlex.quote(self.mbed_os_posix_socket_path)}") + if self.data_model_interface is not None: + flags.append(f"-DCHIP_DATA_MODEL_INTERFACE={self.data_model_interface}") + if self.options.pregen_dir: flags.append(f"-DCHIP_CODEGEN_PREGEN_DIR={shlex.quote(self.options.pregen_dir)}") diff --git a/scripts/build/builders/nrf.py b/scripts/build/builders/nrf.py index f9c801da0b5dd1..5fbc417ffe2c13 100644 --- a/scripts/build/builders/nrf.py +++ b/scripts/build/builders/nrf.py @@ -16,6 +16,7 @@ import os import shlex from enum import Enum, auto +from typing import Optional from .builder import Builder, BuilderOutput @@ -139,11 +140,14 @@ def __init__(self, runner, app: NrfApp = NrfApp.LIGHT, board: NrfBoard = NrfBoard.NRF52840DK, - enable_rpcs: bool = False): + enable_rpcs: bool = False, + use_data_model_interface: Optional[bool] = None, + ): super(NrfConnectBuilder, self).__init__(root, runner) self.app = app self.board = board self.enable_rpcs = enable_rpcs + self.use_data_model_interface = use_data_model_interface def generate(self): if not os.path.exists(self.output_dir): @@ -187,18 +191,18 @@ def generate(self): if self.options.pregen_dir: flags.append(f"-DCHIP_CODEGEN_PREGEN_DIR={shlex.quote(self.options.pregen_dir)}") + if self.use_data_model_interface is not None: + value = 'y' if self.use_data_model_interface else 'n' + flags.append(f"-DCONFIG_USE_CHIP_DATA_MODEL_INTERFACE={value}") + build_flags = " -- " + " ".join(flags) if len(flags) > 0 else "" - cmd = ''' -source "$ZEPHYR_BASE/zephyr-env.sh"; -export ZEPHYR_TOOLCHAIN_VARIANT=zephyr;''' + cmd = 'source "$ZEPHYR_BASE/zephyr-env.sh";\nexport ZEPHYR_TOOLCHAIN_VARIANT=zephyr;' + if zephyr_sdk_dir: - cmd += f''' -export ZEPHYR_SDK_INSTALL_DIR={zephyr_sdk_dir};''' + cmd += f'\nexport ZEPHYR_SDK_INSTALL_DIR={zephyr_sdk_dir};' - cmd += ''' -west build --cmake-only -d {outdir} -b {board} --sysbuild {sourcedir}{build_flags} - '''.format( + cmd += '\nwest build --cmake-only -d {outdir} -b {board} --sysbuild {sourcedir}{build_flags}\n'.format( outdir=shlex.quote(self.output_dir), board=self.board.GnArgName(), sourcedir=shlex.quote(os.path.join( diff --git a/scripts/build/builders/nxp.py b/scripts/build/builders/nxp.py index 81dc425169b06e..6a297cf8174d6a 100644 --- a/scripts/build/builders/nxp.py +++ b/scripts/build/builders/nxp.py @@ -16,6 +16,7 @@ import logging import os from enum import Enum, auto +from typing import Optional from .builder import BuilderOutput from .gn import GnBuilder @@ -136,7 +137,9 @@ def __init__(self, enable_wifi: bool = False, disable_ipv4: bool = False, enable_shell: bool = False, - enable_ota: bool = False): + enable_ota: bool = False, + data_model_interface: Optional[str] = None, + ): super(NxpBuilder, self).__init__( root=app.BuildRoot(root, board, os_env), runner=runner) @@ -158,6 +161,7 @@ def __init__(self, self.enable_wifi = enable_wifi self.enable_ota = enable_ota self.enable_shell = enable_shell + self.data_model_interface = data_model_interface def GnBuildArgs(self): args = [] @@ -207,6 +211,9 @@ def GnBuildArgs(self): if self.board == NxpBoard.RW61X: args.append('chip_enable_openthread=true chip_inet_config_enable_ipv4=false') + if self.data_model_interface is not None: + args.append(f'chip_use_data_model_interface="{self.data_model_interface}"') + return args def WestBuildArgs(self): @@ -217,27 +224,30 @@ def WestBuildArgs(self): if self.has_sw_version_2: args.append('-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2') + if self.data_model_interface: + # NOTE: this is not supporting "check" + enabled = "y" if self.data_model_interface.lower() == "enabled" else "n" + args.append(f"-DCONFIG_USE_CHIP_DATA_MODEL_INTERFACE={enabled}") + build_args = " -- " + " ".join(args) if len(args) > 0 else "" return build_args def generate(self): if self.os_env == NxpOsUsed.ZEPHYR: - if 'ZEPHYR_NXP_SDK_INSTALL_DIR' in os.environ: - cmd = 'export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_NXP_SDK_INSTALL_DIR"\n' - else: - raise Exception("ZEPHYR_SDK_INSTALL_DIR need to be set") - if 'ZEPHYR_NXP_BASE' in os.environ: - cmd += 'export ZEPHYR_BASE="$ZEPHYR_NXP_BASE"\n' - else: + if 'ZEPHYR_NXP_SDK_INSTALL_DIR' not in os.environ: + raise Exception("ZEPHYR_NXP_SDK_INSTALL_DIR need to be set") + + if 'ZEPHYR_NXP_BASE' not in os.environ: raise Exception("ZEPHYR_NXP_BASE need to be set") - build_args = self.WestBuildArgs() - cmd += ''' - west build -p --cmake-only -b {board_name} -d {out_folder} {example_folder} {build_args} - '''.format( + + cmd = 'export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_NXP_SDK_INSTALL_DIR"' + cmd += '\nexport ZEPHYR_BASE="$ZEPHYR_NXP_BASE"' + + cmd += '\nwest build -p --cmake-only -b {board_name} -d {out_folder} {example_folder}{build_args}'.format( board_name=self.board.Name(self.os_env), out_folder=self.output_dir, example_folder=self.app.BuildRoot(self.code_root, self.board, self.os_env), - build_args=build_args).strip() + build_args=self.WestBuildArgs()) self._Execute(['bash', '-c', cmd], title='Generating ' + self.identifier) else: cmd = '' @@ -269,7 +279,7 @@ def generate(self): extra_args.extend(self.GnBuildArgs() or []) if extra_args: - cmd += ' --args="%s' % ' '.join(extra_args) + '" ' + cmd += " --args='%s" % ' '.join(extra_args) + "' " cmd += self.output_dir diff --git a/scripts/build/builders/qpg.py b/scripts/build/builders/qpg.py index 330f4e3b74977d..93feaee78f6b99 100644 --- a/scripts/build/builders/qpg.py +++ b/scripts/build/builders/qpg.py @@ -14,6 +14,7 @@ import os from enum import Enum, auto +from typing import Optional from .builder import BuilderOutput from .gn import GnBuilder @@ -108,7 +109,9 @@ def __init__(self, board: QpgBoard = QpgBoard.QPG6105, flavour: QpgFlavour = QpgFlavour.EXT_FLASH, enable_rpcs: bool = False, - update_image: bool = False): + update_image: bool = False, + data_model_interface: Optional[str] = None, + ): super(QpgBuilder, self).__init__( root=app.BuildRoot(root), runner=runner) @@ -117,6 +120,7 @@ def __init__(self, self.flavour = flavour self.enable_rpcs = enable_rpcs self.update_image = update_image + self.data_model_interface = data_model_interface def GnBuildArgs(self): args = ['qpg_target_ic=\"%s\" qpg_flavour=\"%s\"' % (self.board.GnArgName(), self.flavour.GnFlavourName())] @@ -124,6 +128,8 @@ def GnBuildArgs(self): args.append('import("//with_pw_rpc.gni")') if self.update_image: args.append('matter_ota_test_image=true') + if self.data_model_interface: + args.append(f'chip_use_data_model_interface="{self.data_model_interface}"') return args def build_outputs(self): diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index b9cd709ba6b44c..6ac4c30ca241f5 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -16,6 +16,7 @@ import os import shlex from enum import Enum, auto +from typing import Optional from .builder import Builder, BuilderOutput @@ -152,7 +153,9 @@ def __init__(self, enable_factory_data: bool = False, enable_4mb_flash: bool = False, mars_board_config: bool = False, - usb_board_config: bool = False): + usb_board_config: bool = False, + use_data_model_interface: Optional[str] = None, + ): super(TelinkBuilder, self).__init__(root, runner) self.app = app self.board = board @@ -164,6 +167,7 @@ def __init__(self, self.enable_4mb_flash = enable_4mb_flash self.mars_board_config = mars_board_config self.usb_board_config = usb_board_config + self.use_data_model_interface = use_data_model_interface def get_cmd_prefixes(self): if not self._runner.dry_run: @@ -211,13 +215,16 @@ def generate(self): if self.options.pregen_dir: flags.append(f"-DCHIP_CODEGEN_PREGEN_DIR={shlex.quote(self.options.pregen_dir)}") + if self.use_data_model_interface is not None: + value = 'y' if self.use_data_model_interface else 'n' + flags.append(f"-DCONFIG_USE_CHIP_DATA_MODEL_INTERFACE={value}") + build_flags = " -- " + " ".join(flags) if len(flags) > 0 else "" cmd = self.get_cmd_prefixes() - cmd += ''' -source "$ZEPHYR_BASE/zephyr-env.sh"; -west build --cmake-only -d {outdir} -b {board} {sourcedir}{build_flags} - '''.format( + cmd += '\nsource "$ZEPHYR_BASE/zephyr-env.sh";' + + cmd += '\nwest build --cmake-only -d {outdir} -b {board} {sourcedir}{build_flags}\n'.format( outdir=shlex.quote(self.output_dir), board=self.board.GnArgName(), sourcedir=shlex.quote(os.path.join(self.root, 'examples', self.app.ExampleName(), 'telink')), diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index b177abfbf7117a..dbbf90508b0245 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -6,21 +6,21 @@ cc32xx-{lock,air-purifier} ti-cc13x4_26x4-{lighting,lock,pump,pump-controller}[-mtd][-ftd] cyw30739-{cyw30739b2_p5_evk_01,cyw30739b2_p5_evk_02,cyw30739b2_p5_evk_03,cyw930739m2evb_01,cyw930739m2evb_02}-{light,light-switch,lock,thermostat} efr32-{brd2704b,brd4316a,brd4317a,brd4318a,brd4319a,brd4186a,brd4187a,brd2601b,brd4187c,brd4186c,brd2703a,brd4338a,brd2605a}-{window-covering,switch,unit-test,light,lock,thermostat,pump}[-rpc][-with-ota-requestor][-icd][-low-power][-shell][-no-logging][-openthread-mtd][-heap-monitoring][-no-openthread-cli][-show-qr-code][-wifi][-rs9116][-wf200][-siwx917][-ipv4][-additional-data-advertising][-use-ot-lib][-use-ot-coap-lib][-no-version][-skip-rps-generation] -esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,energy-management,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only][-tracing] +esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,energy-management,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only][-tracing][-data-model-disabled][-data-model-enabled] genio-lighting-app linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang] linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,light-data-model-no-unique-id,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,fabric-admin,fabric-bridge,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event][-enable-dnssd-tests][-disable-dnssd-tests][-chip-casting-simplified][-data-model-check][-data-model-disabled][-data-model-enabled][-check-failure-die] linux-x64-efr32-test-runner[-clang] imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release] infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm] -nxp-{k32w0,k32w1,rw61x,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-thread][-matter-shell] -mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug] +nxp-{k32w0,k32w1,rw61x,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-thread][-matter-shell][-data-model-disabled][-data-model-enabled] +mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug][-data-model-disabled][-data-model-enabled] mw320-all-clusters-app -nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc] +nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc][-data-model-disabled][-data-model-enabled] nrf-native-posix-64-tests nuttx-x64-light -qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage] +qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage][-data-model-disabled][-data-model-enabled] stm32-stm32wb5mm-dk-light tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-with-ui] -telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb] +telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tlsr9258a,tlsr9258a_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-data-model-disabled][-data-model-enabled] openiotsdk-{shell,lock}[-mbedtls][-psa]