Files
AVA2/tools/bundle_macos_libraries.py
shenandshen 281418f351 Fix cross-platform rendering and optimize frame performance
Correct selection orientation, game-entry lifecycle, mounted NPCs, labels and skill panels. Add the native GPU scene path, resident geometry, bounded texture and Python caches, and collision broad phase.

Pin the independently maintained Metin2 SDK through a submodule and document reproducible setup. Include rendering regressions and macOS packaging improvements.

Validation: client Debug build and 12 targeted client tests passed; SDK build and all 14 SDK tests passed.
2026-10-11 17:55:53 -07:00

43 lines
1.9 KiB
Python

#!/usr/bin/env python3
"""Bundle non-system dylibs recursively, including optional font dependencies."""
import pathlib
import shutil
import subprocess
import sys
bundle = pathlib.Path(sys.argv[1]).resolve()
executable = bundle / "Contents/MacOS/ava2_client"
frameworks = bundle / "Contents/Frameworks"
frameworks.mkdir(parents=True, exist_ok=True)
pending = [executable]
copied = {}
while pending:
binary = pending.pop()
lines = subprocess.check_output(["otool", "-L", str(binary)], text=True).splitlines()[1:]
for line in lines:
library = line.strip().split(" (", 1)[0]
if not library.startswith(("/opt/homebrew/", "/usr/local/")):
continue
source = pathlib.Path(library)
target = frameworks / source.name
# otool includes a dylib's own install ID; it is handled by -id below.
if source.name == binary.name:
continue
if source.name not in copied:
if target.exists():
target.chmod(target.stat().st_mode | 0o200)
shutil.copy2(source, target)
copied[source.name] = source.resolve()
pending.append(target)
elif copied[source.name] != source.resolve():
raise RuntimeError(f"Conflicting library names: {source.name}")
subprocess.run(["install_name_tool", "-change", library,
"@executable_path/../Frameworks/" + source.name, str(binary)], check=True)
if binary != executable:
subprocess.run(["install_name_tool", "-id", "@executable_path/../Frameworks/" + binary.name,
str(binary)], check=True)
for binary in [*frameworks.glob("*.dylib"), executable]:
subprocess.run(["codesign", "-f", "-s", "-", str(binary)], check=True)
subprocess.run(["codesign", "-f", "-s", "-", str(bundle)], check=True)
subprocess.run(["codesign", "--verify", "--deep", str(bundle)], check=True)