Provides the following rules for organizing Metal builds:
metal_library
for reusable targets, akin tocc_library
. Can be depended on bymetal_binary
andmetal_library
targets. Can include.h
,.hpp
headers and.metal
sources.metal_binary
for producing a final.metallib
file to be loaded at runtime. Build structure-wise, it is akin tocc_binary
, the root of a Metal dependency graph. Can depend onmetal_library
. Can include.h
,.hpp
headers and.metal
sources.
# Produces the final executable
cc_binary(
name = "app",
srcs = [
"vertex_types.h",
"main1.cc",
],
# Bundles shaders.metallib into a runfile for the executable
data = [":shaders"],
)
# Produces shaders.metallib
metal_binary(
name = "shaders",
srcs = [
"vertex_function.metal",
"fragment_function.metal",
],
deps = [":vertex_types"],
)
# A Metal library target usable by other Metal targets
metal_library(
name = "vertex_types",
hdrs = ["vertex_types.h"],
)