xref: /openbmc/qemu/scripts/shaderinclude.py (revision 7d87775f)
1#!/usr/bin/env python3
2#
3# Copyright (C) 2023 Red Hat, Inc.
4#
5# SPDX-License-Identifier: GPL-2.0-or-later
6
7import sys
8import os
9
10
11def 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
25if __name__ == '__main__':
26    sys.exit(main(sys.argv))
27