blob: 2e5d7bc4238bf4c342e98679d0e92401135c05f3 [file] [log] [blame]
Jeff Gilbert1b605ee2017-10-30 18:41:46 -07001#!/usr/bin/python2
Jamie Madill2e16d962017-04-19 14:06:36 -04002#
3# Copyright 2017 The ANGLE Project Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6#
7# generate_entry_points.py:
8# Generates the OpenGL bindings and entry point layers for ANGLE.
9
Corentin Wallez2e568cf2017-09-18 17:05:22 -040010import sys, os, pprint, json
Jamie Madill2e16d962017-04-19 14:06:36 -040011import xml.etree.ElementTree as etree
12from datetime import date
13
Jamie Madillfa920eb2018-01-04 11:45:50 -050014# List of supported extensions. Add to this list to enable new extensions
15# available in gl.xml.
Brandon Jones416aaf92018-04-10 08:10:16 -070016
17angle_extensions = [
18 # ANGLE extensions
19 "GL_CHROMIUM_bind_uniform_location",
20 "GL_CHROMIUM_framebuffer_mixed_samples",
21 "GL_CHROMIUM_path_rendering",
22 "GL_CHROMIUM_copy_texture",
23 "GL_CHROMIUM_copy_compressed_texture",
24 "GL_ANGLE_request_extension",
25 "GL_ANGLE_robust_client_memory",
26 "GL_ANGLE_multiview",
Brandon Jones4e6f2ae2018-09-19 11:09:51 -070027 "GL_ANGLE_copy_texture_3d",
Brandon Jones416aaf92018-04-10 08:10:16 -070028]
29
Lingfeng Yanga0648782018-03-12 14:45:25 -070030gles1_extensions = [
31 # ES1 (Possibly the min set of extensions needed by Android)
32 "GL_OES_draw_texture",
33 "GL_OES_framebuffer_object",
34 "GL_OES_matrix_palette",
Geoff Lang2aaa7b42018-01-12 17:17:27 -050035 "GL_OES_point_size_array",
36 "GL_OES_query_matrix",
Lingfeng Yanga0648782018-03-12 14:45:25 -070037 "GL_OES_texture_cube_map",
38]
39
40# List of GLES1 extensions for which we don't need to add Context.h decls.
41gles1_no_context_decl_extensions = [
42 "GL_OES_framebuffer_object",
43]
44
45# List of GLES1 API calls that have had their semantics changed in later GLES versions, but the
46# name was kept the same
47gles1_overloaded = [
48 "glGetPointerv",
49]
50
Brandon Jones416aaf92018-04-10 08:10:16 -070051supported_extensions = sorted(angle_extensions + gles1_extensions + [
Geoff Lang2aaa7b42018-01-12 17:17:27 -050052 # ES2+
Jamie Madillfa920eb2018-01-04 11:45:50 -050053 "GL_ANGLE_framebuffer_blit",
54 "GL_ANGLE_framebuffer_multisample",
55 "GL_ANGLE_instanced_arrays",
56 "GL_ANGLE_translated_shader_source",
57 "GL_EXT_debug_marker",
58 "GL_EXT_discard_framebuffer",
59 "GL_EXT_disjoint_timer_query",
60 "GL_EXT_draw_buffers",
Jiawei Shao5f9482f2018-05-18 09:00:09 +080061 "GL_EXT_geometry_shader",
Jamie Madillfa920eb2018-01-04 11:45:50 -050062 "GL_EXT_map_buffer_range",
63 "GL_EXT_occlusion_query_boolean",
64 "GL_EXT_robustness",
65 "GL_EXT_texture_storage",
66 "GL_KHR_debug",
67 "GL_NV_fence",
68 "GL_OES_EGL_image",
69 "GL_OES_get_program_binary",
70 "GL_OES_mapbuffer",
Olli Etuaho064458a2018-08-30 14:02:02 +030071 "GL_OES_texture_storage_multisample_2d_array",
Jamie Madillfa920eb2018-01-04 11:45:50 -050072 "GL_OES_vertex_array_object",
jchen1082af6202018-06-22 10:59:52 +080073 "GL_KHR_parallel_shader_compile",
Jamie Madillfa920eb2018-01-04 11:45:50 -050074])
75
Brandon Jones2b0cdcc2018-05-02 08:02:50 -070076# The EGL_ANGLE_explicit_context extension is generated differently from other extensions.
77# Toggle generation here.
78support_EGL_ANGLE_explicit_context = True
79
Jamie Madillfa920eb2018-01-04 11:45:50 -050080# This is a list of exceptions for entry points which don't want to have
81# the EVENT macro. This is required for some debug marker entry points.
82no_event_marker_exceptions_list = sorted([
83 "glPushGroupMarkerEXT",
84 "glPopGroupMarkerEXT",
85 "glInsertEventMarkerEXT",
86])
87
88# Strip these suffixes from Context entry point names. NV is excluded (for now).
Brandon Jones416aaf92018-04-10 08:10:16 -070089strip_suffixes = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM"]
Jamie Madillfa920eb2018-01-04 11:45:50 -050090
Jamie Madill2e16d962017-04-19 14:06:36 -040091template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
92// Generated by {script_name} using data from {data_source_name}.
93//
94// Copyright {year} The ANGLE Project Authors. All rights reserved.
95// Use of this source code is governed by a BSD-style license that can be
96// found in the LICENSE file.
97//
Jamie Madillc8c9a242018-01-02 13:39:00 -050098// entry_points_gles_{annotation_lower}_autogen.h:
99// Defines the GLES {comment} entry points.
Jamie Madill2e16d962017-04-19 14:06:36 -0400100
Jamie Madillc8c9a242018-01-02 13:39:00 -0500101#ifndef LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
102#define LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400103
Jamie Madillc8c9a242018-01-02 13:39:00 -0500104{includes}
105
Jamie Madill2e16d962017-04-19 14:06:36 -0400106namespace gl
107{{
108{entry_points}
109}} // namespace gl
110
Jamie Madillc8c9a242018-01-02 13:39:00 -0500111#endif // LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400112"""
113
Jamie Madillee769dd2017-05-04 11:38:30 -0400114template_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
115// Generated by {script_name} using data from {data_source_name}.
116//
117// Copyright {year} The ANGLE Project Authors. All rights reserved.
118// Use of this source code is governed by a BSD-style license that can be
119// found in the LICENSE file.
120//
Jamie Madillc8c9a242018-01-02 13:39:00 -0500121// entry_points_gles_{annotation_lower}_autogen.cpp:
122// Defines the GLES {comment} entry points.
Jamie Madillee769dd2017-05-04 11:38:30 -0400123
Jamie Madillc8c9a242018-01-02 13:39:00 -0500124{includes}
Jamie Madillee769dd2017-05-04 11:38:30 -0400125
126namespace gl
127{{
128{entry_points}}} // namespace gl
129"""
130
131template_entry_points_enum_header = """// GENERATED FILE - DO NOT EDIT.
132// Generated by {script_name} using data from {data_source_name}.
133//
134// Copyright {year} The ANGLE Project Authors. All rights reserved.
135// Use of this source code is governed by a BSD-style license that can be
136// found in the LICENSE file.
137//
138// entry_points_enum_autogen.h:
139// Defines the GLES entry points enumeration.
140
141#ifndef LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
142#define LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
143
144namespace gl
145{{
146enum class EntryPoint
147{{
148{entry_points_list}
149}};
150}} // namespace gl
151#endif // LIBGLESV2_ENTRY_POINTS_ENUM_AUTOGEN_H_
152"""
153
Brandon Jones41e59f52018-05-02 12:45:28 -0700154template_libgles_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
155// Generated by {script_name} using data from {data_source_name}.
156//
157// Copyright {year} The ANGLE Project Authors. All rights reserved.
158// Use of this source code is governed by a BSD-style license that can be
159// found in the LICENSE file.
160//
161// libGLESv2.cpp: Implements the exported OpenGL ES functions.
162
163{includes}
164extern "C" {{
165{entry_points}
166}} // extern "C"
167"""
168
169template_libgles_entry_point_export = """; GENERATED FILE - DO NOT EDIT.
170; Generated by {script_name} using data from {data_source_name}.
171;
172; Copyright {year} The ANGLE Project Authors. All rights reserved.
173; Use of this source code is governed by a BSD-style license that can be
174; found in the LICENSE file.
175LIBRARY libGLESv2
176EXPORTS
177{exports}
178"""
179
Jamie Madill2e16d962017-04-19 14:06:36 -0400180template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}({params});"""
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700181template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
Jamie Madill2e16d962017-04-19 14:06:36 -0400182
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700183template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
Jamie Madillee769dd2017-05-04 11:38:30 -0400184{{
Geoff Langb02fc662018-08-21 09:48:01 -0400185 ANGLE_SCOPED_GLOBAL_LOCK();
Jamie Madillfa920eb2018-01-04 11:45:50 -0500186 {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400187
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700188 Context *context = {context_getter};
Jamie Madillee769dd2017-05-04 11:38:30 -0400189 if (context)
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700190 {{{assert_explicit_context}{packed_gl_enum_conversions}
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400191 context->gatherParams<EntryPoint::{name}>({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400192
Jamie Madill53d38412017-04-20 11:33:00 -0400193 if (context->skipValidation() || Validate{name}({validate_params}))
Jamie Madillee769dd2017-05-04 11:38:30 -0400194 {{
Jamie Madillc8c9a242018-01-02 13:39:00 -0500195 {return_if_needed}context->{name_lower_no_suffix}({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400196 }}
Jamie Madillee769dd2017-05-04 11:38:30 -0400197 }}
198{default_return_if_needed}}}
199"""
200
Lingfeng Yanga0648782018-03-12 14:45:25 -0700201context_gles_header = """// GENERATED FILE - DO NOT EDIT.
202// Generated by {script_name} using data from {data_source_name}.
203//
204// Copyright {year} The ANGLE Project Authors. All rights reserved.
205// Use of this source code is governed by a BSD-style license that can be
206// found in the LICENSE file.
207//
208// Context_gles_{annotation_lower}_autogen.h: Creates a macro for interfaces in Context.
209
210#ifndef ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
211#define ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
212
213#define ANGLE_GLES1_CONTEXT_API \\
214{interface}
215
216#endif // ANGLE_CONTEXT_API_{annotation_upper}_AUTOGEN_H_
217"""
218
219context_gles_decl = """ {return_type} {name_lower_no_suffix}({internal_params}); \\"""
220
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700221libgles_entry_point_def = """{return_type}GL_APIENTRY gl{name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
Brandon Jones41e59f52018-05-02 12:45:28 -0700222{{
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700223 return gl::{name}{explicit_context_suffix}({explicit_context_internal_param}{explicit_context_comma}{internal_params});
Brandon Jones41e59f52018-05-02 12:45:28 -0700224}}
225"""
226
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700227libgles_entry_point_export = """ {name}{explicit_context_suffix}{spaces}@{ordinal}"""
228
229template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
230// Generated by {script_name} using data from {data_source_name}.
231//
232// Copyright {year} The ANGLE Project Authors. All rights reserved.
233// Use of this source code is governed by a BSD-style license that can be
234// found in the LICENSE file.
235//
236// gl{version}ext_explicit_context_autogen.inc:
237// Function declarations for the EGL_ANGLE_explicit_context extension
238
239{function_pointers}
240#ifdef GL_GLEXT_PROTOTYPES
241{function_prototypes}
242#endif
243"""
244
245template_glext_function_pointer = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper})({explicit_context_param}{explicit_context_comma}{params});"""
246template_glext_function_prototype = """{apicall} {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
Brandon Jones41e59f52018-05-02 12:45:28 -0700247
Jamie Madill16daadb2017-08-26 23:34:31 -0400248def script_relative(path):
249 return os.path.join(os.path.dirname(sys.argv[0]), path)
250
251tree = etree.parse(script_relative('gl.xml'))
252root = tree.getroot()
Jamie Madill2e16d962017-04-19 14:06:36 -0400253commands = root.find(".//commands[@namespace='GL']")
Jamie Madill2e16d962017-04-19 14:06:36 -0400254
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400255with open(script_relative('entry_point_packed_gl_enums.json')) as f:
256 cmd_packed_gl_enums = json.loads(f.read())
257
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700258def format_entry_point_decl(cmd_name, proto, params, is_explicit_context):
259 comma_if_needed = ", " if len(params) > 0 else ""
Jamie Madill2e16d962017-04-19 14:06:36 -0400260 return template_entry_point_decl.format(
261 name = cmd_name[2:],
262 return_type = proto[:-len(cmd_name)],
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700263 params = ", ".join(params),
264 comma_if_needed = comma_if_needed,
265 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
266 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
267 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "")
Jamie Madill2e16d962017-04-19 14:06:36 -0400268
Jamie Madillee769dd2017-05-04 11:38:30 -0400269def type_name_sep_index(param):
270 space = param.rfind(" ")
271 pointer = param.rfind("*")
272 return max(space, pointer)
273
274def just_the_type(param):
Lingfeng Yanga0648782018-03-12 14:45:25 -0700275 if "*" in param:
276 return param[:type_name_sep_index(param) + 1]
Jamie Madillee769dd2017-05-04 11:38:30 -0400277 return param[:type_name_sep_index(param)]
278
279def just_the_name(param):
280 return param[type_name_sep_index(param)+1:]
281
Lingfeng Yanga0648782018-03-12 14:45:25 -0700282def make_param(param_type, param_name):
283 return param_type + " " + param_name
284
285def just_the_type_packed(param, entry):
286 name = just_the_name(param)
287 if entry.has_key(name):
288 return entry[name]
289 else:
290 return just_the_type(param)
291
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400292def just_the_name_packed(param, reserved_set):
293 name = just_the_name(param)
294 if name in reserved_set:
295 return name + 'Packed'
296 else:
297 return name
298
Jamie Madillee769dd2017-05-04 11:38:30 -0400299format_dict = {
300 "GLbitfield": "0x%X",
301 "GLboolean": "%u",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500302 "GLclampx": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400303 "GLenum": "0x%X",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500304 "GLfixed": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400305 "GLfloat": "%f",
306 "GLint": "%d",
307 "GLintptr": "%d",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500308 "GLshort": "%d",
Jamie Madillee769dd2017-05-04 11:38:30 -0400309 "GLsizei": "%d",
310 "GLsizeiptr": "%d",
Jamie Madill16daadb2017-08-26 23:34:31 -0400311 "GLsync": "0x%0.8p",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500312 "GLubyte": "%d",
Jamie Madillff161f82017-08-26 23:49:10 -0400313 "GLuint": "%u",
Jamie Madillfa920eb2018-01-04 11:45:50 -0500314 "GLuint64": "%llu",
315 "GLDEBUGPROC": "0x%0.8p",
316 "GLDEBUGPROCKHR": "0x%0.8p",
317 "GLeglImageOES": "0x%0.8p",
Jamie Madillee769dd2017-05-04 11:38:30 -0400318}
319
320def param_format_string(param):
321 if "*" in param:
322 return param + " = 0x%0.8p"
323 else:
Jamie Madill16daadb2017-08-26 23:34:31 -0400324 type_only = just_the_type(param)
325 if type_only not in format_dict:
326 raise Exception(type_only + " is not a known type in 'format_dict'")
327
328 return param + " = " + format_dict[type_only]
Jamie Madillee769dd2017-05-04 11:38:30 -0400329
Jamie Madill2e29b132017-08-28 17:22:11 -0400330def default_return_value(cmd_name, return_type):
Jamie Madillee769dd2017-05-04 11:38:30 -0400331 if return_type == "void":
332 return ""
Jamie Madill2e29b132017-08-28 17:22:11 -0400333 return "GetDefaultReturnValue<EntryPoint::" + cmd_name[2:] + ", " + return_type + ">()"
Jamie Madillee769dd2017-05-04 11:38:30 -0400334
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700335def get_context_getter_function(cmd_name, is_explicit_context):
Geoff Langcae72d62017-06-01 11:53:45 -0400336 if cmd_name == "glGetError":
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700337 return "GetGlobalContext()"
338 elif is_explicit_context:
339 return "static_cast<gl::Context *>(ctx)"
Geoff Langcae72d62017-06-01 11:53:45 -0400340 else:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700341 return "GetValidGlobalContext()"
Geoff Langcae72d62017-06-01 11:53:45 -0400342
Jamie Madillfa920eb2018-01-04 11:45:50 -0500343template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marker entry points.
344 // It can interfere with the debug events being set by the caller.
345 // """
346
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700347def format_entry_point_def(cmd_name, proto, params, is_explicit_context):
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400348 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
349 internal_params = [just_the_name_packed(param, packed_gl_enums) for param in params]
350 packed_gl_enum_conversions = []
351 for param in params:
352 name = just_the_name(param)
353 if name in packed_gl_enums:
354 internal_name = name + "Packed"
355 internal_type = packed_gl_enums[name]
356 packed_gl_enum_conversions += ["\n " + internal_type + " " + internal_name +" = FromGLenum<" +
357 internal_type + ">(" + name + ");"]
358
Jamie Madillee769dd2017-05-04 11:38:30 -0400359 pass_params = [just_the_name(param) for param in params]
360 format_params = [param_format_string(param) for param in params]
361 return_type = proto[:-len(cmd_name)]
Jamie Madill2e29b132017-08-28 17:22:11 -0400362 default_return = default_return_value(cmd_name, return_type.strip())
Jamie Madillfa920eb2018-01-04 11:45:50 -0500363 event_comment = template_event_comment if cmd_name in no_event_marker_exceptions_list else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500364 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
365
Jamie Madillfa920eb2018-01-04 11:45:50 -0500366 for suffix in strip_suffixes:
367 if name_lower_no_suffix.endswith(suffix):
368 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
369
Jamie Madillee769dd2017-05-04 11:38:30 -0400370 return template_entry_point_def.format(
371 name = cmd_name[2:],
Jamie Madillc8c9a242018-01-02 13:39:00 -0500372 name_lower_no_suffix = name_lower_no_suffix,
Jamie Madillee769dd2017-05-04 11:38:30 -0400373 return_type = return_type,
374 params = ", ".join(params),
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400375 internal_params = ", ".join(internal_params),
376 packed_gl_enum_conversions = "".join(packed_gl_enum_conversions),
Jamie Madillee769dd2017-05-04 11:38:30 -0400377 pass_params = ", ".join(pass_params),
378 comma_if_needed = ", " if len(params) > 0 else "",
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400379 validate_params = ", ".join(["context"] + internal_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400380 format_params = ", ".join(format_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400381 return_if_needed = "" if default_return == "" else "return ",
Geoff Langcae72d62017-06-01 11:53:45 -0400382 default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n",
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700383 context_getter = get_context_getter_function(cmd_name, is_explicit_context),
384 event_comment = event_comment,
385 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
386 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
387 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
388 assert_explicit_context = "\nASSERT(context == GetValidGlobalContext());"
389 if is_explicit_context else "")
Jamie Madillee769dd2017-05-04 11:38:30 -0400390
Lingfeng Yanga0648782018-03-12 14:45:25 -0700391def format_context_gles_decl(cmd_name, proto, params):
392 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
393 internal_params = ", ".join([make_param(just_the_type_packed(param, packed_gl_enums),
394 just_the_name_packed(param, packed_gl_enums)) for param in params])
395
396 return_type = proto[:-len(cmd_name)]
397 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
398
399 for suffix in strip_suffixes:
400 if name_lower_no_suffix.endswith(suffix):
401 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
402
403 return context_gles_decl.format(
404 return_type = return_type,
405 name_lower_no_suffix = name_lower_no_suffix,
406 internal_params = internal_params)
407
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700408def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700409 internal_params = [just_the_name(param) for param in params]
410 return_type = proto[:-len(cmd_name)]
411
412 return libgles_entry_point_def.format(
413 name = cmd_name[2:],
414 return_type = return_type,
415 params = ", ".join(params),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700416 internal_params = ", ".join(internal_params),
417 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
418 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
419 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
420 explicit_context_internal_param = "ctx" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700421
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700422def format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700423 return libgles_entry_point_export.format(
424 name = cmd_name,
425 ordinal = ordinal,
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700426 spaces = " "*(50 - len(cmd_name)),
427 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700428
Jiajia Qincb59a902017-11-22 13:03:42 +0800429def path_to(folder, file):
430 return os.path.join(script_relative(".."), "src", folder, file)
Jamie Madill2e16d962017-04-19 14:06:36 -0400431
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700432def get_entry_points(all_commands, gles_commands, ordinal, is_explicit_context):
Jamie Madillc8c9a242018-01-02 13:39:00 -0500433 decls = []
434 defs = []
Brandon Jones41e59f52018-05-02 12:45:28 -0700435 export_defs = []
436 exports = []
437
Jamie Madillffa2cd02017-12-28 14:57:53 -0500438 for command in all_commands:
439 proto = command.find('proto')
440 cmd_name = proto.find('name').text
441
442 if cmd_name not in gles_commands:
443 continue
444
445 param_text = ["".join(param.itertext()) for param in command.findall('param')]
446 proto_text = "".join(proto.itertext())
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700447 decls.append(format_entry_point_decl(cmd_name, proto_text, param_text,
448 is_explicit_context))
449 defs.append(format_entry_point_def(cmd_name, proto_text, param_text, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700450
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700451 export_defs.append(format_libgles_entry_point_def(cmd_name, proto_text, param_text,
452 is_explicit_context))
453 exports.append(format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700454 ordinal = ordinal + 1
455
456 return decls, defs, export_defs, exports
Jamie Madill16daadb2017-08-26 23:34:31 -0400457
Lingfeng Yanga0648782018-03-12 14:45:25 -0700458def get_gles1_decls(all_commands, gles_commands):
459 decls = []
460 for command in all_commands:
461 proto = command.find('proto')
462 cmd_name = proto.find('name').text
463
464 if cmd_name not in gles_commands:
465 continue
466
467 if cmd_name in gles1_overloaded:
468 continue
469
470 param_text = ["".join(param.itertext()) for param in command.findall('param')]
471 proto_text = "".join(proto.itertext())
472 decls.append(format_context_gles_decl(cmd_name, proto_text, param_text))
473
474 return decls
475
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700476def get_glext_decls(all_commands, gles_commands, version, is_explicit_context):
477 glext_ptrs = []
478 glext_protos = []
479 is_gles1 = False
480
481 if(version == ""):
482 is_gles1 = True
483
484 for command in all_commands:
485 proto = command.find('proto')
486 cmd_name = proto.find('name').text
487
488 if cmd_name not in gles_commands:
489 continue
490
491 param_text = ["".join(param.itertext()) for param in command.findall('param')]
492 proto_text = "".join(proto.itertext())
493
494 return_type = proto_text[:-len(cmd_name)]
495 params = ", ".join(param_text)
496
497 format_params = {
498 "apicall": "GL_API" if is_gles1 else "GL_APICALL",
499 "name": cmd_name,
500 "name_upper": cmd_name.upper(),
501 "return_type": return_type,
502 "params": params,
503 "explicit_context_comma": ", " if is_explicit_context and len(params) > 0 else "",
504 "explicit_context_suffix": "ContextANGLE" if is_explicit_context else "",
505 "explicit_context_suffix_upper": "CONTEXTANGLE" if is_explicit_context else "",
506 "explicit_context_param": "GLeglContext ctx" if is_explicit_context else ""}
507
508 glext_ptrs.append(template_glext_function_pointer.format(
509 **format_params))
510 glext_protos.append(template_glext_function_prototype.format(
511 **format_params))
512
513 return glext_ptrs, glext_protos
514
Brandon Jones416aaf92018-04-10 08:10:16 -0700515def write_file(annotation, comment, template, entry_points, suffix, includes, file):
Jiajia Qincb59a902017-11-22 13:03:42 +0800516
Jamie Madillc8c9a242018-01-02 13:39:00 -0500517 content = template.format(
518 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700519 data_source_name = file,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500520 year = date.today().year,
521 annotation_lower = annotation.lower(),
522 annotation_upper = annotation.upper(),
523 comment = comment,
524 includes = includes,
525 entry_points = entry_points)
Jiajia Qincb59a902017-11-22 13:03:42 +0800526
Jamie Madillc8c9a242018-01-02 13:39:00 -0500527 path = path_to("libGLESv2", "entry_points_gles_{}_autogen.{}".format(
528 annotation.lower(), suffix))
529
530 with open(path, "w") as out:
531 out.write(content)
532 out.close()
533
Brandon Jones41e59f52018-05-02 12:45:28 -0700534def write_export_files(entry_points, includes, exports):
535
536 content = template_libgles_entry_point_source.format(
537 script_name = os.path.basename(sys.argv[0]),
538 data_source_name = "gl.xml and gl_angle_ext.xml",
539 year = date.today().year,
540 includes = includes,
541 entry_points = entry_points)
542
543 path = path_to("libGLESv2", "libGLESv2_autogen.cpp")
544
545 with open(path, "w") as out:
546 out.write(content)
547 out.close()
548
549 content = template_libgles_entry_point_export.format(
550 script_name = os.path.basename(sys.argv[0]),
551 data_source_name = "gl.xml and gl_angle_ext.xml",
552 exports = exports,
553 year = date.today().year)
554
555 path = path_to("libGLESv2", "libGLESv2_autogen.def")
556
557 with open(path, "w") as out:
558 out.write(content)
559 out.close()
560
Lingfeng Yanga0648782018-03-12 14:45:25 -0700561def write_context_api_decls(annotation, template, decls):
562
563 interface_lines = []
564
565 for i in decls['core']:
566 interface_lines.append(i)
567
568 for extname in sorted(decls['exts'].keys()):
569 interface_lines.append(" /* " + extname + " */ \\")
570 interface_lines.extend(decls['exts'][extname])
571
572 content = template.format(
573 annotation_lower = annotation.lower(),
574 annotation_upper = annotation.upper(),
575 script_name = os.path.basename(sys.argv[0]),
576 data_source_name = "gl.xml",
577 year = date.today().year,
578 interface = "\n".join(interface_lines))
579
580 path = path_to("libANGLE", "Context_gles_%s_autogen.h" % annotation.lower())
581
582 with open(path, "w") as out:
583 out.write(content)
584 out.close()
585
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700586def write_glext_explicit_context_inc(version, ptrs, protos):
587 folder_version = version if version != "31" else "3"
588
589 content = template_glext_explicit_context_inc.format(
590 script_name = os.path.basename(sys.argv[0]),
591 data_source_name = "gl.xml and gl_angle_ext.xml",
592 year = date.today().year,
593 version = version,
594 function_pointers = ptrs,
595 function_prototypes = protos)
596
Brandon Jones795ab712018-05-24 15:45:40 -0700597 path = os.path.join(script_relative(".."), "include", "GLES{}".format(folder_version),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700598 "gl{}ext_explicit_context_autogen.inc".format(version))
599
600 with open(path, "w") as out:
601 out.write(content)
602 out.close()
603
Brandon Jones416aaf92018-04-10 08:10:16 -0700604def append_angle_extensions(base_root):
605 angle_ext_tree = etree.parse(script_relative('gl_angle_ext.xml'))
606 angle_ext_root = angle_ext_tree.getroot()
607
608 insertion_point = base_root.findall("./commands")[0]
609 for command in angle_ext_root.iter('commands'):
610 insertion_point.extend(command)
611
612 insertion_point = base_root.findall("./extensions")[0]
613 for extension in angle_ext_root.iter('extensions'):
614 insertion_point.extend(extension)
615 return base_root
616
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700617class GLCommandNames:
618 def __init__(self):
619 self.command_names = {}
620
621 def get_commands(self, version):
622 return self.command_names[version]
623
624 def get_all_commands(self):
625 cmd_names = []
626 # Combine all the version lists into a single list
627 for version, version_cmd_names in sorted(self.command_names.iteritems()):
628 cmd_names += version_cmd_names
629
630 return cmd_names
631
632 def add_commands(self, version, commands):
633 # Add key if it doesn't exist
634 if version not in self.command_names:
635 self.command_names[version] = []
636 # Add the commands that aren't duplicates
637 self.command_names[version] += commands
638
Brandon Jones416aaf92018-04-10 08:10:16 -0700639root = append_angle_extensions(root)
640
Jamie Madillc8c9a242018-01-02 13:39:00 -0500641all_commands = root.findall('commands/command')
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700642all_cmd_names = GLCommandNames()
Jamie Madillc8c9a242018-01-02 13:39:00 -0500643
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500644template_header_includes = """#include <GLES{major}/gl{major}{minor}.h>
Jamie Madillc8c9a242018-01-02 13:39:00 -0500645#include <export.h>"""
646
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500647template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen.h"
648
649#include "libANGLE/Context.h"
Jamie Madillc8c9a242018-01-02 13:39:00 -0500650#include "libANGLE/validationES{}{}.h"
651#include "libGLESv2/global_state.h"
652"""
653
Lingfeng Yanga0648782018-03-12 14:45:25 -0700654gles1decls = {}
655
656gles1decls['core'] = []
657gles1decls['exts'] = {}
658
Brandon Jones41e59f52018-05-02 12:45:28 -0700659libgles_ep_defs = []
660libgles_ep_exports = []
661
662ordinal_start = 1
663
Lingfeng Yanga0648782018-03-12 14:45:25 -0700664# First run through the main GLES entry points. Since ES2+ is the primary use
665# case, we go through those first and then add ES1-only APIs at the end.
666for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]:
Jamie Madillc8c9a242018-01-02 13:39:00 -0500667 annotation = "{}_{}".format(major_version, minor_version)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500668 name_prefix = "GL_ES_VERSION_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700669
670 is_gles1 = major_version == 1
671 if is_gles1:
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500672 name_prefix = "GL_VERSION_ES_CM_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700673
Jamie Madillc8c9a242018-01-02 13:39:00 -0500674 comment = annotation.replace("_", ".")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500675 gles_xpath = ".//feature[@name='{}{}']//command".format(name_prefix, annotation)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500676 gles_commands = [cmd.attrib['name'] for cmd in root.findall(gles_xpath)]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500677
678 # Remove commands that have already been processed
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700679 gles_commands = [cmd for cmd in gles_commands if cmd not in all_cmd_names.get_all_commands()]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500680
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700681 all_cmd_names.add_commands(annotation, gles_commands)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500682
Brandon Jones41e59f52018-05-02 12:45:28 -0700683 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700684 all_commands, gles_commands, ordinal_start, False)
Brandon Jones41e59f52018-05-02 12:45:28 -0700685
686 # Increment the ordinal before inserting the version comment
687 ordinal_start += len(libgles_exports)
688
689 # Write the version as a comment before the first EP.
690 libgles_defs.insert(0, "\n// OpenGL ES {}.{}".format(major_version, minor_version))
691 libgles_exports.insert(0, "\n ; OpenGL ES {}.{}".format(major_version, minor_version))
692
693 libgles_ep_defs += libgles_defs
694 libgles_ep_exports += libgles_exports
Jamie Madillc8c9a242018-01-02 13:39:00 -0500695
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500696 major_if_not_one = major_version if major_version != 1 else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500697 minor_if_not_zero = minor_version if minor_version != 0 else ""
698
699 header_includes = template_header_includes.format(
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500700 major=major_if_not_one, minor=minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500701
702 # We include the platform.h header since it undefines the conflicting MemoryBarrier macro.
703 if major_version == 3 and minor_version == 1:
704 header_includes += "\n#include \"common/platform.h\"\n"
705
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500706 source_includes = template_sources_includes.format(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700707 annotation.lower(), major_version, minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500708
709 write_file(annotation, comment, template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700710 "\n".join(decls), "h", header_includes, "gl.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500711 write_file(annotation, comment, template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700712 "\n".join(defs), "cpp", source_includes, "gl.xml")
Lingfeng Yanga0648782018-03-12 14:45:25 -0700713 if is_gles1:
714 gles1decls['core'] = get_gles1_decls(all_commands, gles_commands)
715
Jamie Madill57ae8c12017-08-30 12:14:29 -0400716
Jamie Madillfa920eb2018-01-04 11:45:50 -0500717# After we finish with the main entry points, we process the extensions.
718extension_defs = []
719extension_decls = []
720
721# Use a first step to run through the extensions so we can generate them
722# in sorted order.
723ext_data = {}
724
Lingfeng Yanga0648782018-03-12 14:45:25 -0700725for gles1ext in gles1_extensions:
726 gles1decls['exts'][gles1ext] = []
727
Jamie Madillfa920eb2018-01-04 11:45:50 -0500728for extension in root.findall("extensions/extension"):
729 extension_name = extension.attrib['name']
730 if not extension_name in supported_extensions:
731 continue
732
733 ext_cmd_names = []
734
735 # There's an extra step here to filter out 'api=gl' extensions. This
736 # is necessary for handling KHR extensions, which have separate entry
737 # point signatures (without the suffix) for desktop GL. Note that this
738 # extra step is necessary because of Etree's limited Xpath support.
739 for require in extension.findall('require'):
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500740 if 'api' in require.attrib and require.attrib['api'] != 'gles2' and require.attrib['api'] != 'gles1':
Jamie Madillfa920eb2018-01-04 11:45:50 -0500741 continue
742
743 # Another special case for EXT_texture_storage
744 filter_out_comment = "Supported only if GL_EXT_direct_state_access is supported"
745 if 'comment' in require.attrib and require.attrib['comment'] == filter_out_comment:
746 continue
747
748 extension_commands = require.findall('command')
749 ext_cmd_names += [command.attrib['name'] for command in extension_commands]
750
751 ext_data[extension_name] = sorted(ext_cmd_names)
752
753for extension_name, ext_cmd_names in sorted(ext_data.iteritems()):
754
755 # Detect and filter duplicate extensions.
756 dupes = []
757 for ext_cmd in ext_cmd_names:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700758 if ext_cmd in all_cmd_names.get_all_commands():
Jamie Madillfa920eb2018-01-04 11:45:50 -0500759 dupes.append(ext_cmd)
760
761 for dupe in dupes:
762 ext_cmd_names.remove(dupe)
763
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700764 if extension_name in gles1_extensions:
765 all_cmd_names.add_commands("glext", ext_cmd_names)
766 else:
767 all_cmd_names.add_commands("gl2ext", ext_cmd_names)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500768
Brandon Jones41e59f52018-05-02 12:45:28 -0700769 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700770 all_commands, ext_cmd_names, ordinal_start, False)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500771
772 # Avoid writing out entry points defined by a prior extension.
773 for dupe in dupes:
774 msg = "// {} is already defined.\n".format(dupe[2:])
775 defs.append(msg)
776
Brandon Jones41e59f52018-05-02 12:45:28 -0700777 # Increment starting ordinal before adding extension comment
778 ordinal_start += len(libgles_exports)
779
Jamie Madillfa920eb2018-01-04 11:45:50 -0500780 # Write the extension name as a comment before the first EP.
781 comment = "\n// {}".format(extension_name)
782 defs.insert(0, comment)
783 decls.insert(0, comment)
Brandon Jones41e59f52018-05-02 12:45:28 -0700784 libgles_defs.insert(0, comment)
785 libgles_exports.insert(0, "\n ; {}".format(extension_name))
Jamie Madillfa920eb2018-01-04 11:45:50 -0500786
787 extension_defs += defs
788 extension_decls += decls
789
Brandon Jones41e59f52018-05-02 12:45:28 -0700790 libgles_ep_defs += libgles_defs
791 libgles_ep_exports += libgles_exports
792
Lingfeng Yanga0648782018-03-12 14:45:25 -0700793 if extension_name in gles1_extensions:
794 if extension_name not in gles1_no_context_decl_extensions:
795 gles1decls['exts'][extension_name] = get_gles1_decls(all_commands, ext_cmd_names)
796
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700797# Special handling for EGL_ANGLE_explicit_context extension
798if support_EGL_ANGLE_explicit_context:
799 comment = "\n// EGL_ANGLE_explicit_context"
800 extension_defs.append(comment)
801 extension_decls.append(comment)
802 libgles_ep_defs.append(comment)
803 libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context")
804
805 # Get the explicit context entry points
806 decls, defs, libgles_defs, libgles_exports = get_entry_points(all_commands,
807 all_cmd_names.get_all_commands(), ordinal_start, True)
808
809 # Append the explicit context entry points
810 extension_decls += decls
811 extension_defs += defs
812 libgles_ep_defs += libgles_defs
813 libgles_ep_exports += libgles_exports
814
815 # Generate .inc files for extension function pointers and declarations
816 for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]:
817 annotation = "{}_{}".format(major, minor)
818
819 major_if_not_one = major if major != 1 else ""
820 minor_if_not_zero = minor if minor != 0 else ""
821 version = "{}{}".format(major_if_not_one, minor_if_not_zero)
822
823 glext_ptrs, glext_protos = get_glext_decls(all_commands,
824 all_cmd_names.get_commands(annotation), version, True)
825
826 glext_ext_ptrs = []
827 glext_ext_protos = []
828
829 # Append extensions for 1.0 and 2.0
830 if(annotation == "1_0"):
831 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
832 all_cmd_names.get_commands("glext"), version, True)
833 elif(annotation == "2_0"):
834 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
835 all_cmd_names.get_commands("gl2ext"), version, True)
836
837 glext_ptrs += glext_ext_ptrs
838 glext_protos += glext_ext_protos
839
840 write_glext_explicit_context_inc(version, "\n".join(glext_ptrs), "\n".join(glext_protos))
841
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500842header_includes = template_header_includes.format(
843 major="", minor="")
844header_includes += """
845#include <GLES/gl.h>
846#include <GLES/glext.h>
847#include <GLES2/gl2.h>
848#include <GLES2/gl2ext.h>
849"""
Jamie Madillfa920eb2018-01-04 11:45:50 -0500850
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500851source_includes = template_sources_includes.format("ext", "", "")
852source_includes += """
853#include "libANGLE/validationES.h"
854#include "libANGLE/validationES1.h"
Jamie Madillfa920eb2018-01-04 11:45:50 -0500855#include "libANGLE/validationES3.h"
856#include "libANGLE/validationES31.h"
857"""
858
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500859write_file("ext", "extension", template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700860 "\n".join([item for item in extension_decls]), "h", header_includes,
861 "gl.xml and gl_angle_ext.xml")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500862write_file("ext", "extension", template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700863 "\n".join([item for item in extension_defs]), "cpp", source_includes,
864 "gl.xml and gl_angle_ext.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500865
Lingfeng Yanga0648782018-03-12 14:45:25 -0700866write_context_api_decls("1_0", context_gles_header, gles1decls)
867
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700868sorted_cmd_names = ["Invalid"] + [cmd[2:] for cmd in sorted(all_cmd_names.get_all_commands())]
Jamie Madillc8c9a242018-01-02 13:39:00 -0500869
Jamie Madillee769dd2017-05-04 11:38:30 -0400870entry_points_enum = template_entry_points_enum_header.format(
871 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700872 data_source_name = "gl.xml and gl_angle_ext.xml",
Jamie Madillee769dd2017-05-04 11:38:30 -0400873 year = date.today().year,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500874 entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names]))
Jamie Madillee769dd2017-05-04 11:38:30 -0400875
Jamie Madillee769dd2017-05-04 11:38:30 -0400876entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
Jamie Madillee769dd2017-05-04 11:38:30 -0400877with open(entry_points_enum_header_path, "w") as out:
878 out.write(entry_points_enum)
Geoff Langcae72d62017-06-01 11:53:45 -0400879 out.close()
Brandon Jones41e59f52018-05-02 12:45:28 -0700880
881source_includes = """
882#include "angle_gl.h"
883
884#include "libGLESv2/entry_points_gles_1_0_autogen.h"
885#include "libGLESv2/entry_points_gles_2_0_autogen.h"
886#include "libGLESv2/entry_points_gles_3_0_autogen.h"
887#include "libGLESv2/entry_points_gles_3_1_autogen.h"
888#include "libGLESv2/entry_points_gles_ext_autogen.h"
889
890#include "common/event_tracer.h"
891"""
892
jchen1082af6202018-06-22 10:59:52 +0800893write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes, "\n".join([item for item in libgles_ep_exports]))