从Xcode已安装组件定位Metal工具以修复默认入口失效

这个提交包含在:
mac 于 2026-11-14 22:59:32 +08:00 提交
1 父节点 f96e1967a1
当前提交 7763be5468
2 个文件已更改
+21 -5

没有与搜索条件相匹配的文件

+20 -4
查看文件
@@ -2,16 +2,32 @@
"""Build the versioned AIR arithmetic and Dayu's authored Metal boundary."""
from pathlib import Path
import argparse
import re
import subprocess
from build_masked_kernel import masked_kernel
from float_air_boundary import float_boundary
def metal_tools():
component = subprocess.check_output(
['xcodebuild', '-showComponent', 'MetalToolchain'], text=True)
location = re.search(r'^Toolchain Search Path: (.+)$', component, re.MULTILINE)
if not location:
raise RuntimeError('Xcode did not report an installed Metal toolchain')
directory = Path(location.group(1)) / 'Metal.xctoolchain/usr/bin'
commands = {name: str(directory / name) for name in ('metal-opt', 'metal', 'metallib')}
for command in commands.values():
if not Path(command).is_file():
raise RuntimeError('Installed Metal tool is missing: ' + command)
return commands
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()
tools = metal_tools()
root = Path(__file__).resolve().parent.parent
work = args.intermediates.resolve()
work.mkdir(parents=True, exist_ok=True)
@@ -28,17 +44,17 @@ def main():
generated = work / (name + 'Float.ll')
generated.write_text(float_boundary(source.read_text(), name))
source = generated
subprocess.run(['xcrun', 'metal-opt', str(source),
subprocess.run([tools['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',
subprocess.run([tools['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)
subprocess.run([tools['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,
subprocess.run([tools['metallib'], str(wrapper), *objects,
'-o', str(args.output)], check=True)
print(args.output)