pio: generate .cpp.ipp instead of .cpp.inc

fixes #2479
This commit is contained in:
Maxim Prokhorov
2021-11-30 00:13:04 +03:00
parent c738b91b6a
commit a7a9c5045f
7 changed files with 39 additions and 36 deletions

View File

@@ -78,24 +78,27 @@ def app_add_target_build_and_copy(env):
# 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
# - .cpp.re.inc <-> .re dependency will be injected into the scons database of the *environment*,
# - constantly re-generating files in $project_dir only useful in development, as we need already
# 'compiled' .re.cpp.ipp in the source at commit time
# - .cpp.re.ipp <-> .re dependency will be injected into the scons database of the *environment*,
# which may accidentally cause a rebuild when using 2 envs at the same time
# - .cpp file `#include`ing the .inc file may be built before the file is actually generated by the re2c (or, in a parallel job)
# 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)
# - .cpp file `#include`ing the .ipp file may be built before the file is actually generated by the re2c
# (or, it may happen in a parallel job)
# scons has a C source scanner that is tracking `#include` directives. but, file may *already* exist before the
# scanning phase even starts and it may be assumed something static during the build
# (since 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
env.File(target) for target in COMMAND_LINE_TARGETS if ".re.cpp.ipp" in target
]
cmd = "re2c --no-generation-date --case-ranges -W -Werror -o {} {}"
if targets:
sources = [
target.File("{}".format(target.name.replace(".cpp.inc", "")))
target.File("{}".format(target.name.replace(".cpp.ipp", "")))
for target in targets
]
for target, source in zip(targets, sources):