Browse Source

scripts: formatting

pull/2484/head
Maxim Prokhorov 2 years ago
parent
commit
cf0315c231
4 changed files with 19 additions and 6 deletions
  1. +15
    -3
      code/scripts/espurna_utils/build.py
  2. +1
    -0
      code/scripts/espurna_utils/checks.py
  3. +2
    -2
      code/scripts/pio_main.py
  4. +1
    -1
      code/scripts/pio_pre.py

+ 15
- 3
code/scripts/espurna_utils/build.py View File

@ -63,6 +63,7 @@ def app_add_target_build_and_copy(env):
description="Build and store firmware.bin as $ESPURNA_BUILD_DESTINATION/espurna-<version>-$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)

+ 1
- 0
code/scripts/espurna_utils/checks.py View File

@ -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")


+ 2
- 2
code/scripts/pio_main.py View File

@ -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")


+ 1
- 1
code/scripts/pio_pre.py View File

@ -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)

Loading…
Cancel
Save