kitty/glad/generate.py

49 lines
1.0 KiB
Python
Raw Normal View History

2017-11-08 12:45:25 +03:00
#!/usr/bin/env python3
# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import os
import re
import shlex
import shutil
import subprocess
2019-07-07 21:12:09 +03:00
2017-11-08 12:45:25 +03:00
cmdline = (
2019-07-07 21:12:09 +03:00
'glad --out-path {dest} --api gl:core=3.3 '
' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug '
'c --header-only --debug'
2017-11-08 12:45:25 +03:00
)
def clean(x):
if os.path.exists(x):
shutil.rmtree(x)
def regenerate():
clean('out')
subprocess.check_call(
2019-07-07 21:12:09 +03:00
shlex.split(cmdline.format(dest='out'))
2017-11-08 12:45:25 +03:00
)
def strip_trailing_whitespace(c):
return re.sub(r'\s+$', '', c, flags=re.MULTILINE) + '\n'
2017-11-08 12:45:25 +03:00
def export():
2019-07-07 21:12:09 +03:00
with open('out/include/glad/gl.h', 'r', encoding='utf-8') as source:
data = source.read()
data = strip_trailing_whitespace(data)
2017-11-08 12:45:25 +03:00
2019-07-07 21:12:09 +03:00
with open('../kitty/gl-wrapper.h', 'w', encoding='utf-8') as dest:
dest.write(data)
2017-11-08 12:45:25 +03:00
if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.abspath(__file__)))
regenerate()
export()