Skip to content

Commit ca14626

Browse files
danieldegrassecarlescufi
authored andcommitted
scripts: build: update gen_relocate_app.py to use new argument separators
Update gen_relocate_app.py to use "|" to separate code relocation directives, and ";" to separate multiple files in a relocation directive. This will enable multiple files to be passed to zephyr_code_relocate, as well as multiple files to be passed from a CMake generator expression. The script will then seperate these files and relocate each according to the arguments given to zephyr_code_relocate. Note! This commit will break support for zephyr_code_relocate until the CMake function is updated Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 3454a25 commit ca14626

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

scripts/build/gen_relocate_app.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,24 +464,35 @@ def create_dict_wrt_mem():
464464

465465
if args.input_rel_dict == '':
466466
sys.exit("Disable CONFIG_CODE_DATA_RELOCATION if no file needs relocation")
467-
for line in args.input_rel_dict.split(';'):
467+
for line in args.input_rel_dict.split('|'):
468468
if ':' not in line:
469469
continue
470470

471-
mem_region, phdr, copy_flag, file_name = parse_input_string(line)
471+
mem_region, phdr, copy_flag, file_list = parse_input_string(line)
472472

473473
# Handle any program header
474474
if phdr != '':
475475
phdrs[mem_region] = f':{phdr}'
476476

477-
file_name_list = glob.glob(file_name)
478-
if not file_name_list:
479-
warnings.warn("File: "+file_name+" Not found")
477+
# Split file names by semicolons, to support generator expressions
478+
file_glob_list = file_list.split(';')
479+
file_name_list = []
480+
# Use glob matching on each file in the list
481+
for file_glob in file_glob_list:
482+
glob_results = glob.glob(file_glob)
483+
if not glob_results:
484+
warnings.warn("File: "+file_glob+" Not found")
485+
continue
486+
elif len(glob_results) > 1:
487+
warnings.warn("Regex in file lists is deprecated, please use file(GLOB) instead")
488+
file_name_list.extend(glob_results)
489+
if len(file_name_list) == 0:
490+
warnings.warn("No files in string: "+file_list+" found")
480491
continue
481492
if mem_region == '':
482493
continue
483494
if args.verbose:
484-
print("Memory region ", mem_region, " Selected for file:", file_name_list)
495+
print("Memory region ", mem_region, " Selected for files:", file_name_list)
485496

486497
mem_region = "|".join((mem_region, copy_flag))
487498

0 commit comments

Comments
 (0)