File: rules.bzl

package info (click to toggle)
cmake-format 0.6.13-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,436 kB
  • sloc: python: 16,990; makefile: 14
file content (33 lines) | stat: -rw-r--r-- 765 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def _glslang_compile_impl(ctx):
  src = ctx.attr.src.files.to_list()[0]
  out = ctx.actions.declare_file(ctx.attr.out)

  cmd = "glslangValidator -V -o {out} {src}".format(
    out = out.path,
    src = src.path,
  )

  ctx.actions.run_shell(
    outputs = [out],
    inputs = [src],
    command = cmd,
    mnemonic = "glslangValidator",
    use_default_shell_env = True,
  )

  return [DefaultInfo(files = depset([out]))]

glslang_compile = rule(
  _glslang_compile_impl,
  attrs = {
    "src": attr.label(
      allow_files = [".vert", ".frag"],
      doc = "Source file to compile into binary",
    ),
    "out": attr.string(
      #allow_files=[".spv"],
      doc = "Output file to generate",
    ),
  },
  doc = "Compile one or more glsl files into SPIR-V",
)