|
| 1 | +# Copyright (c) 2020 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/dishwasher-app/silabs" |
| 35 | +examples_common_plat_dir = "${chip_root}/examples/platform/silabs" |
| 36 | +example_enegy_management_dir = "${chip_root}/examples/energy-management-app" |
| 37 | + |
| 38 | +if (wifi_soc) { |
| 39 | + import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") |
| 40 | + examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" |
| 41 | +} else { |
| 42 | + import("${efr32_sdk_build_root}/efr32_sdk.gni") |
| 43 | + examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" |
| 44 | +} |
| 45 | + |
| 46 | +import("${examples_common_plat_dir}/args.gni") |
| 47 | + |
| 48 | +declare_args() { |
| 49 | + # Dump memory usage at link time. |
| 50 | + chip_print_memory_usage = false |
| 51 | +} |
| 52 | + |
| 53 | +if (slc_generate) { |
| 54 | + # Generate Project Specific config (Board, hardware used etc..) |
| 55 | + print(exec_script("${chip_root}/third_party/silabs/slc_gen/run_slc.py", |
| 56 | + [ |
| 57 | + rebase_path(chip_root), |
| 58 | + "${silabs_board}", |
| 59 | + "${disable_lcd}", |
| 60 | + "${use_wstk_buttons}", |
| 61 | + "${use_wstk_leds}", |
| 62 | + "${use_external_flash}", |
| 63 | + "${silabs_mcu}", |
| 64 | + rebase_path(slc_gen_path), |
| 65 | + ], |
| 66 | + "list lines")) |
| 67 | +} |
| 68 | + |
| 69 | +if (wifi_soc) { |
| 70 | + siwx917_sdk("sdk") { |
| 71 | + sources = [ |
| 72 | + "${examples_common_plat_dir}/FreeRTOSConfig.h", |
| 73 | + "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 74 | + ] |
| 75 | + |
| 76 | + include_dirs = [ |
| 77 | + "${chip_root}/src/platform/silabs/SiWx917", |
| 78 | + "${silabs_project_dir}/include", |
| 79 | + "${examples_plat_dir}", |
| 80 | + "${chip_root}/src/lib", |
| 81 | + "${examples_common_plat_dir}", |
| 82 | + ] |
| 83 | + |
| 84 | + defines = [] |
| 85 | + if (chip_enable_pw_rpc) { |
| 86 | + defines += [ |
| 87 | + "HAL_VCOM_ENABLE=1", |
| 88 | + "PW_RPC_ENABLED", |
| 89 | + ] |
| 90 | + } |
| 91 | + } |
| 92 | +} else { |
| 93 | + efr32_sdk("sdk") { |
| 94 | + sources = [ |
| 95 | + "${examples_common_plat_dir}/FreeRTOSConfig.h", |
| 96 | + "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 97 | + ] |
| 98 | + |
| 99 | + include_dirs = [ |
| 100 | + "${chip_root}/src/platform/silabs/efr32", |
| 101 | + "${silabs_project_dir}/include", |
| 102 | + "${examples_plat_dir}", |
| 103 | + "${chip_root}/src/lib", |
| 104 | + "${examples_common_plat_dir}", |
| 105 | + ] |
| 106 | + |
| 107 | + if (use_wf200) { |
| 108 | + # TODO efr32_sdk should not need a header from this location |
| 109 | + include_dirs += [ "${examples_plat_dir}/wf200" ] |
| 110 | + } |
| 111 | + |
| 112 | + if (chip_enable_ble_rs911x) { |
| 113 | + # TODO efr32_sdk should not need a header from this location |
| 114 | + include_dirs += [ |
| 115 | + "${examples_plat_dir}/rs911x", |
| 116 | + "${examples_plat_dir}/rs911x/hal", |
| 117 | + ] |
| 118 | + } |
| 119 | + |
| 120 | + defines = [] |
| 121 | + if (chip_enable_pw_rpc) { |
| 122 | + defines += [ |
| 123 | + "HAL_VCOM_ENABLE=1", |
| 124 | + "PW_RPC_ENABLED", |
| 125 | + ] |
| 126 | + } |
| 127 | + } |
| 128 | +} |
| 129 | +silabs_executable("dishwasher_app") { |
| 130 | + output_name = "matter-silabs-dishwasher-example.out" |
| 131 | + defines = [] |
| 132 | + include_dirs = [ |
| 133 | + "include", |
| 134 | + "${example_enegy_management_dir}/energy-management-common/device-energy-management/include", |
| 135 | + "${example_enegy_management_dir}/energy-management-common/energy-reporting/include", |
| 136 | + "${example_enegy_management_dir}/energy-management-common/common/include", |
| 137 | + ] |
| 138 | + |
| 139 | + if (silabs_board == "BRD2704A") { |
| 140 | + defines += [ "SL_STATUS_LED=0" ] |
| 141 | + } |
| 142 | + |
| 143 | + sources = [ |
| 144 | + "${example_enegy_management_dir}/energy-management-common/common/src/EnergyTimeUtils.cpp", |
| 145 | + "${example_enegy_management_dir}/energy-management-common/device-energy-management/src/DEMTestEventTriggers.cpp", |
| 146 | + "${example_enegy_management_dir}/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp", |
| 147 | + "${example_enegy_management_dir}/energy-management-common/device-energy-management/src/DeviceEnergyManagementManager.cpp", |
| 148 | + "${example_enegy_management_dir}/energy-management-common/device-energy-management/src/device-energy-management-mode.cpp", |
| 149 | + "${example_enegy_management_dir}/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp", |
| 150 | + "${example_enegy_management_dir}/energy-management-common/energy-reporting/src/EnergyReportingEventTriggers.cpp", |
| 151 | + "${example_enegy_management_dir}/energy-management-common/energy-reporting/src/FakeReadings.cpp", |
| 152 | + "${example_enegy_management_dir}/energy-management-common/energy-reporting/src/PowerTopologyDelegate.cpp", |
| 153 | + "${examples_common_plat_dir}/main.cpp", |
| 154 | + "src/AppTask.cpp", |
| 155 | + "src/DataModelHelper.cpp", |
| 156 | + "src/DeviceEnergyManager.cpp", |
| 157 | + "src/DishwasherManager.cpp", |
| 158 | + "src/ElectricalEnergyMeasurementInstance.cpp", |
| 159 | + "src/ElectricalSensorManager.cpp", |
| 160 | + "src/PowerTopologyDelegateImpl.cpp", |
| 161 | + "src/ZclCallbacks.cpp", |
| 162 | + "src/operational-state-delegate-impl.cpp", |
| 163 | + ] |
| 164 | + |
| 165 | + deps = [ |
| 166 | + ":sdk", |
| 167 | + "${chip_root}/src/platform/logging:default", |
| 168 | + app_data_model, |
| 169 | + ] |
| 170 | + |
| 171 | + if (wifi_soc) { |
| 172 | + deps += [ "${examples_plat_dir}:siwx917-common" ] |
| 173 | + } else { |
| 174 | + deps += [ "${examples_plat_dir}:efr32-common" ] |
| 175 | + } |
| 176 | + |
| 177 | + if (chip_enable_pw_rpc) { |
| 178 | + defines += [ |
| 179 | + "PW_RPC_ENABLED", |
| 180 | + "PW_RPC_ATTRIBUTE_SERVICE=1", |
| 181 | + "PW_RPC_BUTTON_SERVICE=1", |
| 182 | + "PW_RPC_DESCRIPTOR_SERVICE=1", |
| 183 | + "PW_RPC_DEVICE_SERVICE=1", |
| 184 | + "PW_RPC_OTCLI_SERVICE=1", |
| 185 | + "PW_RPC_THREAD_SERVICE=1", |
| 186 | + "PW_RPC_TRACING_SERVICE=1", |
| 187 | + ] |
| 188 | + |
| 189 | + sources += [ |
| 190 | + "${chip_root}/examples/common/pigweed/RpcService.cpp", |
| 191 | + "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", |
| 192 | + "${examples_common_plat_dir}/PigweedLogger.cpp", |
| 193 | + "${examples_common_plat_dir}/Rpc.cpp", |
| 194 | + ] |
| 195 | + |
| 196 | + deps += [ |
| 197 | + "$dir_pw_hdlc:default_addresses", |
| 198 | + "$dir_pw_hdlc:rpc_channel_output", |
| 199 | + "$dir_pw_stream:sys_io_stream", |
| 200 | + "$dir_pw_trace", |
| 201 | + "$dir_pw_trace_tokenized", |
| 202 | + "$dir_pw_trace_tokenized:trace_rpc_service", |
| 203 | + "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc", |
| 204 | + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", |
| 205 | + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", |
| 206 | + "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", |
| 207 | + "${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc", |
| 208 | + "${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc", |
| 209 | + ] |
| 210 | + |
| 211 | + if (wifi_soc) { |
| 212 | + deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ] |
| 213 | + } else { |
| 214 | + deps += [ "${examples_common_plat_dir}/pw_sys_io:pw_sys_io_silabs" ] |
| 215 | + } |
| 216 | + |
| 217 | + deps += pw_build_LINK_DEPS |
| 218 | + |
| 219 | + include_dirs += [ |
| 220 | + "${chip_root}/examples/common", |
| 221 | + "${chip_root}/examples/common/pigweed/efr32", |
| 222 | + ] |
| 223 | + } |
| 224 | + |
| 225 | + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" |
| 226 | + |
| 227 | + inputs = [ ldscript ] |
| 228 | + |
| 229 | + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] |
| 230 | + |
| 231 | + if (chip_print_memory_usage) { |
| 232 | + ldflags += [ |
| 233 | + "-Wl,--print-memory-usage", |
| 234 | + "-fstack-usage", |
| 235 | + ] |
| 236 | + } |
| 237 | + |
| 238 | + # WiFi Settings |
| 239 | + if (chip_enable_wifi) { |
| 240 | + ldflags += [ |
| 241 | + "-Wl,--defsym", |
| 242 | + "-Wl,SILABS_WIFI=1", |
| 243 | + ] |
| 244 | + } |
| 245 | + |
| 246 | + output_dir = root_out_dir |
| 247 | +} |
| 248 | + |
| 249 | +group("silabs") { |
| 250 | + deps = [ ":dishwasher_app" ] |
| 251 | +} |
| 252 | + |
| 253 | +group("default") { |
| 254 | + deps = [ ":silabs" ] |
| 255 | +} |
0 commit comments