forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.gn
395 lines (330 loc) · 10.3 KB
/
BUILD.gn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# 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.
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")
import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/SiWx917_sdk.gni")
import("${efr32_sdk_build_root}/efr32_executable.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
}
assert(current_os == "freertos")
efr32_project_dir = "${chip_root}/examples/lighting-app/silabs/SiWx917"
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
# Monitor & log memory usage at runtime.
enable_heap_monitoring = false
# Enable Sleepy end device
enable_sleepy_device = false
# OTA timeout in seconds
OTA_periodic_query_timeout = 86400
# Wifi related stuff - they are overridden by gn -args="use_wf200=true"
use_wf200 = false
use_rs911x = false
use_rs911x_sockets = false
sl_wfx_config_softap = false
sl_wfx_config_scan = true
# Disable LCD on supported devices
disable_lcd = true
# Argument to Disable IPv4 for wifi(rs911)
chip_enable_wifi_ipv4 = false
# Argument to force enable WPA3 security on rs91x
rs91x_wpa3_only = false
#default WiFi SSID
ssid = ""
#default Wifi Password
psk = ""
}
declare_args() {
# Enables LCD Qr Code on supported devices
show_qr_code = !disable_lcd
}
# qr code cannot be true if lcd is disabled
assert(!(disable_lcd && show_qr_code))
# Sanity check
assert(!(chip_enable_wifi && chip_enable_openthread))
assert(!(use_rs911x && chip_enable_openthread))
assert(!(use_wf200 && chip_enable_openthread))
if (chip_enable_wifi) {
assert(use_rs911x || use_wf200)
enable_openthread_cli = false
import("${chip_root}/src/platform/silabs/SiWx917/wifi_args.gni")
}
# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD)
if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" ||
silabs_board == "BRD2703A" || silabs_board == "BRD4319A") {
show_qr_code = false
disable_lcd = true
}
defines = []
# WiFi settings
if (chip_enable_wifi) {
# disabling LCD for MG24 for wifi
if (silabs_board == "BRD4186A" || silabs_board == "BRD4187A") {
show_qr_code = false
disable_lcd = true
}
if (ssid != "") {
defines += [
"CHIP_ONNETWORK_PAIRING = 1",
"CHIP_WIFI_SSID = $ssid",
]
}
if (psk != "") {
assert(ssid != "", "ssid can't be null if psk is provided")
defines += [ "CHIP_WIFI_PSK = $psk" ]
}
wifi_sdk_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi"
efr32_lwip_defs = [ "LWIP_NETIF_API=1" ]
if (lwip_ipv4) {
efr32_lwip_defs += [
"LWIP_IPV4=1",
# adds following options to provide
# them to .cpp source files
# flags ported from lwipopts file
# TODO: move lwipopts to one location
"LWIP_ARP=1",
"LWIP_ICMP=1",
"LWIP_IGMP=1",
"LWIP_DHCP=1",
"LWIP_DNS=0",
]
} else {
efr32_lwip_defs += [ "LWIP_IPV4=0" ]
}
if (lwip_ipv6) {
efr32_lwip_defs += [ "LWIP_IPV6=1" ]
} else {
efr32_lwip_defs += [ "LWIP_IPV6=0" ]
}
wiseconnect_sdk_root = "${chip_root}/third_party/silabs/wisemcu-wifi-bt-sdk"
import("${examples_plat_dir}/SiWx917/rs911x.gni")
}
efr32_sdk("sdk") {
sources = [
"${efr32_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/FreeRTOSConfig.h",
]
include_dirs = [
"${chip_root}/src/platform/silabs/SiWx917",
"${efr32_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
"${examples_common_plat_dir}",
]
defines += [
"BOARD_ID=${silabs_board}",
"OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}",
]
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
"PW_RPC_ENABLED",
]
}
# WiFi Settings
if (chip_enable_wifi) {
if (use_rs911x) {
defines += rs911x_defs
include_dirs += rs911x_plat_incs
} else if (use_wf200) {
defines += wf200_defs
include_dirs += wf200_plat_incs
}
if (use_rs911x_sockets) {
include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ]
defines += rs911x_sock_defs
} else {
# Using LWIP instead of the native TCP/IP stack
defines += efr32_lwip_defs
}
if (sl_wfx_config_softap) {
defines += [ "SL_WFX_CONFIG_SOFTAP" ]
}
if (sl_wfx_config_scan) {
defines += [ "SL_WFX_CONFIG_SCAN" ]
}
}
}
efr32_executable("lighting_app") {
output_name = "chip-efr32-lighting-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []
sources = [
"${examples_common_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/init_ccpPlatform.cpp",
"${examples_plat_dir}/matter_config.cpp",
"${examples_plat_dir}/siwx917_utils.cpp",
"src/AppTask.cpp",
"src/LightingManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]
if (use_wstk_leds) {
# TODO: Commentting for CCP till the bring up of this is done
#sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}
if (chip_enable_pw_rpc || chip_build_libshell || use_rs911x) {
# TODO: Commentting for CCP till the bring up of this is done
#sources += [ "${examples_plat_dir}/uart.cpp" ]
}
deps = [
":sdk",
"${chip_root}/examples/lighting-app/lighting-common",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
# OpenThread Settings
if (chip_enable_openthread) {
deps += [
"${chip_root}/third_party/openthread:openthread",
"${chip_root}/third_party/openthread:openthread-platform",
"${examples_plat_dir}:efr-matter-shell",
]
}
#TODO: OTA should be added
# WiFi Settings
if (chip_enable_wifi) {
if (use_rs911x) {
sources += rs911x_src_plat
# All the stuff from wiseconnect
sources += rs911x_src_sapi
# Apparently - the rsi library needs this (though we may not use use it)
sources += rs911x_src_sock
include_dirs += rs911x_inc_plat
if (use_rs911x_sockets) {
#
# Using native sockets inside RS911x
#
include_dirs += rs911x_sock_inc
} else {
#
# We use LWIP - not built-in sockets
#
sources += rs911x_src_lwip
}
} else if (use_wf200) {
sources += wf200_plat_src
include_dirs += wf200_plat_incs
}
if (chip_enable_wifi_ipv4) {
defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ]
}
if (rs91x_wpa3_only) {
# TODO: Change this macro once WF200 support is provided
defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ]
}
}
if (!disable_lcd) {
sources += [
"${examples_plat_dir}/display/demo-ui.c",
"${examples_plat_dir}/display/lcd.cpp",
]
include_dirs += [ "${examples_plat_dir}/display" ]
defines += [
"DISPLAY_ENABLED",
"IS_DEMO_LIGHT=1",
]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
}
}
if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED",
"PW_RPC_ATTRIBUTE_SERVICE=1",
"PW_RPC_BUTTON_SERVICE=1",
"PW_RPC_DESCRIPTOR_SERVICE=1",
"PW_RPC_DEVICE_SERVICE=1",
"PW_RPC_LIGHTING_SERVICE=1",
"PW_RPC_OTCLI_SERVICE=1",
"PW_RPC_THREAD_SERVICE=1",
"PW_RPC_TRACING_SERVICE=1",
]
sources += [
"${chip_root}/examples/common/pigweed/RpcService.cpp",
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
"${examples_common_plat_dir}/PigweedLogger.cpp",
"${examples_common_plat_dir}/Rpc.cpp",
]
deps += [
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_stream:sys_io_stream",
"$dir_pw_trace",
"$dir_pw_trace_tokenized",
"$dir_pw_trace_tokenized:trace_rpc_service",
"${chip_root}/config/efr32/lib/pw_rpc:pw_rpc",
"${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:button_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917",
]
deps += pw_build_LINK_DEPS
include_dirs += [
"${chip_root}/examples/common",
"${chip_root}/examples/common/pigweed/efr32",
]
}
if (enable_heap_monitoring) {
sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ]
defines += [ "HEAP_MONITORING" ]
}
ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld"
inputs = [ ldscript ]
ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
if (chip_print_memory_usage) {
ldflags += [
"-Wl,--print-memory-usage",
"-fstack-usage",
]
}
# WiFi Settings
if (chip_enable_wifi) {
ldflags += [
"-Wl,--defsym",
"-Wl,SILABS_WIFI=1",
]
}
# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ "${examples_plat_dir}:siwx917-attestation-credentials" ]
}
# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}
output_dir = root_out_dir
}
group("efr32") {
deps = [ ":lighting_app" ]
}
group("default") {
deps = [ ":efr32" ]
}