Skip to content

Commit

Permalink
[Silabs] Refactor/Cleanup examples build files (#24742)
Browse files Browse the repository at this point in the history
* WIP : Move common example platform source files to a common source_set. Move some build args to better/generic locations to reduce code duplication and build system complexity. Lighting-app mainly done

* Bring efr32_common to the others efr32 efr32 app and some more cleanup. Fix thread lib build with new gsdk

* WIP WiFi build cleanup. Rs911x Lighting-app builds

* WIP more clean up for wifi platform. wf200 now builds lighting app

* Apply refactore to the other examples builg.gn

* Fix window_app build for wifi, fix thermostat build.gn. fix test_driver build

* Fix so SiWx917 platform builds with the efr32 refactor. SiWx917 Refactor will come at another time

Remove a Todo. It is not needed

remove extra bracket in chef's  build.gn

* fix build with pw rpc

Fix lock-rpc build
  • Loading branch information
jmartinez-silabs authored and pull[bot] committed Dec 5, 2023
1 parent 1f9c050 commit 1686732
Show file tree
Hide file tree
Showing 32 changed files with 458 additions and 1,564 deletions.
203 changes: 15 additions & 188 deletions examples/chef/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,229 +35,71 @@ assert(current_os == "freertos")

chef_project_dir = "${chip_root}/examples/chef"
efr32_project_dir = "${chef_project_dir}/efr32"
examples_plat_dir = "${chip_root}/examples/platform/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
app_data_model = "${efr32_project_dir}:chef-comon"
import("${examples_plat_dir}/args.gni")

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 = false

sample_name = ""
}

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
}

chip_data_model("chef-common") {
zap_file = "${chef_project_dir}/devices/${sample_name}.zap"

zap_pregenerated_dir = "${chef_project_dir}/out/${sample_name}/zap-generated/"
is_server = true
}

# 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
}

# WiFi settings
if (chip_enable_wifi) {
wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi"
efr32_lwip_defs = [ "LWIP_NETIF_API=1" ]
efr32_lwip_defs += [
"LWIP_IPV4=1",
"LWIP_ARP=1",
"LWIP_ICMP=1",
"LWIP_DHCP=1",
"LWIP_IPV6_ND=1",
"LWIP_IGMP=1",
]

if (use_rs911x) {
wiseconnect_sdk_root =
"${chip_root}/third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"
import("${wifi_sdk_dir}/rs911x/rs911x.gni")
} else {
import("${wifi_sdk_dir}/wf200/wf200.gni")
}
}

efr32_sdk("sdk") {
sources = [
"${efr32_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/FreeRTOSConfig.h",
]

include_dirs = [
"${chip_root}/src/platform/EFR32",
"${chip_root}/src/platform/silabs/EFR32",
"${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 (use_wf200) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

defines = []
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("chef_app") {
output_name = "chip-efr32-chef-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

sources = [
"${examples_plat_dir}/BaseApplication.cpp",
"${examples_plat_dir}/efr32_utils.cpp",
"${examples_plat_dir}/heap_4_silabs.c",
"${examples_plat_dir}/init_efrPlatform.cpp",
"${examples_plat_dir}/matter_config.cpp",
"src/AppTask.cpp",
"src/LightingManager.cpp",
"src/ZclCallbacks.cpp",
"src/main.cpp",
]

if (use_wstk_leds) {
sources += [ "${examples_plat_dir}/LEDWidget.cpp" ]
}

if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli ||
use_wf200 || use_rs911x) {
sources += [ "${examples_plat_dir}/uart.cpp" ]
}

deps = [
":chef-common",
":sdk",
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
"${examples_plat_dir}:efr32-common",
]

# 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",
]
}

if (chip_enable_ota_requestor) {
defines += [ "EFR32_OTA_ENABLED" ]
sources += [ "${examples_plat_dir}/OTAConfig.cpp" ]
}

# 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 (!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" ]
if (show_qr_code) {
defines += [ "QR_CODE_ENABLED" ]
deps += [ "${chip_root}/examples/common/QRCode" ]
}
}

if (chip_enable_pw_rpc) {
defines += [
"PW_RPC_ENABLED",
Expand All @@ -274,8 +116,8 @@ efr32_executable("chef_app") {
sources += [
"${chip_root}/examples/common/pigweed/RpcService.cpp",
"${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
"${examples_plat_dir}/PigweedLogger.cpp",
"${examples_plat_dir}/Rpc.cpp",
"${examples_common_plat_dir}/PigweedLogger.cpp",
"${examples_common_plat_dir}/Rpc.cpp",
]

deps += [
Expand Down Expand Up @@ -303,11 +145,6 @@ efr32_executable("chef_app") {
]
}

if (enable_heap_monitoring) {
sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
defines += [ "HEAP_MONITORING" ]
}

ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld"

inputs = [ ldscript ]
Expand All @@ -329,16 +166,6 @@ efr32_executable("chef_app") {
]
}

# Attestation Credentials
if (chip_build_platform_attestation_credentials_provider) {
deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ]
}

# Factory Data Provider
if (use_efr32_factory_data_provider) {
deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ]
}

output_dir = root_out_dir
}

Expand Down
14 changes: 0 additions & 14 deletions examples/light-switch-app/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,9 @@ declare_args() {
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

Expand All @@ -71,14 +65,6 @@ declare_args() {
chip_default_wifi_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))
Expand Down
Loading

0 comments on commit 1686732

Please sign in to comment.