Skip to content

Commit d5c7f72

Browse files
[nrf fromtree] Parametrize app-common zap-generated path (#37816)
* [app] Parametrize app-common zap-generated path Parametrize app-common zap-generated path to allow building Matter using custom generated zap files stored in different path. When user adds custom clusters, full zap regeneration is needed. Storing these files in fixed place requires regeneration every time user wants to build different project (with different clusters). This commit allows to store zap-generated files separately and provide their path by seting `CHIP_APP_ZAP_DIR` cmake and `chip_app_zap_dir` GN flags. Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no> * [nrfconnect] Allow switching `CHIP_APP_ZAP_DIR` by cmake. Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no> --------- Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no> (cherry picked from commit a4530cbd8f3241355f232f7d23016eb5c57f6f3f)
1 parent 2c3f0a0 commit d5c7f72

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

config/common/cmake/chip_gn.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ if (NOT CHIP_ROOT)
3636
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../.. REALPATH)
3737
endif()
3838

39+
if (NOT CHIP_APP_ZAP_DIR)
40+
get_filename_component(CHIP_APP_ZAP_DIR ${CHIP_ROOT}/zzz_generated/app-common REALPATH)
41+
endif()
42+
3943
# ==============================================================================
4044
# Find required programs
4145
# ==============================================================================
@@ -165,7 +169,7 @@ macro(matter_build target)
165169
${CHIP_ROOT}/third_party/nlassert/repo/include
166170
${CHIP_ROOT}/third_party/nlio/repo/include
167171
${CHIP_ROOT}/third_party/nlfaultinjection/include
168-
${CHIP_ROOT}/zzz_generated/app-common
172+
${CHIP_APP_ZAP_DIR}
169173
${CMAKE_CURRENT_BINARY_DIR}/gen/include
170174
)
171175

config/nrfconnect/chip-module/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ include(generate_factory_data.cmake)
4141
if (NOT CHIP_ROOT)
4242
get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH)
4343
endif()
44+
45+
if (NOT CHIP_APP_ZAP_DIR)
46+
get_filename_component(CHIP_APP_ZAP_DIR ${CHIP_ROOT}/zzz_generated/app-common REALPATH)
47+
endif()
48+
4449
get_filename_component(GN_ROOT_TARGET ${CHIP_ROOT}/config/nrfconnect/chip-gn REALPATH)
4550
get_filename_component(COMMON_CMAKE_SOURCE_DIR ${CHIP_ROOT}/config/common/cmake REALPATH)
4651

@@ -140,6 +145,7 @@ matter_common_gn_args(
140145
matter_add_gn_arg_string("zephyr_ar" ${CMAKE_AR})
141146
matter_add_gn_arg_string("zephyr_cc" ${CMAKE_C_COMPILER})
142147
matter_add_gn_arg_string("zephyr_cxx" ${CMAKE_CXX_COMPILER})
148+
matter_add_gn_arg_string("chip_app_zap_dir" ${CHIP_APP_ZAP_DIR})
143149
matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG)
144150
matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD)
145151
matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD)

src/app/chip_data_model.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ if (NOT CHIP_ROOT)
2020
get_filename_component(CHIP_ROOT ${CHIP_APP_BASE_DIR}/../.. REALPATH)
2121
endif()
2222

23+
if (NOT CHIP_APP_ZAP_DIR)
24+
get_filename_component(CHIP_APP_ZAP_DIR ${CHIP_ROOT}/zzz_generated/app-common REALPATH)
25+
endif()
26+
2327
include("${CHIP_ROOT}/build/chip/chip_codegen.cmake")
2428
include("${CHIP_ROOT}/src/app/codegen-data-model-provider/model.cmake")
2529

@@ -152,7 +156,7 @@ function(chip_configure_data_model APP_TARGET)
152156
endif()
153157

154158
target_sources(${APP_TARGET} ${SCOPE}
155-
${CHIP_APP_BASE_DIR}/../../zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp
159+
${CHIP_APP_ZAP_DIR}/app-common/zap-generated/attributes/Accessors.cpp
156160
${CHIP_APP_BASE_DIR}/reporting/reporting.cpp
157161
${CHIP_APP_BASE_DIR}/util/attribute-storage.cpp
158162
${CHIP_APP_BASE_DIR}/util/attribute-table.cpp

src/app/common/BUILD.gn

+11-10
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,24 @@
1313
# limitations under the License.
1414

1515
import("//build_overrides/chip.gni")
16+
import("${chip_root}/src/app/common_flags.gni")
1617

1718
config("includes") {
18-
include_dirs = [ "${chip_root}/zzz_generated/app-common" ]
19+
include_dirs = [ "${chip_app_zap_dir}" ]
1920
}
2021

2122
source_set("attribute-type") {
22-
sources = [ "${chip_root}/zzz_generated/app-common/app-common/zap-generated/attribute-type.h" ]
23+
sources = [ "${chip_app_zap_dir}/app-common/zap-generated/attribute-type.h" ]
2324

2425
public_configs = [ ":includes" ]
2526
}
2627

2728
source_set("ids") {
2829
sources = [
29-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h",
30-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/ids/Clusters.h",
31-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h",
32-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/ids/Events.h",
30+
"${chip_app_zap_dir}/app-common/zap-generated/ids/Attributes.h",
31+
"${chip_app_zap_dir}/app-common/zap-generated/ids/Clusters.h",
32+
"${chip_app_zap_dir}/app-common/zap-generated/ids/Commands.h",
33+
"${chip_app_zap_dir}/app-common/zap-generated/ids/Events.h",
3334
]
3435

3536
public_deps = [ "${chip_root}/src/app/util:types" ]
@@ -41,8 +42,8 @@ static_library("cluster-objects") {
4142
output_name = "libClusterObjects"
4243

4344
sources = [
44-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp",
45-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h",
45+
"${chip_app_zap_dir}/app-common/zap-generated/cluster-objects.cpp",
46+
"${chip_app_zap_dir}/app-common/zap-generated/cluster-objects.h",
4647
]
4748

4849
public_deps = [
@@ -61,8 +62,8 @@ static_library("cluster-objects") {
6162

6263
source_set("enums") {
6364
sources = [
64-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h",
65-
"${chip_root}/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h",
65+
"${chip_app_zap_dir}/app-common/zap-generated/cluster-enums-check.h",
66+
"${chip_app_zap_dir}/app-common/zap-generated/cluster-enums.h",
6667
"CompatEnumNames.h",
6768
]
6869

src/app/common_flags.gni

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ declare_args() {
3535
chip_use_data_model_interface = "disabled"
3636
}
3737

38+
# Flag that sets path to zap-generated app-common directory
39+
chip_app_zap_dir = chip_root + "/zzz_generated/app-common"
40+
3841
# Whether we call `chipDie` on DM `check` errors
3942
#
4043
# If/once the chip_use_data_model_interface flag is removed or does not support

0 commit comments

Comments
 (0)