Skip to content

Commit d225def

Browse files
authored
Update arduino.py
1 parent fcff03a commit d225def

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

builder/frameworks/arduino.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from SCons.Script import DefaultEnvironment, SConscript
4040
from platformio import fs
4141
from platformio.package.version import pepver_to_semver
42-
from platformio.project.config import ProjectConfig
4342
from platformio.package.manager.tool import ToolPackageManager
4443

4544
IS_WINDOWS = sys.platform.startswith("win")
@@ -72,6 +71,12 @@ def setup_logging():
7271
if os.environ.get('ARDUINO_FRAMEWORK_ENABLE_LOGGING'):
7372
setup_logging()
7473

74+
# Constants for better performance
75+
UNICORE_FLAGS = {
76+
"CORE32SOLO1",
77+
"CONFIG_FREERTOS_UNICORE=y"
78+
}
79+
7580
# Thread-safe global flags to prevent message spam
7681
_PATH_SHORTENING_LOCK = threading.Lock()
7782
_PATH_SHORTENING_MESSAGES = {
@@ -537,20 +542,16 @@ def safe_remove_sdkconfig_files():
537542
platform = env.PioPlatform()
538543
config = env.GetProjectConfig()
539544
board = env.BoardConfig()
540-
print("******* board", board)
541-
542545

543546
# Cached values
544547
mcu = board.get("build.mcu", "esp32")
545548
pioenv = env["PIOENV"]
546549
project_dir = env.subst("$PROJECT_DIR")
547550
path_cache = PathCache(platform, mcu)
548-
current_env_section = "env:"+pioenv
549-
551+
current_env_section = f"env:{pioenv}"
550552

551553
# Board configuration
552554
board_sdkconfig = board.get("espidf.custom_sdkconfig", "")
553-
print("****** board sdkconfig:", board_sdkconfig)
554555
entry_custom_sdkconfig = "\n"
555556
flag_custom_sdkconfig = False
556557
flag_custom_component_remove = False
@@ -568,21 +569,20 @@ def safe_remove_sdkconfig_files():
568569
if config.has_option(current_env_section, "custom_component_remove"):
569570
flag_custom_component_remove = True
570571

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-
576572
# Custom SDKConfig check
577573
if config.has_option(current_env_section, "custom_sdkconfig"):
578574
entry_custom_sdkconfig = env.GetProjectOption("custom_sdkconfig")
579-
print("entry custom_sdkconfig", entry_custom_sdkconfig)
580575
flag_custom_sdkconfig = True
581576

582-
if len(str(board_sdkconfig)) > 2:
577+
if board_sdkconfig:
578+
print(f"board_sdkconfig: {board_sdkconfig}")
583579
flag_custom_sdkconfig = True
584580

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", " ")
586586

587587
framework_reinstall = False
588588

@@ -593,8 +593,13 @@ def safe_remove_sdkconfig_files():
593593

594594
flag_any_custom_sdkconfig = exists(join(platform.get_package_dir("framework-arduinoespressif32-libs"),"sdkconfig"))
595595

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+
596601
# 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():
598603
build_unflags = env.GetProjectOption("build_unflags")
599604
if not build_unflags: # not existing needs init
600605
env['BUILD_UNFLAGS'] = []

0 commit comments

Comments
 (0)