14
14
15
15
import os
16
16
from enum import Enum , auto
17
+ import shlex
17
18
18
19
from .gn import GnBuilder
19
20
@@ -115,16 +116,30 @@ def __init__(self,
115
116
runner ,
116
117
app : Efr32App = Efr32App .LIGHT ,
117
118
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 ,
118
125
enable_rpcs : bool = False ,
119
126
enable_ota_requestor : bool = False ,
120
127
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
122
136
):
123
137
super (Efr32Builder , self ).__init__ (
124
138
root = app .BuildRoot (root ),
125
139
runner = runner )
126
140
self .app = app
127
141
self .extra_gn_options = ['silabs_board="%s"' % board .GnArgName ()]
142
+ self .dotfile = ''
128
143
129
144
if enable_rpcs :
130
145
self .extra_gn_options .append ('is_debug=false import("//with_pw_rpc.gni")' )
@@ -139,6 +154,52 @@ def __init__(self,
139
154
self .extra_gn_options .append (
140
155
'chip_build_libshell=false enable_openthread_cli=false show_qr_code=false disable_lcd=true' )
141
156
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
+
142
203
def GnBuildArgs (self ):
143
204
return self .extra_gn_options
144
205
@@ -163,3 +224,33 @@ def build_outputs(self):
163
224
name ] = os .path .join (self .output_dir , name )
164
225
165
226
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 )
0 commit comments