1414
1515script_path = Path (__file__ ).parent .resolve ()
1616sys .path .append (str (script_path .parent ))
17- from utils import deleteFolder , execute_cmd , getRepoBranchName
17+ from utils import defaultConfig , deleteFolder , execute_cmd , getRepoBranchName
1818
1919mcu_list = [] # 'name'
2020io_list = [] # 'PIN','name'
@@ -1274,9 +1274,9 @@ def print_pinamevar():
12741274
12751275# Variant files generation
12761276def spi_pins_variant ():
1277- ss_pin = (
1278- ss1_pin
1279- ) = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = "PNUM_NOT_DEFINED"
1277+ ss_pin = ss1_pin = ss2_pin = ss3_pin = mosi_pin = miso_pin = sck_pin = (
1278+ "PNUM_NOT_DEFINED"
1279+ )
12801280
12811281 # Iterate to find match instance if any
12821282 for mosi in spimosi_list :
@@ -2385,51 +2385,41 @@ def default_cubemxdir():
23852385
23862386
23872387# Config management
2388- def create_config ():
2389- # Create a Json file for a better path management
2390- try :
2391- print (f"Please set your configuration in '{ config_filename } ' file" )
2392- config_file = open (config_filename , "w" , newline = "\n " )
2393- config_file .write (
2394- json .dumps (
2395- {
2396- "CUBEMX_DIRECTORY" : str (cubemxdir ),
2397- "REPO_LOCAL_PATH" : str (repo_local_path ),
2398- },
2399- indent = 2 ,
2400- )
2401- )
2402- config_file .close ()
2403- except IOError :
2404- print (f"Failed to open { config_filename } " )
2405- exit (1 )
2406-
2407-
2408- def check_config ():
2388+ def checkConfig ():
24092389 global cubemxdir
24102390 global repo_local_path
24112391 global repo_path
24122392 default_cubemxdir ()
24132393 if config_filename .is_file ():
24142394 try :
24152395 config_file = open (config_filename , "r" )
2416- config = json .load (config_file )
2396+ path_config = json .load (config_file )
24172397 config_file .close ()
24182398
2419- if "REPO_LOCAL_PATH" in config :
2420- conf = config ["REPO_LOCAL_PATH" ]
2421- if conf :
2422- if conf != "" :
2423- repo_local_path = Path (conf )
2424- repo_path = repo_local_path / repo_name
2425- if "CUBEMX_DIRECTORY" in config :
2426- conf = config ["CUBEMX_DIRECTORY" ]
2427- if conf :
2428- cubemxdir = Path (conf )
2399+ if "REPO_LOCAL_PATH" not in path_config :
2400+ path_config ["REPO_LOCAL_PATH" ] = str (repo_local_path )
2401+ defaultConfig (config_filename , path_config )
2402+ else :
2403+ conf = path_config ["REPO_LOCAL_PATH" ]
2404+ if conf != "" :
2405+ repo_local_path = Path (conf )
2406+ repo_path = repo_local_path / repo_name
2407+
2408+ if "CUBEMX_DIRECTORY" not in path_config :
2409+ path_config ["CUBEMX_DIRECTORY" ] = str (cubemxdir )
2410+ defaultConfig (config_filename , path_config )
2411+ else :
2412+ cubemxdir = Path (path_config ["CUBEMX_DIRECTORY" ])
24292413 except IOError :
24302414 print (f"Failed to open { config_filename } " )
24312415 else :
2432- create_config ()
2416+ defaultConfig (
2417+ config_filename ,
2418+ {
2419+ "CUBEMX_DIRECTORY" : str (cubemxdir ),
2420+ "REPO_LOCAL_PATH" : str (repo_local_path ),
2421+ },
2422+ )
24332423
24342424
24352425def manage_repo ():
@@ -2487,7 +2477,7 @@ def manage_repo():
24872477refname_filter = ["STM32MP13" , "STM32H7R" , "STM32H7S" ]
24882478periph_c_filename = "PeripheralPins.c"
24892479pinvar_h_filename = "PinNamesVar.h"
2490- config_filename = script_path / "variant_config .json"
2480+ config_filename = script_path / "update_config .json"
24912481variant_h_filename = "variant_generic.h"
24922482variant_cpp_filename = "variant_generic.cpp"
24932483boards_entry_filename = "boards_entry.txt"
@@ -2499,7 +2489,7 @@ def manage_repo():
24992489repo_path = repo_local_path / repo_name
25002490db_release = "Unknown"
25012491
2502- check_config ()
2492+ checkConfig ()
25032493
25042494# By default, generate for all mcu xml files description
25052495parser = argparse .ArgumentParser (
0 commit comments