Skip to content

Commit 2021763

Browse files
lpbeliveau-silabspull[bot]
authored andcommitted
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
1 parent 19d8f7d commit 2021763

File tree

3 files changed

+109
-3
lines changed

3 files changed

+109
-3
lines changed

scripts/build/build/targets.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,20 @@ def BuildEfr32Target():
207207
target.AppendModifier('rpc', enable_rpcs=True)
208208
target.AppendModifier('with-ota-requestor', enable_ota_requestor=True)
209209
target.AppendModifier('sed', enable_sed=True)
210-
target.AppendModifier('low-power', enable_low_power=True)
210+
target.AppendModifier('low-power', enable_low_power=True).OnlyIfRe('-sed')
211+
target.AppendModifier('shell', chip_build_libshell=True)
212+
target.AppendModifier('no_logging', chip_logging=False)
213+
target.AppendModifier('openthread_mtd', chip_openthread_ftd=False)
214+
target.AppendModifier('enable_heap_monitoring', enable_heap_monitoring=True)
215+
target.AppendModifier('no_openthread_cli', enable_openthread_cli=False)
216+
target.AppendModifier('show_qr_code', show_qr_code=True).ExceptIfRe('-low-power')
217+
target.AppendModifier('wifi', enable_wifi=True)
218+
target.AppendModifier('rs911x', enable_rs911x=True).OnlyIfRe('-wifi')
219+
target.AppendModifier('wf200', enable_wf200=True).OnlyIfRe('-wifi')
220+
target.AppendModifier('wifi_ipv4', enable_wifi_ipv4=True).OnlyIfRe('-wifi')
221+
target.AppendModifier('additional_data_advertising', enable_additional_data_advertising=True)
222+
target.AppendModifier('use_ot_lib', enable_ot_lib=True).ExceptIfRe('-(wifi|use_ot_coap_lib)')
223+
target.AppendModifier('use_ot_coap_lib', enable_ot_coap_lib=True).ExceptIfRe('-(wifi|use_ot_lib)')
211224

212225
return target
213226

@@ -536,4 +549,6 @@ def BuildTelinkTarget():
536549
BuildQorvoTarget(),
537550
BuildTizenTarget(),
538551
BuildTelinkTarget(),
552+
553+
539554
]

scripts/build/builders/efr32.py

+92-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import os
1616
from enum import Enum, auto
17+
import shlex
1718

1819
from .gn import GnBuilder
1920

@@ -115,16 +116,30 @@ def __init__(self,
115116
runner,
116117
app: Efr32App = Efr32App.LIGHT,
117118
board: Efr32Board = Efr32Board.BRD4161A,
119+
chip_build_libshell: bool = False,
120+
chip_logging: bool = True,
121+
chip_openthread_ftd: bool = True,
122+
enable_heap_monitoring: bool = False,
123+
enable_openthread_cli: bool = True,
124+
show_qr_code: bool = False,
118125
enable_rpcs: bool = False,
119126
enable_ota_requestor: bool = False,
120127
enable_sed: bool = False,
121-
enable_low_power: bool = False
128+
enable_low_power: bool = False,
129+
enable_wifi: bool = False,
130+
enable_rs911x: bool = False,
131+
enable_wf200: bool = False,
132+
enable_wifi_ipv4: bool = False,
133+
enable_additional_data_advertising: bool = False,
134+
enable_ot_lib: bool = False,
135+
enable_ot_coap_lib: bool = False
122136
):
123137
super(Efr32Builder, self).__init__(
124138
root=app.BuildRoot(root),
125139
runner=runner)
126140
self.app = app
127141
self.extra_gn_options = ['silabs_board="%s"' % board.GnArgName()]
142+
self.dotfile = ''
128143

129144
if enable_rpcs:
130145
self.extra_gn_options.append('is_debug=false import("//with_pw_rpc.gni")')
@@ -139,6 +154,52 @@ def __init__(self,
139154
self.extra_gn_options.append(
140155
'chip_build_libshell=false enable_openthread_cli=false show_qr_code=false disable_lcd=true')
141156

157+
if chip_build_libshell:
158+
self.extra_gn_options.append('chip_build_libshell=true')
159+
160+
if chip_logging == False:
161+
self.extra_gn_options.append('chip_logging=false')
162+
163+
if chip_openthread_ftd == False:
164+
self.extra_gn_options.append('chip_openthread_ftd=false')
165+
166+
if enable_heap_monitoring:
167+
self.extra_gn_options.append('enable_heap_monitoring=true')
168+
169+
if enable_openthread_cli == False:
170+
self.extra_gn_options.append('enable_openthread_cli=false')
171+
172+
if show_qr_code:
173+
self.extra_gn_options.append('show_qr_code=true')
174+
175+
if enable_wifi:
176+
self.dotfile += self.root + '/build_for_wifi_gnfile.gn'
177+
if board == Efr32Board.BRD4161A:
178+
self.extra_gn_options.append('is_debug=false chip_logging=false')
179+
else:
180+
self.extra_gn_options.append('disable_lcd=true use_external_flash=false')
181+
182+
if enable_rs911x:
183+
self.extra_gn_options.append('use_rs911x=true')
184+
elif enable_wf200:
185+
self.extra_gn_options.append('use_wf200=true')
186+
else:
187+
raise Exception('Wifi usage: ...-wifi-[rs911x|wf200]-...')
188+
189+
if enable_wifi_ipv4:
190+
self.extra_gn_options.append('chip_enable_wifi_ipv4=true')
191+
192+
if enable_additional_data_advertising:
193+
self.extra_gn_options.append('chip_enable_additional_data_advertising=true chip_enable_rotating_device_id=true')
194+
195+
if enable_ot_lib:
196+
self.extra_gn_options.append(
197+
'use_silabs_thread_lib=true chip_openthread_target="../silabs:ot-efr32-cert" openthread_external_platform=""')
198+
199+
if enable_ot_coap_lib:
200+
self.extra_gn_options.append(
201+
'use_silabs_thread_lib=true chip_openthread_target="../silabs:ot-efr32-cert" use_thread_coap_lib=true openthread_external_platform=""')
202+
142203
def GnBuildArgs(self):
143204
return self.extra_gn_options
144205

@@ -163,3 +224,33 @@ def build_outputs(self):
163224
name] = os.path.join(self.output_dir, name)
164225

165226
return items
227+
228+
def generate(self):
229+
cmd = [
230+
'gn', 'gen', '--check', '--fail-on-unused-args',
231+
'--export-compile-commands',
232+
'--root=%s' % self.root
233+
]
234+
if self.dotfile:
235+
cmd += ['--dotfile=%s' % self.dotfile]
236+
237+
extra_args = self.GnBuildArgs()
238+
if extra_args:
239+
cmd += ['--args=%s' % ' '.join(extra_args)]
240+
241+
cmd += [self.output_dir]
242+
243+
title = 'Generating ' + self.identifier
244+
extra_env = self.GnBuildEnv()
245+
246+
if extra_env:
247+
# convert the command into a bash command that includes
248+
# setting environment variables
249+
cmd = [
250+
'bash', '-c', '\n' + ' '.join(
251+
['%s="%s" \\\n' % (key, value) for key, value in extra_env.items()] +
252+
[shlex.join(cmd)]
253+
)
254+
]
255+
256+
self._Execute(cmd, title=title)

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x
33
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]
44
cc13x2x7_26x2x7-{all-clusters,all-clusters-minimal,lock,pump,pump-controller,shell}[-ftd][-mtd]
55
cyw30739-cyw930739m2evb_01-{light,lock,ota-requestor}[-no-progress-logging]
6-
efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,brd4304a}-{window-covering,switch,unit-test,light,lock}[-rpc][-with-ota-requestor][-sed][-low-power]
6+
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]
77
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]
88
genio-lighting-app
99
linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-libfuzzer][-coverage][-dmalloc][-clang]

0 commit comments

Comments
 (0)