diff --git a/code/scripts/espurna_utils/build.py b/code/scripts/espurna_utils/build.py index 4f1dabb2..c87cec31 100644 --- a/code/scripts/espurna_utils/build.py +++ b/code/scripts/espurna_utils/build.py @@ -63,6 +63,7 @@ def app_add_target_build_and_copy(env): description="Build and store firmware.bin as $ESPURNA_BUILD_DESTINATION/espurna--$ESPURNA_BUILD_NAME.bin (default destination is $PROJECT_DIR)", ) + # TODO: *could* be a Builder object, just the same it will detect targets via src_suffix & suffix properties # but, notice that: # - constantly re-generating files in $project_dir only useful in development, as the source tree includes already 'compiled' .re.cpp.inc @@ -72,12 +73,23 @@ def app_add_target_build_and_copy(env): # scons has a C source scanner that is tracking `#include` directives. but, file may *already* exist at the scanning phase and # it may be assumed something static during the build (as most include directives are for the system, sdk, and the build-tree headers) + def app_add_target_build_re2c(env): from SCons.Script import COMMAND_LINE_TARGETS - targets = [env.File(target) for target in COMMAND_LINE_TARGETS if ".re.cpp.inc" in target] + + targets = [ + env.File(target) for target in COMMAND_LINE_TARGETS if ".re.cpp.inc" in target + ] cmd = "re2c --no-generation-date --case-ranges -W -Werror -o {} {}" if targets: - sources = [target.File("{}".format(target.name.replace(".cpp.inc", ""))) for target in targets] + sources = [ + target.File("{}".format(target.name.replace(".cpp.inc", ""))) + for target in targets + ] for target, source in zip(targets, sources): - env.Execute(env.VerboseAction(cmd.format(target, source), "Generating {}".format(target.name))) + env.Execute( + env.VerboseAction( + cmd.format(target, source), "Generating {}".format(target.name) + ) + ) env.Exit(0) diff --git a/code/scripts/espurna_utils/checks.py b/code/scripts/espurna_utils/checks.py index 6b8ad0b8..008f7984 100644 --- a/code/scripts/espurna_utils/checks.py +++ b/code/scripts/espurna_utils/checks.py @@ -2,6 +2,7 @@ import os from .display import Color, clr, print_filler, print_warning + def check_env(name, default): return os.environ.get(name, default) in ("1", "y", "yes", "true") diff --git a/code/scripts/pio_main.py b/code/scripts/pio_main.py index cf7a498f..556ba37c 100644 --- a/code/scripts/pio_main.py +++ b/code/scripts/pio_main.py @@ -16,7 +16,7 @@ from espurna_utils import ( app_inject_version, dummy_ets_printf, app_inject_flags, - app_add_target_build_and_copy + app_add_target_build_and_copy, ) @@ -27,7 +27,7 @@ import os CI = "true" == os.environ.get("CI") # See what happens in-between linking .cpp.o + .a into the resulting .elf -env.ProcessFlags("-Wl,-Map -Wl,\\\"${BUILD_DIR}/${PROGNAME}.map\\\"") +env.ProcessFlags('-Wl,-Map -Wl,\\"${BUILD_DIR}/${PROGNAME}.map\\"') # Always show warnings for project code projenv.ProcessUnFlags("-w") diff --git a/code/scripts/pio_pre.py b/code/scripts/pio_pre.py index 29b7ca13..87037033 100644 --- a/code/scripts/pio_pre.py +++ b/code/scripts/pio_pre.py @@ -141,5 +141,5 @@ if check_env("ESPURNA_BUILD_SINGLE_SOURCE", "0"): cpp_files.append(relpath) merge_cpp(cpp_files, "espurna/espurna_single_source.cpp") -# handle explicit dependency for .re, so the source is built correctly +# handle explicit targets that have .re.cpp.inc, build them before falling into the next sconsfile app_add_target_build_re2c(env)