Debian Codegraph @

debian/mini-shadercross/shadercross

raw
1 #!/usr/bin/python3
2 # Minimal reimplementation of https://github.com/libsdl-org/SDL_shadercross
3 # using glslangValidator to avoid being blocked by
4 # https://bugs.debian.org/1095081, https://bugs.debian.org/1095077
5
6 import argparse
7 import subprocess
8 import sys
9
10
11 def main() -> None:
12 parser = argparse.ArgumentParser()
13 parser.add_argument('-o', dest='output', default='')
14 parser.add_argument('input', default='')
15
16 args = parser.parse_args()
17
18 if not args.output:
19 parser.error('requires -o OUTPUT')
20
21 if args.output.endswith('.spv'):
22 subprocess.run(
23 [
24 'glslangValidator',
25 '-e', 'main',
26 '-o', args.output,
27 '-V',
28 '-D',
29 args.input,
30 ],
31 check=True,
32 )
33 elif args.output.endswith(('.dxil', '.msl')):
34 # We don't use these on Linux, they just need to exist
35 with open(args.output, 'wb'):
36 pass
37 else:
38 parser.error('unrecognised output format')
39
40
41 if __name__ == '__main__':
42 try:
43 main()
44 except subprocess.CalledProcessError as e:
45 raise SystemExit(str(e))