1#!/usr/local/bin/python3.8 2# vim:fileencoding=utf-8 3# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net> 4 5import os 6import re 7import shlex 8import shutil 9import subprocess 10 11 12cmdline = ( 13 'glad --out-path {dest} --api gl:core=3.3 ' 14 ' --extensions GL_ARB_texture_storage,GL_ARB_copy_image,GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug ' 15 'c --header-only --debug' 16) 17 18 19def clean(x): 20 if os.path.exists(x): 21 shutil.rmtree(x) 22 23 24def regenerate(): 25 clean('out') 26 27 subprocess.check_call( 28 shlex.split(cmdline.format(dest='out')) 29 ) 30 31 32def strip_trailing_whitespace(c): 33 return re.sub(r'\s+$', '', c, flags=re.MULTILINE) + '\n' 34 35 36def export(): 37 with open('out/include/glad/gl.h', 'r', encoding='utf-8') as source: 38 data = source.read() 39 data = strip_trailing_whitespace(data) 40 41 with open('../kitty/gl-wrapper.h', 'w', encoding='utf-8') as dest: 42 dest.write(data) 43 44 45if __name__ == '__main__': 46 os.chdir(os.path.dirname(os.path.abspath(__file__))) 47 regenerate() 48 export() 49