14
14
15
15
script_path = Path (__file__ ).parent .resolve ()
16
16
sys .path .append (str (script_path .parent ))
17
- from utils import deleteFolder , execute_cmd , getRepoBranchName
17
+ from utils import defaultConfig , deleteFolder , execute_cmd , getRepoBranchName
18
18
19
19
mcu_list = [] # 'name'
20
20
io_list = [] # 'PIN','name'
@@ -1274,9 +1274,9 @@ def print_pinamevar():
1274
1274
1275
1275
# Variant files generation
1276
1276
def 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
+ )
1280
1280
1281
1281
# Iterate to find match instance if any
1282
1282
for mosi in spimosi_list :
@@ -2385,51 +2385,41 @@ def default_cubemxdir():
2385
2385
2386
2386
2387
2387
# 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 ():
2409
2389
global cubemxdir
2410
2390
global repo_local_path
2411
2391
global repo_path
2412
2392
default_cubemxdir ()
2413
2393
if config_filename .is_file ():
2414
2394
try :
2415
2395
config_file = open (config_filename , "r" )
2416
- config = json .load (config_file )
2396
+ path_config = json .load (config_file )
2417
2397
config_file .close ()
2418
2398
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" ])
2429
2413
except IOError :
2430
2414
print (f"Failed to open { config_filename } " )
2431
2415
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
+ )
2433
2423
2434
2424
2435
2425
def manage_repo ():
@@ -2487,7 +2477,7 @@ def manage_repo():
2487
2477
refname_filter = ["STM32MP13" , "STM32H7R" , "STM32H7S" ]
2488
2478
periph_c_filename = "PeripheralPins.c"
2489
2479
pinvar_h_filename = "PinNamesVar.h"
2490
- config_filename = script_path / "variant_config .json"
2480
+ config_filename = script_path / "update_config .json"
2491
2481
variant_h_filename = "variant_generic.h"
2492
2482
variant_cpp_filename = "variant_generic.cpp"
2493
2483
boards_entry_filename = "boards_entry.txt"
@@ -2499,7 +2489,7 @@ def manage_repo():
2499
2489
repo_path = repo_local_path / repo_name
2500
2490
db_release = "Unknown"
2501
2491
2502
- check_config ()
2492
+ checkConfig ()
2503
2493
2504
2494
# By default, generate for all mcu xml files description
2505
2495
parser = argparse .ArgumentParser (
0 commit comments