4 lines
704 B
Python
4 lines
704 B
Python
from pathlib import Path
|
|
import shlex,subprocess,hashlib,json
|
|
S=Path(__file__).resolve().parent;R=Path.home()/'run/fly-knp';R.mkdir(exist_ok=True)
|
|
cmd=shlex.split((Path.home()/'run/altai-official-probe/compile-command.txt').read_text());cmd=[str(S/'controller.cpp') if v.endswith('/probe.cpp') else v for v in cmd];out=R/'controller.new';cmd[cmd.index('-o')+1]=str(out);cmd.insert(1,'-Werror=dangling-else');subprocess.run(cmd,check=True);out.replace(R/'controller');(R/'build.json').write_text(json.dumps({'command':cmd,'source_sha256':hashlib.sha256((S/'controller.cpp').read_bytes()).hexdigest(),'binary_sha256':hashlib.sha256((R/'controller').read_bytes()).hexdigest()},indent=2));print('FLY_BUILT')
|