@@ -129,9 +129,11 @@ def __init__(self,
129
129
disable_ble : bool = False ,
130
130
enable_thread : bool = False ,
131
131
enable_wifi : bool = False ,
132
- disable_ipv4 : bool = False ,
133
132
enable_shell : bool = False ,
134
- enable_ota : bool = False ):
133
+ enable_ota : bool = False ,
134
+ enable_factory_data_build : bool = False ,
135
+ disable_pairing_autostart : bool = False ,
136
+ board_variant : str = None ):
135
137
super (NxpBuilder , self ).__init__ (
136
138
root = app .BuildRoot (root , board , os_env ),
137
139
runner = runner )
@@ -147,12 +149,14 @@ def __init__(self,
147
149
self .enable_lit = enable_lit
148
150
self .enable_rotating_id = enable_rotating_id
149
151
self .has_sw_version_2 = has_sw_version_2
150
- self .disable_ipv4 = disable_ipv4
151
152
self .disable_ble = disable_ble
152
153
self .enable_thread = enable_thread
153
154
self .enable_wifi = enable_wifi
154
155
self .enable_ota = enable_ota
155
156
self .enable_shell = enable_shell
157
+ self .enable_factory_data_build = enable_factory_data_build
158
+ self .disable_pairing_autostart = disable_pairing_autostart
159
+ self .board_variant = board_variant
156
160
157
161
def GnBuildArgs (self ):
158
162
args = []
@@ -204,18 +208,54 @@ def GnBuildArgs(self):
204
208
205
209
return args
206
210
207
- def WestBuildArgs (self ):
208
- args = []
211
+ def CmakeBuildFlags (self ):
212
+ flags = []
209
213
if self .enable_factory_data :
210
- args .append ('-DFILE_SUFFIX=fdata' )
214
+ if self .os_env == NxpOsUsed .ZEPHYR :
215
+ flags .append ('-DFILE_SUFFIX=fdata' )
216
+ else :
217
+ flags .append ("-DCONFIG_CHIP_FACTORY_DATA=true" )
211
218
212
219
if self .has_sw_version_2 :
213
- args .append ('-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2' )
220
+ flags .append ("-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2" )
221
+ flags .append ("-DCONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING=\" 2.0\" " )
222
+
223
+ if self .enable_ota :
224
+ flags .append ("-DCONFIG_CHIP_OTA_REQUESTOR=true" )
225
+ if self .os_env == NxpOsUsed .FREERTOS and self .board == NxpBoard .RW61X :
226
+ flags .append ("-DCONFIG_BOOTLOADER_MCUBOOT=true" )
214
227
215
- build_args = " -- " + " " .join (args ) if len (args ) > 0 else ""
216
- return build_args
228
+ if self .disable_ble :
229
+ flags .append ("-DCONFIG_BT=false" )
230
+
231
+ if self .enable_wifi :
232
+ flags .append ('-DCONFIG_CHIP_WIFI=true' )
233
+
234
+ if self .enable_thread :
235
+ flags .append ("-DCONFIG_NET_L2_OPENTHREAD=true -DCONFIG_CHIP_IPV4=false" )
236
+
237
+ if self .enable_factory_data_build :
238
+ # Generate the factory data binary
239
+ flags .append ("-DCONFIG_CHIP_FACTORY_DATA_BUILD=true -DCONFIG_CHIP_FACTORY_DATA=true" )
240
+
241
+ if self .enable_shell :
242
+ flags .append ("-DCONFIG_CHIP_LIB_SHELL=true" )
243
+
244
+ if self .disable_pairing_autostart :
245
+ flags .append ('-DCONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=false' )
246
+
247
+ if self .board_variant :
248
+ if self .board == NxpBoard .RW61X :
249
+ flag_board_variant = "-DCONFIG_BOARD_VARIANT=\" %s\" " % self .board_variant
250
+
251
+ flags .append (flag_board_variant )
252
+
253
+ build_flags = " " .join (flags ) if len (flags ) > 0 else ""
254
+
255
+ return build_flags
217
256
218
257
def generate (self ):
258
+ build_flags = self .CmakeBuildFlags ()
219
259
if self .os_env == NxpOsUsed .ZEPHYR :
220
260
if 'ZEPHYR_NXP_SDK_INSTALL_DIR' in os .environ :
221
261
cmd = 'export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_NXP_SDK_INSTALL_DIR"\n '
@@ -225,14 +265,13 @@ def generate(self):
225
265
cmd += 'export ZEPHYR_BASE="$ZEPHYR_NXP_BASE"\n '
226
266
else :
227
267
raise Exception ("ZEPHYR_NXP_BASE need to be set" )
228
- build_args = self .WestBuildArgs ()
229
268
cmd += '''
230
- west build -p --cmake-only -b {board_name} -d {out_folder} {example_folder} {build_args }
269
+ west build -p --cmake-only -b {board_name} -d {out_folder} {example_folder} {build_flags }
231
270
''' .format (
232
271
board_name = self .board .Name (self .os_env ),
233
272
out_folder = self .output_dir ,
234
273
example_folder = self .app .BuildRoot (self .code_root , self .board , self .os_env ),
235
- build_args = build_args ).strip ()
274
+ build_flags = build_flags ).strip ()
236
275
self ._Execute (['bash' , '-c' , cmd ], title = 'Generating ' + self .identifier )
237
276
else :
238
277
cmd = ''
@@ -248,29 +287,40 @@ def generate(self):
248
287
cmd += 'export NXP_K32W0_SDK_ROOT="' + str (p .sdk_storage_location_abspath ) + '" \n '
249
288
elif p .sdk_name == 'common' :
250
289
cmd += 'export NXP_SDK_ROOT="' + str (p .sdk_storage_location_abspath ) + '" \n '
251
- # add empty space at the end to avoid concatenation issue when there is no --args
252
- cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self .root
253
290
254
- extra_args = []
291
+ if self .board == NxpBoard .RW61X :
292
+ cmd += '''
293
+ cmake -GNinja {build_flags} -H{example_folder} -B{out_folder}
294
+ ''' .format (
295
+ build_flags = build_flags ,
296
+ example_folder = self .app .BuildRoot (self .code_root , self .board , self .os_env ),
297
+ out_folder = self .output_dir ).strip ()
298
+ self ._Execute (['bash' , '-c' , cmd ], title = 'Generating ' + self .identifier )
255
299
256
- if self .options .pw_command_launcher :
257
- extra_args .append ('pw_command_launcher="%s"' % self .options .pw_command_launcher )
300
+ else :
301
+ # add empty space at the end to avoid concatenation issue when there is no --args
302
+ cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self .root
258
303
259
- if self .options .enable_link_map_file :
260
- extra_args .append ('chip_generate_link_map_file=true' )
304
+ extra_args = []
305
+
306
+ if self .options .pw_command_launcher :
307
+ extra_args .append ('pw_command_launcher="%s"' % self .options .pw_command_launcher )
308
+
309
+ if self .options .enable_link_map_file :
310
+ extra_args .append ('chip_generate_link_map_file=true' )
261
311
262
- if self .options .pregen_dir :
263
- extra_args .append ('chip_code_pre_generated_directory="%s"' % self .options .pregen_dir )
312
+ if self .options .pregen_dir :
313
+ extra_args .append ('chip_code_pre_generated_directory="%s"' % self .options .pregen_dir )
264
314
265
- extra_args .extend (self .GnBuildArgs () or [])
266
- if extra_args :
267
- cmd += ' --args="%s' % ' ' .join (extra_args ) + '" '
315
+ extra_args .extend (self .GnBuildArgs () or [])
316
+ if extra_args :
317
+ cmd += ' --args="%s' % ' ' .join (extra_args ) + '" '
268
318
269
- cmd += self .output_dir
319
+ cmd += self .output_dir
270
320
271
- title = 'Generating ' + self .identifier
321
+ title = 'Generating ' + self .identifier
272
322
273
- self ._Execute (['bash' , '-c' , cmd ], title = title )
323
+ self ._Execute (['bash' , '-c' , cmd ], title = title )
274
324
275
325
def build_outputs (self ):
276
326
name = 'chip-%s-%s' % (self .board .Name (self .os_env ), self .app .NameSuffix ())
0 commit comments