From 83dcfe074a9b225db8b1fb3bbf83e622983bd404 Mon Sep 17 00:00:00 2001 From: Rohan S <3526930+brosahay@users.noreply.github.com> Date: Mon, 6 Nov 2023 23:37:25 +0530 Subject: [PATCH] [Silabs] Adds changes in build system to support docker image change (#30181) * refactors GN build system * Restyled by shfmt * Adds changes based on comments * adds bugfix --------- Co-authored-by: Restyled.io --- .gitmodules | 2 +- examples/platform/silabs/SiWx917/BUILD.gn | 18 +++++------- examples/platform/silabs/efr32/BUILD.gn | 3 -- .../platform/silabs/efr32/rs911x/rs9117.gni | 8 ++--- .../platform/silabs/efr32/rs911x/rs911x.gni | 8 ++--- .../platform/silabs/efr32/wf200/wf200.gni | 7 ++--- scripts/build/builders/efr32.py | 6 ++++ scripts/examples/gn_silabs_example.sh | 2 ++ third_party/silabs/SiWx917_sdk.gni | 4 +-- third_party/silabs/efr32_sdk.gni | 29 ++++++++++++------- 10 files changed, 45 insertions(+), 42 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1cce5933d07eb6..ac8f8bde39fbe8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -245,7 +245,7 @@ path = third_party/silabs/wiseconnect-wifi-bt-sdk url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git branch = 2.8.2 - platforms = efr32,silabs_docker + platforms = efr32 [submodule "third_party/silabs/wifi_sdk"] path = third_party/silabs/wifi_sdk url = https://github.com/SiliconLabs/wiseconnect.git diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 83bd592c77132e..36a5aef1a860c1 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -17,10 +17,9 @@ import("//build_overrides/efr32_sdk.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/platform/device.gni") +import("${chip_root}/src/platform/silabs/wifi_args.gni") import("${chip_root}/third_party/silabs/silabs_board.gni") import("${efr32_sdk_build_root}/SiWx917_sdk.gni") -silabs_common_plat_dir = "${chip_root}/examples/platform/silabs" -wifi_sdk_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi" declare_args() { enable_heap_monitoring = false @@ -52,13 +51,12 @@ declare_args() { silabs_test_event_trigger_enable_key = "00112233445566778899aabbccddeeff" } -import("${chip_root}/src/platform/silabs/wifi_args.gni") -import("${silabs_common_plat_dir}/args.gni") - # Sanity check assert(chip_enable_wifi) silabs_common_plat_dir = "${chip_root}/examples/platform/silabs" +silabs_plat_si91x_wifi_dir = "${chip_root}/src/platform/silabs/SiWx917/wifi" +import("${silabs_common_plat_dir}/args.gni") config("chip_examples_project_config") { include_dirs = [ "project_include" ] @@ -207,7 +205,7 @@ source_set("siwx917-common") { include_dirs = [ ".", "SiWx917/", - "${wifi_sdk_dir}", + "${silabs_plat_si91x_wifi_dir}", ] sources = [ @@ -218,10 +216,10 @@ source_set("siwx917-common") { "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/silabs_utils.cpp", "${silabs_common_plat_dir}/syscalls_stubs.cpp", - "${wifi_sdk_dir}/dhcp_client.cpp", - "${wifi_sdk_dir}/ethernetif.cpp", - "${wifi_sdk_dir}/lwip_netif.cpp", - "${wifi_sdk_dir}/wfx_notify.cpp", + "${silabs_plat_si91x_wifi_dir}/dhcp_client.cpp", + "${silabs_plat_si91x_wifi_dir}/ethernetif.cpp", + "${silabs_plat_si91x_wifi_dir}/lwip_netif.cpp", + "${silabs_plat_si91x_wifi_dir}/wfx_notify.cpp", "SiWx917/sl_wifi_if.c", "SiWx917/wfx_rsi_host.c", ] diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 477ecf1214b0bf..a4fb8f1ac684dc 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -63,11 +63,8 @@ if (chip_enable_wifi) { import("${chip_root}/src/platform/silabs/wifi_args.gni") if (use_rs9116) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" import("rs911x/rs911x.gni") } else if (use_SiWx917) { - wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" import("rs911x/rs9117.gni") } if (use_wf200) { diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/examples/platform/silabs/efr32/rs911x/rs9117.gni index 3aa5e3e775b999..a753a66153bec4 100644 --- a/examples/platform/silabs/efr32/rs911x/rs9117.gni +++ b/examples/platform/silabs/efr32/rs911x/rs9117.gni @@ -1,15 +1,13 @@ import("//build_overrides/chip.gni") - -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -wifi_sdk_dir = "${chip_root}/src/platform/silabs/efr32/wifi" -wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" +import("//build_overrides/efr32_sdk.gni") +import("${efr32_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ "${examples_plat_dir}/rs911x/sl_wifi_if.c", "${examples_plat_dir}/rs911x/wfx_rsi_host.c", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", "${examples_plat_dir}/rs911x/hal/efx_spi.c", - "${wifi_sdk_dir}/wfx_notify.cpp", + "${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp", ] rs911x_inc_plat = [ diff --git a/examples/platform/silabs/efr32/rs911x/rs911x.gni b/examples/platform/silabs/efr32/rs911x/rs911x.gni index 0c305ce810abd1..6b52ff1b99c676 100644 --- a/examples/platform/silabs/efr32/rs911x/rs911x.gni +++ b/examples/platform/silabs/efr32/rs911x/rs911x.gni @@ -1,8 +1,6 @@ import("//build_overrides/chip.gni") - -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -wifi_sdk_dir = "${chip_root}/src/platform/silabs/efr32/wifi" -wiseconnect_sdk_root = "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" +import("//build_overrides/efr32_sdk.gni") +import("${efr32_sdk_build_root}/efr32_sdk.gni") rs911x_src_plat = [ "${examples_plat_dir}/rs911x/rsi_if.c", @@ -11,7 +9,7 @@ rs911x_src_plat = [ "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c", "${examples_plat_dir}/rs911x/hal/efx_spi.c", - "${wifi_sdk_dir}/wfx_notify.cpp", + "${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp", ] # diff --git a/examples/platform/silabs/efr32/wf200/wf200.gni b/examples/platform/silabs/efr32/wf200/wf200.gni index 4cd2943b12f8fb..7e3b4ae6f18d75 100644 --- a/examples/platform/silabs/efr32/wf200/wf200.gni +++ b/examples/platform/silabs/efr32/wf200/wf200.gni @@ -1,11 +1,10 @@ import("//build_overrides/chip.gni") - -examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" -wifi_sdk_dir = "${chip_root}/src/platform/silabs/efr32/wifi" +import("//build_overrides/efr32_sdk.gni") +import("${efr32_sdk_build_root}/efr32_sdk.gni") wf200_plat_incs = [ "${examples_plat_dir}/wf200" ] wf200_plat_src = [ - "${wifi_sdk_dir}/wfx_notify.cpp", + "${silabs_plat_efr32_wifi_dir}/wfx_notify.cpp", "${examples_plat_dir}/wf200/sl_wfx_task.c", "${examples_plat_dir}/wf200/wf200_init.c", "${examples_plat_dir}/wf200/efr_spi.c", diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index 990f44993eb55d..944ef08d130168 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -230,8 +230,14 @@ def __init__(self, # case for pre-installed images), use it directly. sdk_path = shlex.quote(os.environ['GSDK_ROOT']) self.extra_gn_options.append(f"efr32_sdk_root=\"{sdk_path}\"") + + if "GSDK_ROOT" in os.environ and not enable_wifi: self.extra_gn_options.append(f"openthread_root=\"{sdk_path}/util/third_party/openthread\"") + if "WISECONNECT_SDK_ROOT" in os.environ and enable_rs911x: + wiseconnect_sdk_path = shlex.quote(os.environ['WISECONNECT_SDK_ROOT']) + self.extra_gn_options.append(f"wiseconnect_sdk_root=\"{wiseconnect_sdk_path}\"") + def GnBuildArgs(self): return self.extra_gn_options diff --git a/scripts/examples/gn_silabs_example.sh b/scripts/examples/gn_silabs_example.sh index 174985b376d117..717783cff2925f 100755 --- a/scripts/examples/gn_silabs_example.sh +++ b/scripts/examples/gn_silabs_example.sh @@ -227,6 +227,8 @@ else ;; --docker) optArgs+="efr32_sdk_root=\"$GSDK_ROOT\" " + optArgs+="wiseconnect_sdk_root=\"$WISECONNECT_SDK_ROOT\" " + optArgs+="wifi_sdk_root=\"$WIFI_SDK_ROOT\" " USE_DOCKER=true shift ;; diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index eb9a35240833c4..932ccebe79904c 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -23,15 +23,13 @@ import("${chip_root}/src/lib/lib.gni") import("silabs_board.gni") declare_args() { - wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" - examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" - if (silabs_board == "BRD4338A") { sdk_support_board = "BRD4338A" } else { sdk_support_board = "BRD4325x" } } +examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" # Defines an siwx917 SDK build target. # diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index e928870cc7fba6..00329d05e88a5f 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -21,16 +21,13 @@ import("${chip_root}/src/app/icd/icd.gni") import("${chip_root}/src/lib/lib.gni") import("silabs_board.gni") -if (use_rs9116) { - wifi_sapi_root = "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" -} else if (use_SiWx917) { - wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" -} - declare_args() { # Location of the efr32 SDK. efr32_sdk_root = "${chip_root}/third_party/silabs/gecko_sdk" sdk_support_root = "${chip_root}/third_party/silabs/matter_support" + wiseconnect_sdk_root = + "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" + wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" # Build openthread with prebuilt silabs lib use_silabs_thread_lib = false @@ -72,9 +69,19 @@ declare_args() { # Use SLC generated files slc_reuse_files = false } +examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" +silabs_plat_efr32_wifi_dir = "${chip_root}/src/platform/silabs/efr32/wifi" assert(efr32_sdk_root != "", "efr32_sdk_root must be specified") +if (use_rs9116) { + assert(wiseconnect_sdk_root != "", "wiseconnect_sdk_root must be specified") +} + +if (use_SiWx917) { + assert(wifi_sdk_root != "", "wifi_sdk_root must be specified") +} + declare_args() { sl_ot_libs_path = "${efr32_sdk_root}/protocol/openthread" sl_ot_platform_abstraction = @@ -228,7 +235,7 @@ template("efr32_sdk") { if (chip_enable_ble_rs911x) { if (use_rs9116) { - _include_dirs += [ "${wifi_sapi_root}/sapi/include" ] + _include_dirs += [ "${wiseconnect_sdk_root}/sapi/include" ] } else { _include_dirs += [ "${wifi_sdk_root}/components/si91x/ble/inc" ] } @@ -750,10 +757,10 @@ template("efr32_sdk") { if (chip_enable_ble_rs911x) { if (use_rs9116) { sources += [ - "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gap_apis.c", - "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gatt_apis.c", - "${wifi_sapi_root}/sapi/bluetooth/rsi_bt_common_apis.c", - "${wifi_sapi_root}/sapi/driver/rsi_bt_ble.c", + "${wiseconnect_sdk_root}/sapi/bluetooth/rsi_ble_gap_apis.c", + "${wiseconnect_sdk_root}/sapi/bluetooth/rsi_ble_gatt_apis.c", + "${wiseconnect_sdk_root}/sapi/bluetooth/rsi_bt_common_apis.c", + "${wiseconnect_sdk_root}/sapi/driver/rsi_bt_ble.c", ] } else { sources += [