From 2021763fbc189a643ceaa35ded993afa0b68654f Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Tue, 29 Nov 2022 08:09:39 -0500 Subject: [PATCH] feature/efr32_python_build_integration (#23530) * Added efr32 arguments to python build scripts to support various build options * refactored build flag to shorter names * Added the name changes to all_targets_linux_x64.txt --- scripts/build/build/targets.py | 17 +++- scripts/build/builders/efr32.py | 93 ++++++++++++++++++- .../build/testdata/all_targets_linux_x64.txt | 2 +- 3 files changed, 109 insertions(+), 3 deletions(-) diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 3c424d3f175f18..41fe5783888670 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -207,7 +207,20 @@ def BuildEfr32Target(): target.AppendModifier('rpc', enable_rpcs=True) target.AppendModifier('with-ota-requestor', enable_ota_requestor=True) target.AppendModifier('sed', enable_sed=True) - target.AppendModifier('low-power', enable_low_power=True) + target.AppendModifier('low-power', enable_low_power=True).OnlyIfRe('-sed') + target.AppendModifier('shell', chip_build_libshell=True) + target.AppendModifier('no_logging', chip_logging=False) + target.AppendModifier('openthread_mtd', chip_openthread_ftd=False) + target.AppendModifier('enable_heap_monitoring', enable_heap_monitoring=True) + target.AppendModifier('no_openthread_cli', enable_openthread_cli=False) + target.AppendModifier('show_qr_code', show_qr_code=True).ExceptIfRe('-low-power') + target.AppendModifier('wifi', enable_wifi=True) + target.AppendModifier('rs911x', enable_rs911x=True).OnlyIfRe('-wifi') + target.AppendModifier('wf200', enable_wf200=True).OnlyIfRe('-wifi') + target.AppendModifier('wifi_ipv4', enable_wifi_ipv4=True).OnlyIfRe('-wifi') + 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)') return target @@ -536,4 +549,6 @@ def BuildTelinkTarget(): BuildQorvoTarget(), BuildTizenTarget(), BuildTelinkTarget(), + + ] diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index d622a9bd6eab3f..ba807439ed1492 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -14,6 +14,7 @@ import os from enum import Enum, auto +import shlex from .gn import GnBuilder @@ -115,16 +116,30 @@ def __init__(self, runner, app: Efr32App = Efr32App.LIGHT, board: Efr32Board = Efr32Board.BRD4161A, + chip_build_libshell: bool = False, + chip_logging: bool = True, + chip_openthread_ftd: bool = True, + enable_heap_monitoring: bool = False, + enable_openthread_cli: bool = True, + show_qr_code: bool = False, enable_rpcs: bool = False, enable_ota_requestor: bool = False, enable_sed: bool = False, - enable_low_power: bool = False + enable_low_power: bool = False, + enable_wifi: bool = False, + enable_rs911x: bool = False, + enable_wf200: bool = False, + enable_wifi_ipv4: bool = False, + enable_additional_data_advertising: bool = False, + enable_ot_lib: bool = False, + enable_ot_coap_lib: bool = False ): super(Efr32Builder, self).__init__( root=app.BuildRoot(root), runner=runner) self.app = app self.extra_gn_options = ['silabs_board="%s"' % board.GnArgName()] + self.dotfile = '' if enable_rpcs: self.extra_gn_options.append('is_debug=false import("//with_pw_rpc.gni")') @@ -139,6 +154,52 @@ def __init__(self, self.extra_gn_options.append( 'chip_build_libshell=false enable_openthread_cli=false show_qr_code=false disable_lcd=true') + if chip_build_libshell: + self.extra_gn_options.append('chip_build_libshell=true') + + if chip_logging == False: + self.extra_gn_options.append('chip_logging=false') + + if chip_openthread_ftd == False: + self.extra_gn_options.append('chip_openthread_ftd=false') + + if enable_heap_monitoring: + self.extra_gn_options.append('enable_heap_monitoring=true') + + if enable_openthread_cli == False: + self.extra_gn_options.append('enable_openthread_cli=false') + + if show_qr_code: + self.extra_gn_options.append('show_qr_code=true') + + if enable_wifi: + self.dotfile += self.root + '/build_for_wifi_gnfile.gn' + if board == Efr32Board.BRD4161A: + self.extra_gn_options.append('is_debug=false chip_logging=false') + else: + self.extra_gn_options.append('disable_lcd=true use_external_flash=false') + + if enable_rs911x: + self.extra_gn_options.append('use_rs911x=true') + elif enable_wf200: + self.extra_gn_options.append('use_wf200=true') + else: + raise Exception('Wifi usage: ...-wifi-[rs911x|wf200]-...') + + if enable_wifi_ipv4: + self.extra_gn_options.append('chip_enable_wifi_ipv4=true') + + if enable_additional_data_advertising: + self.extra_gn_options.append('chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true') + + if enable_ot_lib: + self.extra_gn_options.append( + 'use_silabs_thread_lib=true chip_openthread_target="../silabs:ot-efr32-cert" openthread_external_platform=""') + + if enable_ot_coap_lib: + 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=""') + def GnBuildArgs(self): return self.extra_gn_options @@ -163,3 +224,33 @@ def build_outputs(self): name] = os.path.join(self.output_dir, name) return items + + def generate(self): + cmd = [ + 'gn', 'gen', '--check', '--fail-on-unused-args', + '--export-compile-commands', + '--root=%s' % self.root + ] + if self.dotfile: + cmd += ['--dotfile=%s' % self.dotfile] + + extra_args = self.GnBuildArgs() + if extra_args: + cmd += ['--args=%s' % ' '.join(extra_args)] + + cmd += [self.output_dir] + + title = 'Generating ' + self.identifier + extra_env = self.GnBuildEnv() + + if extra_env: + # convert the command into a bash command that includes + # setting environment variables + cmd = [ + 'bash', '-c', '\n' + ' '.join( + ['%s="%s" \\\n' % (key, value) for key, value in extra_env.items()] + + [shlex.join(cmd)] + ) + ] + + self._Execute(cmd, title=title) diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index dcb2963b1177ee..19e19d89afeb32 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] +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] 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]