mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-22 09:31:10 +00:00
Improve patching
This commit is contained in:
parent
9076a42206
commit
30043d5622
@ -136,26 +136,41 @@ for lb in env.GetLibBuilders():
|
|||||||
|
|
||||||
############################# Libraries Patching #############################
|
############################# Libraries Patching #############################
|
||||||
|
|
||||||
env.Execute("$PYTHONEXE -m pip install patch")
|
env.Execute("$PYTHONEXE -m pip install patch pyyaml")
|
||||||
|
|
||||||
import pathlib
|
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
import patch
|
import patch
|
||||||
|
import yaml
|
||||||
|
|
||||||
libsToPatch = {}
|
patches = {}
|
||||||
for entry in glob.glob("patches/*.patch"):
|
config_path = os.path.join(env["PROJECT_DIR"], "patches/config.yaml")
|
||||||
p = pathlib.Path(entry).stem
|
with open(config_path, "r") as file:
|
||||||
libsToPatch[p] = entry
|
y = yaml.safe_load(file)
|
||||||
|
for p in y["patches"]:
|
||||||
|
name = p["name"]
|
||||||
|
p.pop("name", None)
|
||||||
|
patches[name] = p
|
||||||
|
|
||||||
for lb in env.GetLibBuilders():
|
for lb in env.GetLibBuilders():
|
||||||
if lb.name in libsToPatch:
|
if not lb.name in patches:
|
||||||
marker_path = os.path.join(pathlib.Path(lb.src_dir), ".patched")
|
continue
|
||||||
if not os.path.exists(marker_path):
|
p = patches[lb.name]
|
||||||
patch_path = libsToPatch[lb.name]
|
if "version" in p and not (lb.version == p["version"]):
|
||||||
|
print(f"Skipping {lb.name}.patch: version doesn't match")
|
||||||
|
continue
|
||||||
|
if "targets" in p and not (env.get("PIOENV") in p["targets"]):
|
||||||
|
print(f"Skipping {lb.name}.patch: target doesn't match")
|
||||||
|
continue
|
||||||
|
|
||||||
|
marker_path = os.path.join(lb.src_dir, ".patched")
|
||||||
|
if os.path.exists(marker_path):
|
||||||
|
print(f"Skipping {lb.name}.patch: already patched")
|
||||||
|
continue
|
||||||
|
|
||||||
|
patch_path = env["PROJECT_DIR"] + "/patches/" + lb.name + ".patch"
|
||||||
ps = patch.fromfile(patch_path)
|
ps = patch.fromfile(patch_path)
|
||||||
if not ps.apply(0, lb.src_dir):
|
if not ps.apply(0, lb.src_dir):
|
||||||
print(f"Failed to apply patch {patch_path}")
|
print(f"Failed to apply patch {patch_path}")
|
||||||
continue # XXX
|
exit(1)
|
||||||
print(f"Patched {lb.name}")
|
print(f"Patched {lb.name}")
|
||||||
open(marker_path, "w").close()
|
open(marker_path, "w").close()
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
Fix compiler warning
|
||||||
|
|
||||||
|
diff --git a/OLEDDisplay.cpp b/OLEDDisplay.cpp
|
||||||
|
index dca2ad1..35eb456 100644
|
||||||
|
--- a/OLEDDisplay.cpp
|
||||||
|
+++ b/OLEDDisplay.cpp
|
||||||
|
@@ -941,15 +941,6 @@ size_t OLEDDisplay::write(uint8_t c) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-size_t OLEDDisplay::write(const char* str) {
|
||||||
|
- if (str == NULL) return 0;
|
||||||
|
- size_t length = strlen(str);
|
||||||
|
- for (size_t i = 0; i < length; i++) {
|
||||||
|
- write(str[i]);
|
||||||
|
- }
|
||||||
|
- return length;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
#ifdef __MBED__
|
||||||
|
int OLEDDisplay::_putc(int c) {
|
||||||
|
|
||||||
|
diff --git a/OLEDDisplay.h b/OLEDDisplay.h
|
||||||
|
index 23e6845..07cb9a2 100644
|
||||||
|
--- a/OLEDDisplay.h
|
||||||
|
+++ b/OLEDDisplay.h
|
||||||
|
@@ -330,7 +330,6 @@ class OLEDDisplay : public Stream {
|
||||||
|
|
||||||
|
// Implement needed function to be compatible with Print class
|
||||||
|
size_t write(uint8_t c);
|
||||||
|
- size_t write(const char* s);
|
||||||
|
|
||||||
|
// Implement needed function to be compatible with Stream class
|
||||||
|
#ifdef __MBED__
|
24
patches/INA3221.patch
Normal file
24
patches/INA3221.patch
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
Fix compiler warning
|
||||||
|
|
||||||
|
diff --git a/INA3221.h b/INA3221.h
|
||||||
|
index bf09c8e..3fc7ad7 100644
|
||||||
|
--- a/INA3221.h
|
||||||
|
+++ b/INA3221.h
|
||||||
|
@@ -109,7 +109,7 @@ class INA3221 {
|
||||||
|
uint16_t ch2_en : 1;
|
||||||
|
uint16_t ch1_en : 1;
|
||||||
|
uint16_t reset : 1;
|
||||||
|
- } __attribute__((packed)) conf_reg_t;
|
||||||
|
+ } __attribute__((packed, aligned(sizeof(uint16_t)))) conf_reg_t;
|
||||||
|
|
||||||
|
// Mask/Enable register
|
||||||
|
typedef struct {
|
||||||
|
@@ -129,7 +129,7 @@ class INA3221 {
|
||||||
|
uint16_t shunt_sum_en_ch2 : 1;
|
||||||
|
uint16_t shunt_sum_en_ch1 : 1;
|
||||||
|
uint16_t reserved : 1;
|
||||||
|
- } __attribute__((packed)) masken_reg_t;
|
||||||
|
+ } __attribute__((packed, aligned(sizeof(uint16_t)))) masken_reg_t;
|
||||||
|
|
||||||
|
// Arduino's I2C library
|
||||||
|
TwoWire *_i2c;
|
10
patches/config.yaml
Normal file
10
patches/config.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
patches:
|
||||||
|
- name: ESP8266 and ESP32 OLED driver for SSD1306 displays
|
||||||
|
- name: ETHClass2
|
||||||
|
- name: INA3221
|
||||||
|
- name: LovyanGFX
|
||||||
|
version: 1.1.16
|
||||||
|
# targets:
|
||||||
|
# - seeed-sensecap-indicator-tft
|
||||||
|
- name: NonBlockingRTTTL
|
||||||
|
- name: SdFat
|
Loading…
Reference in New Issue
Block a user