blob: 3264344396e73f959869ea093e6af28f0c380fdd [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",
Yizhou Jiang7818a852018-09-06 15:02:04 +080056 "GL_ANGLE_texture_multisample",
Jamie Madillfa920eb2018-01-04 11:45:50 -050057 "GL_ANGLE_translated_shader_source",
Olli Etuaho0ca09752018-09-24 11:00:50 +030058 "GL_EXT_blend_func_extended",
Jamie Madillfa920eb2018-01-04 11:45:50 -050059 "GL_EXT_debug_marker",
60 "GL_EXT_discard_framebuffer",
61 "GL_EXT_disjoint_timer_query",
62 "GL_EXT_draw_buffers",
Jiawei Shao5f9482f2018-05-18 09:00:09 +080063 "GL_EXT_geometry_shader",
Jamie Madillfa920eb2018-01-04 11:45:50 -050064 "GL_EXT_map_buffer_range",
65 "GL_EXT_occlusion_query_boolean",
66 "GL_EXT_robustness",
67 "GL_EXT_texture_storage",
68 "GL_KHR_debug",
69 "GL_NV_fence",
70 "GL_OES_EGL_image",
71 "GL_OES_get_program_binary",
72 "GL_OES_mapbuffer",
Olli Etuaho064458a2018-08-30 14:02:02 +030073 "GL_OES_texture_storage_multisample_2d_array",
Jamie Madillfa920eb2018-01-04 11:45:50 -050074 "GL_OES_vertex_array_object",
jchen1082af6202018-06-22 10:59:52 +080075 "GL_KHR_parallel_shader_compile",
Jamie Madillfa920eb2018-01-04 11:45:50 -050076])
77
Brandon Jones2b0cdcc2018-05-02 08:02:50 -070078# The EGL_ANGLE_explicit_context extension is generated differently from other extensions.
79# Toggle generation here.
80support_EGL_ANGLE_explicit_context = True
81
Jamie Madillfa920eb2018-01-04 11:45:50 -050082# This is a list of exceptions for entry points which don't want to have
83# the EVENT macro. This is required for some debug marker entry points.
84no_event_marker_exceptions_list = sorted([
85 "glPushGroupMarkerEXT",
86 "glPopGroupMarkerEXT",
87 "glInsertEventMarkerEXT",
88])
89
90# Strip these suffixes from Context entry point names. NV is excluded (for now).
Brandon Jones416aaf92018-04-10 08:10:16 -070091strip_suffixes = ["ANGLE", "EXT", "KHR", "OES", "CHROMIUM"]
Jamie Madillfa920eb2018-01-04 11:45:50 -050092
Jamie Madill2e16d962017-04-19 14:06:36 -040093template_entry_point_header = """// GENERATED FILE - DO NOT EDIT.
94// Generated by {script_name} using data from {data_source_name}.
95//
96// Copyright {year} The ANGLE Project Authors. All rights reserved.
97// Use of this source code is governed by a BSD-style license that can be
98// found in the LICENSE file.
99//
Jamie Madillc8c9a242018-01-02 13:39:00 -0500100// entry_points_gles_{annotation_lower}_autogen.h:
101// Defines the GLES {comment} entry points.
Jamie Madill2e16d962017-04-19 14:06:36 -0400102
Jamie Madillc8c9a242018-01-02 13:39:00 -0500103#ifndef LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
104#define LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400105
Jamie Madillc8c9a242018-01-02 13:39:00 -0500106{includes}
107
Jamie Madill2e16d962017-04-19 14:06:36 -0400108namespace gl
109{{
110{entry_points}
111}} // namespace gl
112
Jamie Madillc8c9a242018-01-02 13:39:00 -0500113#endif // LIBGLESV2_ENTRY_POINTS_GLES_{annotation_upper}_AUTOGEN_H_
Jamie Madill2e16d962017-04-19 14:06:36 -0400114"""
115
Jamie Madillee769dd2017-05-04 11:38:30 -0400116template_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
117// Generated by {script_name} using data from {data_source_name}.
118//
119// Copyright {year} The ANGLE Project Authors. All rights reserved.
120// Use of this source code is governed by a BSD-style license that can be
121// found in the LICENSE file.
122//
Jamie Madillc8c9a242018-01-02 13:39:00 -0500123// entry_points_gles_{annotation_lower}_autogen.cpp:
124// Defines the GLES {comment} entry points.
Jamie Madillee769dd2017-05-04 11:38:30 -0400125
Jamie Madillc8c9a242018-01-02 13:39:00 -0500126{includes}
Jamie Madillee769dd2017-05-04 11:38:30 -0400127
128namespace gl
129{{
130{entry_points}}} // namespace gl
131"""
132
133template_entry_points_enum_header = """// GENERATED FILE - DO NOT EDIT.
134// Generated by {script_name} using data from {data_source_name}.
135//
136// Copyright {year} The ANGLE Project Authors. All rights reserved.
137// Use of this source code is governed by a BSD-style license that can be
138// found in the LICENSE file.
139//
140// entry_points_enum_autogen.h:
141// Defines the GLES entry points enumeration.
142
143#ifndef LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
144#define LIBGLESV2_ENTRYPOINTSENUM_AUTOGEN_H_
145
146namespace gl
147{{
148enum class EntryPoint
149{{
150{entry_points_list}
151}};
152}} // namespace gl
153#endif // LIBGLESV2_ENTRY_POINTS_ENUM_AUTOGEN_H_
154"""
155
Brandon Jones41e59f52018-05-02 12:45:28 -0700156template_libgles_entry_point_source = """// GENERATED FILE - DO NOT EDIT.
157// Generated by {script_name} using data from {data_source_name}.
158//
159// Copyright {year} The ANGLE Project Authors. All rights reserved.
160// Use of this source code is governed by a BSD-style license that can be
161// found in the LICENSE file.
162//
163// libGLESv2.cpp: Implements the exported OpenGL ES functions.
164
165{includes}
166extern "C" {{
167{entry_points}
168}} // extern "C"
169"""
170
171template_libgles_entry_point_export = """; GENERATED FILE - DO NOT EDIT.
172; Generated by {script_name} using data from {data_source_name}.
173;
174; Copyright {year} The ANGLE Project Authors. All rights reserved.
175; Use of this source code is governed by a BSD-style license that can be
176; found in the LICENSE file.
177LIBRARY libGLESv2
178EXPORTS
179{exports}
180"""
181
Jamie Madill2e16d962017-04-19 14:06:36 -0400182template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}({params});"""
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700183template_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 -0400184
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700185template_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 -0400186{{
Geoff Langb02fc662018-08-21 09:48:01 -0400187 ANGLE_SCOPED_GLOBAL_LOCK();
Jamie Madillfa920eb2018-01-04 11:45:50 -0500188 {event_comment}EVENT("({format_params})"{comma_if_needed}{pass_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400189
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700190 Context *context = {context_getter};
Jamie Madillee769dd2017-05-04 11:38:30 -0400191 if (context)
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700192 {{{assert_explicit_context}{packed_gl_enum_conversions}
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400193 context->gatherParams<EntryPoint::{name}>({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400194
Jamie Madill53d38412017-04-20 11:33:00 -0400195 if (context->skipValidation() || Validate{name}({validate_params}))
Jamie Madillee769dd2017-05-04 11:38:30 -0400196 {{
Jamie Madillc8c9a242018-01-02 13:39:00 -0500197 {return_if_needed}context->{name_lower_no_suffix}({internal_params});
Jamie Madillee769dd2017-05-04 11:38:30 -0400198 }}
Jamie Madillee769dd2017-05-04 11:38:30 -0400199 }}
200{default_return_if_needed}}}
201"""
202
Lingfeng Yanga0648782018-03-12 14:45:25 -0700203context_gles_header = """// GENERATED FILE - DO NOT EDIT.
204// Generated by {script_name} using data from {data_source_name}.
205//
206// Copyright {year} The ANGLE Project Authors. All rights reserved.
207// Use of this source code is governed by a BSD-style license that can be
208// found in the LICENSE file.
209//
210// Context_gles_{annotation_lower}_autogen.h: Creates a macro for interfaces in Context.
211
212#ifndef ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
213#define ANGLE_CONTEXT_GLES_{annotation_upper}_AUTOGEN_H_
214
215#define ANGLE_GLES1_CONTEXT_API \\
216{interface}
217
218#endif // ANGLE_CONTEXT_API_{annotation_upper}_AUTOGEN_H_
219"""
220
221context_gles_decl = """ {return_type} {name_lower_no_suffix}({internal_params}); \\"""
222
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700223libgles_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 -0700224{{
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700225 return gl::{name}{explicit_context_suffix}({explicit_context_internal_param}{explicit_context_comma}{internal_params});
Brandon Jones41e59f52018-05-02 12:45:28 -0700226}}
227"""
228
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700229libgles_entry_point_export = """ {name}{explicit_context_suffix}{spaces}@{ordinal}"""
230
231template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
232// Generated by {script_name} using data from {data_source_name}.
233//
234// Copyright {year} The ANGLE Project Authors. All rights reserved.
235// Use of this source code is governed by a BSD-style license that can be
236// found in the LICENSE file.
237//
238// gl{version}ext_explicit_context_autogen.inc:
239// Function declarations for the EGL_ANGLE_explicit_context extension
240
241{function_pointers}
242#ifdef GL_GLEXT_PROTOTYPES
243{function_prototypes}
244#endif
245"""
246
247template_glext_function_pointer = """typedef {return_type}(GL_APIENTRYP PFN{name_upper}{explicit_context_suffix_upper})({explicit_context_param}{explicit_context_comma}{params});"""
248template_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 -0700249
Jamie Madill16daadb2017-08-26 23:34:31 -0400250def script_relative(path):
251 return os.path.join(os.path.dirname(sys.argv[0]), path)
252
253tree = etree.parse(script_relative('gl.xml'))
254root = tree.getroot()
Jamie Madill2e16d962017-04-19 14:06:36 -0400255commands = root.find(".//commands[@namespace='GL']")
Jamie Madill2e16d962017-04-19 14:06:36 -0400256
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400257with open(script_relative('entry_point_packed_gl_enums.json')) as f:
258 cmd_packed_gl_enums = json.loads(f.read())
259
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700260def format_entry_point_decl(cmd_name, proto, params, is_explicit_context):
261 comma_if_needed = ", " if len(params) > 0 else ""
Jamie Madill2e16d962017-04-19 14:06:36 -0400262 return template_entry_point_decl.format(
263 name = cmd_name[2:],
264 return_type = proto[:-len(cmd_name)],
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700265 params = ", ".join(params),
266 comma_if_needed = comma_if_needed,
267 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
268 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
269 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "")
Jamie Madill2e16d962017-04-19 14:06:36 -0400270
Jamie Madillee769dd2017-05-04 11:38:30 -0400271def type_name_sep_index(param):
272 space = param.rfind(" ")
273 pointer = param.rfind("*")
274 return max(space, pointer)
275
276def just_the_type(param):
Lingfeng Yanga0648782018-03-12 14:45:25 -0700277 if "*" in param:
278 return param[:type_name_sep_index(param) + 1]
Jamie Madillee769dd2017-05-04 11:38:30 -0400279 return param[:type_name_sep_index(param)]
280
281def just_the_name(param):
282 return param[type_name_sep_index(param)+1:]
283
Lingfeng Yanga0648782018-03-12 14:45:25 -0700284def make_param(param_type, param_name):
285 return param_type + " " + param_name
286
287def just_the_type_packed(param, entry):
288 name = just_the_name(param)
289 if entry.has_key(name):
290 return entry[name]
291 else:
292 return just_the_type(param)
293
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400294def just_the_name_packed(param, reserved_set):
295 name = just_the_name(param)
296 if name in reserved_set:
297 return name + 'Packed'
298 else:
299 return name
300
Jamie Madillee769dd2017-05-04 11:38:30 -0400301format_dict = {
302 "GLbitfield": "0x%X",
303 "GLboolean": "%u",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500304 "GLclampx": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400305 "GLenum": "0x%X",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500306 "GLfixed": "0x%X",
Jamie Madillee769dd2017-05-04 11:38:30 -0400307 "GLfloat": "%f",
308 "GLint": "%d",
309 "GLintptr": "%d",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500310 "GLshort": "%d",
Jamie Madillee769dd2017-05-04 11:38:30 -0400311 "GLsizei": "%d",
312 "GLsizeiptr": "%d",
Jamie Madill16daadb2017-08-26 23:34:31 -0400313 "GLsync": "0x%0.8p",
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500314 "GLubyte": "%d",
Jamie Madillff161f82017-08-26 23:49:10 -0400315 "GLuint": "%u",
Jamie Madillfa920eb2018-01-04 11:45:50 -0500316 "GLuint64": "%llu",
317 "GLDEBUGPROC": "0x%0.8p",
318 "GLDEBUGPROCKHR": "0x%0.8p",
319 "GLeglImageOES": "0x%0.8p",
Jamie Madillee769dd2017-05-04 11:38:30 -0400320}
321
322def param_format_string(param):
323 if "*" in param:
324 return param + " = 0x%0.8p"
325 else:
Jamie Madill16daadb2017-08-26 23:34:31 -0400326 type_only = just_the_type(param)
327 if type_only not in format_dict:
328 raise Exception(type_only + " is not a known type in 'format_dict'")
329
330 return param + " = " + format_dict[type_only]
Jamie Madillee769dd2017-05-04 11:38:30 -0400331
Jamie Madill2e29b132017-08-28 17:22:11 -0400332def default_return_value(cmd_name, return_type):
Jamie Madillee769dd2017-05-04 11:38:30 -0400333 if return_type == "void":
334 return ""
Jamie Madill2e29b132017-08-28 17:22:11 -0400335 return "GetDefaultReturnValue<EntryPoint::" + cmd_name[2:] + ", " + return_type + ">()"
Jamie Madillee769dd2017-05-04 11:38:30 -0400336
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700337def get_context_getter_function(cmd_name, is_explicit_context):
Geoff Langcae72d62017-06-01 11:53:45 -0400338 if cmd_name == "glGetError":
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700339 return "GetGlobalContext()"
340 elif is_explicit_context:
341 return "static_cast<gl::Context *>(ctx)"
Geoff Langcae72d62017-06-01 11:53:45 -0400342 else:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700343 return "GetValidGlobalContext()"
Geoff Langcae72d62017-06-01 11:53:45 -0400344
Jamie Madillfa920eb2018-01-04 11:45:50 -0500345template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marker entry points.
346 // It can interfere with the debug events being set by the caller.
347 // """
348
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700349def format_entry_point_def(cmd_name, proto, params, is_explicit_context):
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400350 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
351 internal_params = [just_the_name_packed(param, packed_gl_enums) for param in params]
352 packed_gl_enum_conversions = []
353 for param in params:
354 name = just_the_name(param)
355 if name in packed_gl_enums:
356 internal_name = name + "Packed"
357 internal_type = packed_gl_enums[name]
358 packed_gl_enum_conversions += ["\n " + internal_type + " " + internal_name +" = FromGLenum<" +
359 internal_type + ">(" + name + ");"]
360
Jamie Madillee769dd2017-05-04 11:38:30 -0400361 pass_params = [just_the_name(param) for param in params]
362 format_params = [param_format_string(param) for param in params]
363 return_type = proto[:-len(cmd_name)]
Jamie Madill2e29b132017-08-28 17:22:11 -0400364 default_return = default_return_value(cmd_name, return_type.strip())
Jamie Madillfa920eb2018-01-04 11:45:50 -0500365 event_comment = template_event_comment if cmd_name in no_event_marker_exceptions_list else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500366 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
367
Jamie Madillfa920eb2018-01-04 11:45:50 -0500368 for suffix in strip_suffixes:
369 if name_lower_no_suffix.endswith(suffix):
370 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
371
Jamie Madillee769dd2017-05-04 11:38:30 -0400372 return template_entry_point_def.format(
373 name = cmd_name[2:],
Jamie Madillc8c9a242018-01-02 13:39:00 -0500374 name_lower_no_suffix = name_lower_no_suffix,
Jamie Madillee769dd2017-05-04 11:38:30 -0400375 return_type = return_type,
376 params = ", ".join(params),
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400377 internal_params = ", ".join(internal_params),
378 packed_gl_enum_conversions = "".join(packed_gl_enum_conversions),
Jamie Madillee769dd2017-05-04 11:38:30 -0400379 pass_params = ", ".join(pass_params),
380 comma_if_needed = ", " if len(params) > 0 else "",
Corentin Wallez2e568cf2017-09-18 17:05:22 -0400381 validate_params = ", ".join(["context"] + internal_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400382 format_params = ", ".join(format_params),
Jamie Madillee769dd2017-05-04 11:38:30 -0400383 return_if_needed = "" if default_return == "" else "return ",
Geoff Langcae72d62017-06-01 11:53:45 -0400384 default_return_if_needed = "" if default_return == "" else "\n return " + default_return + ";\n",
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700385 context_getter = get_context_getter_function(cmd_name, is_explicit_context),
386 event_comment = event_comment,
387 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
388 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
389 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
390 assert_explicit_context = "\nASSERT(context == GetValidGlobalContext());"
391 if is_explicit_context else "")
Jamie Madillee769dd2017-05-04 11:38:30 -0400392
Lingfeng Yanga0648782018-03-12 14:45:25 -0700393def format_context_gles_decl(cmd_name, proto, params):
394 packed_gl_enums = cmd_packed_gl_enums.get(cmd_name, {})
395 internal_params = ", ".join([make_param(just_the_type_packed(param, packed_gl_enums),
396 just_the_name_packed(param, packed_gl_enums)) for param in params])
397
398 return_type = proto[:-len(cmd_name)]
399 name_lower_no_suffix = cmd_name[2:3].lower() + cmd_name[3:]
400
401 for suffix in strip_suffixes:
402 if name_lower_no_suffix.endswith(suffix):
403 name_lower_no_suffix = name_lower_no_suffix[0:-len(suffix)]
404
405 return context_gles_decl.format(
406 return_type = return_type,
407 name_lower_no_suffix = name_lower_no_suffix,
408 internal_params = internal_params)
409
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700410def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700411 internal_params = [just_the_name(param) for param in params]
412 return_type = proto[:-len(cmd_name)]
413
414 return libgles_entry_point_def.format(
415 name = cmd_name[2:],
416 return_type = return_type,
417 params = ", ".join(params),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700418 internal_params = ", ".join(internal_params),
419 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "",
420 explicit_context_param = "GLeglContext ctx" if is_explicit_context else "",
421 explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
422 explicit_context_internal_param = "ctx" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700423
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700424def format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context):
Brandon Jones41e59f52018-05-02 12:45:28 -0700425 return libgles_entry_point_export.format(
426 name = cmd_name,
427 ordinal = ordinal,
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700428 spaces = " "*(50 - len(cmd_name)),
429 explicit_context_suffix = "ContextANGLE" if is_explicit_context else "")
Brandon Jones41e59f52018-05-02 12:45:28 -0700430
Jiajia Qincb59a902017-11-22 13:03:42 +0800431def path_to(folder, file):
432 return os.path.join(script_relative(".."), "src", folder, file)
Jamie Madill2e16d962017-04-19 14:06:36 -0400433
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700434def get_entry_points(all_commands, gles_commands, ordinal, is_explicit_context):
Jamie Madillc8c9a242018-01-02 13:39:00 -0500435 decls = []
436 defs = []
Brandon Jones41e59f52018-05-02 12:45:28 -0700437 export_defs = []
438 exports = []
439
Jamie Madillffa2cd02017-12-28 14:57:53 -0500440 for command in all_commands:
441 proto = command.find('proto')
442 cmd_name = proto.find('name').text
443
444 if cmd_name not in gles_commands:
445 continue
446
447 param_text = ["".join(param.itertext()) for param in command.findall('param')]
448 proto_text = "".join(proto.itertext())
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700449 decls.append(format_entry_point_decl(cmd_name, proto_text, param_text,
450 is_explicit_context))
451 defs.append(format_entry_point_def(cmd_name, proto_text, param_text, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700452
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700453 export_defs.append(format_libgles_entry_point_def(cmd_name, proto_text, param_text,
454 is_explicit_context))
455 exports.append(format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context))
Brandon Jones41e59f52018-05-02 12:45:28 -0700456 ordinal = ordinal + 1
457
458 return decls, defs, export_defs, exports
Jamie Madill16daadb2017-08-26 23:34:31 -0400459
Lingfeng Yanga0648782018-03-12 14:45:25 -0700460def get_gles1_decls(all_commands, gles_commands):
461 decls = []
462 for command in all_commands:
463 proto = command.find('proto')
464 cmd_name = proto.find('name').text
465
466 if cmd_name not in gles_commands:
467 continue
468
469 if cmd_name in gles1_overloaded:
470 continue
471
472 param_text = ["".join(param.itertext()) for param in command.findall('param')]
473 proto_text = "".join(proto.itertext())
474 decls.append(format_context_gles_decl(cmd_name, proto_text, param_text))
475
476 return decls
477
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700478def get_glext_decls(all_commands, gles_commands, version, is_explicit_context):
479 glext_ptrs = []
480 glext_protos = []
481 is_gles1 = False
482
483 if(version == ""):
484 is_gles1 = True
485
486 for command in all_commands:
487 proto = command.find('proto')
488 cmd_name = proto.find('name').text
489
490 if cmd_name not in gles_commands:
491 continue
492
493 param_text = ["".join(param.itertext()) for param in command.findall('param')]
494 proto_text = "".join(proto.itertext())
495
496 return_type = proto_text[:-len(cmd_name)]
497 params = ", ".join(param_text)
498
499 format_params = {
500 "apicall": "GL_API" if is_gles1 else "GL_APICALL",
501 "name": cmd_name,
502 "name_upper": cmd_name.upper(),
503 "return_type": return_type,
504 "params": params,
505 "explicit_context_comma": ", " if is_explicit_context and len(params) > 0 else "",
506 "explicit_context_suffix": "ContextANGLE" if is_explicit_context else "",
507 "explicit_context_suffix_upper": "CONTEXTANGLE" if is_explicit_context else "",
508 "explicit_context_param": "GLeglContext ctx" if is_explicit_context else ""}
509
510 glext_ptrs.append(template_glext_function_pointer.format(
511 **format_params))
512 glext_protos.append(template_glext_function_prototype.format(
513 **format_params))
514
515 return glext_ptrs, glext_protos
516
Brandon Jones416aaf92018-04-10 08:10:16 -0700517def write_file(annotation, comment, template, entry_points, suffix, includes, file):
Jiajia Qincb59a902017-11-22 13:03:42 +0800518
Jamie Madillc8c9a242018-01-02 13:39:00 -0500519 content = template.format(
520 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700521 data_source_name = file,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500522 year = date.today().year,
523 annotation_lower = annotation.lower(),
524 annotation_upper = annotation.upper(),
525 comment = comment,
526 includes = includes,
527 entry_points = entry_points)
Jiajia Qincb59a902017-11-22 13:03:42 +0800528
Jamie Madillc8c9a242018-01-02 13:39:00 -0500529 path = path_to("libGLESv2", "entry_points_gles_{}_autogen.{}".format(
530 annotation.lower(), suffix))
531
532 with open(path, "w") as out:
533 out.write(content)
534 out.close()
535
Brandon Jones41e59f52018-05-02 12:45:28 -0700536def write_export_files(entry_points, includes, exports):
537
538 content = template_libgles_entry_point_source.format(
539 script_name = os.path.basename(sys.argv[0]),
540 data_source_name = "gl.xml and gl_angle_ext.xml",
541 year = date.today().year,
542 includes = includes,
543 entry_points = entry_points)
544
545 path = path_to("libGLESv2", "libGLESv2_autogen.cpp")
546
547 with open(path, "w") as out:
548 out.write(content)
549 out.close()
550
551 content = template_libgles_entry_point_export.format(
552 script_name = os.path.basename(sys.argv[0]),
553 data_source_name = "gl.xml and gl_angle_ext.xml",
554 exports = exports,
555 year = date.today().year)
556
557 path = path_to("libGLESv2", "libGLESv2_autogen.def")
558
559 with open(path, "w") as out:
560 out.write(content)
561 out.close()
562
Lingfeng Yanga0648782018-03-12 14:45:25 -0700563def write_context_api_decls(annotation, template, decls):
564
565 interface_lines = []
566
567 for i in decls['core']:
568 interface_lines.append(i)
569
570 for extname in sorted(decls['exts'].keys()):
571 interface_lines.append(" /* " + extname + " */ \\")
572 interface_lines.extend(decls['exts'][extname])
573
574 content = template.format(
575 annotation_lower = annotation.lower(),
576 annotation_upper = annotation.upper(),
577 script_name = os.path.basename(sys.argv[0]),
578 data_source_name = "gl.xml",
579 year = date.today().year,
580 interface = "\n".join(interface_lines))
581
582 path = path_to("libANGLE", "Context_gles_%s_autogen.h" % annotation.lower())
583
584 with open(path, "w") as out:
585 out.write(content)
586 out.close()
587
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700588def write_glext_explicit_context_inc(version, ptrs, protos):
589 folder_version = version if version != "31" else "3"
590
591 content = template_glext_explicit_context_inc.format(
592 script_name = os.path.basename(sys.argv[0]),
593 data_source_name = "gl.xml and gl_angle_ext.xml",
594 year = date.today().year,
595 version = version,
596 function_pointers = ptrs,
597 function_prototypes = protos)
598
Brandon Jones795ab712018-05-24 15:45:40 -0700599 path = os.path.join(script_relative(".."), "include", "GLES{}".format(folder_version),
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700600 "gl{}ext_explicit_context_autogen.inc".format(version))
601
602 with open(path, "w") as out:
603 out.write(content)
604 out.close()
605
Brandon Jones416aaf92018-04-10 08:10:16 -0700606def append_angle_extensions(base_root):
607 angle_ext_tree = etree.parse(script_relative('gl_angle_ext.xml'))
608 angle_ext_root = angle_ext_tree.getroot()
609
610 insertion_point = base_root.findall("./commands")[0]
611 for command in angle_ext_root.iter('commands'):
612 insertion_point.extend(command)
613
614 insertion_point = base_root.findall("./extensions")[0]
615 for extension in angle_ext_root.iter('extensions'):
616 insertion_point.extend(extension)
617 return base_root
618
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700619class GLCommandNames:
620 def __init__(self):
621 self.command_names = {}
622
623 def get_commands(self, version):
624 return self.command_names[version]
625
626 def get_all_commands(self):
627 cmd_names = []
628 # Combine all the version lists into a single list
629 for version, version_cmd_names in sorted(self.command_names.iteritems()):
630 cmd_names += version_cmd_names
631
632 return cmd_names
633
634 def add_commands(self, version, commands):
635 # Add key if it doesn't exist
636 if version not in self.command_names:
637 self.command_names[version] = []
638 # Add the commands that aren't duplicates
639 self.command_names[version] += commands
640
Brandon Jones416aaf92018-04-10 08:10:16 -0700641root = append_angle_extensions(root)
642
Jamie Madillc8c9a242018-01-02 13:39:00 -0500643all_commands = root.findall('commands/command')
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700644all_cmd_names = GLCommandNames()
Jamie Madillc8c9a242018-01-02 13:39:00 -0500645
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500646template_header_includes = """#include <GLES{major}/gl{major}{minor}.h>
Jamie Madillc8c9a242018-01-02 13:39:00 -0500647#include <export.h>"""
648
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500649template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen.h"
650
651#include "libANGLE/Context.h"
Jamie Madillc8c9a242018-01-02 13:39:00 -0500652#include "libANGLE/validationES{}{}.h"
653#include "libGLESv2/global_state.h"
654"""
655
Lingfeng Yanga0648782018-03-12 14:45:25 -0700656gles1decls = {}
657
658gles1decls['core'] = []
659gles1decls['exts'] = {}
660
Brandon Jones41e59f52018-05-02 12:45:28 -0700661libgles_ep_defs = []
662libgles_ep_exports = []
663
664ordinal_start = 1
665
Lingfeng Yanga0648782018-03-12 14:45:25 -0700666# First run through the main GLES entry points. Since ES2+ is the primary use
667# case, we go through those first and then add ES1-only APIs at the end.
668for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]:
Jamie Madillc8c9a242018-01-02 13:39:00 -0500669 annotation = "{}_{}".format(major_version, minor_version)
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500670 name_prefix = "GL_ES_VERSION_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700671
672 is_gles1 = major_version == 1
673 if is_gles1:
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500674 name_prefix = "GL_VERSION_ES_CM_"
Lingfeng Yanga0648782018-03-12 14:45:25 -0700675
Jamie Madillc8c9a242018-01-02 13:39:00 -0500676 comment = annotation.replace("_", ".")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500677 gles_xpath = ".//feature[@name='{}{}']//command".format(name_prefix, annotation)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500678 gles_commands = [cmd.attrib['name'] for cmd in root.findall(gles_xpath)]
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500679
680 # Remove commands that have already been processed
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700681 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 -0500682
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700683 all_cmd_names.add_commands(annotation, gles_commands)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500684
Brandon Jones41e59f52018-05-02 12:45:28 -0700685 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700686 all_commands, gles_commands, ordinal_start, False)
Brandon Jones41e59f52018-05-02 12:45:28 -0700687
688 # Increment the ordinal before inserting the version comment
689 ordinal_start += len(libgles_exports)
690
691 # Write the version as a comment before the first EP.
692 libgles_defs.insert(0, "\n// OpenGL ES {}.{}".format(major_version, minor_version))
693 libgles_exports.insert(0, "\n ; OpenGL ES {}.{}".format(major_version, minor_version))
694
695 libgles_ep_defs += libgles_defs
696 libgles_ep_exports += libgles_exports
Jamie Madillc8c9a242018-01-02 13:39:00 -0500697
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500698 major_if_not_one = major_version if major_version != 1 else ""
Jamie Madillc8c9a242018-01-02 13:39:00 -0500699 minor_if_not_zero = minor_version if minor_version != 0 else ""
700
701 header_includes = template_header_includes.format(
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500702 major=major_if_not_one, minor=minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500703
704 # We include the platform.h header since it undefines the conflicting MemoryBarrier macro.
705 if major_version == 3 and minor_version == 1:
706 header_includes += "\n#include \"common/platform.h\"\n"
707
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500708 source_includes = template_sources_includes.format(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700709 annotation.lower(), major_version, minor_if_not_zero)
Jamie Madillc8c9a242018-01-02 13:39:00 -0500710
711 write_file(annotation, comment, template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700712 "\n".join(decls), "h", header_includes, "gl.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500713 write_file(annotation, comment, template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700714 "\n".join(defs), "cpp", source_includes, "gl.xml")
Lingfeng Yanga0648782018-03-12 14:45:25 -0700715 if is_gles1:
716 gles1decls['core'] = get_gles1_decls(all_commands, gles_commands)
717
Jamie Madill57ae8c12017-08-30 12:14:29 -0400718
Jamie Madillfa920eb2018-01-04 11:45:50 -0500719# After we finish with the main entry points, we process the extensions.
720extension_defs = []
721extension_decls = []
722
723# Use a first step to run through the extensions so we can generate them
724# in sorted order.
725ext_data = {}
726
Lingfeng Yanga0648782018-03-12 14:45:25 -0700727for gles1ext in gles1_extensions:
728 gles1decls['exts'][gles1ext] = []
729
Jamie Madillfa920eb2018-01-04 11:45:50 -0500730for extension in root.findall("extensions/extension"):
731 extension_name = extension.attrib['name']
732 if not extension_name in supported_extensions:
733 continue
734
735 ext_cmd_names = []
736
737 # There's an extra step here to filter out 'api=gl' extensions. This
738 # is necessary for handling KHR extensions, which have separate entry
739 # point signatures (without the suffix) for desktop GL. Note that this
740 # extra step is necessary because of Etree's limited Xpath support.
741 for require in extension.findall('require'):
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500742 if 'api' in require.attrib and require.attrib['api'] != 'gles2' and require.attrib['api'] != 'gles1':
Jamie Madillfa920eb2018-01-04 11:45:50 -0500743 continue
744
745 # Another special case for EXT_texture_storage
746 filter_out_comment = "Supported only if GL_EXT_direct_state_access is supported"
747 if 'comment' in require.attrib and require.attrib['comment'] == filter_out_comment:
748 continue
749
750 extension_commands = require.findall('command')
751 ext_cmd_names += [command.attrib['name'] for command in extension_commands]
752
753 ext_data[extension_name] = sorted(ext_cmd_names)
754
755for extension_name, ext_cmd_names in sorted(ext_data.iteritems()):
756
757 # Detect and filter duplicate extensions.
758 dupes = []
759 for ext_cmd in ext_cmd_names:
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700760 if ext_cmd in all_cmd_names.get_all_commands():
Jamie Madillfa920eb2018-01-04 11:45:50 -0500761 dupes.append(ext_cmd)
762
763 for dupe in dupes:
764 ext_cmd_names.remove(dupe)
765
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700766 if extension_name in gles1_extensions:
767 all_cmd_names.add_commands("glext", ext_cmd_names)
768 else:
769 all_cmd_names.add_commands("gl2ext", ext_cmd_names)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500770
Brandon Jones41e59f52018-05-02 12:45:28 -0700771 decls, defs, libgles_defs, libgles_exports = get_entry_points(
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700772 all_commands, ext_cmd_names, ordinal_start, False)
Jamie Madillfa920eb2018-01-04 11:45:50 -0500773
774 # Avoid writing out entry points defined by a prior extension.
775 for dupe in dupes:
776 msg = "// {} is already defined.\n".format(dupe[2:])
777 defs.append(msg)
778
Brandon Jones41e59f52018-05-02 12:45:28 -0700779 # Increment starting ordinal before adding extension comment
780 ordinal_start += len(libgles_exports)
781
Jamie Madillfa920eb2018-01-04 11:45:50 -0500782 # Write the extension name as a comment before the first EP.
783 comment = "\n// {}".format(extension_name)
784 defs.insert(0, comment)
785 decls.insert(0, comment)
Brandon Jones41e59f52018-05-02 12:45:28 -0700786 libgles_defs.insert(0, comment)
787 libgles_exports.insert(0, "\n ; {}".format(extension_name))
Jamie Madillfa920eb2018-01-04 11:45:50 -0500788
789 extension_defs += defs
790 extension_decls += decls
791
Brandon Jones41e59f52018-05-02 12:45:28 -0700792 libgles_ep_defs += libgles_defs
793 libgles_ep_exports += libgles_exports
794
Lingfeng Yanga0648782018-03-12 14:45:25 -0700795 if extension_name in gles1_extensions:
796 if extension_name not in gles1_no_context_decl_extensions:
797 gles1decls['exts'][extension_name] = get_gles1_decls(all_commands, ext_cmd_names)
798
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700799# Special handling for EGL_ANGLE_explicit_context extension
800if support_EGL_ANGLE_explicit_context:
801 comment = "\n// EGL_ANGLE_explicit_context"
802 extension_defs.append(comment)
803 extension_decls.append(comment)
804 libgles_ep_defs.append(comment)
805 libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context")
806
807 # Get the explicit context entry points
808 decls, defs, libgles_defs, libgles_exports = get_entry_points(all_commands,
809 all_cmd_names.get_all_commands(), ordinal_start, True)
810
811 # Append the explicit context entry points
812 extension_decls += decls
813 extension_defs += defs
814 libgles_ep_defs += libgles_defs
815 libgles_ep_exports += libgles_exports
816
817 # Generate .inc files for extension function pointers and declarations
818 for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]:
819 annotation = "{}_{}".format(major, minor)
820
821 major_if_not_one = major if major != 1 else ""
822 minor_if_not_zero = minor if minor != 0 else ""
823 version = "{}{}".format(major_if_not_one, minor_if_not_zero)
824
825 glext_ptrs, glext_protos = get_glext_decls(all_commands,
826 all_cmd_names.get_commands(annotation), version, True)
827
828 glext_ext_ptrs = []
829 glext_ext_protos = []
830
831 # Append extensions for 1.0 and 2.0
832 if(annotation == "1_0"):
833 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
834 all_cmd_names.get_commands("glext"), version, True)
835 elif(annotation == "2_0"):
836 glext_ext_ptrs, glext_ext_protos = get_glext_decls(all_commands,
837 all_cmd_names.get_commands("gl2ext"), version, True)
838
839 glext_ptrs += glext_ext_ptrs
840 glext_protos += glext_ext_protos
841
842 write_glext_explicit_context_inc(version, "\n".join(glext_ptrs), "\n".join(glext_protos))
843
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500844header_includes = template_header_includes.format(
845 major="", minor="")
846header_includes += """
847#include <GLES/gl.h>
848#include <GLES/glext.h>
849#include <GLES2/gl2.h>
850#include <GLES2/gl2ext.h>
851"""
Jamie Madillfa920eb2018-01-04 11:45:50 -0500852
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500853source_includes = template_sources_includes.format("ext", "", "")
854source_includes += """
855#include "libANGLE/validationES.h"
856#include "libANGLE/validationES1.h"
Jamie Madillfa920eb2018-01-04 11:45:50 -0500857#include "libANGLE/validationES3.h"
858#include "libANGLE/validationES31.h"
859"""
860
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500861write_file("ext", "extension", template_entry_point_header,
Brandon Jones416aaf92018-04-10 08:10:16 -0700862 "\n".join([item for item in extension_decls]), "h", header_includes,
863 "gl.xml and gl_angle_ext.xml")
Geoff Lang2aaa7b42018-01-12 17:17:27 -0500864write_file("ext", "extension", template_entry_point_source,
Brandon Jones416aaf92018-04-10 08:10:16 -0700865 "\n".join([item for item in extension_defs]), "cpp", source_includes,
866 "gl.xml and gl_angle_ext.xml")
Jamie Madillc8c9a242018-01-02 13:39:00 -0500867
Lingfeng Yanga0648782018-03-12 14:45:25 -0700868write_context_api_decls("1_0", context_gles_header, gles1decls)
869
Brandon Jones2b0cdcc2018-05-02 08:02:50 -0700870sorted_cmd_names = ["Invalid"] + [cmd[2:] for cmd in sorted(all_cmd_names.get_all_commands())]
Jamie Madillc8c9a242018-01-02 13:39:00 -0500871
Jamie Madillee769dd2017-05-04 11:38:30 -0400872entry_points_enum = template_entry_points_enum_header.format(
873 script_name = os.path.basename(sys.argv[0]),
Brandon Jones416aaf92018-04-10 08:10:16 -0700874 data_source_name = "gl.xml and gl_angle_ext.xml",
Jamie Madillee769dd2017-05-04 11:38:30 -0400875 year = date.today().year,
Jamie Madillc8c9a242018-01-02 13:39:00 -0500876 entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names]))
Jamie Madillee769dd2017-05-04 11:38:30 -0400877
Jamie Madillee769dd2017-05-04 11:38:30 -0400878entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
Jamie Madillee769dd2017-05-04 11:38:30 -0400879with open(entry_points_enum_header_path, "w") as out:
880 out.write(entry_points_enum)
Geoff Langcae72d62017-06-01 11:53:45 -0400881 out.close()
Brandon Jones41e59f52018-05-02 12:45:28 -0700882
883source_includes = """
884#include "angle_gl.h"
885
886#include "libGLESv2/entry_points_gles_1_0_autogen.h"
887#include "libGLESv2/entry_points_gles_2_0_autogen.h"
888#include "libGLESv2/entry_points_gles_3_0_autogen.h"
889#include "libGLESv2/entry_points_gles_3_1_autogen.h"
890#include "libGLESv2/entry_points_gles_ext_autogen.h"
891
892#include "common/event_tracer.h"
893"""
894
jchen1082af6202018-06-22 10:59:52 +0800895write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes, "\n".join([item for item in libgles_ep_exports]))