From 69f93c78cffc7be0a1bd905c60b7a8ae15a928ca Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Fri, 2 Dec 2022 11:49:59 -0500 Subject: [PATCH 1/5] Script to format a version string based on the git repo state. set CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING --- .../efr32/include/CHIPProjectConfig.h | 11 ----- .../silabs/efr32/include/CHIPProjectConfig.h | 11 ----- .../efr32/include/CHIPProjectConfig.h | 11 ----- .../efr32/include/CHIPProjectConfig.h | 10 ---- .../efr32/include/CHIPProjectConfig.h | 11 ----- .../shell/efr32/include/CHIPProjectConfig.h | 11 ----- .../efr32/include/CHIPProjectConfig.h | 11 ----- .../efr32/include/CHIPProjectConfig.h | 11 ----- scripts/tools/silabs/format_sw_version.py | 46 +++++++++++++++++++ src/include/platform/CHIPDeviceConfig.h | 2 +- .../efr32/include/CHIPProjectConfig.h | 10 ---- third_party/silabs/SiWx917_sdk.gni | 27 ++++++++++- third_party/silabs/efr32_sdk.gni | 11 +++++ 13 files changed, 84 insertions(+), 99 deletions(-) create mode 100644 scripts/tools/silabs/format_sw_version.py diff --git a/examples/light-switch-app/efr32/include/CHIPProjectConfig.h b/examples/light-switch-app/efr32/include/CHIPProjectConfig.h index 94c82dcbb0281d..1b74c802fd4f09 100644 --- a/examples/light-switch-app/efr32/include/CHIPProjectConfig.h +++ b/examples/light-switch-app/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h b/examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h index 4b3d8f571c9057..1d3fefcce8232e 100644 --- a/examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h +++ b/examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/lock-app/efr32/include/CHIPProjectConfig.h b/examples/lock-app/efr32/include/CHIPProjectConfig.h index 6e8342dc0f7a99..9793e98ac9bc0a 100644 --- a/examples/lock-app/efr32/include/CHIPProjectConfig.h +++ b/examples/lock-app/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/persistent-storage/efr32/include/CHIPProjectConfig.h b/examples/persistent-storage/efr32/include/CHIPProjectConfig.h index 4502afd537724f..24733d37871d5b 100644 --- a/examples/persistent-storage/efr32/include/CHIPProjectConfig.h +++ b/examples/persistent-storage/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/pigweed-app/efr32/include/CHIPProjectConfig.h b/examples/pigweed-app/efr32/include/CHIPProjectConfig.h index 9c6a21703649ac..6af96beac88f4a 100644 --- a/examples/pigweed-app/efr32/include/CHIPProjectConfig.h +++ b/examples/pigweed-app/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/shell/efr32/include/CHIPProjectConfig.h b/examples/shell/efr32/include/CHIPProjectConfig.h index bd5c6355cae55a..72a56579663289 100644 --- a/examples/shell/efr32/include/CHIPProjectConfig.h +++ b/examples/shell/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/thermostat/efr32/include/CHIPProjectConfig.h b/examples/thermostat/efr32/include/CHIPProjectConfig.h index 35f6d54e785c70..526cede60faa2a 100644 --- a/examples/thermostat/efr32/include/CHIPProjectConfig.h +++ b/examples/thermostat/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/examples/window-app/efr32/include/CHIPProjectConfig.h b/examples/window-app/efr32/include/CHIPProjectConfig.h index 23c653c12b396e..6a12dbc3794c8f 100644 --- a/examples/window-app/efr32/include/CHIPProjectConfig.h +++ b/examples/window-app/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/scripts/tools/silabs/format_sw_version.py b/scripts/tools/silabs/format_sw_version.py new file mode 100644 index 00000000000000..bbacfa0000fe6d --- /dev/null +++ b/scripts/tools/silabs/format_sw_version.py @@ -0,0 +1,46 @@ +# +# Copyright (c) 2022 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 sys +import subprocess + +""" + Simple script to fetch some information on the current git repo. + This script is used by gn in a exec_script to format a sotfware version + string based on the branch, commit SHA and state. + The gn exec_script retrieves the output from the stdout. +""" + + +def getGitCommitSHA() -> str: + return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() + + +def getGitShortCommitSHA() -> str: + return subprocess.check_output(['git', 'describe', '--always', '--dirty']).decode('ascii').strip() + + +def getGitCurrentBranchName() -> str: + return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('ascii').strip() + + +def main(): + # --[-dirty] + print("v1.0-" + getGitCurrentBranchName() + "-" + getGitShortCommitSHA()) + sys.exit(0) + + +if __name__ == "__main__": + main() diff --git a/src/include/platform/CHIPDeviceConfig.h b/src/include/platform/CHIPDeviceConfig.h index 5dfc6fcf9ba258..05065105d207f4 100644 --- a/src/include/platform/CHIPDeviceConfig.h +++ b/src/include/platform/CHIPDeviceConfig.h @@ -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 /** diff --git a/src/test_driver/efr32/include/CHIPProjectConfig.h b/src/test_driver/efr32/include/CHIPProjectConfig.h index 04b0577e94ced3..451292ff519b7b 100644 --- a/src/test_driver/efr32/include/CHIPProjectConfig.h +++ b/src/test_driver/efr32/include/CHIPProjectConfig.h @@ -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 * diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 5d6a857916320f..ea34ed5a787907 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -10,7 +10,7 @@ # 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. +# limitations under the License. import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") @@ -37,6 +37,11 @@ declare_args() { # Use Silabs factory data provider example. # Users can implement their own. use_efr32_factory_data_provider = true + + # Enable Segger System View + use_system_view = false + + use_silabs_sw_versioning = true } # Explorer Kit and MGM240L do not have external flash @@ -138,6 +143,26 @@ 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", + "${efr32_sdk_root}/util/third_party/segger/systemview/Sample/FreeRTOSV10/Config/Cortex-M", + "${efr32_sdk_root}/util/third_party/segger/systemview/Sample/FreeRTOSV10", + "${efr32_sdk_root}/util/third_party/segger/systemview/Config/", + ] + + defines += [ "SL_SYSTEM_VIEW=1" ] + } + defines += board_defines if (defined(invoker.enable_sleepy_device)) { diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index c6aa9d95a4fdb0..38f4ee838a5cc4 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -40,6 +40,8 @@ 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 @@ -200,6 +202,15 @@ 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", From b381ffc3c03c27c5fabe83f99f3daa51c3930236 Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Wed, 7 Dec 2022 11:11:51 -0500 Subject: [PATCH 2/5] Rework for the versioning. Format the command at pre-compile time (in scripts) pass it in a gn arg and set to a define --- examples/light-switch-app/efr32/BUILD.gn | 1 + examples/lighting-app/silabs/SiWx917/BUILD.gn | 1 + examples/lighting-app/silabs/efr32/BUILD.gn | 1 + examples/lock-app/efr32/BUILD.gn | 1 + examples/thermostat/efr32/BUILD.gn | 1 + examples/window-app/efr32/BUILD.gn | 1 + scripts/build/build/targets.py | 1 + scripts/build/builders/efr32.py | 10 +++- .../build/testdata/all_targets_linux_x64.txt | 2 +- scripts/examples/gn_efr32_example.sh | 15 +++++- scripts/tools/silabs/format_sw_version.py | 46 ------------------- .../silabs/CHIPDevicePlatformConfig.h | 9 ++++ third_party/silabs/BUILD.gn | 7 +++ third_party/silabs/SiWx917_sdk.gni | 11 ----- third_party/silabs/efr32_sdk.gni | 11 ----- 15 files changed, 47 insertions(+), 71 deletions(-) delete mode 100644 scripts/tools/silabs/format_sw_version.py diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 83704a8fa6cc1b..5c03b769dc964c 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -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 = [] diff --git a/examples/lighting-app/silabs/SiWx917/BUILD.gn b/examples/lighting-app/silabs/SiWx917/BUILD.gn index 61f849a88854f5..dbedc37a233b5c 100644 --- a/examples/lighting-app/silabs/SiWx917/BUILD.gn +++ b/examples/lighting-app/silabs/SiWx917/BUILD.gn @@ -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 = [] diff --git a/examples/lighting-app/silabs/efr32/BUILD.gn b/examples/lighting-app/silabs/efr32/BUILD.gn index 3a812b966d3361..d2f68f8b44541e 100644 --- a/examples/lighting-app/silabs/efr32/BUILD.gn +++ b/examples/lighting-app/silabs/efr32/BUILD.gn @@ -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 = [] diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 8e22a6add4864e..88983a2f058284 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -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 = [] diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn index 1e5deb78ef4f10..2322a2ae887ded 100644 --- a/examples/thermostat/efr32/BUILD.gn +++ b/examples/thermostat/efr32/BUILD.gn @@ -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 = [] diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 142a4dc84146ab..93119f1b263aae 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -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", diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 68dc45f69e813a..d6120712fd65bd 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -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 diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index ba807439ed1492..6afcb77b2ce0a4 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -15,6 +15,7 @@ import os from enum import Enum, auto import shlex +import subprocess from .gn import GnBuilder @@ -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), @@ -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 diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index a5ca0ac89564e7..c897c94ca0eed9 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -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-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] diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index 2062c079ac391c..f21e6fb0efec59 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -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 @@ -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 []" @@ -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 @@ -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 diff --git a/scripts/tools/silabs/format_sw_version.py b/scripts/tools/silabs/format_sw_version.py deleted file mode 100644 index bbacfa0000fe6d..00000000000000 --- a/scripts/tools/silabs/format_sw_version.py +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (c) 2022 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 sys -import subprocess - -""" - Simple script to fetch some information on the current git repo. - This script is used by gn in a exec_script to format a sotfware version - string based on the branch, commit SHA and state. - The gn exec_script retrieves the output from the stdout. -""" - - -def getGitCommitSHA() -> str: - return subprocess.check_output(['git', 'rev-parse', 'HEAD']).decode('ascii').strip() - - -def getGitShortCommitSHA() -> str: - return subprocess.check_output(['git', 'describe', '--always', '--dirty']).decode('ascii').strip() - - -def getGitCurrentBranchName() -> str: - return subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('ascii').strip() - - -def main(): - # --[-dirty] - print("v1.0-" + getGitCurrentBranchName() + "-" + getGitShortCommitSHA()) - sys.exit(0) - - -if __name__ == "__main__": - main() diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 4852dc97c63cb6..30cfcf437f5b13 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -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 diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 9c59de25de7056..9ef1251fd88f31 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -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 ] } diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index ea34ed5a787907..a60d443f7ed2c0 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -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 @@ -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", diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 38f4ee838a5cc4..c6aa9d95a4fdb0 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -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 @@ -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", From d8708533aca2d403c2cb2deb14809947e0050ff5 Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Wed, 7 Dec 2022 11:24:48 -0500 Subject: [PATCH 3/5] Restyle and add some description for the new parameters --- scripts/examples/gn_efr32_example.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index f21e6fb0efec59..b51664561a1316 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -82,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 --skip_versioning use_rs911x Build wifi example with extension board rs911x. (Default false) use_wf200 @@ -105,6 +109,9 @@ if [ "$#" == "0" ]; then enable Addition data advertissing and rotating device ID --use_ot_lib use the silabs openthread library + --skip_versioning + Skip the silabs formating for the Matter software version string + Currently : v1.0-- " elif [ "$#" -lt "2" ]; then echo "Invalid number of arguments @@ -164,7 +171,7 @@ 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) + --skip_versioning) USE_SILABS_VERSIONING=false shift ;; @@ -189,7 +196,7 @@ else ShortCommitSha=$(git describe --always --dirty) branchName=$(git rev-parse --abbrev-ref HEAD) optArgs+="sl_matter_version_str=\"v1.0-$branchName-$ShortCommitSha\" " - } &> /dev/null + } &>/dev/null fi BUILD_DIR=$OUTDIR/$SILABS_BOARD From 6390d1348ef5a22ce8909ceccb0c61350685e64a Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Wed, 7 Dec 2022 15:03:42 -0500 Subject: [PATCH 4/5] address last comments --- scripts/build/build/targets.py | 2 +- scripts/build/builders/efr32.py | 4 ++-- scripts/build/testdata/all_targets_linux_x64.txt | 2 +- scripts/examples/gn_efr32_example.sh | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index d6120712fd65bd..a7d024b643ad8a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -223,7 +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) + target.AppendModifier('no-version', no_version=True) return target diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index 6afcb77b2ce0a4..cd99b7a29eab1a 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -134,7 +134,7 @@ def __init__(self, enable_additional_data_advertising: bool = False, enable_ot_lib: bool = False, enable_ot_coap_lib: bool = False, - skip_version: bool = False + no_version: bool = False ): super(Efr32Builder, self).__init__( root=app.BuildRoot(root), @@ -202,7 +202,7 @@ 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: + 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( diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index c897c94ca0eed9..3bce2a8dd07b14 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -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][-skip-versioning] +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] diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index b51664561a1316..d577b074539b90 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -33,7 +33,7 @@ source "$CHIP_ROOT/scripts/activate.sh" set -x env USE_WIFI=false -USE_SILABS_VERSIONING=true +USE_GIT_SHA_FOR_VERSION=true SILABS_THREAD_TARGET=\""../silabs:ot-efr32-cert"\" USAGE="./scripts/examples/gn_efr32_example.sh []" @@ -85,7 +85,7 @@ if [ "$#" == "0" ]; then 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 --skip_versioning + 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 @@ -109,7 +109,7 @@ if [ "$#" == "0" ]; then enable Addition data advertissing and rotating device ID --use_ot_lib use the silabs openthread library - --skip_versioning + --no-version Skip the silabs formating for the Matter software version string Currently : v1.0-- " @@ -136,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 @@ -171,8 +171,8 @@ else optArgs+="use_silabs_thread_lib=true chip_openthread_target=$SILABS_THREAD_TARGET openthread_external_platform=\"""\" use_thread_coap_lib=true " shift ;; - --skip_versioning) - USE_SILABS_VERSIONING=false + --no-version) + USE_GIT_SHA_FOR_VERSION=false shift ;; *) @@ -191,7 +191,7 @@ else exit 1 fi - if [ "$USE_SILABS_VERSIONING" == true ]; then + if [ "$USE_GIT_SHA_FOR_VERSION" == true ]; then { ShortCommitSha=$(git describe --always --dirty) branchName=$(git rev-parse --abbrev-ref HEAD) From 2fe64d072dd850a3974feca3773756aa2bf25995 Mon Sep 17 00:00:00 2001 From: Junior Martinez Date: Wed, 7 Dec 2022 16:30:52 -0500 Subject: [PATCH 5/5] 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 --- scripts/build/BUILD.gn | 2 +- scripts/build/test.py | 2 +- ...xt => dry_run_efr32-brd4161a-light-rpc-no-version.txt} | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename scripts/build/testdata/{dry_run_efr32-brd4161a-light-rpc.txt => dry_run_efr32-brd4161a-light-rpc-no-version.txt} (57%) diff --git a/scripts/build/BUILD.gn b/scripts/build/BUILD.gn index 39580c63f86341..b19ffcd8d78a7f 100644 --- a/scripts/build/BUILD.gn +++ b/scripts/build/BUILD.gn @@ -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", diff --git a/scripts/build/test.py b/scripts/build/test.py index 85f66535c49106..8cf88b0571c44e 100644 --- a/scripts/build/test.py +++ b/scripts/build/test.py @@ -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' ] diff --git a/scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc.txt b/scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc-no-version.txt similarity index 57% rename from scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc.txt rename to scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc-no-version.txt index 4a241682b02f49..d48088b2048379 100644 --- a/scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc.txt +++ b/scripts/build/testdata/dry_run_efr32-brd4161a-light-rpc-no-version.txt @@ -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