Debian Codegraph @

build_tooling/bazel/rules.bzl

raw
1 def _glslang_compile_impl(ctx):
2 src = ctx.attr.src.files.to_list()[0]
3 out = ctx.actions.declare_file(ctx.attr.out)
4
5 cmd = "glslangValidator -V -o {out} {src}".format(
6 out = out.path,
7 src = src.path,
8 )
9
10 ctx.actions.run_shell(
11 outputs = [out],
12 inputs = [src],
13 command = cmd,
14 mnemonic = "glslangValidator",
15 use_default_shell_env = True,
16 )
17
18 return [DefaultInfo(files = depset([out]))]
19
20 glslang_compile = rule(
21 _glslang_compile_impl,
22 attrs = {
23 "src": attr.label(
24 allow_files = [".vert", ".frag"],
25 doc = "Source file to compile into binary",
26 ),
27 "out": attr.string(
28 #allow_files=[".spv"],
29 doc = "Output file to generate",
30 ),
31 },
32 doc = "Compile one or more glsl files into SPIR-V",
33 )