Changelog: Repeater, room server, sensor, companion: the same commit builds into the same firmware, byte for byte (anyone can check a release against the source) Changelog-cs: Repeater, room server, sensor, companion: ze stejného commitu vznikne bajtově stejný firmware (vydání se dá ověřit proti zdrojákům)
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
# SPDX-License-Identifier: MIT
|
|
# PlatformIO extra script: wrap every C/C++ compiler invocation with ccache.
|
|
#
|
|
# Usage (CI or local):
|
|
# PLATFORMIO_EXTRA_SCRIPTS=pre:tools/ccache_wrap.py pio run -e <env>
|
|
#
|
|
# Uses env.AddBuildMiddleware so the wrapper applies to every cloned SCons
|
|
# environment -- framework, libraries and project sources -- across both nRF52
|
|
# and ESP32. A `post:` script that only mutates `env["CC"/"CXX"]` misses
|
|
# `projenv` and already-cloned library/framework builders (~85% of nRF52 units
|
|
# and 100% of ESP32 units).
|
|
#
|
|
# No-op when `ccache` is not on PATH.
|
|
#
|
|
# SCons script, not a module: `Import` and `env` are SCons builtins.
|
|
# ruff: noqa: F821, E402
|
|
# mypy: disable-error-code="name-defined"
|
|
if __name__ == "__main__":
|
|
with open(__file__) as _f:
|
|
for _ln in _f:
|
|
if not _ln.startswith("#"):
|
|
break
|
|
if "SPDX-License-Identifier" not in _ln:
|
|
print(_ln[2:].rstrip() if _ln.startswith("# ") else "")
|
|
raise SystemExit(0)
|
|
|
|
Import("env")
|
|
import shutil
|
|
|
|
if shutil.which("ccache"):
|
|
_wrapped_envs = set()
|
|
|
|
def _wrap_ccache(e, node):
|
|
if id(e) not in _wrapped_envs:
|
|
_wrapped_envs.add(id(e))
|
|
for var in ("CC", "CXX"):
|
|
cur = e.get(var)
|
|
if cur and not str(cur).startswith("ccache "):
|
|
e.Replace(**{var: "ccache " + str(cur)})
|
|
return node
|
|
|
|
env.AddBuildMiddleware(_wrap_ccache)
|