|
| 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("${silabs_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 | +assert(current_os == "freertos") |
| 28 | + |
| 29 | +silabs_project_dir = "${chip_root}/examples/multi-sensor-app/silabs" |
| 30 | +examples_common_plat_dir = "${chip_root}/examples/platform/silabs" |
| 31 | + |
| 32 | +if (wifi_soc) { |
| 33 | + import("${silabs_sdk_build_root}/SiWx917_sdk.gni") |
| 34 | + examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" |
| 35 | +} else { |
| 36 | + import("${silabs_sdk_build_root}/efr32_sdk.gni") |
| 37 | + examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" |
| 38 | +} |
| 39 | + |
| 40 | +import("${examples_common_plat_dir}/args.gni") |
| 41 | + |
| 42 | +declare_args() { |
| 43 | + # Dump memory usage at link time. |
| 44 | + chip_print_memory_usage = false |
| 45 | + |
| 46 | + # Configures the frequency at which the sensor values are measured |
| 47 | + sl_sensor_timer_period_s = 60 |
| 48 | + |
| 49 | + # Configures the threshold necessary to trigger a report |
| 50 | + sl_sensor_report_threshold = 100 |
| 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 | +} else { |
| 85 | + efr32_sdk("sdk") { |
| 86 | + sources = [ |
| 87 | + "${examples_common_plat_dir}/FreeRTOSConfig.h", |
| 88 | + "${silabs_project_dir}/include/CHIPProjectConfig.h", |
| 89 | + ] |
| 90 | + |
| 91 | + include_dirs = [ |
| 92 | + "${chip_root}/src/platform/silabs/efr32", |
| 93 | + "${silabs_project_dir}/include", |
| 94 | + "${examples_plat_dir}", |
| 95 | + "${chip_root}/src/lib", |
| 96 | + "${examples_common_plat_dir}", |
| 97 | + ] |
| 98 | + |
| 99 | + if (use_wf200) { |
| 100 | + # TODO efr32_sdk should not need a header from this location |
| 101 | + include_dirs += [ "${examples_plat_dir}/wf200" ] |
| 102 | + } |
| 103 | + |
| 104 | + if (chip_enable_ble_rs911x) { |
| 105 | + # TODO efr32_sdk should not need a header from this location |
| 106 | + include_dirs += [ |
| 107 | + "${examples_plat_dir}/rs911x", |
| 108 | + "${examples_plat_dir}/rs911x/hal", |
| 109 | + ] |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +silabs_executable("multi-sensor-app") { |
| 115 | + output_name = "matter-silabs-multi-sensor-example.out" |
| 116 | + |
| 117 | + defines = [ |
| 118 | + "SL_MATTER_SENSOR_TIMER_PERIOD_S=${sl_sensor_timer_period_s}", |
| 119 | + "SL_MATTER_SENSOR_REPORT_THRESHOLD=${sl_sensor_report_threshold}", |
| 120 | + ] |
| 121 | + |
| 122 | + include_dirs = [ "include" ] |
| 123 | + |
| 124 | + if (silabs_board == "BRD2704A") { |
| 125 | + defines += [ "SL_STATUS_LED=0" ] |
| 126 | + } |
| 127 | + |
| 128 | + sources = [ |
| 129 | + "${examples_common_plat_dir}/main.cpp", |
| 130 | + "src/AppTask.cpp", |
| 131 | + "src/DataModelCallbacks.cpp", |
| 132 | + "src/SensorManager.cpp", |
| 133 | + ] |
| 134 | + |
| 135 | + if (!disable_lcd) { |
| 136 | + sources += [ "src/SensorsUI.cpp" ] |
| 137 | + } |
| 138 | + |
| 139 | + deps = [ |
| 140 | + ":sdk", |
| 141 | + app_data_model, |
| 142 | + ] |
| 143 | + |
| 144 | + if (wifi_soc) { |
| 145 | + deps += [ "${examples_plat_dir}:siwx917-common" ] |
| 146 | + } else { |
| 147 | + deps += [ "${examples_plat_dir}:efr32-common" ] |
| 148 | + } |
| 149 | + |
| 150 | + ldscript = "${examples_common_plat_dir}/ldscripts/${silabs_family}.ld" |
| 151 | + |
| 152 | + inputs = [ ldscript ] |
| 153 | + |
| 154 | + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] |
| 155 | + |
| 156 | + if (chip_print_memory_usage) { |
| 157 | + ldflags += [ |
| 158 | + "-Wl,--print-memory-usage", |
| 159 | + "-fstack-usage", |
| 160 | + ] |
| 161 | + } |
| 162 | + |
| 163 | + # WiFi Settings |
| 164 | + if (chip_enable_wifi) { |
| 165 | + ldflags += [ |
| 166 | + "-Wl,--defsym", |
| 167 | + "-Wl,SILABS_WIFI=1", |
| 168 | + ] |
| 169 | + } |
| 170 | + |
| 171 | + output_dir = root_out_dir |
| 172 | +} |
| 173 | + |
| 174 | +group("efr32") { |
| 175 | + deps = [ ":multi-sensor-app" ] |
| 176 | +} |
| 177 | + |
| 178 | +group("default") { |
| 179 | + deps = [ ":efr32" ] |
| 180 | +} |
0 commit comments