Files
pyxis/patch_msgpack.py
torlando-agent[bot] 4c5ca8cbc8 chore(greptile): iteration 4 — applied 1, rejected 0
patch_msgpack.py + patch_filestore.py: read PIOENV instead of
hardcoding "tdeck" in the libdeps path. The hardcode meant the
msgpack public-modifier patch silently no-op'd under tdeck-bluedroid
(and tdeck-ota), making microLXMF's packRawBytes / raw_data /
indices accesses fail to compile. Mirrors the pattern already used
in sync_file_libdeps.py. Resolves the failing tdeck-bluedroid build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 01:30:50 -04:00

53 lines
2.0 KiB
Python

"""
PlatformIO pre-build script: Expose hideakitai/MsgPack internals used by microLXMF.
LXMessage's wire format includes a `dict[int, Any]` fields map. To splice
arbitrary msgpack values into the stream without LXMessage knowing each
value's type, the encoder uses Packer::packRawBytes (private upstream)
to write pre-encoded bytes; the decoder uses Unpacker::indices /
raw_data (also private upstream) to capture each key+value byte span as
an opaque slice.
This patch promotes the relevant access modifiers from private to
public. Idempotent: only rewrites on first apply, no-op afterward.
Mirrors the patch the microLXMF conformance-bridge applies via its
CMakeLists (microLXMF/conformance-bridge/CMakeLists.txt:106-125).
"""
Import("env")
import os
MSGPACK_BASE = os.path.join(
env.get("PROJECT_DIR", "."),
".pio", "libdeps", env.get("PIOENV", "tdeck"), "MsgPack", "MsgPack"
)
def apply_patch(filepath, old, new, label):
if not os.path.exists(filepath):
print(f"PATCH: {os.path.basename(filepath)} not found, skipping {label}")
return
with open(filepath, "r") as f:
content = f.read()
if old in content:
with open(filepath, "w") as f:
f.write(content.replace(old, new))
print(f"PATCH: {label}")
elif new in content or "patched by pyxis" in content:
print(f"PATCH: {label} (already applied)")
else:
print(f"PATCH: WARNING -- {label}: expected pattern not found")
apply_patch(
os.path.join(MSGPACK_BASE, "Packer.h"),
" private:\n void packRawByte",
" public: // patched by pyxis (microLXMF needs packRawBytes)\n void packRawByte",
"Packer.h: expose packRawBytes/packRawByte as public",
)
apply_patch(
os.path.join(MSGPACK_BASE, "Unpacker.h"),
" class Unpacker {\n uint8_t* raw_data",
" class Unpacker {\n public: // patched by pyxis (microLXMF needs indices/raw_data)\n uint8_t* raw_data",
"Unpacker.h: expose indices/raw_data as public",
)