#!/usr/bin/env python3 """Build the bounded 2.0.77 envelope adapter and real map-header probe.""" import subprocess from pathlib import Path ROOT=Path(__file__).resolve().parents[1] OUT=ROOT/'build/save-layout' OUT.mkdir(parents=True,exist_ok=True) RUNTIME=ROOT/'third_party/wabt/wasm2c' includes=['-I'+str(p) for p in (ROOT/'runtime',ROOT/'build/version',ROOT/'build/map-header',RUNTIME)] flags=['-O2','-DWASM_RT_USE_MMAP=0','-DWASM_RT_MEMCHECK_BOUNDS_CHECK=1'] sources=[ROOT/'runtime/save_layout.c',ROOT/'runtime/save_header.c',ROOT/'runtime/version_bridge.c', ROOT/'runtime/map_header_bridge.c',ROOT/'build/version/factorio_version.c', ROOT/'build/map-header/factorio_map_header.c',RUNTIME/'wasm-rt-impl.c',RUNTIME/'wasm-rt-mem-impl.c', ROOT/'tests/save_layout_probe.c'] subprocess.run(['xcrun','clang',*flags,*includes,*map(str,sources),'-lz','-o',str(OUT/'probe')],cwd=ROOT,check=True) subprocess.run(['xcrun','clang',*flags,*includes,*map(str,sources[:-1]), str(ROOT/'tests/save_layout_native.c'),str(ROOT/'build/map-header/oracle.S'), '-lz','-o',str(OUT/'verify_native')],cwd=ROOT,check=True) sdk=subprocess.check_output(['xcrun','--sdk','iphoneos','--show-sdk-path'],text=True).strip() obj=OUT/'save_layout.ios.o' subprocess.run(['xcrun','--sdk','iphoneos','clang','-target','arm64-apple-ios15.0','-isysroot',sdk, *flags,*includes,'-c',str(ROOT/'runtime/save_layout.c'),'-o',str(obj)],check=True) subprocess.run(['xcrun','libtool','-static','-o',str(OUT/'libfactorio_save_layout_ios.a'),str(obj)],check=True) print('Built bounded scenario-envelope adapter and linked AOT constructor probe')