diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 8998fcde78..a462ff391a 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -139,12 +139,8 @@ def scons_patched_match_splitext(path, suffixes=None): join(FRAMEWORK_DIR, "tools", "sdk", "ld") ], - # A list of one or more libraries that will be linked with any executable programs created by this environment - LIBS=[ - "hal", "phy", "pp", "net80211", "wpa", "crypto", "main", - "wps", "bearssl", "espnow", "smartconfig", "airkiss", "wpa2", - "m", "c", "gcc" - ], + # LIBS is set at the bottom of the builder script + # where we know about all system libraries to be included LIBSOURCE_DIRS=[ join(FRAMEWORK_DIR, "libraries") @@ -218,43 +214,44 @@ def scons_patched_match_splitext(path, suffixes=None): # # lwIP # +lwip_lib = None if "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY" in flatten_cppdefines: env.Append( CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip6-536-feat"] ) + lwip_lib = "lwip6-536-feat" elif "PIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_HIGHER_BANDWIDTH" in flatten_cppdefines: env.Append( CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 1)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip6-1460-feat"] ) + lwip_lib = "lwip6-1460-feat" elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH" in flatten_cppdefines: env.Append( CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip2-1460-feat"] ) + lwip_lib = "lwip2-1460-feat" elif "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH" in flatten_cppdefines: env.Append( CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip2-536"] ) + lwip_lib = "lwip2-536" elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH" in flatten_cppdefines: env.Append( CPPDEFINES=[("TCP_MSS", 1460), ("LWIP_FEATURES", 0), ("LWIP_IPV6", 0)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip2-1460"] ) + lwip_lib = "lwip2-1460" # PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY (default) else: env.Append( CPPDEFINES=[("TCP_MSS", 536), ("LWIP_FEATURES", 1), ("LWIP_IPV6", 0)], CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")], - LIBS=["lwip2-536-feat"] ) + lwip_lib = "lwip2-536-feat" # # Waveform @@ -266,17 +263,17 @@ def scons_patched_match_splitext(path, suffixes=None): # # Exceptions # +stdcpp_lib = None if "PIO_FRAMEWORK_ARDUINO_ENABLE_EXCEPTIONS" in flatten_cppdefines: env.Append( CXXFLAGS=["-fexceptions"], - LIBS=["stdc++-exc"] ) + stdcpp_lib = "stdc++-exc" else: env.Append( CXXFLAGS=["-fno-exceptions"], - LIBS=["stdc++"] ) - + stdcpp_lib = "stdc++" # # VTables # @@ -355,6 +352,15 @@ def scons_patched_match_splitext(path, suffixes=None): assert mmu_flags env.Append(CPPDEFINES=mmu_flags) +# A list of one or more libraries that will be linked with any executable programs created by this environment +# We do this at this point so that we can put the libraries in their correct order more easily +env.Append( + LIBS=[ + "hal", "phy", "pp", "net80211", lwip_lib, "wpa", "crypto", "main", + "wps", "bearssl", "espnow", "smartconfig", "airkiss", "wpa2", + stdcpp_lib, "m", "c", "gcc" + ] +) # Build the eagle.app.v6.common.ld linker file app_ld = env.Command(