@@ -386,18 +386,22 @@ def kconfig_snippet(meta, path, kconfig_file=None, blobs=False, taint_blobs=Fals
386
386
return '\n ' .join (snippet )
387
387
388
388
389
+ def process_kconfig_module_dir (module , meta ):
390
+ module_path = PurePath (module )
391
+ name_sanitized = meta ['name-sanitized' ]
392
+ return f'ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR={ module_path .as_posix ()} \n '
393
+
394
+
389
395
def process_kconfig (module , meta ):
390
396
blobs = process_blobs (module , meta )
391
397
taint_blobs = any (b ['status' ] != BLOB_NOT_PRESENT for b in blobs )
392
398
section = meta .get ('build' , dict ())
393
399
module_path = PurePath (module )
394
400
module_yml = module_path .joinpath ('zephyr/module.yml' )
395
401
kconfig_extern = section .get ('kconfig-ext' , False )
396
- name_sanitized = meta ['name-sanitized' ]
397
- snippet = f'ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR := { module_path .as_posix ()} \n '
398
402
399
403
if kconfig_extern :
400
- return snippet + kconfig_snippet (meta , module_path , blobs = blobs , taint_blobs = taint_blobs )
404
+ return kconfig_snippet (meta , module_path , blobs = blobs , taint_blobs = taint_blobs )
401
405
402
406
kconfig_setting = section .get ('kconfig' , None )
403
407
if not validate_setting (kconfig_setting , module ):
@@ -407,10 +411,11 @@ def process_kconfig(module, meta):
407
411
408
412
kconfig_file = os .path .join (module , kconfig_setting or 'zephyr/Kconfig' )
409
413
if os .path .isfile (kconfig_file ):
410
- return snippet + kconfig_snippet (meta , module_path , Path (kconfig_file ),
411
- blobs = blobs , taint_blobs = taint_blobs )
414
+ return kconfig_snippet (meta , module_path , Path (kconfig_file ),
415
+ blobs = blobs , taint_blobs = taint_blobs )
412
416
else :
413
- return snippet + '\n ' .join (kconfig_module_opts (name_sanitized , blobs , taint_blobs )) + '\n '
417
+ name_sanitized = meta ['name-sanitized' ]
418
+ return '\n ' .join (kconfig_module_opts (name_sanitized , blobs , taint_blobs )) + '\n '
414
419
415
420
416
421
def process_sysbuildkconfig (module , meta ):
@@ -419,10 +424,9 @@ def process_sysbuildkconfig(module, meta):
419
424
module_yml = module_path .joinpath ('zephyr/module.yml' )
420
425
kconfig_extern = section .get ('sysbuild-kconfig-ext' , False )
421
426
name_sanitized = meta ['name-sanitized' ]
422
- snippet = f'ZEPHYR_{ name_sanitized .upper ()} _MODULE_DIR := { module_path .as_posix ()} \n '
423
427
424
428
if kconfig_extern :
425
- return snippet + kconfig_snippet (meta , module_path , sysbuild = True )
429
+ return kconfig_snippet (meta , module_path , sysbuild = True )
426
430
427
431
kconfig_setting = section .get ('sysbuild-kconfig' , None )
428
432
if not validate_setting (kconfig_setting , module ):
@@ -433,10 +437,9 @@ def process_sysbuildkconfig(module, meta):
433
437
if kconfig_setting is not None :
434
438
kconfig_file = os .path .join (module , kconfig_setting )
435
439
if os .path .isfile (kconfig_file ):
436
- return snippet + kconfig_snippet (meta , module_path , Path (kconfig_file ))
440
+ return kconfig_snippet (meta , module_path , Path (kconfig_file ))
437
441
438
- return snippet + \
439
- (f'config ZEPHYR_{ name_sanitized .upper ()} _MODULE\n '
442
+ return (f'config ZEPHYR_{ name_sanitized .upper ()} _MODULE\n '
440
443
f' bool\n '
441
444
f' default y\n ' )
442
445
@@ -866,6 +869,7 @@ def main():
866
869
help = 'Path to zephyr repository' )
867
870
args = parser .parse_args ()
868
871
872
+ kconfig_module_dirs = ""
869
873
kconfig = ""
870
874
cmake = ""
871
875
sysbuild_kconfig = ""
@@ -878,6 +882,7 @@ def main():
878
882
args .modules , args .extra_modules )
879
883
880
884
for module in modules :
885
+ kconfig_module_dirs += process_kconfig_module_dir (module .project , module .meta )
881
886
kconfig += process_kconfig (module .project , module .meta )
882
887
cmake += process_cmake (module .project , module .meta )
883
888
sysbuild_kconfig += process_sysbuildkconfig (
@@ -886,6 +891,16 @@ def main():
886
891
settings += process_settings (module .project , module .meta )
887
892
twister += process_twister (module .project , module .meta )
888
893
894
+ if args .kconfig_out or args .sysbuild_kconfig_out :
895
+ if args .kconfig_out :
896
+ kconfig_module_dirs_out = PurePath (args .kconfig_out ).parent / 'kconfig_module_dirs.env'
897
+ elif args .sysbuild_kconfig_out :
898
+ kconfig_module_dirs_out = PurePath (args .sysbuild_kconfig_out ).parent / \
899
+ 'kconfig_module_dirs.env'
900
+
901
+ with open (kconfig_module_dirs_out , 'w' , encoding = "utf-8" ) as fp :
902
+ fp .write (kconfig_module_dirs )
903
+
889
904
if args .kconfig_out :
890
905
with open (args .kconfig_out , 'w' , encoding = "utf-8" ) as fp :
891
906
fp .write (kconfig )
0 commit comments