Skip to content

Instantly share code, notes, and snippets.

Last active June 18, 2022 16:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save petertretyakov/3fe54fc12d7f585f27610841616e8b5f to your computer and use it in GitHub Desktop.
Build Metal Library from Shell
# This is a gist from
# If you want to know what the hell is happening here check
# Create intermediate representation from Metal files
METAL_FILES=`ls /path/to/metal/files/*.metal`
for path in $METAL_FILES
xcrun -sdk macosx metal -c $path -o ${FILE_NAME}.air
# Archive AIR files to single MetalAR file
AIR_FILES=`ls /path/to/air/files/*.air`
for path in $AIR_FILES
xcrun metal-ar r default.metalar $path
# Build Metal Library from MetalAR archive
xcrun -sdk macosx metallib default.metalar -o default.metallib
# Clean up
rm default.metalar
for path in $AIR_FILES
rm $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment