2
0

shaderinclude.py 712 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright (C) 2023 Red Hat, Inc.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0-or-later
  6. import sys
  7. import os
  8. def main(args):
  9. file_path = args[1]
  10. basename = os.path.basename(file_path)
  11. varname = basename.replace('-', '_').replace('.', '_')
  12. with os.fdopen(sys.stdout.fileno(), "wt", closefd=False, newline='\n') as stdout:
  13. with open(file_path, "r", encoding='utf-8') as file:
  14. print(f'static GLchar {varname}_src[] =', file=stdout)
  15. for line in file:
  16. line = line.rstrip()
  17. print(f' "{line}\\n"', file=stdout)
  18. print(' "\\n";', file=stdout)
  19. if __name__ == '__main__':
  20. sys.exit(main(sys.argv))