our_knp/altai-objects/build.py

17 lines
890 B
Python

"""Build native AltAI applications after configuring KNP with KNP_BUILD_OBJECTS=ON."""
import argparse
import os
from pathlib import Path
import subprocess
p = argparse.ArgumentParser()
p.add_argument('sources', nargs='*', help='Optional source filenames or target names')
p.add_argument('--build-dir', type=Path, default=Path(os.environ.get('KNP_BUILD_DIR', Path(__file__).resolve().parents[1] / 'build')))
p.add_argument('--jobs', type=int, default=8)
a = p.parse_args()
targets = [Path(s).stem for s in a.sources] or ['altai_infer', 'altai_objects', 'bench_conv']
if any(t not in {'altai_infer', 'altai_objects', 'bench_conv'} for t in targets):
p.error('Unknown object application target')
subprocess.run(['cmake', '--build', str(a.build_dir), '--parallel', str(a.jobs), '--target', *targets], check=True)
for target in targets:
print(a.build_dir / 'bin' / target, flush=True)