Convert .ino -> .cpp (#2228)

- general conversion from .ino modules into a separate .cpp files
- clean-up internal headers, place libraries into .h. guard .cpp with _SUPPORT flags 
- fix some instances of shared variables instead of public methods
- tweak build system to still build a single source file via os environment variable ESPURNA_BUILD_SINGLE_SOURCE
This commit is contained in:
Max Prokhorov
2020-04-30 13:55:07 +03:00
committed by GitHub
parent 732e84c45e
commit edb23dbfc4
125 changed files with 2977 additions and 2352 deletions

View File

@@ -1,5 +1,17 @@
import atexit
import os
import shutil
import tempfile
from .display import print_warning
def try_remove(path):
try:
os.remove(path)
except: # pylint: disable=bare-except
print_warning("Please manually remove the file `{}`".format(path))
def copy_release(target, source, env):
# target filename and subdir for release files
@@ -20,3 +32,18 @@ def copy_release(target, source, env):
shutil.copy(src, dest)
# emulate .ino concatenation to speed up compilation times
def merge_cpp(sources, output):
with tempfile.TemporaryFile() as tmp:
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:
shutil.copyfileobj(fobj, tmp)
tmp.seek(0)
with open(output, "wb") as fobj:
shutil.copyfileobj(tmp, fobj)
atexit.register(try_remove, output)