]> git.proxmox.com Git - mirror_qemu.git/blob - scripts/shaderinclude.py
Merge tag 'pull-request-2023-12-20' of https://gitlab.com/thuth/qemu into staging
[mirror_qemu.git] / scripts / shaderinclude.py
1 #!/usr/bin/env python3
2 #
3 # Copyright (C) 2023 Red Hat, Inc.
4 #
5 # SPDX-License-Identifier: GPL-2.0-or-later
6
7 import sys
8 import os
9
10
11 def main(args):
12 file_path = args[1]
13 basename = os.path.basename(file_path)
14 varname = basename.replace('-', '_').replace('.', '_')
15
16 with os.fdopen(sys.stdout.fileno(), "wt", closefd=False, newline='\n') as stdout:
17 with open(file_path, "r", encoding='utf-8') as file:
18 print(f'static GLchar {varname}_src[] =', file=stdout)
19 for line in file:
20 line = line.rstrip()
21 print(f' "{line}\\n"', file=stdout)
22 print(' "\\n";', file=stdout)
23
24
25 if __name__ == '__main__':
26 sys.exit(main(sys.argv))