genheaders.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. #!/usr/bin/env python
  2. #
  3. # Copyright (c) 2013-2014 The Khronos Group Inc.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and/or associated documentation files (the
  7. # "Materials"), to deal in the Materials without restriction, including
  8. # without limitation the rights to use, copy, modify, merge, publish,
  9. # distribute, sublicense, and/or sell copies of the Materials, and to
  10. # permit persons to whom the Materials are furnished to do so, subject to
  11. # the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included
  14. # in all copies or substantial portions of the Materials.
  15. #
  16. # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  19. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  20. # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  22. # MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
  23. import sys, time, pdb, string, cProfile
  24. from reg import *
  25. # debug - start header generation in debugger
  26. # dump - dump registry after loading
  27. # profile - enable Python profiling
  28. # protect - whether to use #ifndef protections
  29. # registry <filename> - use specified XML registry instead of gl.xml
  30. # target - string name of target header, or all targets if None
  31. # timeit - time length of registry loading & header generation
  32. # validate - validate return & parameter group tags against <group>
  33. debug = False
  34. dump = False
  35. profile = False
  36. protect = True
  37. target = None
  38. timeit = False
  39. validate= False
  40. # Default input / log files
  41. errFilename = None
  42. diagFilename = 'diag.txt'
  43. regFilename = 'gl.xml'
  44. if __name__ == '__main__':
  45. i = 1
  46. while (i < len(sys.argv)):
  47. arg = sys.argv[i]
  48. i = i + 1
  49. if (arg == '-debug'):
  50. write('Enabling debug (-debug)', file=sys.stderr)
  51. debug = True
  52. elif (arg == '-dump'):
  53. write('Enabling dump (-dump)', file=sys.stderr)
  54. dump = True
  55. elif (arg == '-noprotect'):
  56. write('Disabling inclusion protection in output headers', file=sys.stderr)
  57. protect = False
  58. elif (arg == '-profile'):
  59. write('Enabling profiling (-profile)', file=sys.stderr)
  60. profile = True
  61. elif (arg == '-registry'):
  62. regFilename = sys.argv[i]
  63. i = i+1
  64. write('Using registry ', regFilename, file=sys.stderr)
  65. elif (arg == '-time'):
  66. write('Enabling timing (-time)', file=sys.stderr)
  67. timeit = True
  68. elif (arg == '-validate'):
  69. write('Enabling group validation (-validate)', file=sys.stderr)
  70. validate = True
  71. elif (arg[0:1] == '-'):
  72. write('Unrecognized argument:', arg, file=sys.stderr)
  73. exit(1)
  74. else:
  75. target = arg
  76. write('Using target', target, file=sys.stderr)
  77. # Simple timer functions
  78. startTime = None
  79. def startTimer():
  80. global startTime
  81. startTime = time.clock()
  82. def endTimer(msg):
  83. global startTime
  84. endTime = time.clock()
  85. if (timeit):
  86. write(msg, endTime - startTime)
  87. startTime = None
  88. # Load & parse registry
  89. reg = Registry()
  90. startTimer()
  91. tree = etree.parse(regFilename)
  92. endTimer('Time to make ElementTree =')
  93. startTimer()
  94. reg.loadElementTree(tree)
  95. endTimer('Time to parse ElementTree =')
  96. if (validate):
  97. reg.validateGroups()
  98. if (dump):
  99. write('***************************************')
  100. write('Performing Registry dump to regdump.txt')
  101. write('***************************************')
  102. reg.dumpReg(filehandle = open('regdump.txt','w'))
  103. # Turn a list of strings into a regexp string matching exactly those strings
  104. def makeREstring(list):
  105. return '^(' + '|'.join(list) + ')$'
  106. # These are "mandatory" OpenGL ES 1 extensions, to
  107. # be included in the core GLES/gl.h header.
  108. es1CoreList = [
  109. 'GL_OES_read_format',
  110. 'GL_OES_compressed_paletted_texture',
  111. 'GL_OES_point_size_array',
  112. 'GL_OES_point_sprite'
  113. ]
  114. # Descriptive names for various regexp patterns used to select
  115. # versions and extensions
  116. allVersions = allExtensions = '.*'
  117. noVersions = noExtensions = None
  118. gl12andLaterPat = '1\.[2-9]|[234]\.[0-9]'
  119. gles2onlyPat = '2\.[0-9]'
  120. gles2and30Pat = '2\.[0-9]|3.0'
  121. gles2and30and31Pat = '2.[0-9]|3.[01]'
  122. es1CorePat = makeREstring(es1CoreList)
  123. # Extensions in old glcorearb.h but not yet tagged accordingly in gl.xml
  124. glCoreARBPat = None
  125. glx13andLaterPat = '1\.[3-9]'
  126. # Copyright text prefixing all headers (list of strings).
  127. prefixStrings = [
  128. '/*',
  129. '** Copyright (c) 2013-2014 The Khronos Group Inc.',
  130. '**',
  131. '** Permission is hereby granted, free of charge, to any person obtaining a',
  132. '** copy of this software and/or associated documentation files (the',
  133. '** "Materials"), to deal in the Materials without restriction, including',
  134. '** without limitation the rights to use, copy, modify, merge, publish,',
  135. '** distribute, sublicense, and/or sell copies of the Materials, and to',
  136. '** permit persons to whom the Materials are furnished to do so, subject to',
  137. '** the following conditions:',
  138. '**',
  139. '** The above copyright notice and this permission notice shall be included',
  140. '** in all copies or substantial portions of the Materials.',
  141. '**',
  142. '** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,',
  143. '** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF',
  144. '** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.',
  145. '** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY',
  146. '** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,',
  147. '** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE',
  148. '** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.',
  149. '*/',
  150. '/*',
  151. '** This header is generated from the Khronos OpenGL / OpenGL ES XML',
  152. '** API Registry. The current version of the Registry, generator scripts',
  153. '** used to make the header, and the header can be found at',
  154. '** http://www.opengl.org/registry/',
  155. '**',
  156. '** Khronos $' + 'Revision$ on $' + 'Date$',
  157. '*/',
  158. ''
  159. ]
  160. # glext.h / glcorearb.h define calling conventions inline (no GL *platform.h)
  161. glExtPlatformStrings = [
  162. '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
  163. '#ifndef WIN32_LEAN_AND_MEAN',
  164. '#define WIN32_LEAN_AND_MEAN 1',
  165. '#endif',
  166. '#include <windows.h>',
  167. '#endif',
  168. '',
  169. '#ifndef APIENTRY',
  170. '#define APIENTRY',
  171. '#endif',
  172. '#ifndef APIENTRYP',
  173. '#define APIENTRYP APIENTRY *',
  174. '#endif',
  175. '#ifndef GLAPI',
  176. '#define GLAPI extern',
  177. '#endif',
  178. ''
  179. ]
  180. glCorearbPlatformStrings = glExtPlatformStrings + [
  181. '/* glcorearb.h is for use with OpenGL core profile implementations.',
  182. '** It should should be placed in the same directory as gl.h and',
  183. '** included as <GL/glcorearb.h>.',
  184. '**',
  185. '** glcorearb.h includes only APIs in the latest OpenGL core profile',
  186. '** implementation together with APIs in newer ARB extensions which ',
  187. '** can be supported by the core profile. It does not, and never will',
  188. '** include functionality removed from the core profile, such as',
  189. '** fixed-function vertex and fragment processing.',
  190. '**',
  191. '** Do not #include both <GL/glcorearb.h> and either of <GL/gl.h> or',
  192. '** <GL/glext.h> in the same source file.',
  193. '*/',
  194. ''
  195. ]
  196. # wglext.h needs Windows include
  197. wglPlatformStrings = [
  198. '#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)',
  199. '#define WIN32_LEAN_AND_MEAN 1',
  200. '#include <windows.h>',
  201. '#endif',
  202. '',
  203. ]
  204. # GLES 1/2/3 core .h have separate *platform.h files to define calling conventions
  205. gles1PlatformStrings = [ '#include <GLES/glplatform.h>', '' ]
  206. gles2PlatformStrings = [ '#include <GLES2/gl2platform.h>', '' ]
  207. gles3PlatformStrings = [ '#include <GLES3/gl3platform.h>', '' ]
  208. eglPlatformStrings = [ '#include <EGL/eglplatform.h>', '' ]
  209. # GLES 1/2 extension .h have small addition to calling convention headers
  210. gles1ExtPlatformStrings = gles2ExtPlatformStrings = [
  211. '#ifndef GL_APIENTRYP',
  212. '#define GL_APIENTRYP GL_APIENTRY*',
  213. '#endif',
  214. ''
  215. ]
  216. # Insert generation date in a comment for headers not having *GLEXT_VERSION macros
  217. genDateCommentString = [
  218. format("/* Generated on date %s */" % time.strftime("%Y%m%d")),
  219. ''
  220. ]
  221. # GL_GLEXT_VERSION is defined only in glext.h
  222. glextVersionStrings = [
  223. format("#define GL_GLEXT_VERSION %s" % time.strftime("%Y%m%d")),
  224. ''
  225. ]
  226. # WGL_WGLEXT_VERSION is defined only in wglext.h
  227. wglextVersionStrings = [
  228. format("#define WGL_WGLEXT_VERSION %s" % time.strftime("%Y%m%d")),
  229. ''
  230. ]
  231. # GLX_GLXEXT_VERSION is defined only in glxext.h
  232. glxextVersionStrings = [
  233. format("#define GLX_GLXEXT_VERSION %s" % time.strftime("%Y%m%d")),
  234. ''
  235. ]
  236. # EGL_EGLEXT_VERSION is defined only in eglext.h
  237. eglextVersionStrings = [
  238. format("#define EGL_EGLEXT_VERSION %s" % time.strftime("%Y%m%d")),
  239. ''
  240. ]
  241. # Defaults for generating re-inclusion protection wrappers (or not)
  242. protectFile = protect
  243. protectFeature = protect
  244. protectProto = protect
  245. buildList = [
  246. # GL API 1.2+ + extensions - GL/glext.h
  247. CGeneratorOptions(
  248. filename = 'GL/glext.h',
  249. apiname = 'gl',
  250. profile = 'compatibility',
  251. versions = allVersions,
  252. emitversions = gl12andLaterPat,
  253. defaultExtensions = 'gl', # Default extensions for GL
  254. addExtensions = None,
  255. removeExtensions = None,
  256. prefixText = prefixStrings + glExtPlatformStrings + glextVersionStrings,
  257. genFuncPointers = True,
  258. protectFile = protectFile,
  259. protectFeature = protectFeature,
  260. protectProto = protectProto,
  261. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  262. apicall = 'GLAPI ',
  263. apientry = 'APIENTRY ',
  264. apientryp = 'APIENTRYP '),
  265. # GL core profile + extensions - GL/glcorearb.h
  266. CGeneratorOptions(
  267. filename = 'GL/glcorearb.h',
  268. apiname = 'gl',
  269. profile = 'core',
  270. versions = allVersions,
  271. emitversions = allVersions,
  272. defaultExtensions = 'glcore', # Default extensions for GL core profile (only)
  273. addExtensions = glCoreARBPat,
  274. removeExtensions = None,
  275. prefixText = prefixStrings + glCorearbPlatformStrings,
  276. genFuncPointers = True,
  277. protectFile = protectFile,
  278. protectFeature = protectFeature,
  279. protectProto = protectProto,
  280. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  281. apicall = 'GLAPI ',
  282. apientry = 'APIENTRY ',
  283. apientryp = 'APIENTRYP '),
  284. # GLES 1.x API + mandatory extensions - GLES/gl.h (no function pointers)
  285. CGeneratorOptions(
  286. filename = 'GLES/gl.h',
  287. apiname = 'gles1',
  288. profile = 'common',
  289. versions = allVersions,
  290. emitversions = allVersions,
  291. defaultExtensions = None, # No default extensions
  292. addExtensions = es1CorePat, # Add mandatory ES1 extensions in GLES1/gl.h
  293. removeExtensions = None,
  294. prefixText = prefixStrings + gles1PlatformStrings + genDateCommentString,
  295. genFuncPointers = False,
  296. protectFile = protectFile,
  297. protectFeature = protectFeature,
  298. protectProto = False, # Core ES API functions are in the static link libraries
  299. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  300. apicall = 'GL_API ',
  301. apientry = 'GL_APIENTRY ',
  302. apientryp = 'GL_APIENTRYP '),
  303. # GLES 1.x extensions - GLES/glext.h
  304. CGeneratorOptions(
  305. filename = 'GLES/glext.h',
  306. apiname = 'gles1',
  307. profile = 'common',
  308. versions = allVersions,
  309. emitversions = noVersions,
  310. defaultExtensions = 'gles1', # Default extensions for GLES 1
  311. addExtensions = None,
  312. removeExtensions = es1CorePat, # Remove mandatory ES1 extensions in GLES1/glext.h
  313. prefixText = prefixStrings + gles1ExtPlatformStrings + genDateCommentString,
  314. genFuncPointers = True,
  315. protectFile = protectFile,
  316. protectFeature = protectFeature,
  317. protectProto = protectProto,
  318. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  319. apicall = 'GL_API ',
  320. apientry = 'GL_APIENTRY ',
  321. apientryp = 'GL_APIENTRYP '),
  322. # GLES 2.0 API - GLES2/gl2.h (no function pointers)
  323. CGeneratorOptions(
  324. filename = 'GLES2/gl2.h',
  325. apiname = 'gles2',
  326. profile = 'common',
  327. versions = gles2onlyPat,
  328. emitversions = allVersions,
  329. defaultExtensions = None, # No default extensions
  330. addExtensions = None,
  331. removeExtensions = None,
  332. prefixText = prefixStrings + gles2PlatformStrings + genDateCommentString,
  333. genFuncPointers = False,
  334. protectFile = protectFile,
  335. protectFeature = protectFeature,
  336. protectProto = False, # Core ES API functions are in the static link libraries
  337. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  338. apicall = 'GL_APICALL ',
  339. apientry = 'GL_APIENTRY ',
  340. apientryp = 'GL_APIENTRYP '),
  341. # GLES 3.1 / 3.0 / 2.0 extensions - GLES2/gl2ext.h
  342. CGeneratorOptions(
  343. filename = 'GLES2/gl2ext.h',
  344. apiname = 'gles2',
  345. profile = 'common',
  346. versions = gles2onlyPat,
  347. emitversions = None,
  348. defaultExtensions = 'gles2', # Default extensions for GLES 2
  349. addExtensions = None,
  350. removeExtensions = None,
  351. prefixText = prefixStrings + gles2ExtPlatformStrings + genDateCommentString,
  352. genFuncPointers = True,
  353. protectFile = protectFile,
  354. protectFeature = protectFeature,
  355. protectProto = protectProto,
  356. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  357. apicall = 'GL_APICALL ',
  358. apientry = 'GL_APIENTRY ',
  359. apientryp = 'GL_APIENTRYP '),
  360. # GLES 3.1 API - GLES3/gl31.h (no function pointers)
  361. CGeneratorOptions(
  362. filename = 'GLES3/gl31.h',
  363. apiname = 'gles2',
  364. profile = 'common',
  365. versions = gles2and30and31Pat,
  366. emitversions = allVersions,
  367. defaultExtensions = None, # No default extensions
  368. addExtensions = None,
  369. removeExtensions = None,
  370. prefixText = prefixStrings + gles3PlatformStrings + genDateCommentString,
  371. genFuncPointers = False,
  372. protectFile = protectFile,
  373. protectFeature = protectFeature,
  374. protectProto = False, # Core ES API functions are in the static link libraries
  375. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  376. apicall = 'GL_APICALL ',
  377. apientry = 'GL_APIENTRY ',
  378. apientryp = 'GL_APIENTRYP '),
  379. # GLES 3.0 API - GLES3/gl3.h (no function pointers)
  380. CGeneratorOptions(
  381. filename = 'GLES3/gl3.h',
  382. apiname = 'gles2',
  383. profile = 'common',
  384. versions = gles2and30Pat,
  385. emitversions = allVersions,
  386. defaultExtensions = None, # No default extensions
  387. addExtensions = None,
  388. removeExtensions = None,
  389. prefixText = prefixStrings + gles3PlatformStrings + genDateCommentString,
  390. genFuncPointers = False,
  391. protectFile = protectFile,
  392. protectFeature = protectFeature,
  393. protectProto = False, # Core ES API functions are in the static link libraries
  394. protectProtoStr = 'GL_GLEXT_PROTOTYPES',
  395. apicall = 'GL_APICALL ',
  396. apientry = 'GL_APIENTRY ',
  397. apientryp = 'GL_APIENTRYP '),
  398. # EGL API - EGL/egl.h (no function pointers, yet @@@)
  399. CGeneratorOptions(
  400. filename = 'EGL/egl.h',
  401. apiname = 'egl',
  402. profile = None,
  403. versions = allVersions,
  404. emitversions = allVersions,
  405. defaultExtensions = None, # No default extensions
  406. addExtensions = None,
  407. removeExtensions = None,
  408. prefixText = prefixStrings + eglPlatformStrings + genDateCommentString,
  409. genFuncPointers = False,
  410. protectFile = protectFile,
  411. protectFeature = protectFeature,
  412. protectProto = False,
  413. protectProtoStr = 'EGL_EGLEXT_PROTOTYPES',
  414. apicall = 'EGLAPI ',
  415. apientry = 'EGLAPIENTRY ',
  416. apientryp = 'EGLAPIENTRYP '),
  417. # EGL extensions - EGL/eglext.h (no function pointers, yet @@@)
  418. CGeneratorOptions(
  419. filename = 'EGL/eglext.h',
  420. apiname = 'egl',
  421. profile = None,
  422. versions = allVersions,
  423. emitversions = None,
  424. defaultExtensions = 'egl', # Default extensions for EGL
  425. addExtensions = None,
  426. removeExtensions = None,
  427. prefixText = prefixStrings + eglPlatformStrings + eglextVersionStrings,
  428. genFuncPointers = True,
  429. protectFile = protectFile,
  430. protectFeature = protectFeature,
  431. protectProto = protectProto,
  432. protectProtoStr = 'EGL_EGLEXT_PROTOTYPES',
  433. apicall = 'EGLAPI ',
  434. apientry = 'EGLAPIENTRY ',
  435. apientryp = 'EGLAPIENTRYP '),
  436. # GLX 1.* API - GL/glx.h
  437. CGeneratorOptions(
  438. filename = 'GL/glx.h',
  439. apiname = 'glx',
  440. profile = None,
  441. versions = allVersions,
  442. emitversions = allVersions,
  443. defaultExtensions = None, # No default extensions
  444. addExtensions = None,
  445. removeExtensions = None,
  446. # add glXPlatformStrings?
  447. prefixText = prefixStrings + genDateCommentString,
  448. genFuncPointers = True,
  449. protectFile = protectFile,
  450. protectFeature = protectFeature,
  451. protectProto = protectProto,
  452. protectProtoStr = 'GLX_GLXEXT_PROTOTYPES',
  453. apicall = '',
  454. apientry = '',
  455. apientryp = ' *'),
  456. # GLX 1.3+ API + extensions - GL/glxext.h (no function pointers, yet @@@)
  457. CGeneratorOptions(
  458. filename = 'GL/glxext.h',
  459. apiname = 'glx',
  460. profile = None,
  461. versions = allVersions,
  462. emitversions = glx13andLaterPat,
  463. defaultExtensions = 'glx', # Default extensions for GLX
  464. addExtensions = None,
  465. removeExtensions = None,
  466. # add glXPlatformStrings?
  467. prefixText = prefixStrings + glxextVersionStrings,
  468. genFuncPointers = True,
  469. protectFile = protectFile,
  470. protectFeature = protectFeature,
  471. protectProto = protectProto,
  472. protectProtoStr = 'GLX_GLXEXT_PROTOTYPES',
  473. apicall = '',
  474. apientry = '',
  475. apientryp = ' *'),
  476. # WGL API + extensions - GL/wgl.h (no function pointers, yet @@@)
  477. CGeneratorOptions(
  478. filename = 'GL/wgl.h',
  479. apiname = 'wgl',
  480. profile = None,
  481. versions = allVersions,
  482. emitversions = allVersions,
  483. defaultExtensions = 'wgl', # Default extensions for WGL
  484. addExtensions = None,
  485. removeExtensions = None,
  486. prefixText = prefixStrings + wglPlatformStrings + genDateCommentString,
  487. genFuncPointers = True,
  488. protectFile = protectFile,
  489. protectFeature = protectFeature,
  490. protectProto = protectProto,
  491. protectProtoStr = 'WGL_WGLEXT_PROTOTYPES',
  492. apicall = '',
  493. apientry = 'WINAPI ',
  494. apientryp = 'WINAPI * '),
  495. # WGL extensions - GL/wglext.h (no function pointers, yet @@@)
  496. CGeneratorOptions(
  497. filename = 'GL/wglext.h',
  498. apiname = 'wgl',
  499. profile = None,
  500. versions = allVersions,
  501. emitversions = None,
  502. defaultExtensions = 'wgl', # Default extensions for WGL
  503. addExtensions = None,
  504. removeExtensions = None,
  505. prefixText = prefixStrings + wglPlatformStrings + wglextVersionStrings,
  506. genFuncPointers = True,
  507. protectFile = protectFile,
  508. protectFeature = protectFeature,
  509. protectProto = protectProto,
  510. protectProtoStr = 'WGL_WGLEXT_PROTOTYPES',
  511. apicall = '',
  512. apientry = 'WINAPI ',
  513. apientryp = 'WINAPI * '),
  514. # End of list
  515. None
  516. ]
  517. # create error/warning & diagnostic files
  518. if (errFilename):
  519. errWarn = open(errFilename,'w')
  520. else:
  521. errWarn = sys.stderr
  522. diag = open(diagFilename, 'w')
  523. def genHeaders():
  524. # Loop over targets, building each
  525. generated = 0
  526. for genOpts in buildList:
  527. if (genOpts == None):
  528. break
  529. if (target and target != genOpts.filename):
  530. # write('*** Skipping', genOpts.filename)
  531. continue
  532. write('*** Building', genOpts.filename)
  533. generated = generated + 1
  534. startTimer()
  535. gen = COutputGenerator(errFile=errWarn,
  536. warnFile=errWarn,
  537. diagFile=diag)
  538. reg.setGenerator(gen)
  539. reg.apiGen(genOpts)
  540. write('** Generated', genOpts.filename)
  541. endTimer('Time to generate ' + genOpts.filename + ' =')
  542. if (target and generated == 0):
  543. write('Failed to generate target:', target)
  544. if (debug):
  545. pdb.run('genHeaders()')
  546. elif (profile):
  547. import cProfile, pstats
  548. cProfile.run('genHeaders()', 'profile.txt')
  549. p = pstats.Stats('profile.txt')
  550. p.strip_dirs().sort_stats('time').print_stats(50)
  551. else:
  552. genHeaders()