10 lines
1 KiB
Python
10 lines
1 KiB
Python
from pathlib import Path
|
|
import shlex,subprocess,json,hashlib
|
|
S=Path(__file__).resolve().parent; B=Path.home()/'KNP/build';R=Path.home()/'run/pets-knp';R.mkdir(exist_ok=True)
|
|
flags=(B/'altai-objects/CMakeFiles/altai_infer.dir/flags.make').read_text();incs=shlex.split(next(l.split('=',1)[1] for l in flags.splitlines() if l.startswith('CXX_INCLUDES')))
|
|
for name in ['pets_infer','pets_readout','pets_hidden','pets_worker']:
|
|
src=S/f'{name}.cpp'
|
|
if not src.exists():continue
|
|
out=R/(name+'.new');cmd=['c++','-std=c++17','-O3','-Werror=dangling-else',*incs,str(src),'-o',str(out),str(B/'bin/libknp-base-framework-core.so.2.0.0'),str(B/'lib/libknp-core.a'),str(B/'bin/libzmq.so.5.2.5'),'-lbsd','-lrt',str(B/'lib/libflatbuffers.a'),'-Wl,-rpath,'+str(B/'bin')]
|
|
subprocess.run(cmd,check=True);out.replace(R/name);(R/(name+'-build.json')).write_text(json.dumps({'command':cmd,'source_sha256':hashlib.sha256(src.read_bytes()).hexdigest(),'executable_sha256':hashlib.sha256((R/name).read_bytes()).hexdigest()},indent=2))
|
|
print(name,'BUILT',flush=True)
|