Skip to content

Commit

Permalink
Fix duplicated code in Silabs examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jepenven-silabs committed May 17, 2023
1 parent 367404f commit 5690165
Show file tree
Hide file tree
Showing 51 changed files with 657 additions and 405 deletions.
2 changes: 1 addition & 1 deletion examples/chef/efr32/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/efr32/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_ota_requestor = true
chip_enable_openthread = true
Expand Down
4 changes: 2 additions & 2 deletions examples/chef/efr32/build_for_wifi_args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
import("//build_overrides/chip.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/efr32/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi_args.gni")

chip_enable_ota_requestor = true
2 changes: 1 addition & 1 deletion examples/chef/efr32/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/efr32/lib/pw_rpc/pw_rpc.gni")
import("${chip_root}/examples/platform/efr32/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")

chip_enable_pw_rpc = true
chip_enable_openthread = true
Expand Down
4 changes: 2 additions & 2 deletions examples/light-switch-app/silabs/SiWx917/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/silabs/SiWx917/args.gni")
import("${chip_root}/src/platform/silabs/args.gni")

siwx917_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")

app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common"
chip_enable_ota_requestor = true
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/efr32/.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ default_args = {
target_os = "freertos"
chip_openthread_ftd = true

import("//args.gni")
import("//openthread.gni")
}
124 changes: 83 additions & 41 deletions examples/light-switch-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import("//build_overrides/efr32_sdk.gni")
import("//build_overrides/pigweed.gni")

import("${build_root}/config/defaults.gni")
import("${efr32_sdk_build_root}/efr32_sdk.gni")
import("${efr32_sdk_build_root}/silabs_executable.gni")

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/third_party/silabs/silabs_board.gni")

if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
Expand All @@ -31,61 +31,93 @@ if (chip_enable_pw_rpc) {

assert(current_os == "freertos")

efr32_project_dir = "${chip_root}/examples/light-switch-app/silabs/efr32"
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
silabs_project_dir = "${chip_root}/examples/light-switch-app/silabs/efr32"
examples_common_plat_dir = "${chip_root}/examples/platform/silabs"
if (chip_enable_ble_rs911x) {
src_plat_dir = "${chip_root}/src/platform/silabs/efr32"

if (wifi_soc) {
import("${chip_root}/third_party/silabs/SiWx917_sdk.gni")
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"
} else {
import("${efr32_sdk_build_root}/efr32_sdk.gni")
examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32"
}

import("${examples_plat_dir}/args.gni")
import("${examples_common_plat_dir}/args.gni")

declare_args() {
# Dump memory usage at link time.
chip_print_memory_usage = false
}

efr32_sdk("sdk") {
sources = [
"${efr32_project_dir}/include/CHIPProjectConfig.h",
"${examples_plat_dir}/FreeRTOSConfig.h",
]
if (wifi_soc) {
siwx917_sdk("sdk") {
sources = [
"${examples_plat_dir}/FreeRTOSConfig.h",
"${silabs_project_dir}/include/CHIPProjectConfig.h",
]

include_dirs = [
"${chip_root}/examples/light-switch-app/silabs/common",
"${chip_root}/src/platform/silabs/efr32",
"${efr32_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
"${examples_common_plat_dir}",
]
include_dirs = [
"${chip_root}/src/platform/silabs/SiWx917",
"${silabs_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
"${examples_common_plat_dir}",
]

if (use_wf200) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [ "${examples_plat_dir}/wf200" ]
defines = []
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
"PW_RPC_ENABLED",
]
}
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${src_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
} else {
efr32_sdk("sdk") {
sources = [
"${examples_plat_dir}/FreeRTOSConfig.h",
"${silabs_project_dir}/include/CHIPProjectConfig.h",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
"PW_RPC_ENABLED",
include_dirs = [
"${chip_root}/examples/light-switch-app/silabs/common",
"${chip_root}/src/platform/silabs/efr32",
"${silabs_project_dir}/include",
"${examples_plat_dir}",
"${chip_root}/src/lib",
"${examples_common_plat_dir}",
]

if (use_wf200) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [ "${examples_plat_dir}/wf200" ]
}

if (chip_enable_ble_rs911x) {
# TODO efr32_sdk should not need a header from this location
include_dirs += [
"${chip_root}/src/platform/silabs/efr32/rs911x",
"${examples_plat_dir}/rs911x",
"${examples_plat_dir}/rs911x/hal",
]
}

defines = []
if (chip_enable_pw_rpc) {
defines += [
"HAL_VCOM_ENABLE=1",
"PW_RPC_ENABLED",
]
}
}
}

silabs_executable("light_switch_app") {
output_name = "chip-efr32-light-switch-example.out"
include_dirs = [ "include" ]
output_name = "chip-silabs-light-switch-example.out"
include_dirs = [
"include",
"${chip_root}/examples/light-switch-app/silabs/common/",
]
defines = []

sources = [
Expand All @@ -98,10 +130,15 @@ silabs_executable("light_switch_app") {

deps = [
":sdk",
"${examples_plat_dir}:efr32-common",
app_data_model,
]

if (wifi_soc) {
deps += [ "${examples_plat_dir}:siwx917-common" ]
} else {
deps += [ "${examples_plat_dir}:efr32-common" ]
}

if (chip_build_libshell) {
sources += [
"${chip_root}/examples/light-switch-app/silabs/common/ShellCommands.cpp",
Expand Down Expand Up @@ -134,9 +171,14 @@ silabs_executable("light_switch_app") {
"${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:device_service.nanopb_rpc",
"${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc",
"${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32",
]

if (wifi_soc) {
deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_siwx917" ]
} else {
deps += [ "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32" ]
}

deps += pw_build_LINK_DEPS

include_dirs += [
Expand Down Expand Up @@ -169,10 +211,10 @@ silabs_executable("light_switch_app") {
output_dir = root_out_dir
}

group("efr32") {
group("silabs") {
deps = [ ":light_switch_app" ]
}

group("default") {
deps = [ ":efr32" ]
deps = [ ":silabs" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
chip_enable_openthread = false
import("${chip_root}/src/platform/silabs/efr32/wifi_args.gni")
import("${chip_root}/src/platform/silabs/wifi_args.gni")

chip_enable_ota_requestor = true
app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common"
29 changes: 29 additions & 0 deletions examples/light-switch-app/silabs/efr32/openthread.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2020 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
target_cpu = "arm"
target_os = "freertos"
chip_openthread_ftd = true

import("//openthread.gni")
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/src/platform/silabs/efr32/args.gni")

efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")

app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common"
chip_enable_ota_requestor = true
chip_enable_openthread = true

openthread_external_platform =
"${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"
4 changes: 2 additions & 2 deletions examples/lighting-app/silabs/SiWx917/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import("//build_overrides/chip.gni")
import("${chip_root}/config/standalone/args.gni")

siwx917_sdk_target = get_label_info(":sdk", "label_no_toolchain")
import("${chip_root}/src/platform/silabs/SiWx917/args.gni")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
import("${chip_root}/src/platform/silabs/args.gni")

app_data_model = "${chip_root}/examples/lighting-app/silabs/SiWx917/data_model:silabs-lighting"
chip_enable_ota_requestor = true
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/with_pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/config/efr32/lib/pw_rpc/pw_rpc.gni")
import("${chip_root}/examples/platform/silabs/SiWx917/args.gni")

siwx917_sdk_target = get_label_info(":sdk", "label_no_toolchain")
silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")

app_data_model = "${chip_root}/examples/lighting-app/lighting-common"
chip_enable_pw_rpc = true
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/efr32/.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ default_args = {
target_os = "freertos"
chip_openthread_ftd = true

import("//args.gni")
import("//openthread.gni")
}
Loading

0 comments on commit 5690165

Please sign in to comment.