Chromium Code Reviews| Index: ui/gl/generate_bindings.py |
| diff --git a/ui/gl/generate_bindings.py b/ui/gl/generate_bindings.py |
| index f90797c26d7e175ec95407c376a4a28536a066e5..96e297d345d9744f89fffbda01a4b4819c05bb41 100755 |
| --- a/ui/gl/generate_bindings.py |
| +++ b/ui/gl/generate_bindings.py |
| @@ -5,6 +5,7 @@ |
| """code generator for GL/GLES extension wrangler.""" |
| +import optparse |
| import os |
| import collections |
| import re |
| @@ -1140,21 +1141,32 @@ GLX_FUNCTIONS = [ |
| 'int32* denominator' }, |
| ] |
| +BUNDLED_HEADER_PATHS = [ |
| + '../../third_party/mesa/MesaLib/include', |
| + '../../third_party/khronos', |
| +] |
| + |
| +SYSTEM_HEADER_PATHS = [ |
| + '/usr/include', |
| +] |
| + |
| FUNCTION_SETS = [ |
| - [GL_FUNCTIONS, 'gl', ['../../third_party/mesa/MesaLib/include/GL/glext.h', |
| - '../../third_party/khronos/GLES2/gl2ext.h'], []], |
| + [GL_FUNCTIONS, 'gl', [ |
| + 'GL/glext.h', |
| + 'GLES2/gl2ext.h', |
| + # Files below are Chromium-specific and shipped with Chromium sources. |
| + 'GLES2/gl2chromium.h', |
| + 'GLES2/gl2extchromium.h' |
| + ], []], |
| [OSMESA_FUNCTIONS, 'osmesa', [], []], |
| - [EGL_FUNCTIONS, 'egl', ['../../third_party/khronos/EGL/eglext.h'], |
| + [EGL_FUNCTIONS, 'egl', ['EGL/eglext.h'], |
| [ |
| 'EGL_ANGLE_d3d_share_handle_client_buffer', |
| 'EGL_ANGLE_surface_d3d_texture_2d_share_handle', |
| ], |
| ], |
| - [WGL_FUNCTIONS, 'wgl', [ |
| - '../../third_party/mesa/MesaLib/include/GL/wglext.h'], []], |
| - [GLX_FUNCTIONS, 'glx', [ |
| - '../../third_party/mesa/MesaLib/include/GL/glx.h', |
| - '../../third_party/mesa/MesaLib/include/GL/glxext.h'], []], |
| + [WGL_FUNCTIONS, 'wgl', ['GL/wglext.h'], []], |
| + [GLX_FUNCTIONS, 'glx', ['GL/glx.h', 'GL/glxext.h'], []], |
| ] |
| def GenerateHeader(file, functions, set_name, used_extension_functions): |
| @@ -1585,7 +1597,7 @@ def ParseExtensionFunctionsFromHeader(header_file): |
| Map of extension name => functions. |
| """ |
| extension_start = re.compile(r'#define ([A-Z]+_[A-Z]+_[a-zA-Z]\w+) 1') |
| - extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(.+\);') |
| + extension_function = re.compile(r'.+\s+([a-z]+\w+)\s*\(') |
| typedef = re.compile(r'typedef .*') |
| macro_start = re.compile(r'^#(if|ifdef|ifndef).*') |
| macro_end = re.compile(r'^#endif.*') |
| @@ -1696,15 +1708,51 @@ def GetUsedExtensionFunctions(functions, extension_headers, extra_extensions): |
| return used_extension_functions |
| +def ResolveHeader(header, use_system_mesa): |
|
greggman
2013/01/07 20:23:33
All the changes in this file seem like adding a bu
Paweł Hajdan Jr.
2013/01/07 21:20:05
No. This file is executed during the build process
greggman
2013/01/07 21:32:22
It's not just a burden. The code you added is the
|
| + if use_system_mesa == 1: |
| + paths = SYSTEM_HEADER_PATHS |
| + else: |
| + paths = BUNDLED_HEADER_PATHS |
| + |
| + # Always use a path for Chromium-specific extensions. They are extracted |
| + # to separate files. |
| + paths.append('../../gpu') |
| + |
| + root = os.path.abspath(os.path.dirname(__file__)) |
| + |
| + for path in paths: |
| + result = os.path.join(path, header) |
| + if not os.path.isabs(path): |
| + result = os.path.relpath(os.path.join(root, result), os.getcwd()) |
| + if os.path.exists(result): |
| + return result |
| + |
| + raise Exception('Header %s not found.' % header) |
| + |
| + |
| def main(argv): |
| """This is the main function.""" |
| - if len(argv) >= 1: |
| - dir = argv[0] |
| + parser = optparse.OptionParser() |
| + parser.add_option('--inputs', action='store_true') |
| + parser.add_option('--use-system-mesa', type=int, default=0) |
| + |
| + options, args = parser.parse_args(argv) |
| + |
| + if options.inputs: |
| + for [_, _, headers, _] in FUNCTION_SETS: |
| + for header in headers: |
| + print ResolveHeader(header, options.use_system_mesa) |
| + return 0 |
| + |
| + if len(args) >= 1: |
| + dir = args[0] |
| else: |
| dir = '.' |
| for [functions, set_name, extension_headers, extensions] in FUNCTION_SETS: |
| + extension_headers = [ResolveHeader(h, options.use_system_mesa) |
| + for h in extension_headers] |
| used_extension_functions = GetUsedExtensionFunctions( |
| functions, extension_headers, extensions) |