diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index d9f311efc10e7d..e6f3f887dd3109 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -47,6 +47,8 @@ find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) project(chip-nrfconnect-lighting-example) include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) target_compile_options(app PRIVATE -Werror) @@ -68,51 +70,13 @@ target_sources(app PRIVATE ${GEN_DIR}/lighting-app/zap-generated/callback-stub.cpp ${GEN_DIR}/lighting-app/zap-generated/IMClusterCommandHandler.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp - ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp - ${CHIP_ROOT}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp - ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp - ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp - ${CHIP_ROOT}/src/app/reporting/reporting.cpp - ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp - ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp - ${CHIP_ROOT}/src/app/util/attribute-storage.cpp - ${CHIP_ROOT}/src/app/util/attribute-table.cpp - ${CHIP_ROOT}/src/app/util/binding-table.cpp - ${CHIP_ROOT}/src/app/util/chip-message-send.cpp - ${CHIP_ROOT}/src/app/util/client-api.cpp - ${CHIP_ROOT}/src/app/util/ember-compatibility-functions.cpp - ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/error-mapping.cpp - ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp - ${CHIP_ROOT}/src/app/util/util.cpp - ${CHIP_ROOT}/src/app/server/EchoHandler.cpp - ${CHIP_ROOT}/src/app/server/Mdns.cpp - ${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp - ${CHIP_ROOT}/src/app/server/RendezvousServer.cpp - ${CHIP_ROOT}/src/app/server/Server.cpp - ${CHIP_ROOT}/src/app/server/CommissionManager.cpp - ${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/basic/basic.cpp - ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp - ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp - ${CHIP_ROOT}/src/app/clusters/ethernet_network_diagnostics_server/ethernet_network_diagnostics_server.cpp - ${CHIP_ROOT}/src/app/clusters/thread_network_diagnostics_server/thread_network_diagnostics_server.cpp - ${CHIP_ROOT}/src/app/clusters/wifi_network_diagnostics_server/wifi_network_diagnostics_server.cpp - ${CHIP_ROOT}/src/app/clusters/software_diagnostics_server/software_diagnostics_server.cpp - ${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp - ${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp - ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp - ${CHIP_ROOT}/src/app/clusters/color-control-server/color-control-server.cpp - ${CHIP_ROOT}/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ) + ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp) +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lighting-common/lighting-app.zap +) + if(BUILD_WITH_DFU) target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp) endif() @@ -196,5 +160,3 @@ target_link_libraries(app PRIVATE target_link_libraries(pw_build INTERFACE zephyr_interface) endif(CONFIG_CHIP_PW_RPC) - -include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 37f2d81233b37e..e3f02522868cb2 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -48,6 +48,8 @@ target_compile_options(app PRIVATE -Werror) project(chip-nrfconnect-lock-example) include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) target_include_directories(app PRIVATE main/include @@ -66,45 +68,13 @@ target_sources(app PRIVATE ${GEN_DIR}/lock-app/zap-generated/callback-stub.cpp ${GEN_DIR}/lock-app/zap-generated/IMClusterCommandHandler.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp - ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp - ${CHIP_ROOT}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp - ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp - ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp - ${CHIP_ROOT}/src/app/reporting/reporting.cpp - ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp - ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp - ${CHIP_ROOT}/src/app/util/attribute-storage.cpp - ${CHIP_ROOT}/src/app/util/attribute-table.cpp - ${CHIP_ROOT}/src/app/util/binding-table.cpp - ${CHIP_ROOT}/src/app/util/chip-message-send.cpp - ${CHIP_ROOT}/src/app/util/client-api.cpp - ${CHIP_ROOT}/src/app/util/ember-compatibility-functions.cpp - ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/error-mapping.cpp - ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp - ${CHIP_ROOT}/src/app/util/util.cpp - ${CHIP_ROOT}/src/app/server/EchoHandler.cpp - ${CHIP_ROOT}/src/app/server/Mdns.cpp - ${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp - ${CHIP_ROOT}/src/app/server/RendezvousServer.cpp - ${CHIP_ROOT}/src/app/server/Server.cpp - ${CHIP_ROOT}/src/app/server/CommissionManager.cpp - ${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/basic/basic.cpp - ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp - ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp - ${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp - ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp) + ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp) + +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lock-common/lock-app.zap +) if(BUILD_WITH_DFU) target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp) endif() - -include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/examples/pump-app/nrfconnect/CMakeLists.txt b/examples/pump-app/nrfconnect/CMakeLists.txt index 11ccf3ea1cd0d7..f89e249d29b287 100644 --- a/examples/pump-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-app/nrfconnect/CMakeLists.txt @@ -48,6 +48,8 @@ target_compile_options(app PRIVATE -Werror) project(chip-nrfconnect-pump-example) include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) target_include_directories(app PRIVATE main/include @@ -66,48 +68,13 @@ target_sources(app PRIVATE ${GEN_DIR}/pump-app/zap-generated/callback-stub.cpp ${GEN_DIR}/pump-app/zap-generated/IMClusterCommandHandler.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp - ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp - ${CHIP_ROOT}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp - ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp - ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp - ${CHIP_ROOT}/src/app/reporting/reporting.cpp - ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp - ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp - ${CHIP_ROOT}/src/app/util/attribute-storage.cpp - ${CHIP_ROOT}/src/app/util/attribute-table.cpp - ${CHIP_ROOT}/src/app/util/binding-table.cpp - ${CHIP_ROOT}/src/app/util/chip-message-send.cpp - ${CHIP_ROOT}/src/app/util/client-api.cpp - ${CHIP_ROOT}/src/app/util/ember-compatibility-functions.cpp - ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/error-mapping.cpp - ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp - ${CHIP_ROOT}/src/app/util/util.cpp - ${CHIP_ROOT}/src/app/server/EchoHandler.cpp - ${CHIP_ROOT}/src/app/server/Mdns.cpp - ${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp - ${CHIP_ROOT}/src/app/server/RendezvousServer.cpp - ${CHIP_ROOT}/src/app/server/Server.cpp - ${CHIP_ROOT}/src/app/server/CommissionManager.cpp - ${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/basic/basic.cpp - ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp - ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp - ${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp - ${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp - ${CHIP_ROOT}/src/app/clusters/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp + ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp) + +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-common/pump-app.zap ) if(BUILD_WITH_DFU) target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp) endif() - -include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/examples/pump-controller-app/nrfconnect/CMakeLists.txt b/examples/pump-controller-app/nrfconnect/CMakeLists.txt index 8e34f835ec2030..09c67962a5ad21 100644 --- a/examples/pump-controller-app/nrfconnect/CMakeLists.txt +++ b/examples/pump-controller-app/nrfconnect/CMakeLists.txt @@ -48,6 +48,8 @@ target_compile_options(app PRIVATE -Werror) project(chip-nrfconnect-pump-controller-example) include(${CHIP_ROOT}/config/nrfconnect/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) target_include_directories(app PRIVATE main/include @@ -66,45 +68,13 @@ target_sources(app PRIVATE ${GEN_DIR}/pump-controller-app/zap-generated/callback-stub.cpp ${GEN_DIR}/pump-controller-app/zap-generated/IMClusterCommandHandler.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp - ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp - ${CHIP_ROOT}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp - ${CHIP_ROOT}/src/app/util/DataModelHandler.cpp - ${CHIP_ROOT}/src/app/reporting/reporting-default-configuration.cpp - ${CHIP_ROOT}/src/app/reporting/reporting.cpp - ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.cpp - ${CHIP_ROOT}/src/app/util/attribute-list-byte-span.cpp - ${CHIP_ROOT}/src/app/util/attribute-size-util.cpp - ${CHIP_ROOT}/src/app/util/attribute-storage.cpp - ${CHIP_ROOT}/src/app/util/attribute-table.cpp - ${CHIP_ROOT}/src/app/util/binding-table.cpp - ${CHIP_ROOT}/src/app/util/chip-message-send.cpp - ${CHIP_ROOT}/src/app/util/client-api.cpp - ${CHIP_ROOT}/src/app/util/ember-compatibility-functions.cpp - ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/error-mapping.cpp - ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp - ${CHIP_ROOT}/src/app/util/util.cpp - ${CHIP_ROOT}/src/app/server/EchoHandler.cpp - ${CHIP_ROOT}/src/app/server/Mdns.cpp - ${CHIP_ROOT}/src/app/server/OnboardingCodesUtil.cpp - ${CHIP_ROOT}/src/app/server/RendezvousServer.cpp - ${CHIP_ROOT}/src/app/server/Server.cpp - ${CHIP_ROOT}/src/app/server/CommissionManager.cpp - ${CHIP_ROOT}/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/basic/basic.cpp - ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp - ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp - ${CHIP_ROOT}/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp - ${CHIP_ROOT}/src/app/clusters/pump-configuration-and-control-client/pump-configuration-and-control-client.cpp) + ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp) + +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../pump-controller-common/pump-controller-app.zap +) if(BUILD_WITH_DFU) target_sources(app PRIVATE ${NRFCONNECT_COMMON}/util/DFUOverSMP.cpp) endif() - -include(${CHIP_ROOT}/config/nrfconnect/app/flashing.cmake) diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake new file mode 100644 index 00000000000000..556d3f25dea5fd --- /dev/null +++ b/src/app/chip_data_model.cmake @@ -0,0 +1,96 @@ +# +# 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. +# + +set(CHIP_APP_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) + +# +# Configure ${APP_TARGET} with source files associated with ${CLUSTER} cluster +# +function(chip_configure_cluster APP_TARGET CLUSTER) + file(GLOB CLUSTER_SOURCES "${CHIP_APP_BASE_DIR}/clusters/${CLUSTER}/*.cpp") + target_sources(${APP_TARGET} PRIVATE ${CLUSTER_SOURCES}) +endfunction() + +# +# Configure ${APP_TARGET} with source files associated with clusters enabled in the ${ZAP_FILE} +# +function(chip_configure_zap_file APP_TARGET ZAP_FILE) + find_package(Python3 REQUIRED) + + execute_process( + COMMAND ${Python3_EXECUTABLE} ${CHIP_APP_BASE_DIR}/zap_cluster_list.py --zap_file ${ZAP_FILE} + OUTPUT_VARIABLE CLUSTER_LIST + ERROR_VARIABLE ERROR_MESSAGE + RESULT_VARIABLE RC + ) + if (NOT RC EQUAL 0) + message(FATAL_ERROR "Failed to execute zap_cluster_list.py: ${ERROR_MESSAGE}") + endif() + + string(REPLACE "\n" ";" CLUSTER_LIST "${CLUSTER_LIST}") + foreach(CLUSTER ${CLUSTER_LIST}) + chip_configure_cluster(${APP_TARGET} ${CLUSTER}) + endforeach() +endfunction() + +# +# Configure ${APP_TARGET} based on the selected data model configuration. +# Available options are: +# INCLUDE_SERVER Include source files from src/app/server directory +# ZAP_FILE Path to the ZAP file, used to determine the list of clusters +# supported by the application. +# +function(chip_configure_data_model APP_TARGET) + cmake_parse_arguments(ARG "INCLUDE_SERVER" "ZAP_FILE" "" ${ARGN}) + + if (ARG_INCLUDE_SERVER) + target_sources(${APP_TARGET} PRIVATE + ${CHIP_APP_BASE_DIR}/server/EchoHandler.cpp + ${CHIP_APP_BASE_DIR}/server/Mdns.cpp + ${CHIP_APP_BASE_DIR}/server/OnboardingCodesUtil.cpp + ${CHIP_APP_BASE_DIR}/server/RendezvousServer.cpp + ${CHIP_APP_BASE_DIR}/server/Server.cpp + ${CHIP_APP_BASE_DIR}/server/CommissionManager.cpp + ) + endif() + + if (ARG_ZAP_FILE) + chip_configure_zap_file(${APP_TARGET} ${ARG_ZAP_FILE}) + endif() + + target_sources(${APP_TARGET} PRIVATE + ${CHIP_APP_BASE_DIR}/../../zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp + ${CHIP_APP_BASE_DIR}/reporting/reporting-default-configuration.cpp + ${CHIP_APP_BASE_DIR}/reporting/reporting.cpp + ${CHIP_APP_BASE_DIR}/util/af-event.cpp + ${CHIP_APP_BASE_DIR}/util/af-main-common.cpp + ${CHIP_APP_BASE_DIR}/util/attribute-list-byte-span.cpp + ${CHIP_APP_BASE_DIR}/util/attribute-size-util.cpp + ${CHIP_APP_BASE_DIR}/util/attribute-storage.cpp + ${CHIP_APP_BASE_DIR}/util/attribute-table.cpp + ${CHIP_APP_BASE_DIR}/util/binding-table.cpp + ${CHIP_APP_BASE_DIR}/util/chip-message-send.cpp + ${CHIP_APP_BASE_DIR}/util/client-api.cpp + ${CHIP_APP_BASE_DIR}/util/DataModelHandler.cpp + ${CHIP_APP_BASE_DIR}/util/ember-compatibility-functions.cpp + ${CHIP_APP_BASE_DIR}/util/ember-print.cpp + ${CHIP_APP_BASE_DIR}/util/error-mapping.cpp + ${CHIP_APP_BASE_DIR}/util/message.cpp + ${CHIP_APP_BASE_DIR}/util/process-cluster-message.cpp + ${CHIP_APP_BASE_DIR}/util/process-global-message.cpp + ${CHIP_APP_BASE_DIR}/util/util.cpp + ) +endfunction()