EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 1 | # Copyright (c) 2023 Project CHIP Authors |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import("//build_overrides/build.gni") |
| 16 | import("//build_overrides/chip.gni") |
| 17 | import("//build_overrides/efr32_sdk.gni") |
| 18 | import("//build_overrides/pigweed.gni") |
| 19 | |
| 20 | import("${build_root}/config/defaults.gni") |
Mathieu Kardous | 554c578 | 2024-10-30 17:23:37 -0400 | [diff] [blame] | 21 | import("${silabs_sdk_build_root}/silabs_executable.gni") |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 22 | |
| 23 | import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") |
| 24 | import("${chip_root}/src/platform/device.gni") |
| 25 | import("${chip_root}/third_party/silabs/silabs_board.gni") |
| 26 | |
| 27 | if (chip_enable_pw_rpc) { |
| 28 | import("//build_overrides/pigweed.gni") |
| 29 | import("$dir_pw_build/target_types.gni") |
| 30 | } |
| 31 | |
| 32 | assert(current_os == "freertos") |
| 33 | |
| 34 | silabs_project_dir = "${chip_root}/examples/smoke-co-alarm-app/silabs" |
| 35 | examples_common_plat_dir = "${chip_root}/examples/platform/silabs" |
| 36 | |
| 37 | if (wifi_soc) { |
| 38 | import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") |
| 39 | examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" |
| 40 | } else { |
Mathieu Kardous | 554c578 | 2024-10-30 17:23:37 -0400 | [diff] [blame] | 41 | import("${silabs_sdk_build_root}/efr32_sdk.gni") |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 42 | examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" |
| 43 | } |
| 44 | |
| 45 | import("${examples_common_plat_dir}/args.gni") |
| 46 | |
| 47 | declare_args() { |
| 48 | # Dump memory usage at link time. |
| 49 | chip_print_memory_usage = false |
| 50 | } |
| 51 | |
EricZijian_Siter | 22fa11b | 2023-07-13 22:17:37 +0800 | [diff] [blame] | 52 | if (slc_generate) { |
| 53 | # Generate Project Specific config (Board, hardware used etc..) |
| 54 | print(exec_script("${chip_root}/third_party/silabs/slc_gen/run_slc.py", |
| 55 | [ |
| 56 | rebase_path(chip_root), |
| 57 | "${silabs_board}", |
| 58 | "${disable_lcd}", |
| 59 | "${use_wstk_buttons}", |
| 60 | "${use_wstk_leds}", |
| 61 | "${use_external_flash}", |
| 62 | "${silabs_mcu}", |
Junior Martinez | 85db1da | 2023-07-18 21:09:55 -0400 | [diff] [blame] | 63 | rebase_path(slc_gen_path), |
EricZijian_Siter | 22fa11b | 2023-07-13 22:17:37 +0800 | [diff] [blame] | 64 | ], |
| 65 | "list lines")) |
| 66 | } |
| 67 | |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 68 | if (wifi_soc) { |
| 69 | siwx917_sdk("sdk") { |
| 70 | sources = [ |
Jean-Francois Penven | c1d26c0 | 2023-07-28 10:56:56 -0400 | [diff] [blame] | 71 | "${examples_common_plat_dir}/FreeRTOSConfig.h", |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 72 | "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 73 | ] |
| 74 | |
| 75 | include_dirs = [ |
| 76 | "${chip_root}/src/platform/silabs/SiWx917", |
| 77 | "${silabs_project_dir}/include", |
| 78 | "${examples_plat_dir}", |
| 79 | "${chip_root}/src/lib", |
| 80 | "${examples_common_plat_dir}", |
| 81 | ] |
| 82 | |
| 83 | defines = [] |
| 84 | if (chip_enable_pw_rpc) { |
| 85 | defines += [ |
| 86 | "HAL_VCOM_ENABLE=1", |
| 87 | "PW_RPC_ENABLED", |
| 88 | ] |
| 89 | } |
| 90 | } |
| 91 | } else { |
| 92 | efr32_sdk("sdk") { |
| 93 | sources = [ |
Jean-Francois Penven | c1d26c0 | 2023-07-28 10:56:56 -0400 | [diff] [blame] | 94 | "${examples_common_plat_dir}/FreeRTOSConfig.h", |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 95 | "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 96 | ] |
| 97 | |
| 98 | include_dirs = [ |
| 99 | "${chip_root}/src/platform/silabs/efr32", |
| 100 | "${silabs_project_dir}/include", |
| 101 | "${examples_plat_dir}", |
| 102 | "${chip_root}/src/lib", |
| 103 | "${examples_common_plat_dir}", |
| 104 | ] |
| 105 | |
| 106 | if (use_wf200) { |
| 107 | # TODO efr32_sdk should not need a header from this location |
| 108 | include_dirs += [ "${examples_plat_dir}/wf200" ] |
| 109 | } |
| 110 | |
| 111 | if (chip_enable_ble_rs911x) { |
| 112 | # TODO efr32_sdk should not need a header from this location |
| 113 | include_dirs += [ |
| 114 | "${examples_plat_dir}/rs911x", |
| 115 | "${examples_plat_dir}/rs911x/hal", |
| 116 | ] |
| 117 | } |
| 118 | |
| 119 | defines = [] |
| 120 | if (chip_enable_pw_rpc) { |
| 121 | defines += [ |
| 122 | "HAL_VCOM_ENABLE=1", |
| 123 | "PW_RPC_ENABLED", |
| 124 | ] |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | silabs_executable("smoke_co_alarm_app") { |
| 130 | output_name = "matter-silabs-smoke-co-alarm-example.out" |
| 131 | include_dirs = [ "include" ] |
| 132 | defines = [] |
| 133 | |
EricZijian_Siter | 22fa11b | 2023-07-13 22:17:37 +0800 | [diff] [blame] | 134 | if (silabs_board == "BRD2704A") { |
| 135 | defines += [ "SL_STATUS_LED=0" ] |
| 136 | } |
| 137 | |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 138 | sources = [ |
| 139 | "${examples_common_plat_dir}/main.cpp", |
| 140 | "src/AppTask.cpp", |
| 141 | "src/SmokeCoAlarmManager.cpp", |
| 142 | "src/ZclCallbacks.cpp", |
| 143 | ] |
| 144 | |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 145 | deps = [ |
| 146 | ":sdk", |
Maksymilian Knust | 686e73b | 2024-06-25 07:47:08 +0200 | [diff] [blame] | 147 | "${chip_root}/src/platform/logging:default", |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 148 | app_data_model, |
| 149 | ] |
| 150 | |
| 151 | if (wifi_soc) { |
| 152 | deps += [ "${examples_plat_dir}:siwx917-common" ] |
| 153 | } else { |
| 154 | deps += [ "${examples_plat_dir}:efr32-common" ] |
| 155 | } |
| 156 | |
| 157 | if (chip_enable_pw_rpc) { |
| 158 | defines += [ |
| 159 | "PW_RPC_ENABLED", |
| 160 | "PW_RPC_ATTRIBUTE_SERVICE=1", |
| 161 | "PW_RPC_BUTTON_SERVICE=1", |
| 162 | "PW_RPC_DESCRIPTOR_SERVICE=1", |
| 163 | "PW_RPC_DEVICE_SERVICE=1", |
| 164 | "PW_RPC_LIGHTING_SERVICE=1", |
| 165 | "PW_RPC_OTCLI_SERVICE=1", |
| 166 | "PW_RPC_THREAD_SERVICE=1", |
| 167 | ] |
| 168 | |
| 169 | sources += [ |
| 170 | "${chip_root}/examples/common/pigweed/RpcService.cpp", |
| 171 | "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", |
| 172 | "${examples_common_plat_dir}/PigweedLogger.cpp", |
| 173 | "${examples_common_plat_dir}/Rpc.cpp", |
| 174 | ] |
| 175 | |
| 176 | deps += [ |
dependabot[bot] | f44eb6b | 2024-01-24 16:20:15 -0500 | [diff] [blame] | 177 | "$dir_pw_hdlc:default_addresses", |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 178 | "$dir_pw_hdlc:rpc_channel_output", |
| 179 | "$dir_pw_stream:sys_io_stream", |
| 180 | "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", |
| 181 | "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", |
| 182 | "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", |
| 183 | "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", |
| 184 | "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", |
| 185 | "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", |
| 186 | "${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc", |
| 187 | "${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc", |
| 188 | ] |
| 189 | |
| 190 | if (wifi_soc) { |
| 191 | deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] |
| 192 | } else { |
Jean-Francois Penven | c1d26c0 | 2023-07-28 10:56:56 -0400 | [diff] [blame] | 193 | deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | deps += pw_build_LINK_DEPS |
| 197 | |
| 198 | include_dirs += [ |
| 199 | "${chip_root}/examples/common", |
| 200 | "${chip_root}/examples/common/pigweed/efr32", |
| 201 | ] |
| 202 | } |
| 203 | |
Jean-Francois Penven | c1d26c0 | 2023-07-28 10:56:56 -0400 | [diff] [blame] | 204 | ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" |
EricZijian_Siter | d16b379 | 2023-06-06 22:23:07 +0800 | [diff] [blame] | 205 | |
| 206 | inputs = [ ldscript ] |
| 207 | |
| 208 | ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] |
| 209 | |
| 210 | if (chip_print_memory_usage) { |
| 211 | ldflags += [ |
| 212 | "-Wl,--print-memory-usage", |
| 213 | "-fstack-usage", |
| 214 | ] |
| 215 | } |
| 216 | |
| 217 | # WiFi Settings |
| 218 | if (chip_enable_wifi) { |
| 219 | ldflags += [ |
| 220 | "-Wl,--defsym", |
| 221 | "-Wl,SILABS_WIFI=1", |
| 222 | ] |
| 223 | } |
| 224 | |
| 225 | output_dir = root_out_dir |
| 226 | } |
| 227 | |
| 228 | group("silabs") { |
| 229 | deps = [ ":smoke_co_alarm_app" ] |
| 230 | } |
| 231 | |
| 232 | group("default") { |
| 233 | deps = [ ":silabs" ] |
| 234 | } |