Add a Windows desktop installer for PC-based OmniNX installs.
This lets mass deployments and modchip setups apply the same install/update flow from a PC, with generated deletion lists kept in sync with the payload headers.
This commit is contained in:
21 files changed
+2312
No files matched your search
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate C# deletion list arrays from payload header files."""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE = ROOT / "source"
|
||||
OUT = ROOT / "desktop" / "OmniNX.DesktopInstaller" / "Data" / "DeletionLists.Generated.cs"
|
||||
|
||||
HEADERS = {
|
||||
"Clean": SOURCE / "deletion_lists_clean.h",
|
||||
"Update": SOURCE / "deletion_lists_update.h",
|
||||
}
|
||||
|
||||
|
||||
def parse_arrays(text: str) -> dict[str, list[str]]:
|
||||
arrays: dict[str, list[str]] = {}
|
||||
pattern = re.compile(
|
||||
r"static const char\*\s+(\w+)\[\]\s*=\s*\{([^}]*)\};",
|
||||
re.MULTILINE | re.DOTALL,
|
||||
)
|
||||
for match in pattern.finditer(text):
|
||||
name = match.group(1)
|
||||
body = match.group(2)
|
||||
paths = []
|
||||
for line in body.splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("//"):
|
||||
continue
|
||||
m = re.match(r'"([^"]+)"', line)
|
||||
if m:
|
||||
paths.append(m.group(1))
|
||||
arrays[name] = paths
|
||||
return arrays
|
||||
|
||||
|
||||
def emit_cs(mode: str, arrays: dict[str, list[str]]) -> str:
|
||||
lines = [f" public static class {mode}"]
|
||||
lines.append(" {")
|
||||
for name, paths in arrays.items():
|
||||
lines.append(f" public static readonly string[] {name} =")
|
||||
lines.append(" {")
|
||||
for p in paths:
|
||||
rel = p.replace("sd:/", "").replace("sd:\\", "").replace("/", "\\")
|
||||
lines.append(f' @"{rel}",')
|
||||
lines.append(" };")
|
||||
lines.append("")
|
||||
lines.append(" }")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sections = []
|
||||
for mode, header in HEADERS.items():
|
||||
text = header.read_text(encoding="utf-8")
|
||||
arrays = parse_arrays(text)
|
||||
sections.append(emit_cs(mode, arrays))
|
||||
|
||||
OUT.parent.mkdir(parents=True, exist_ok=True)
|
||||
content = """// <auto-generated />
|
||||
// Generated by tools/generate_deletion_lists.py — do not edit manually.
|
||||
|
||||
namespace OmniNX.DesktopInstaller.Data;
|
||||
|
||||
public static partial class DeletionLists
|
||||
{
|
||||
"""
|
||||
content += "\n\n".join(sections)
|
||||
content += "\n}\n"
|
||||
OUT.write_text(content, encoding="utf-8")
|
||||
print(f"Wrote {OUT}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user