our_knp/mnist-altai-native/build_native.py

3 lines
702 B
Python

from pathlib import Path
import subprocess,shlex,hashlib,json
r=Path('/home/user/run/altai-official-probe');source=Path(__file__).resolve().with_name('native_digits.cpp');cmd=shlex.split((r/'compile-command.txt').read_text());cmd=[str(source) if s.endswith('/probe.cpp') else s for s in cmd];target=r/'native_digits.new';cmd[cmd.index('-o')+1]=str(target);cmd.insert(1,'-Werror=dangling-else');subprocess.run(cmd,check=True);target.replace(r/'native_digits');(r/'native-build.json').write_text(json.dumps({'command':cmd,'source_sha256':hashlib.sha256(source.read_bytes()).hexdigest(),'executable_sha256':hashlib.sha256((r/'native_digits').read_bytes()).hexdigest()},indent=2));print('ATOMIC_BUILD_OK')