summaryrefslogtreecommitdiff
path: root/hid/patch.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-11-11 21:32:22 +0300
committerDevaev Maxim <[email protected]>2020-11-11 22:24:25 +0300
commit55a682803965af9bc4712cb7485a706bd2b25832 (patch)
tree9dbde548843a8d09cbd5f8f5b2a9a1093519b9cf /hid/patch.py
parentfef625aee52015dfdca0a96c31eced033663cb97 (diff)
disable serial port for spi
Diffstat (limited to 'hid/patch.py')
-rw-r--r--hid/patch.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/hid/patch.py b/hid/patch.py
index c05ed262..58462bc1 100644
--- a/hid/patch.py
+++ b/hid/patch.py
@@ -1,5 +1,6 @@
# https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html
+
from os.path import exists
from os.path import join
from os.path import basename
@@ -10,6 +11,12 @@ Import("env")
# =====
+def _get_pkg_path(name: str) -> str:
+ path = env.PioPlatform().get_package_dir(name)
+ assert exists(path)
+ return path
+
+
def _get_libs() -> Dict[str, str]:
return {
builder.name: builder.path
@@ -17,15 +24,17 @@ def _get_libs() -> Dict[str, str]:
}
-def _patch_lib(lib_path: str, patch_path: str) -> None:
- assert exists(lib_path)
- flag_path: str = join(lib_path, f".{basename(patch_path)}.done")
+def _patch(path: str, patch_path: str) -> None:
+ assert exists(path)
+ flag_path: str = join(path, f".{basename(patch_path)}.done")
if not exists(flag_path):
- env.Execute(f"patch -p1 -d {lib_path} < {patch_path}")
+ env.Execute(f"patch -p1 -d {path} < {patch_path}")
env.Execute(lambda *_, **__: open(flag_path, "w").close())
# =====
+_patch(_get_pkg_path("framework-arduino-avr"), "patches/serial.patch")
+
_libs = _get_libs()
if "HID-Project" in _libs:
- _patch_lib(_libs["HID-Project"], "patches/absmouse.patch")
+ _patch(_libs["HID-Project"], "patches/absmouse.patch")