mirror of
https://github.com/lucannez64/darling-lol.git
synced 2026-10-26 19:47:42 +00:00
30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the power-save assertion guest probe (IOPMAssertionCreateWithName)."""
|
|
from pathlib import Path
|
|
import json
|
|
import shlex
|
|
import subprocess
|
|
|
|
root = Path(__file__).resolve().parent.parent
|
|
config = root / "build/config.json"
|
|
sdk = json.loads(config.read_text())["sdk"] if config.exists() else "/usr/local/libexec/darling"
|
|
appkit = root / "build/darling-src/build/src/external/cocotron/AppKit"
|
|
flags = {}
|
|
for line in (appkit / "CMakeFiles/AppKit.dir/flags.make").read_text().splitlines():
|
|
if line.startswith("C_") and " = " in line:
|
|
key, value = line.split(" = ", 1)
|
|
flags[key] = shlex.split(value)
|
|
|
|
source = root / "tools/riot-power-assertion-check.c"
|
|
obj = root / "build/riot-power-assertion-check.o"
|
|
exe = root / "build/riot-power-assertion-check"
|
|
subprocess.run(["clang", "-x", "objective-c", *flags["C_DEFINES"], *flags["C_INCLUDES"],
|
|
*flags["C_FLAGS"], "-fblocks", "-c", str(source),
|
|
"-o", str(obj)], check=True)
|
|
subprocess.run(["clang", "-target", "x86_64-apple-macosx11.0",
|
|
"-fuse-ld=lld", "-nostdlib", "-isysroot",
|
|
sdk, str(obj), "-lSystem",
|
|
"-framework", "IOKit", "-framework", "CoreFoundation",
|
|
"-o", str(exe)],
|
|
check=True)
|