sns: remove need to patch bme680 static library (#2429)

Upstream released a version of their proprietary library which does not require any modification to the linker script.
This commit is contained in:
Rui Marinho
2021-03-31 06:48:09 +01:00
committed by GitHub
parent acfead4229
commit bfa704c2fd
4 changed files with 1 additions and 76 deletions

View File

@@ -22,7 +22,6 @@
from .checks import check_cppcheck, check_printsize
from .float_support import remove_float_support
from .ldscripts import ldscripts_inject_libpath
from .libalgobsec import libalgobsec_inject_patcher
from .postmortem import dummy_ets_printf
from .git import app_inject_revision
from .release import copy_release
@@ -33,7 +32,6 @@ __all__ = [
"check_printsize",
"remove_float_support",
"ldscripts_inject_libpath",
"libalgobsec_inject_patcher",
"dummy_ets_printf",
"app_inject_revision",
"app_inject_flags",

View File

@@ -1,69 +0,0 @@
import os
import sys
def libalgobsec_inject_patcher(env):
libalgobsec_builder = next(
(
builder
for builder in env.GetLibBuilders()
if builder.name == "BSEC Software Library"
),
None,
)
if libalgobsec_builder is None:
return
def process_archive(target, source, env):
import subprocess
# Allows `import espurna_utils` for external scripts, where we might not be within scons runtime
from SCons.Script import Delete, Mkdir
tmpdir = env.get(
"ESPURNA_LIBALGOBSEC_PATCHER_TMPDIR",
os.path.join(str(target[0].get_dir()), "_tmpdir"),
)
env.Execute(Mkdir(tmpdir))
# XXX: $AR does not support output argument for the extraction
# always switch into tmpdir when running commands
def run(cmd):
sys.stdout.write(" ".join(cmd))
sys.stdout.write("\n")
subprocess.check_call(cmd, cwd=tmpdir)
run([env.subst("$AR"), "x", source[0].abspath])
names = []
for infilename in os.listdir(tmpdir):
newname = infilename
if not infilename.endswith(".c.o"):
newname = infilename.replace(".o", ".c.o")
os.rename(os.path.join(tmpdir, infilename), os.path.join(tmpdir, newname))
names.append(newname)
pack_cmd = [env.subst("$AR"), "cr", target[0].abspath]
pack_cmd.extend(names)
run(pack_cmd)
env.Execute(Delete(tmpdir))
# Instead of replacing the file in-place, link with the patched version
libalgobsec_dir = os.path.join(libalgobsec_builder.src_dir, "esp8266")
target = env.File(
"libalgobsec.a", directory=env.subst("$BUILD_DIR/libalgobsec_patched")
)
source = env.File("libalgobsec.a", directory=libalgobsec_dir)
command = env.Command(target, source, process_archive)
patcher = env.Alias("patch-libalgobsec", command)
env.Append(LIBPATH=[target.get_dir()])
env.Append(LIBS=["algobsec"])
env.Depends("$BUILD_DIR/${PROGNAME}.elf", patcher)

View File

@@ -13,7 +13,6 @@ from espurna_utils import (
check_printsize,
remove_float_support,
ldscripts_inject_libpath,
libalgobsec_inject_patcher,
app_inject_revision,
dummy_ets_printf,
app_inject_flags,
@@ -45,9 +44,6 @@ if "DISABLE_POSTMORTEM_STACKDUMP" in env["CPPFLAGS"]:
"$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.cpp.o", dummy_ets_printf
)
# place bsec's libalgobsec.a sections in the flash to avoid "section .text' will not fit in region 'iram1_0_seg'" error
libalgobsec_inject_patcher(env)
# when using git, add -DAPP_REVISION=(git-commit-hash)
app_inject_revision(projenv)