Arduino core 3.3.5
This commit is contained in:
@@ -73,8 +73,9 @@ def get_platform_default_threshold(mcu):
|
||||
"esp32s2": 32000, # ESP32-S2
|
||||
"esp32s3": 32766, # ESP32-S3
|
||||
"esp32c3": 32000, # ESP32-C3
|
||||
"esp32c2": 32000, # ESP32-C2
|
||||
"esp32c2": 31600, # ESP32-C2
|
||||
"esp32c6": 31600, # ESP32-C6
|
||||
"esp32c61": 31600, # ESP32-C61
|
||||
"esp32h2": 32000, # ESP32-H2
|
||||
"esp32p4": 32000, # ESP32-P4
|
||||
}
|
||||
@@ -110,6 +111,7 @@ def validate_threshold(threshold, mcu):
|
||||
"esp32s3": {"min": 30000, "max": 32767},
|
||||
"esp32p4": {"min": 30000, "max": 32767},
|
||||
"esp32c6": {"min": 30000, "max": 32767},
|
||||
"esp32c61": {"min": 30000, "max": 32767},
|
||||
"esp32h2": {"min": 30000, "max": 32767},
|
||||
}
|
||||
|
||||
@@ -236,7 +238,7 @@ def get_threshold_info(env, config, current_env_section):
|
||||
Returns:
|
||||
dict: Information about threshold configuration
|
||||
"""
|
||||
mcu = env.BoardConfig().get("build.mcu", "esp32")
|
||||
mcu = env.BoardConfig().get("build.mcu", "esp32").lower()
|
||||
setting_name = "custom_include_path_length_threshold"
|
||||
|
||||
info = {
|
||||
@@ -285,9 +287,10 @@ def get_threshold_info(env, config, current_env_section):
|
||||
|
||||
# Cache class for frequently used paths
|
||||
class PathCache:
|
||||
def __init__(self, platform, mcu):
|
||||
def __init__(self, platform, mcu, chip_variant):
|
||||
self.platform = platform
|
||||
self.mcu = mcu
|
||||
self.chip_variant = chip_variant
|
||||
self._framework_dir = None
|
||||
self._framework_lib_dir = None
|
||||
self._sdk_dir = None
|
||||
@@ -310,7 +313,7 @@ class PathCache:
|
||||
def sdk_dir(self):
|
||||
if self._sdk_dir is None:
|
||||
self._sdk_dir = fs.to_unix_path(
|
||||
str(Path(self.framework_lib_dir) / self.mcu / "include")
|
||||
str(Path(self.framework_lib_dir) / self.chip_variant / "include")
|
||||
)
|
||||
return self._sdk_dir
|
||||
|
||||
@@ -520,9 +523,11 @@ board = env.BoardConfig()
|
||||
|
||||
# Cached values
|
||||
mcu = board.get("build.mcu", "esp32")
|
||||
chip_variant = env.BoardConfig().get("build.chip_variant", "").lower()
|
||||
chip_variant = chip_variant if chip_variant else mcu
|
||||
pioenv = env["PIOENV"]
|
||||
project_dir = env.subst("$PROJECT_DIR")
|
||||
path_cache = PathCache(platform, mcu)
|
||||
path_cache = PathCache(platform, mcu, chip_variant)
|
||||
current_env_section = f"env:{pioenv}"
|
||||
|
||||
# Board configuration
|
||||
@@ -532,9 +537,7 @@ flag_custom_sdkconfig = False
|
||||
flag_custom_component_remove = False
|
||||
flag_custom_component_add = False
|
||||
flag_lib_ignore = False
|
||||
|
||||
if mcu == "esp32c2":
|
||||
flag_custom_sdkconfig = True
|
||||
flag_lto = False
|
||||
|
||||
# pio lib_ignore check
|
||||
if config.has_option(current_env_section, "lib_ignore"):
|
||||
@@ -598,6 +601,10 @@ if flag_custom_sdkconfig:
|
||||
if has_unicore_flags():
|
||||
build_unflags += " -ustart_app_other_cores"
|
||||
|
||||
# Check for enabling LTO for Arduino HybridCompile part by unflagging -fno-lto
|
||||
if '-fno-lto' in build_unflags:
|
||||
flag_lto = True
|
||||
|
||||
new_build_unflags = build_unflags.split()
|
||||
env.Replace(BUILD_UNFLAGS=new_build_unflags)
|
||||
|
||||
@@ -916,13 +923,76 @@ if ("arduino" in pioframework and "espidf" not in pioframework and
|
||||
from component_manager import ComponentManager
|
||||
component_manager = ComponentManager(env)
|
||||
component_manager.handle_component_settings()
|
||||
|
||||
# Handle LTO flags if flag_lto is set
|
||||
if flag_lto:
|
||||
# First remove existing -fno-lto flags, then add LTO flags
|
||||
component_manager.remove_no_lto_flags()
|
||||
component_manager.add_lto_flags()
|
||||
|
||||
silent_action = env.Action(component_manager.restore_pioarduino_build_py)
|
||||
# silence scons command output
|
||||
silent_action.strfunction = lambda target, source, env: ''
|
||||
env.AddPostAction("checkprogsize", silent_action)
|
||||
|
||||
if IS_WINDOWS:
|
||||
env.AddBuildMiddleware(smart_include_length_shorten)
|
||||
# Integrate smart_include_length_shorten with existing middlewares
|
||||
existing_middlewares = list(env.get("__PIO_BUILD_MIDDLEWARES", []))
|
||||
|
||||
if existing_middlewares:
|
||||
# Wrap user middlewares to work together with smart_include_length_shorten
|
||||
def integrated_middleware(env, node):
|
||||
# Create a custom env.Object wrapper that intercepts calls
|
||||
original_object = env.Object
|
||||
result_holder = {"result": None, "called": False}
|
||||
|
||||
def custom_object_wrapper(_node, **kwargs):
|
||||
# User middleware called env.Object - capture it
|
||||
result_holder["called"] = True
|
||||
result_holder["kwargs"] = kwargs
|
||||
# Don't actually compile yet, just return a marker
|
||||
return None
|
||||
|
||||
# Temporarily replace env.Object
|
||||
env.Object = custom_object_wrapper
|
||||
|
||||
# Call user middleware - it will call our wrapper
|
||||
for middleware_func, _ in existing_middlewares:
|
||||
middleware_func(env, node)
|
||||
|
||||
# Restore original env.Object
|
||||
env.Object = original_object
|
||||
|
||||
# Now compile with smart_include_length_shorten
|
||||
if result_holder["called"] and result_holder.get("kwargs"):
|
||||
# User middleware wants custom flags - merge them
|
||||
user_kwargs = result_holder["kwargs"]
|
||||
|
||||
# Temporarily apply user's custom flags to env
|
||||
old_values = {}
|
||||
for key, value in user_kwargs.items():
|
||||
if key in env:
|
||||
old_values[key] = env[key]
|
||||
env[key] = value
|
||||
|
||||
# Compile with smart_include_length_shorten
|
||||
result = smart_include_length_shorten(env, node)
|
||||
|
||||
# Restore original env values
|
||||
for key, value in old_values.items():
|
||||
env[key] = value
|
||||
|
||||
return result
|
||||
else:
|
||||
# No custom flags, just use smart_include_length_shorten
|
||||
return smart_include_length_shorten(env, node)
|
||||
|
||||
# Replace all middlewares with the integrated one
|
||||
env["__PIO_BUILD_MIDDLEWARES"] = []
|
||||
env.AddBuildMiddleware(integrated_middleware)
|
||||
else:
|
||||
# No user middlewares, just add smart_include_length_shorten
|
||||
env.AddBuildMiddleware(smart_include_length_shorten)
|
||||
|
||||
build_script_path = str(Path(FRAMEWORK_DIR) / "tools" / "pioarduino-build.py")
|
||||
SConscript(build_script_path)
|
||||
|
||||
Reference in New Issue
Block a user