Skip to content

Commit 064898d

Browse files
committed
fix(ci): nx management
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 7e145b5 commit 064898d

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

CI/update/stm32variant.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ def keyflash(x):
21532153
return x[0]
21542154

21552155

2156-
def group_by_flash(group_base_list, glist, index_mcu_base):
2156+
def group_by_flash(glist, index_mcu_base):
21572157
expanded_dir_list = []
21582158
group_flash_list = []
21592159
new_mcu_dirname = ""
@@ -2205,14 +2205,14 @@ def group_by_flash(group_base_list, glist, index_mcu_base):
22052205
for ppe in key_package_list:
22062206
sub = mcu_PE_regex.search(ppe)
22072207
if not sub:
2208-
print(f"Package of {base_name}, ppe {ppe} info not recognized")
2208+
print(f"Package: {base_name}, ppe: {ppe} not recognized")
22092209
exit(1)
22102210
else:
22112211
package_list.append(sub.group(1))
22122212
# Assert
22132213
if sub.group(2) != "x":
22142214
print(
2215-
f"Package of {base_name}, ppe {ppe} info contains {sub.group(2)} instead of 'x'"
2215+
f"Package: {base_name}, ppe: {ppe} contains {sub.group(2)} instead of 'x'"
22162216
)
22172217
exit(1)
22182218
if sub.group(3):
@@ -2241,7 +2241,7 @@ def group_by_flash(group_base_list, glist, index_mcu_base):
22412241
return new_mcu_dirname
22422242

22432243

2244-
def merge_dir(out_temp_path, group_mcu_dir, mcu_family, periph_xml, variant_exp):
2244+
def merge_dir(out_temp_path, group_mcu_dir, mcu_family_name, periph_xml, variant_exp):
22452245
dirname_list = []
22462246
new_mcu_dirname = ""
22472247
# Working mcu directory
@@ -2250,7 +2250,8 @@ def merge_dir(out_temp_path, group_mcu_dir, mcu_family, periph_xml, variant_exp)
22502250
if len(group_mcu_dir) != 1:
22512251
# Handle mcu name length dynamically
22522252
# Add num for extra information line, #pin and flash
2253-
index_mcu_base = len(mcu_family.name.removeprefix("STM32").removesuffix(nx)) + (
2253+
nx = stm32_dict[mcu_family_name.removeprefix("STM32")]
2254+
index_mcu_base = len(mcu_family_name.removeprefix("STM32").removesuffix(nx)) + (
22542255
3 if len(nx) == 2 else 2
22552256
)
22562257
# Extract only dir name
@@ -2271,14 +2272,14 @@ def merge_dir(out_temp_path, group_mcu_dir, mcu_family, periph_xml, variant_exp)
22712272
new_mcu_dirname += f"{'_' if index != 0 else ''}{glist[0].strip('x')}"
22722273
else:
22732274
# Group using flash info
2274-
gbf = group_by_flash(group_base_list, glist, index_mcu_base)
2275+
gbf = group_by_flash(glist, index_mcu_base)
22752276
new_mcu_dirname += f"{'_' if index != 0 else ''}{gbf}"
22762277
del group_package_list[:]
22772278
del group_flash_list[:]
22782279
del group_base_list[:]
22792280
del dirname_list[:]
22802281

2281-
new_mcu_dir = out_temp_path / mcu_family.name / new_mcu_dirname
2282+
new_mcu_dir = out_temp_path / f"{mcu_family_name}{nx}" / new_mcu_dirname
22822283

22832284
board_entry = ""
22842285
with open(mcu_dir / boards_entry_filename) as fp:
@@ -2371,10 +2372,11 @@ def aggregate_dir():
23712372

23722373
# Compare per family
23732374
for mcu_family_name in aggregate_serie_list:
2374-
mcu_family = out_temp_path / f"{mcu_family_name}{nx}"
2375-
out_family_path = root_dir / "variants" / mcu_family.name
2375+
nx = stm32_dict[mcu_family_name.removeprefix("STM32")]
2376+
mcu_family_path = out_temp_path / f"{mcu_family_name}{nx}"
2377+
out_family_path = root_dir / "variants" / mcu_family_path.name
23762378
# Get all mcu_dir
2377-
mcu_dirs = sorted(mcu_family.glob("*/"))
2379+
mcu_dirs = sorted(mcu_family_path.glob("*/"))
23782380
# Get original directory list of current serie STM32YYxx
23792381
mcu_out_dirs_ori = sorted(out_family_path.glob("*/**"))
23802382
mcu_out_dirs_up = []
@@ -2437,7 +2439,7 @@ def aggregate_dir():
24372439

24382440
# Merge directories name and contents if needed
24392441
mcu_dir = merge_dir(
2440-
out_temp_path, group_mcu_dir, mcu_family, periph_xml, variant_exp
2442+
out_temp_path, group_mcu_dir, mcu_family_name, periph_xml, variant_exp
24412443
)
24422444
# Move to variants/ folder
24432445
out_path = out_family_path / mcu_dir.stem
@@ -2460,15 +2462,15 @@ def aggregate_dir():
24602462
if new_dirs:
24612463
nb_new = len(new_dirs)
24622464
dir_str = "directories" if nb_new > 1 else "directory"
2463-
print(f"\nNew {dir_str} for {mcu_family.name}:\n")
2465+
print(f"\nNew {dir_str} for {mcu_family_path.name}:\n")
24642466
for d in new_dirs:
24652467
print(f" - {d.name}")
24662468
print("\n --> Please, check if it is a new directory or a renamed one.")
24672469
old_dirs = set(mcu_out_dirs_ori) - set(mcu_out_dirs_up)
24682470
if old_dirs:
24692471
nb_old = len(old_dirs)
24702472
dir_str = "Directories" if nb_old > 1 else "Directory"
2471-
print(f"\n{dir_str} not updated for {mcu_family.name}:\n")
2473+
print(f"\n{dir_str} not updated for {mcu_family_path.name}:\n")
24722474
for d in old_dirs:
24732475
# Check if ldsript.ld file exists in the folder
24742476
if not (d / "ldscript.ld").exists():

0 commit comments

Comments
 (0)