2019-08-27 20:28:42 -05:00
|
|
|
#
|
|
|
|
# common-cxxflags.py
|
|
|
|
# Convenience script to apply customizations to CPP flags
|
|
|
|
#
|
|
|
|
Import("env")
|
2021-04-17 14:19:33 -05:00
|
|
|
|
|
|
|
# Detect that 'vscode init' is running
|
|
|
|
from SCons.Script import COMMAND_LINE_TARGETS
|
|
|
|
if "idedata" in COMMAND_LINE_TARGETS:
|
|
|
|
env.Exit(0)
|
|
|
|
|
2019-08-27 20:28:42 -05:00
|
|
|
env.Append(CXXFLAGS=[
|
|
|
|
"-Wno-register"
|
|
|
|
#"-Wno-incompatible-pointer-types",
|
|
|
|
#"-Wno-unused-const-variable",
|
|
|
|
#"-Wno-maybe-uninitialized",
|
|
|
|
#"-Wno-sign-compare"
|
|
|
|
])
|
2020-10-31 17:14:10 -05:00
|
|
|
|
2021-02-26 17:59:28 -06:00
|
|
|
#
|
|
|
|
# Add CPU frequency as a compile time constant instead of a runtime variable
|
|
|
|
#
|
|
|
|
def add_cpu_freq():
|
|
|
|
if 'BOARD_F_CPU' in env:
|
|
|
|
env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU'])
|
|
|
|
|
2020-10-31 17:14:10 -05:00
|
|
|
# Useful for JTAG debugging
|
|
|
|
#
|
2021-03-20 22:43:47 -05:00
|
|
|
# It will separate release and debug build folders.
|
|
|
|
# It useful to keep two live versions: a debug version for debugging and another for
|
|
|
|
# release, for flashing when upload is not done automatically by jlink/stlink.
|
|
|
|
# Without this, PIO needs to recompile everything twice for any small change.
|
2021-03-13 05:01:02 -06:00
|
|
|
if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink']:
|
2020-10-31 17:14:10 -05:00
|
|
|
env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug'
|
2021-02-26 17:59:28 -06:00
|
|
|
|
2021-02-27 23:51:56 -06:00
|
|
|
# On some platform, F_CPU is a runtime variable. Since it's used to convert from ns
|
|
|
|
# to CPU cycles, this adds overhead preventing small delay (in the order of less than
|
2021-02-26 17:59:28 -06:00
|
|
|
# 30 cycles) to be generated correctly. By using a compile time constant instead
|
|
|
|
# the compiler will perform the computation and this overhead will be avoided
|
|
|
|
add_cpu_freq()
|