1
+ cmake_minimum_required (VERSION 3.20)
2
+
3
+ project (chip-gn)
4
+
5
+ set (chip_dir "${bee_matter_root} " )
6
+ set (chip_dir_output "${matter_output_path} /chip" )
7
+ set (chip_c_flags "" )
8
+ set (chip_cpp_flags "" )
9
+ set (chip-gn chip-gn)
10
+
11
+ set (matter_enable_rotating_id 1)
12
+
13
+ get_filename_component (CHIP_OUTPUT ${chip_dir_output} REALPATH)
14
+
15
+ include (ExternalProject)
16
+
17
+ # FOR CHIP
18
+ string (APPEND CHIP_GN_ARGS)
19
+
20
+ list (
21
+ APPEND CHIP_CFLAGS
22
+
23
+ -DCHIP_PROJECT=1
24
+ -DCONFIG_USE_MBEDTLS_ROM_ALG
25
+ -DDM_ODM_SUPPORT_TYPE=32
26
+ -DCHIP_DEVICE_LAYER_TARGET=Realtek_bee
27
+ -D_POSIX_REALTIME_SIGNALS
28
+ -DCHIP_SHELL_MAX_TOKENS=11
29
+ )
30
+ # Build Matter otcli
31
+ if (matter_enable_otcli)
32
+ list (APPEND CHIP_CFLAGS -DCHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI=1)
33
+ endif (matter_enable_otcli)
34
+
35
+ if (matter_enable_factory_data)
36
+ list (APPEND CHIP_CFLAGS -DCONFIG_FACTORY_DATA=1)
37
+ endif (matter_enable_factory_data)
38
+
39
+ list (
40
+ APPEND CHIP_CXXFLAGS
41
+
42
+ -DFD_SETSIZE=10
43
+ -Wno-sign-compare
44
+ -Wno-unused-function
45
+ -Wno-unused-but-set-variable
46
+ -Wno-unused-variable
47
+ -Wno-deprecated-declarations
48
+ -Wno-unused-parameter
49
+ -Wno-unused-label
50
+ -Wno-format
51
+ -Wno-stringop-truncation
52
+ -Wno-format-nonliteral
53
+ -Wno-format-security
54
+ -std=gnu++17
55
+ )
56
+
57
+ list (
58
+ APPEND CHIP_INC
59
+
60
+ ${inc_path}
61
+ ${CHIP_ROOT} /config/realtek_bee
62
+ ${CHIP_ROOT} /src/include
63
+ ${CHIP_ROOT} /src/lib
64
+ ${CHIP_ROOT} /src
65
+ ${CHIP_ROOT} /src/system
66
+ ${CHIP_ROOT} /src/app
67
+ ${CHIP_ROOT} /src/platform/Realtek_bee
68
+ ${CHIP_ROOT} /src/platform/OpenThread
69
+ ${CHIP_ROOT} /third_party/nlassert/repo/include
70
+ ${CHIP_ROOT} /third_party/nlio/repo/include
71
+ )
72
+
73
+ execute_process (
74
+ COMMAND echo "mkdir CHIP output folder ..."
75
+ COMMAND mkdir -p ${CHIP_OUTPUT}
76
+ )
77
+
78
+ foreach (tmp IN LISTS CHIP_CFLAGS)
79
+ string (CONCAT appended "\" " ${tmp} "\" , " )
80
+ string (APPEND chip_c_flags "${appended} " )
81
+ endforeach ()
82
+ foreach (tmp IN LISTS GLOBAL_C_FLAGS)
83
+ string (CONCAT appended "\" " ${tmp} "\" , " )
84
+ string (APPEND chip_c_flags "${appended} " )
85
+ endforeach ()
86
+ foreach (tmp IN LISTS inc_path)
87
+ string (CONCAT appended "\" -I" ${tmp} "\" , " )
88
+ string (APPEND chip_c_flags "${appended} " )
89
+ endforeach ()
90
+ foreach (tmp IN LISTS CHIP_INC)
91
+ string (CONCAT appended "\" -I" ${tmp} "\" , " )
92
+ string (APPEND chip_c_flags "${appended} " )
93
+ endforeach ()
94
+ foreach (tmp IN LISTS CHIP_CXXFLAGS)
95
+ string (CONCAT appended "\" " ${tmp} "\" , " )
96
+ string (APPEND chip_cpp_flags "${appended} " )
97
+ endforeach ()
98
+ foreach (tmp IN LISTS GLOBAL_CXX_FLAGS)
99
+ string (CONCAT appended "\" " ${tmp} "\" , " )
100
+ string (APPEND chip_cpp_flags "${appended} " )
101
+ endforeach ()
102
+ string (APPEND chip_cpp_flags "${chip_c_flags} " )
103
+
104
+ set (import_str "import(\" //args.gni\" )\n " )
105
+
106
+ string (APPEND CHIP_GN_ARGS "${import_str} " )
107
+
108
+ string (APPEND CHIP_GN_ARGS "target_cflags_c = [${chip_c_flags} ]\n " )
109
+ string (APPEND CHIP_GN_ARGS "target_cflags_cc = [${chip_cpp_flags} ]\n " )
110
+ string (APPEND CHIP_GN_ARGS "bee_ar = \" arm-none-eabi-ar\"\n " )
111
+ string (APPEND CHIP_GN_ARGS "bee_cc = \" arm-none-eabi-gcc\"\n " )
112
+ string (APPEND CHIP_GN_ARGS "bee_cxx = \" arm-none-eabi-c++\"\n " )
113
+ string (APPEND CHIP_GN_ARGS "bee_cpu = \" arm\"\n " )
114
+ string (APPEND CHIP_GN_ARGS "chip_enable_openthread = true\n " )
115
+ string (APPEND CHIP_GN_ARGS "chip_inet_config_enable_ipv4 = false\n " )
116
+ string (APPEND CHIP_GN_ARGS "chip_use_transitional_commissionable_data_provider = false\n " )
117
+ string (APPEND CHIP_GN_ARGS "chip_logging = true\n " )
118
+ string (APPEND CHIP_GN_ARGS "chip_error_logging = true\n " )
119
+ string (APPEND CHIP_GN_ARGS "chip_progress_logging = true\n " )
120
+ string (APPEND CHIP_GN_ARGS "chip_detail_logging= false\n " )
121
+
122
+ # project config
123
+ string (APPEND CHIP_GN_ARGS "chip_project_config_include_dirs = [\" ${matter_example_path} /main/include\" ]\n " )
124
+ string (APPEND CHIP_GN_ARGS "chip_device_project_config_include = \" <CHIPProjectConfig.h>\"\n " )
125
+ string (APPEND CHIP_GN_ARGS "chip_project_config_include = \" <CHIPProjectConfig.h>\"\n " )
126
+ string (APPEND CHIP_GN_ARGS "chip_system_project_config_include = \" <CHIPProjectConfig.h>\"\n " )
127
+
128
+ # Enable persistent storage audit
129
+ if (matter_enable_persistentstorage_audit)
130
+ string (APPEND CHIP_GN_ARGS "chip_support_enable_storage_api_audit = true\n " )
131
+ endif (matter_enable_persistentstorage_audit)
132
+ #endif
133
+
134
+ # Build RPC
135
+ if (matter_enable_rpc)
136
+ string (APPEND CHIP_GN_ARGS "chip_build_pw_rpc_lib = true\n " )
137
+ string (APPEND CHIP_GN_ARGS "pw_log_BACKEND = \" //third_party/connectedhomeip/third_party/pigweed/repo/pw_log_basic\"\n " )
138
+ string (APPEND CHIP_GN_ARGS "pw_assert_BACKEND = \" //third_party/connectedhomeip/third_party/pigweed/repo/pw_assert_log:check_backend\"\n " )
139
+ string (APPEND CHIP_GN_ARGS "pw_sys_io_BACKEND = \" //third_party/connectedhomeip/examples/platform/realtek_bee/pw_sys_io:pw_sys_io_bee\"\n " )
140
+ string (APPEND CHIP_GN_ARGS "dir_pw_third_party_nanopb = \" //third_party/connectedhomeip/third_party/nanopb/repo\"\n " )
141
+ string (APPEND CHIP_GN_ARGS "pw_build_LINK_DEPS = [\" //third_party/connectedhomeip/third_party/pigweed/repo/pw_assert:impl\" , \" //third_party/connectedhomeip/third_party/pigweed/repo/pw_log:impl\" ]\n " )
142
+ string (APPEND CHIP_GN_ARGS "pw_rpc_CONFIG = \" //third_party/connectedhomeip/third_party/pigweed/repo/pw_rpc:disable_global_mutex\" " )
143
+ endif (matter_enable_rpc)
144
+
145
+ if (matter_enable_ftd)
146
+ string (APPEND CHIP_GN_ARGS "chip_openthread_ftd = true\n " )
147
+ string (APPEND CHIP_GN_ARGS "chip_enable_icd_server = false\n " )
148
+ endif ()
149
+
150
+ if (matter_enable_mtd)
151
+ string (APPEND CHIP_GN_ARGS "chip_openthread_ftd = false\n " )
152
+ if (matter_enable_med)
153
+ string (APPEND CHIP_GN_ARGS "chip_enable_icd_server = false\n " )
154
+ else ()
155
+ string (APPEND CHIP_GN_ARGS "chip_enable_icd_server = true\n " )
156
+ endif ()
157
+ endif ()
158
+
159
+ # Build Matter Shell
160
+ if (matter_enable_shell)
161
+ string (APPEND CHIP_GN_ARGS "chip_build_libshell = true\n " )
162
+ endif (matter_enable_shell)
163
+
164
+ # Build ota-requestor
165
+ if (matter_enable_ota_requestor)
166
+ string (APPEND CHIP_GN_ARGS "chip_enable_ota_requestor = true\n " )
167
+ endif (matter_enable_ota_requestor)
168
+
169
+ # Rotating ID
170
+ if (matter_enable_rotating_id)
171
+ string (APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = true\n " )
172
+ string (APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = true\n " )
173
+ else (matter_enable_rotating_id)
174
+ string (APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = false\n " )
175
+ string (APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = false\n " )
176
+ endif (matter_enable_rotating_id)
177
+
178
+ file (GENERATE OUTPUT ${CHIP_OUTPUT} /args.gn CONTENT ${CHIP_GN_ARGS} )
179
+
180
+ ExternalProject_Add(
181
+ chip-gn
182
+ PREFIX ${CMAKE_CURRENT_BINARY_DIR}
183
+ SOURCE_DIR ${CHIP_ROOT}
184
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}
185
+ CONFIGURE_COMMAND gn --root=${CHIP_ROOT} /config/realtek_bee gen --check --fail-on -unused-args ${CHIP_OUTPUT}
186
+ BUILD_COMMAND ninja -C ${CHIP_OUTPUT} :realtek_bee
187
+ INSTALL_COMMAND ""
188
+ BUILD_BYPRODUCTS -lCHIP -lPwRpc
189
+ CONFIGURE_ALWAYS TRUE
190
+ BUILD_ALWAYS TRUE
191
+ USES_TERMINAL_CONFIGURE TRUE
192
+ USES_TERMINAL_BUILD TRUE
193
+ )
0 commit comments