#!/usr/bin/env python3 """Build the versioned AIR arithmetic and Dayu's authored Metal boundary.""" from pathlib import Path import argparse import subprocess from build_masked_kernel import masked_kernel from float_air_boundary import float_boundary def main(): parser = argparse.ArgumentParser() parser.add_argument('--output', required=True, type=Path) parser.add_argument('--intermediates', required=True, type=Path) args = parser.parse_args() root = Path(__file__).resolve().parent.parent work = args.intermediates.resolve() work.mkdir(parents=True, exist_ok=True) args.output.parent.mkdir(parents=True, exist_ok=True) objects = [] for name in ('DYGradeKernel', 'DYStatisticsKernel', 'DYLUTExportKernel', 'CSTKernel', 'BasisKernel'): target = work / (name + '.air') source = root / 'tools/kernels' / (name + '.ll') if name == 'DYGradeKernel': generated = work / 'DYGradeMasked.ll' generated.write_text(masked_kernel(source.read_text())) source = generated if name in ('CSTKernel', 'BasisKernel'): generated = work / (name + 'Float.ll') generated.write_text(float_boundary(source.read_text(), name)) source = generated subprocess.run(['xcrun', 'metal-opt', str(source), '-o', str(target)], check=True) objects.append(str(target)) wrapper = work / 'DYGradeWrapper.air' subprocess.run(['xcrun', '-sdk', 'macosx', 'metal', '-std=metal3.1', '-mmacosx-version-min=14.6', '-c', str(root / '大鱼调色/Plugin/DYGrade.metal'), '-o', str(wrapper)], check=True) tracking=work / 'DYTracking.air' subprocess.run(['xcrun','-sdk','macosx','metal','-std=metal3.1','-mmacosx-version-min=14.6','-c',str(root/'大鱼调色/Plugin/DYTracking.metal'),'-o',str(tracking)],check=True) objects.append(str(tracking)) subprocess.run(['xcrun', '-sdk', 'macosx', 'metallib', str(wrapper), *objects, '-o', str(args.output)], check=True) print(args.output) if __name__ == '__main__': main()