From cb8443dfa305760e065cac11f2b9684c0cb22b05 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Sun, 31 May 2020 05:48:47 +0300 Subject: [PATCH] Use #include for single source build (#2267) * [1/2] use #include for single source * [2/2] use #include for single source --- code/scripts/espurna_utils/release.py | 5 ++--- code/scripts/pio_pre.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/code/scripts/espurna_utils/release.py b/code/scripts/espurna_utils/release.py index 4c21a038..44b7c16c 100644 --- a/code/scripts/espurna_utils/release.py +++ b/code/scripts/espurna_utils/release.py @@ -39,9 +39,8 @@ def merge_cpp(sources, output): tmp.write(b"// !!! Automatically generated file; DO NOT EDIT !!! \n") tmp.write(b'#include "espurna.h"\n') for source in sources: - with open(source, "rb") as fobj: - tmp.write('# 1 "{}"\n'.format(source.replace("\\", "/")).encode('utf-8')); - shutil.copyfileobj(fobj, tmp) + src_include = '#include "{}"\n'.format(source) + tmp.write(src_include.encode('utf-8')) tmp.seek(0) diff --git a/code/scripts/pio_pre.py b/code/scripts/pio_pre.py index 92f9367c..723390d7 100644 --- a/code/scripts/pio_pre.py +++ b/code/scripts/pio_pre.py @@ -156,7 +156,7 @@ if os.environ.get("ESPURNA_BUILD_SINGLE_SOURCE"): for name in filenames: if not name.endswith(".cpp"): continue - path = os.path.join(root, name) + path = os.path.relpath(os.path.join(root, name), "espurna") env.AddBuildMiddleware(lambda node: None, "*?/{}".format(path)) cpp_files.append(path) merge_cpp(cpp_files, "espurna/espurna_single_source.cpp")