mirror of https://github.com/arendst/Tasmota.git
Refactor `strip_flags.py` and `add_c_flags.py` (#21677)
* refactor strip-flags.py * refac more readable * make failsafe * move var to top * align
This commit is contained in:
parent
c96a48b9e1
commit
b853886cb7
|
@ -1,16 +1,21 @@
|
|||
Import("env")
|
||||
|
||||
build_flags = env['BUILD_FLAGS']
|
||||
chip = env.get("BOARD_MCU").lower()
|
||||
|
||||
# General options that are passed to the C++ compiler
|
||||
env.Append(CXXFLAGS=["-Wno-volatile"])
|
||||
|
||||
# General options that are passed to the C compiler (C only; not C++).
|
||||
env.Append(CFLAGS=["-Wno-discarded-qualifiers", "-Wno-implicit-function-declaration", "-Wno-incompatible-pointer-types"])
|
||||
|
||||
|
||||
# Remove build flags which are not valid for risc-v
|
||||
build_flags = env['BUILD_FLAGS']
|
||||
chip = env.get("BOARD_MCU").lower()
|
||||
|
||||
if "c" in chip:
|
||||
build_flags.pop(build_flags.index("-mno-target-align"))
|
||||
build_flags.pop(build_flags.index("-mtarget-align"))
|
||||
if chip in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
||||
try:
|
||||
build_flags.pop(build_flags.index("-mno-target-align"))
|
||||
except:
|
||||
do_nothing=""
|
||||
try:
|
||||
build_flags.pop(build_flags.index("-mtarget-align"))
|
||||
except:
|
||||
do_nothing=""
|
|
@ -1,15 +1,15 @@
|
|||
Import('env')
|
||||
|
||||
link_flags = " ".join(env['LINKFLAGS'])
|
||||
link_flags = env['LINKFLAGS']
|
||||
build_flags = " ".join(env['BUILD_FLAGS'])
|
||||
|
||||
if "FIRMWARE_SAFEBOOT" in build_flags:
|
||||
# Crash Recorder is not included in safeboot firmware -> remove Linker wrap
|
||||
link_flags = link_flags.replace("-Wl,--wrap=panicHandler", "")
|
||||
link_flags = link_flags.replace("-Wl,--wrap=xt_unhandled_exception", "")
|
||||
|
||||
new_link_flags = link_flags.split()
|
||||
|
||||
env.Replace(
|
||||
LINKFLAGS=new_link_flags
|
||||
)
|
||||
try:
|
||||
link_flags.pop(link_flags.index("-Wl,--wrap=panicHandler"))
|
||||
except:
|
||||
do_nothing=""
|
||||
try:
|
||||
link_flags.pop(link_flags.index("-Wl,--wrap=xt_unhandled_exception"))
|
||||
except:
|
||||
do_nothing=""
|
Loading…
Reference in New Issue