diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index f88e8e7a3fdce1..8008817964cc22 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -206,7 +206,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('chip_build_libshell', chip_build_libshell=True) + target.AppendModifier('disable_chip_logging', chip_logging=False) + target.AppendModifier('disable_chip_openthread_ftd', chip_openthread_ftd=False) + target.AppendModifier('enable_heap_monitoring', enable_heap_monitoring=True) + target.AppendModifier('disable_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('chip_enable_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 @@ -534,4 +547,6 @@ def BuildTelinkTarget(): BuildQorvoTarget(), BuildTizenTarget(), BuildTelinkTarget(), + + ] diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index 6aba4a2a762d88..371c2ebc514e8a 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 @@ -113,16 +114,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")') @@ -137,6 +152,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 @@ -161,3 +222,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 de7b3618c23309..a78ad5afabba3d 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][-chip_build_libshell][-disable_chip_logging][-disable_chip_openthread_ftd][-enable_heap_monitoring][-disable_openthread_cli][-show_qr_code][-wifi][-rs911x][-wf200][-chip_enable_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]