Files
archy/scripts/tests/build_os_ota_native.py

34 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""Build the real current candidate executable from retained source, never sign.
Run in a durable CPU2/8G/no-swap service as the build user. Only compile; the
resulting executable is exercised in the disposable VM, never as a host daemon.
"""
import argparse
import fcntl
import json
import os
from pathlib import Path
import subprocess
import sys
p=argparse.ArgumentParser(description=__doc__)
p.add_argument('--source',type=Path,required=True)
p.add_argument('--output',type=Path,required=True)
p.add_argument('--target',type=Path,required=True)
a=p.parse_args()
with open('/tmp/opencode/release-heavy.lock','a') as lock:
fcntl.flock(lock,fcntl.LOCK_EX)
helper=a.source/'scripts/tests/package_c01_normal_fixture.py'
subprocess.run([sys.executable,'-B',str(helper),'freeze',str(a.source),str(a.output)],check=True)
env=dict(os.environ,CARGO_BUILD_JOBS='1',CARGO_INCREMENTAL='0',CARGO_TARGET_DIR=str(a.target))
command=['/home/archipelago/.cargo/bin/cargo','build','--locked','--offline',
'--manifest-path',str(a.output/'source/core/Cargo.toml'),'--bin','archipelago',
'--config','profile.dev.package.archipelago.debug=0']
with (a.output/'build.log').open('x') as log:
result=subprocess.run(command,env=env,stdout=log,stderr=subprocess.STDOUT)
(a.output/'compile-result.json').write_text(json.dumps(dict(exit=result.returncode,command=command))+'\n')
result.check_returncode()
subprocess.run([sys.executable,'-B',str(helper),'artifact',str(a.target/'debug/archipelago'),str(a.output)],check=True)
subprocess.run([sys.executable,'-B',str(helper),'verify',str(a.source),str(a.output)],check=True)