Skip to content

Commit

Permalink
feature/efr32_python_build_integration (#23530)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lpbeliveau-silabs authored and pull[bot] committed Mar 30, 2023
1 parent 19d8f7d commit 2021763
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 3 deletions.
17 changes: 16 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -536,4 +549,6 @@ def BuildTelinkTarget():
BuildQorvoTarget(),
BuildTizenTarget(),
BuildTelinkTarget(),


]
93 changes: 92 additions & 1 deletion scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import os
from enum import Enum, auto
import shlex

from .gn import GnBuilder

Expand Down Expand Up @@ -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")')
Expand All @@ -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

Expand All @@ -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)
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]
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]
Expand Down

0 comments on commit 2021763

Please sign in to comment.