Skip to content

Commit

Permalink
Rework for the versioning. Format the command at pre-compile time (in…
Browse files Browse the repository at this point in the history
… scripts) pass it in a gn arg and set to a define
  • Loading branch information
jmartinez-silabs committed Dec 7, 2022
1 parent 3f74108 commit 7451ac7
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 71 deletions.
1 change: 1 addition & 0 deletions examples/light-switch-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ efr32_sdk("sdk") {

efr32_executable("light_switch_app") {
output_name = "chip-efr32-light-switch-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/silabs/SiWx917/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ efr32_sdk("sdk") {

efr32_executable("lighting_app") {
output_name = "chip-efr32-lighting-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ efr32_sdk("sdk") {

efr32_executable("lighting_app") {
output_name = "chip-efr32-lighting-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ efr32_sdk("sdk") {

efr32_executable("lock_app") {
output_name = "chip-efr32-lock-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

Expand Down
1 change: 1 addition & 0 deletions examples/thermostat/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ efr32_sdk("sdk") {

efr32_executable("thermostat_app") {
output_name = "chip-efr32-thermostat-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
include_dirs = [ "include" ]
defines = []

Expand Down
1 change: 1 addition & 0 deletions examples/window-app/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ efr32_sdk("sdk") {

efr32_executable("window_app") {
output_name = "chip-efr32-window-example.out"
public_configs = [ "${efr32_sdk_build_root}:silabs_config" ]
output_dir = root_out_dir
include_dirs = [
"include",
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def BuildEfr32Target():
target.AppendModifier('additional_data_advertising', enable_additional_data_advertising=True)
target.AppendModifier('use_ot_lib', enable_ot_lib=True).ExceptIfRe('-(wifi|use_ot_coap_lib)')
target.AppendModifier('use_ot_coap_lib', enable_ot_coap_lib=True).ExceptIfRe('-(wifi|use_ot_lib)')
target.AppendModifier('skip-versioning', skip_version=True)

return target

Expand Down
10 changes: 9 additions & 1 deletion scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
from enum import Enum, auto
import shlex
import subprocess

from .gn import GnBuilder

Expand Down Expand Up @@ -132,7 +133,8 @@ def __init__(self,
enable_wifi_ipv4: bool = False,
enable_additional_data_advertising: bool = False,
enable_ot_lib: bool = False,
enable_ot_coap_lib: bool = False
enable_ot_coap_lib: bool = False,
skip_version: bool = False
):
super(Efr32Builder, self).__init__(
root=app.BuildRoot(root),
Expand Down Expand Up @@ -200,6 +202,12 @@ def __init__(self,
self.extra_gn_options.append(
'use_silabs_thread_lib=true chip_openthread_target="../silabs:ot-efr32-cert" use_thread_coap_lib=true openthread_external_platform=""')

if skip_version == False:
shortCommitSha = subprocess.check_output(['git', 'describe', '--always', '--dirty']).decode('ascii').strip()
branchName = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('ascii').strip()
self.extra_gn_options.append(
'sl_matter_version_str="v1.0-%s-%s"' % (branchName, shortCommitSha))

def GnBuildArgs(self):
return self.extra_gn_options

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x
bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light}-light[-shell][-115200][-rpc]
cc13x2x7_26x2x7-{all-clusters,all-clusters-minimal,lock,pump,pump-controller,shell}[-ftd][-mtd]
cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor}[-no-progress-logging]
efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a}-{window-covering,switch,unit-test,light,lock}[-rpc][-with-ota-requestor][-sed][-low-power][-shell][-no_logging][-openthread_mtd][-enable_heap_monitoring][-no_openthread_cli][-show_qr_code][-wifi][-rs911x][-wf200][-wifi_ipv4][-additional_data_advertising][-use_ot_lib][-use_ot_coap_lib]
efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a}-{window-covering,switch,unit-test,light,lock}[-rpc][-with-ota-requestor][-sed][-low-power][-shell][-no_logging][-openthread_mtd][-enable_heap_monitoring][-no_openthread_cli][-show_qr_code][-wifi][-rs911x][-wf200][-wifi_ipv4][-additional_data_advertising][-use_ot_lib][-use_ot_coap_lib][-skip-versioning]
esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,ota-requestor,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only]
genio-lighting-app
linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-libfuzzer][-coverage][-dmalloc][-clang]
Expand Down
15 changes: 14 additions & 1 deletion scripts/examples/gn_efr32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.
#

# Build script for GN EFT32 examples GitHub workflow.
# Build script for GN EFR32 examples GitHub workflow.

set -e

Expand All @@ -33,6 +33,7 @@ source "$CHIP_ROOT/scripts/activate.sh"
set -x
env
USE_WIFI=false
USE_SILABS_VERSIONING=true

SILABS_THREAD_TARGET=\""../silabs:ot-efr32-cert"\"
USAGE="./scripts/examples/gn_efr32_example.sh <AppRootFolder> <outputFolder> <silabs_board_name> [<Build options>]"
Expand Down Expand Up @@ -163,6 +164,10 @@ else
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" use_thread_coap_lib=true "
shift
;;
--skip_silabs_version)
USE_SILABS_VERSIONING=false
shift
;;
*)
if [ "$1" =~ *"use_rs911x=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
USE_WIFI=true
Expand All @@ -179,6 +184,14 @@ else
exit 1
fi

if [ "$USE_SILABS_VERSIONING" == true ]; then
{
ShortCommitSha=$(git describe --always --dirty)
branchName=$(git rev-parse --abbrev-ref HEAD)
optArgs+="sl_matter_version_str=\"v1.0-$branchName-$ShortCommitSha\" "
} &> /dev/null
fi

BUILD_DIR=$OUTDIR/$SILABS_BOARD
echo BUILD_DIR="$BUILD_DIR"
if [ "$USE_WIFI" == true ]; then
Expand Down
46 changes: 0 additions & 46 deletions scripts/tools/silabs/format_sw_version.py

This file was deleted.

9 changes: 9 additions & 0 deletions src/platform/silabs/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
*/
#ifdef SL_MATTER_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING SL_MATTER_VERSION_STRING
#endif

#if defined(SL_WIFI)
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1
#else
Expand Down
7 changes: 7 additions & 0 deletions third_party/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@ declare_args() {
sl_ot_efr32_root = "${chip_root}/third_party/openthread/ot-efr32"
sl_openthread_root = "${chip_root}/third_party/openthread/ot-efr32/openthread"
use_thread_coap_lib = false
sl_matter_version_str = ""
}

assert(efr32_sdk_target != "", "efr32_sdk_target must be specified")

config("silabs_config") {
if (sl_matter_version_str != "") {
defines = [ "SL_MATTER_VERSION_STRING=\"${sl_matter_version_str}\"" ]
}
}

group("efr32_sdk") {
public_deps = [ efr32_sdk_target ]
}
Expand Down
11 changes: 0 additions & 11 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ declare_args() {

# Enable Segger System View
use_system_view = false

use_silabs_sw_versioning = true
}

# Explorer Kit and MGM240L do not have external flash
Expand Down Expand Up @@ -143,15 +141,6 @@ template("efr32_sdk") {
"RS91X_BLE_ENABLE=1",
]

if (use_silabs_sw_versioning) {
formatted_version =
exec_script("${chip_root}/scripts/tools/silabs/format_sw_version.py",
[],
"trim string")

defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${formatted_version}\"" ]
}

if (use_system_view) {
_include_dirs += [
"${efr32_sdk_root}/util/third_party/segger/systemview/SEGGER",
Expand Down
11 changes: 0 additions & 11 deletions third_party/silabs/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ declare_args() {
use_system_view = false

sleep_time_ms = 3300000 # 55 mins sleep

use_silabs_sw_versioning = true
}

# Explorer Kit and MGM240L do not have external flash
Expand Down Expand Up @@ -202,15 +200,6 @@ template("efr32_sdk") {
#"__STACK_SIZE=0",
]

if (use_silabs_sw_versioning) {
formatted_version =
exec_script("${chip_root}/scripts/tools/silabs/format_sw_version.py",
[],
"trim string")

defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${formatted_version}\"" ]
}

if (use_system_view) {
_include_dirs += [
"${efr32_sdk_root}/util/third_party/segger/systemview/SEGGER",
Expand Down

0 comments on commit 7451ac7

Please sign in to comment.