diff --git a/tools/platformio-build.py b/tools/platformio-build.py index 523e482ad..1ddefc419 100644 --- a/tools/platformio-build.py +++ b/tools/platformio-build.py @@ -51,11 +51,51 @@ assert isdir(FRAMEWORK_DIR) env.Append( + ASFLAGS=["-x", "assembler-with-cpp"], + + CFLAGS=[ + "-std=gnu99", + "-Wpointer-arith", + "-Wno-implicit-function-declaration", + "-Wl,-EL", + "-fno-inline-functions", + "-nostdlib" + ], + CCFLAGS=[ + "-Os", # optimize for size + "-mlongcalls", + "-mtext-section-literals", + "-falign-functions=4", + "-U__STRICT_ANSI__", + "-ffunction-sections", + "-fdata-sections", "-Wall" ], + CXXFLAGS=[ + "-fno-rtti", + "-fno-exceptions", + "-std=c++11" + ], + + LINKFLAGS=[ + "-Os", + "-nostdlib", + "-Wl,--no-check-sections", + "-Wl,-static", + "-Wl,--gc-sections", + "-Wl,-wrap,system_restart_local", + "-Wl,-wrap,spi_flash_read", + "-u", "app_entry", + "-u", "_printf_float", + "-u", "_scanf_float" + ], + CPPDEFINES=[ + ("F_CPU", "$BOARD_F_CPU"), + "__ets__", + "ICACHE_FLASH", ("ARDUINO", 10805), ("ARDUINO_BOARD", '\\"PLATFORMIO_%s\\"' % env.BoardConfig().id.upper()), @@ -84,23 +124,11 @@ env.Append( LIBSOURCE_DIRS=[ join(FRAMEWORK_DIR, "libraries") - ], - - LINKFLAGS=[ - "-Wl,-wrap,system_restart_local", - "-Wl,-wrap,spi_flash_read", - "-u", "app_entry" ] ) -# remove LINKFLAGS defined in main.py and keep user custom flags -try: - index = env['LINKFLAGS'].index("call_user_start") - if index > 0 and env['LINKFLAGS'][index - 1] == "-u": - del env['LINKFLAGS'][index - 1] - env['LINKFLAGS'].remove("call_user_start") -except IndexError: - pass +# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) +env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) flatten_cppdefines = env.Flatten(env['CPPDEFINES'])