39
39
from SCons .Script import DefaultEnvironment , SConscript
40
40
from platformio import fs
41
41
from platformio .package .version import pepver_to_semver
42
- from platformio .project .config import ProjectConfig
43
42
from platformio .package .manager .tool import ToolPackageManager
44
43
45
44
IS_WINDOWS = sys .platform .startswith ("win" )
@@ -72,6 +71,12 @@ def setup_logging():
72
71
if os .environ .get ('ARDUINO_FRAMEWORK_ENABLE_LOGGING' ):
73
72
setup_logging ()
74
73
74
+ # Constants for better performance
75
+ UNICORE_FLAGS = {
76
+ "CORE32SOLO1" ,
77
+ "CONFIG_FREERTOS_UNICORE=y"
78
+ }
79
+
75
80
# Thread-safe global flags to prevent message spam
76
81
_PATH_SHORTENING_LOCK = threading .Lock ()
77
82
_PATH_SHORTENING_MESSAGES = {
@@ -537,20 +542,16 @@ def safe_remove_sdkconfig_files():
537
542
platform = env .PioPlatform ()
538
543
config = env .GetProjectConfig ()
539
544
board = env .BoardConfig ()
540
- print ("******* board" , board )
541
-
542
545
543
546
# Cached values
544
547
mcu = board .get ("build.mcu" , "esp32" )
545
548
pioenv = env ["PIOENV" ]
546
549
project_dir = env .subst ("$PROJECT_DIR" )
547
550
path_cache = PathCache (platform , mcu )
548
- current_env_section = "env:" + pioenv
549
-
551
+ current_env_section = f"env:{ pioenv } "
550
552
551
553
# Board configuration
552
554
board_sdkconfig = board .get ("espidf.custom_sdkconfig" , "" )
553
- print ("****** board sdkconfig:" , board_sdkconfig )
554
555
entry_custom_sdkconfig = "\n "
555
556
flag_custom_sdkconfig = False
556
557
flag_custom_component_remove = False
@@ -568,21 +569,20 @@ def safe_remove_sdkconfig_files():
568
569
if config .has_option (current_env_section , "custom_component_remove" ):
569
570
flag_custom_component_remove = True
570
571
571
- if config .has_option ("env:" + env ["PIOENV" ], "custom_sdkconfig" ):
572
- print ("entry custom_sdkconfig" , entry_custom_sdkconfig )
573
- entry_custom_sdkconfig = env .GetProjectOption ("custom_sdkconfig" )
574
- flag_custom_sdkconfig = True
575
-
576
572
# Custom SDKConfig check
577
573
if config .has_option (current_env_section , "custom_sdkconfig" ):
578
574
entry_custom_sdkconfig = env .GetProjectOption ("custom_sdkconfig" )
579
- print ("entry custom_sdkconfig" , entry_custom_sdkconfig )
580
575
flag_custom_sdkconfig = True
581
576
582
- if len (str (board_sdkconfig )) > 2 :
577
+ if board_sdkconfig :
578
+ print (f"board_sdkconfig: { board_sdkconfig } " )
583
579
flag_custom_sdkconfig = True
584
580
585
- extra_flags = ('' .join ([element for element in board .get ("build.extra_flags" , "" )])).replace ("-D" , " " )
581
+ extra_flags_raw = board .get ("build.extra_flags" , [])
582
+ if isinstance (extra_flags_raw , list ):
583
+ extra_flags = " " .join (extra_flags_raw ).replace ("-D" , " " )
584
+ else :
585
+ extra_flags = str (extra_flags_raw ).replace ("-D" , " " )
586
586
587
587
framework_reinstall = False
588
588
@@ -593,8 +593,13 @@ def safe_remove_sdkconfig_files():
593
593
594
594
flag_any_custom_sdkconfig = exists (join (platform .get_package_dir ("framework-arduinoespressif32-libs" ),"sdkconfig" ))
595
595
596
+ def has_unicore_flags ():
597
+ """Check if any UNICORE flags are present in configuration"""
598
+ return any (flag in extra_flags or flag in entry_custom_sdkconfig
599
+ or flag in board_sdkconfig for flag in UNICORE_FLAGS )
600
+
596
601
# Esp32-solo1 libs settings
597
- if flag_custom_sdkconfig == True and ( "CORE32SOLO1" in extra_flags or "CONFIG_FREERTOS_UNICORE=y" in entry_custom_sdkconfig or "CONFIG_FREERTOS_UNICORE=y" in board_sdkconfig ):
602
+ if flag_custom_sdkconfig and has_unicore_flags ( ):
598
603
build_unflags = env .GetProjectOption ("build_unflags" )
599
604
if not build_unflags : # not existing needs init
600
605
env ['BUILD_UNFLAGS' ] = []
0 commit comments