|
| 1 | +# Copyright (c) 2024 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") |
| 21 | +import("${efr32_sdk_build_root}/silabs_executable.gni") |
| 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/refrigerator-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 { |
| 41 | + import("${efr32_sdk_build_root}/efr32_sdk.gni") |
| 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 | + # Enable the temperature sensor |
| 52 | + # Some boards do not have a temperature sensor |
| 53 | + use_temp_sensor = false |
| 54 | +} |
| 55 | + |
| 56 | +if (wifi_soc) { |
| 57 | + siwx917_sdk("sdk") { |
| 58 | + sources = [ |
| 59 | + "${examples_common_plat_dir}/FreeRTOSConfig.h", |
| 60 | + "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 61 | + ] |
| 62 | + |
| 63 | + include_dirs = [ |
| 64 | + "${chip_root}/src/platform/silabs/SiWx917", |
| 65 | + "${silabs_project_dir}/include", |
| 66 | + "${examples_plat_dir}", |
| 67 | + "${chip_root}/src/lib", |
| 68 | + "${examples_common_plat_dir}", |
| 69 | + ] |
| 70 | + |
| 71 | + defines = [] |
| 72 | + if (chip_enable_pw_rpc) { |
| 73 | + defines += [ |
| 74 | + "HAL_VCOM_ENABLE=1", |
| 75 | + "PW_RPC_ENABLED", |
| 76 | + ] |
| 77 | + } |
| 78 | + } |
| 79 | +} else { |
| 80 | + efr32_sdk("sdk") { |
| 81 | + sources = [ |
| 82 | + "${examples_common_plat_dir}/FreeRTOSConfig.h", |
| 83 | + "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 84 | + ] |
| 85 | + |
| 86 | + include_dirs = [ |
| 87 | + "${chip_root}/src/platform/silabs/efr32", |
| 88 | + "${silabs_project_dir}/include", |
| 89 | + "${examples_plat_dir}", |
| 90 | + "${chip_root}/src/lib", |
| 91 | + "${examples_common_plat_dir}", |
| 92 | + ] |
| 93 | + |
| 94 | + if (use_wf200) { |
| 95 | + include_dirs += [ "${examples_plat_dir}/wf200" ] |
| 96 | + } |
| 97 | + |
| 98 | + if (chip_enable_ble_rs911x) { |
| 99 | + include_dirs += [ |
| 100 | + "${chip_root}/src/platform/silabs/efr32/rs911x", |
| 101 | + "${examples_plat_dir}/rs911x", |
| 102 | + "${examples_plat_dir}/rs911x/hal", |
| 103 | + ] |
| 104 | + } |
| 105 | + |
| 106 | + defines = [] |
| 107 | + if (chip_enable_pw_rpc) { |
| 108 | + defines += [ |
| 109 | + "HAL_VCOM_ENABLE=1", |
| 110 | + "PW_RPC_ENABLED", |
| 111 | + ] |
| 112 | + } |
| 113 | + |
| 114 | + if (use_temp_sensor) { |
| 115 | + include_dirs += [ |
| 116 | + "${efr32_sdk_root}/platform/driver/i2cspm/inc", |
| 117 | + "${efr32_sdk_root}/app/bluetooth/common/sensor_rht", |
| 118 | + "${efr32_sdk_root}/app/bluetooth/common/sensor_rht/config", |
| 119 | + "${efr32_sdk_root}/hardware/driver/si70xx/inc", |
| 120 | + "${efr32_sdk_root}/app/bluetooth/common/sensor_select", |
| 121 | + "${efr32_sdk_root}/platform/common/config", |
| 122 | + ] |
| 123 | + |
| 124 | + defines += [ "USE_TEMP_SENSOR" ] |
| 125 | + } |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +silabs_executable("refrigerator_app") { |
| 130 | + output_name = "matter-silabs-refrigerator-example.out" |
| 131 | + defines = [] |
| 132 | + include_dirs = [ |
| 133 | + "include", |
| 134 | + "${chip_root}/examples/refrigerator-app/refrigerator-common/include", |
| 135 | + ] |
| 136 | + |
| 137 | + sources = [ |
| 138 | + "${chip_root}/examples/refrigerator-app/refrigerator-common/src/static-supported-temperature-levels.cpp", |
| 139 | + "${examples_common_plat_dir}/main.cpp", |
| 140 | + "src/AppTask.cpp", |
| 141 | + "src/RefrigeratorManager.cpp", |
| 142 | + "src/ZclCallbacks.cpp", |
| 143 | + "src/refrigerator-and-temperature-controlled-cabinet-mode.cpp", |
| 144 | + ] |
| 145 | + |
| 146 | + if (use_temp_sensor) { |
| 147 | + sources += [ |
| 148 | + "${efr32_sdk_root}/hardware/driver/si70xx/src/sl_si70xx.c", |
| 149 | + "${efr32_sdk_root}/platform/common/src/sl_status.c", |
| 150 | + "${efr32_sdk_root}/platform/driver/i2cspm/src/sl_i2cspm.c", |
| 151 | + "${efr32_sdk_root}/platform/emlib/src/em_i2c.c", |
| 152 | + "${examples_common_plat_dir}/TemperatureSensor.cpp", |
| 153 | + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_i2cspm_init.c", |
| 154 | + ] |
| 155 | + } |
| 156 | + |
| 157 | + if (!disable_lcd) { |
| 158 | + sources += [ "src/RefrigeratorUI.cpp" ] |
| 159 | + } |
| 160 | + |
| 161 | + deps = [ |
| 162 | + ":sdk", |
| 163 | + app_data_model, |
| 164 | + ] |
| 165 | + |
| 166 | + if (wifi_soc) { |
| 167 | + deps += [ "${examples_plat_dir}:siwx917-common" ] |
| 168 | + } else { |
| 169 | + deps += [ "${examples_plat_dir}:efr32-common" ] |
| 170 | + } |
| 171 | + |
| 172 | + if (chip_enable_pw_rpc) { |
| 173 | + defines += [ |
| 174 | + "PW_RPC_ENABLED", |
| 175 | + "PW_RPC_ATTRIBUTE_SERVICE=1", |
| 176 | + "PW_RPC_BUTTON_SERVICE=1", |
| 177 | + "PW_RPC_DESCRIPTOR_SERVICE=1", |
| 178 | + "PW_RPC_DEVICE_SERVICE=1", |
| 179 | + ] |
| 180 | + |
| 181 | + sources += [ |
| 182 | + "${chip_root}/examples/common/pigweed/RpcService.cpp", |
| 183 | + "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", |
| 184 | + "${examples_common_plat_dir}/PigweedLogger.cpp", |
| 185 | + "${examples_common_plat_dir}/Rpc.cpp", |
| 186 | + ] |
| 187 | + |
| 188 | + deps += [ |
| 189 | + "$dir_pw_hdlc:default_addresses", |
| 190 | + "$dir_pw_hdlc:rpc_channel_output", |
| 191 | + "$dir_pw_stream:sys_io_stream", |
| 192 | + "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", |
| 193 | + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", |
| 194 | + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", |
| 195 | + "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", |
| 196 | + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", |
| 197 | + ] |
| 198 | + |
| 199 | + if (wifi_soc) { |
| 200 | + deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] |
| 201 | + } else { |
| 202 | + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] |
| 203 | + } |
| 204 | + |
| 205 | + deps += pw_build_LINK_DEPS |
| 206 | + |
| 207 | + include_dirs += [ |
| 208 | + "${chip_root}/examples/common", |
| 209 | + "${chip_root}/examples/common/pigweed/efr32", |
| 210 | + ] |
| 211 | + } |
| 212 | + |
| 213 | + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" |
| 214 | + |
| 215 | + inputs = [ ldscript ] |
| 216 | + |
| 217 | + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] |
| 218 | + |
| 219 | + if (chip_print_memory_usage) { |
| 220 | + ldflags += [ |
| 221 | + "-Wl,--print-memory-usage", |
| 222 | + "-fstack-usage", |
| 223 | + ] |
| 224 | + } |
| 225 | + |
| 226 | + # WiFi Settings |
| 227 | + if (chip_enable_wifi) { |
| 228 | + ldflags += [ |
| 229 | + "-Wl,--defsym", |
| 230 | + "-Wl,SILABS_WIFI=1", |
| 231 | + ] |
| 232 | + } |
| 233 | + |
| 234 | + output_dir = root_out_dir |
| 235 | +} |
| 236 | + |
| 237 | +group("silabs") { |
| 238 | + deps = [ ":refrigerator_app" ] |
| 239 | +} |
| 240 | + |
| 241 | +group("default") { |
| 242 | + deps = [ ":silabs" ] |
| 243 | +} |
0 commit comments