#!/usr/bin/env python3 """Generate pkg-config metadata without shell/sed interpolation of paths.""" import argparse from pathlib import Path from dist import version parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--prefix', required=True) parser.add_argument('--jack', default='') parser.add_argument('--output', type=Path, required=True) args = parser.parse_args() if not args.prefix.startswith('/') or any(c in args.prefix for c in '\n\r\0"$\\'): parser.error('PREFIX must be absolute, without newlines, quotes, $, or backslashes') text = Path('packaging/xtc.pc.in').read_text().replace('@PREFIX@', args.prefix) text = text.replace('@VERSION@', version(Path.cwd())).replace('@JACK@', args.jack) args.output.parent.mkdir(parents=True, exist_ok=True) args.output.write_text(text)