41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
import urllib.request
|
|
from pathlib import Path
|
|
|
|
from warium_source import BUILD_DIR, ROOT, clean_dir, download_original
|
|
|
|
VINEFLOWER_URL = "https://repo1.maven.org/maven2/org/vineflower/vineflower/1.11.1/vineflower-1.11.1.jar"
|
|
VINEFLOWER_JAR = BUILD_DIR / "vineflower-1.11.1.jar"
|
|
DECOMPILED_DIR = ROOT / "build" / "decompiled" / "warium-1.2.7"
|
|
|
|
|
|
def main() -> None:
|
|
original = download_original()
|
|
BUILD_DIR.mkdir(parents=True, exist_ok=True)
|
|
if not VINEFLOWER_JAR.exists():
|
|
request = urllib.request.Request(VINEFLOWER_URL, headers={"User-Agent": "MrSphay/Warium-NeoForge-Port/1.0"})
|
|
with urllib.request.urlopen(request) as response, VINEFLOWER_JAR.open("wb") as out:
|
|
shutil.copyfileobj(response, out)
|
|
clean_dir(DECOMPILED_DIR)
|
|
subprocess.run(
|
|
["java", "-jar", str(VINEFLOWER_JAR), str(original), str(DECOMPILED_DIR)],
|
|
cwd=ROOT,
|
|
check=True,
|
|
)
|
|
report = ROOT / "docs" / "inventory" / "decompile-report.md"
|
|
report.parent.mkdir(parents=True, exist_ok=True)
|
|
report.write_text(
|
|
"# Decompile Report\n\n"
|
|
f"- Source: `{original}`\n"
|
|
f"- Output: `{DECOMPILED_DIR}`\n"
|
|
"- Decompiler: Vineflower 1.11.1\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|