Files
arcade/scripts/build-desktop.py
T
waozi ed1d07cd72 Build Arcade from locked packages, with Apps as a real dependency
Apps is pinned in ziran.lock like every other package, so the desktop
build, the sound test and the game bundles resolve it through Ziran's
project mode instead of a hand-assembled import map. The shared Apps
controller is built from the locked Apps package and must match the
reviewed digest in apps-controller.sha256. The toolchain tracks master.
Inner Breeze stays a dependency only for its node-app publisher and host
compatibility checks.
2026-10-19 00:46:11 -03:00

46 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Build native Arcade, or standalone Pushy, from the project's locked packages."""
import argparse
import os
from pathlib import Path
import shutil
import subprocess
ROOT = Path(__file__).resolve().parents[1]
ZIRAN = str(ROOT / 'scripts/ziran.sh')
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', type=Path, default=ROOT / 'build/arcade')
parser.add_argument('--standalone-pushy', action='store_true')
args = parser.parse_args()
output = args.output.resolve()
lock = [] if (ROOT / 'ziran.local.toml').exists() else ['--locked']
toolchain = Path(subprocess.check_output([ZIRAN, 'pkg', 'path', 'ziran', *lock],
cwd=ROOT, text=True).strip())
generated = ROOT / ('build/pushy-native' if args.standalone_pushy else 'build/arcade-native') / 'c'
# Only this build purpose owns generated C. Never replace an installed
# binary in place: link separately, then atomically replace the path.
if generated.exists():
shutil.rmtree(generated)
subprocess.run([ZIRAN, 'build', '--project', *lock, '--target=c', '--define', 'PLATFORM_DESKTOP',
*(['--define', 'PUSHY_STANDALONE'] if args.standalone_pushy else []),
'--entry', 'desktop:main', '-o', str(generated), 'src/desktop.zi'], cwd=ROOT, check=True)
libraries = subprocess.check_output(['pkg-config', '--libs', 'sdl2', 'cairo', 'freetype2',
'fontconfig', 'pangocairo'], text=True).split()
temporary = output.with_suffix('.new')
output.parent.mkdir(parents=True, exist_ok=True)
subprocess.run([os.environ.get('CC', 'cc'), '-std=c11', '-O2', '-ffunction-sections',
'-fdata-sections', '-I' + str(toolchain / 'include'), '-iquote', str(generated),
*[item for path in generated.rglob('*') if path.is_dir()
for item in ('-iquote', str(path))],
*map(str, generated.rglob('*.c')), str(ROOT / 'build/ziran/libziran.a'),
'-Wl,--gc-sections', *libraries, '-lm', '-lpthread', '-o', str(temporary)], check=True)
temporary.replace(output)
print(('Pushy' if args.standalone_pushy else 'Arcade') + ' native build passed')
if __name__ == '__main__':
main()