Skip to content

Commit

Permalink
[Silabs] Format the sw version string with some git repo info (#23877)
Browse files Browse the repository at this point in the history
* Script to format a version string based on the git repo state. set CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING

* Rework for the versioning. Format the command at pre-compile time (in scripts) pass it in a gn arg and set to a define

* Restyle and add some description for the new parameters

* address last comments

* fix efr32-brd4161a-light-rpc build/test.py dry run test by using -no-version as using the git formatted version will change for every commit
  • Loading branch information
jmartinez-silabs authored Dec 8, 2022
1 parent 3af0acd commit 6ccbb7c
Show file tree
Hide file tree
Showing 26 changed files with 78 additions and 110 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
11 changes: 0 additions & 11 deletions examples/light-switch-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
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
11 changes: 0 additions & 11 deletions examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
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
11 changes: 0 additions & 11 deletions examples/lock-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
Expand Down
10 changes: 0 additions & 10 deletions examples/persistent-storage/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
11 changes: 0 additions & 11 deletions examples/pigweed-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
Expand Down
11 changes: 0 additions & 11 deletions examples/shell/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
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
11 changes: 0 additions & 11 deletions examples/thermostat/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
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
11 changes: 0 additions & 11 deletions examples/window-app/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pw_python_package("build_examples") {
# Dependency for the unit test
"testdata/all_targets_linux_x64.txt",
"testdata/dry_run_android-arm64-chip-tool.txt",
"testdata/dry_run_efr32-brd4161a-light-rpc.txt",
"testdata/dry_run_efr32-brd4161a-light-rpc-no-version.txt",
"testdata/dry_run_esp32-devkitc-light-rpc.txt",
"testdata/dry_run_esp32-m5stack-all-clusters-minimal-rpc-ipv6only.txt",
"testdata/dry_run_linux-arm64-chip-tool-ipv6only-clang.txt",
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('no-version', no_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,
no_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 not no_version:
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/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_general_dry_runs(self):
'esp32-m5stack-all-clusters-minimal-rpc-ipv6only',
'android-arm64-chip-tool',
'nrf-nrf52840dk-pump',
'efr32-brd4161a-light-rpc',
'efr32-brd4161a-light-rpc-no-version',
'openiotsdk-lock',
'openiotsdk-shell'
]
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][-no-version]
esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,ota-provider,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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Commands will be run in CHIP project root.
cd "{root}"

# Generating efr32-brd4161a-light-rpc
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/silabs/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-light-rpc
# Generating efr32-brd4161a-light-rpc-no-version
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/silabs/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-light-rpc-no-version

# Building efr32-brd4161a-light-rpc
ninja -C {out}/efr32-brd4161a-light-rpc
# Building efr32-brd4161a-light-rpc-no-version
ninja -C {out}/efr32-brd4161a-light-rpc-no-version
26 changes: 23 additions & 3 deletions 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_GIT_SHA_FOR_VERSION=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 @@ -81,6 +82,10 @@ if [ "$#" == "0" ]; then
enable_sleepy_device
Enable Sleepy end device. (Default false)
Must also set chip_openthread_ftd=false
sl_matter_version_str
Set a Matter sotfware version string for the Silabs examples
Used and formatted by default in this script.
To skip that formatting or use your own version string use --no-version
use_rs911x
Build wifi example with extension board rs911x. (Default false)
use_wf200
Expand All @@ -104,6 +109,9 @@ if [ "$#" == "0" ]; then
enable Addition data advertissing and rotating device ID
--use_ot_lib
use the silabs openthread library
--no-version
Skip the silabs formating for the Matter software version string
Currently : v1.0-<branchName>-<ShortCommitSha>
"
elif [ "$#" -lt "2" ]; then
echo "Invalid number of arguments
Expand All @@ -128,9 +136,9 @@ else
exit 1
fi
if [ "$2" = "rs911x" ]; then
optArgs+="use_rs911x=true"
optArgs+="use_rs911x=true "
elif [ "$2" = "wf200" ]; then
optArgs+="use_wf200=true"
optArgs+="use_wf200=true "
else
echo "Wifi usage: --wifi rs911x|wf200"
exit 1
Expand Down Expand Up @@ -163,6 +171,10 @@ else
optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" use_thread_coap_lib=true "
shift
;;
--no-version)
USE_GIT_SHA_FOR_VERSION=false
shift
;;
*)
if [ "$1" =~ *"use_rs911x=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
USE_WIFI=true
Expand All @@ -179,6 +191,14 @@ else
exit 1
fi

if [ "$USE_GIT_SHA_FOR_VERSION" == 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
2 changes: 1 addition & 1 deletion src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
* A string identifying the software version running on the device.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "prerelease"
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0"
#endif

/**
Expand Down
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
10 changes: 0 additions & 10 deletions src/test_driver/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
*
* A string identifying the software version running on the device.
* CHIP service currently expects the software version to be in the format
* {MAJOR_VERSION}.0d{MINOR_VERSION}
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA"
#endif
/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
Loading

0 comments on commit 6ccbb7c

Please sign in to comment.