Browse Source

pio: helper to build single-source .E

pull/2575/head
Maxim Prokhorov 1 year ago
parent
commit
579a5b239b
2 changed files with 22 additions and 0 deletions
  1. +19
    -0
      code/scripts/espurna_utils/build.py
  2. +3
    -0
      code/scripts/pio_main.py

+ 19
- 0
code/scripts/espurna_utils/build.py View File

@ -69,6 +69,25 @@ def merge_cpp(target, source, env, encoding="utf-8"):
def app_add_builder_single_source(env):
# generate things in the $BUILD_DIR, so there's no need for any extra clean-up code
source = os.path.join("${BUILD_DIR}", "espurna_single_source", "src", "main.cpp")
env.SetDefault(ESPURNA_SINGLE_SOURCE_TARGET=source)
# also allow to generate .E file from the .cpp, so we can inspect build flags
env.SetDefault(PREPROCESSCOM=env["CXXCOM"].replace("-c", "-dM -E"))
# Create pseudo-builder and add to enviroment
def builder_generator(target, source, env, for_signature):
return env.VerboseAction(
"$PREPROCESSCOM",
"Preprocessing $SOURCE",
)
env.Append(
BUILDERS={
"PreProcess": env.Builder(
generator=builder_generator, suffix=".E", src_suffix=".cpp"
)
}
)
# substitute a single node instead of building it somewhere else as a lib or extra source dir
# (...and since we can't seem to modify src_filter specifically for the project dir, only middleware works :/)


+ 3
- 0
code/scripts/pio_main.py View File

@ -70,3 +70,6 @@ app_add_target_build_and_copy(projenv)
# handle special GzipFile builder
app_add_gzip_file(projenv)
# pre-processed single-source only makes sense from projenv
projenv.PreProcess(env["ESPURNA_SINGLE_SOURCE_TARGET"])

Loading…
Cancel
Save