mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 05:51:05 +01:00
Pre-generate hb-gpu-{fragment,vertex}-glsl.hh from the .glsl
sources so the library builds without Python/stringize at
compile time.
When stringize is found, a build rule regenerates them from
the .glsl sources and copies back to the source tree, matching
the ragel artifact pattern.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
563 B
Python
Executable File
27 lines
563 B
Python
Executable File
#! /usr/bin/env python3
|
|
|
|
import sys
|
|
|
|
try:
|
|
decl = sys.argv[1]
|
|
except IndexError:
|
|
sys.stderr.write("hb-gpu-stringize: missing declaration: {}\n".format(sys.argv))
|
|
sys.exit(1)
|
|
|
|
try:
|
|
filename = sys.argv[2]
|
|
except IndexError:
|
|
sys.stderr.write("hb-gpu-stringize: missing filename: {}\n".format(sys.argv))
|
|
sys.exit(1)
|
|
|
|
file = open(filename, 'r')
|
|
|
|
print(f'{decl} =')
|
|
text = file.read(-1)
|
|
lines = text.splitlines()
|
|
for line in lines:
|
|
line = line.replace(r'\\', r'\\\\')
|
|
line = line.replace(r'"', r'\"')
|
|
print(f'"{line}\\n"')
|
|
print(';')
|