patch radiolib on-the-fly while building.

This commit is contained in:
Thomas Göttgens 2022-06-10 20:38:56 +02:00
parent beb8bc9e72
commit 2a3272b7d0
4 changed files with 1427 additions and 0 deletions

27
bin/apply_patches.py Normal file
View File

@ -0,0 +1,27 @@
from os.path import join, isfile
Import("env")
LIBRARY_DIR = join (env["PROJECT_LIBDEPS_DIR"], env["PIOENV"], "RadioLib")
patchflag_path = join(LIBRARY_DIR, ".patching-done")
patch = join(env["PROJECT_DIR"], "bin", "patch_ng.py")
# patch file only if we didn't do it before
if not isfile(join(LIBRARY_DIR, ".patching-done")):
original_path = join(LIBRARY_DIR)
patch_file = join(env["PROJECT_DIR"], "patches", "0001-RadioLib-SPItransfer-virtual.patch")
assert isfile(patch_file)
env.Execute(
env.VerboseAction(
"$PYTHONEXE %s -p 1 --directory=%s %s" % (patch, original_path, patch_file)
, "Applying patch to RadioLib"
)
)
def _touch(path):
with open(path, "w") as fp:
fp.write("")
env.Execute(lambda *args, **kwargs: _touch(patchflag_path))

1381
bin/patch_ng.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
index 3a7b098..2492c1a 100644
--- a/src/Module.h
+++ b/src/Module.h
@@ -190,7 +190,7 @@ class Module {
\param numBytes Number of bytes to transfer.
*/
- void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes);
+ virtual void SPItransfer(uint8_t cmd, uint8_t reg, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes);
// pin number access methods

View File

@ -93,6 +93,10 @@ build_src_filter =
${arduino_base.build_src_filter} -<nrf52/>
upload_speed = 921600
debug_init_break = tbreak setup
extra_scripts =
${env.extra_scripts}
pre:bin/apply_patches.py
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
@ -144,6 +148,9 @@ build_src_filter =
${arduino_base.build_src_filter} -<esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/>
lib_ignore =
BluetoothOTA
extra_scripts =
${env.extra_scripts}
pre:bin/apply_patches.py
[nrf52840_base]
extends = nrf52_base