Commit dfaccbc0 by Jamie Madill Committed by Commit Bot

Clean up Windows DEF file generation.

Ordinal numbers weren't necessary. It's a legacy function from Win16. Also refactor the def file generator to be much simpler. Will be helpful for adding the libGLESv2 EGL entry points to the DEF files. This will enable loading the right GLES libs on Linux and Mac once we break the link dependency of libEGL on libGLESv2. Bug: angleproject:2871 Bug: angleproject:2621 Change-Id: Ia2585323b076446af55359d875a6b67bcdc4d6f9 Reviewed-on: https://chromium-review.googlesource.com/c/1372378 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 828c5946
......@@ -170,18 +170,6 @@ extern "C" {{
}} // extern "C"
"""
template_libgles_entry_point_export = """; GENERATED FILE - DO NOT EDIT.
; Generated by {script_name} using data from {data_source_name}.
;
; Copyright {year} The ANGLE Project Authors. All rights reserved.
; Use of this source code is governed by a BSD-style license that can be
; found in the LICENSE file.
LIBRARY libGLESv2
EXPORTS
{exports}
"""
template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}({params});"""
template_entry_point_decl = """ANGLE_EXPORT {return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params});"""
template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_suffix}({explicit_context_param}{explicit_context_comma}{params})
......@@ -226,8 +214,6 @@ libgles_entry_point_def = """{return_type}GL_APIENTRY gl{name}{explicit_context_
}}
"""
libgles_entry_point_export = """ {name}{explicit_context_suffix}{spaces}@{ordinal}"""
template_glext_explicit_context_inc = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
......@@ -323,6 +309,17 @@ template_event_comment = """// Don't run an EVENT() macro on the EXT_debug_marke
template_validation_proto = "bool Validate%s(%s);"
template_windows_def_file = """; GENERATED FILE - DO NOT EDIT.
; Generated by {script_name} using data from {data_source_name}.
;
; Copyright {year} The ANGLE Project Authors. All rights reserved.
; Use of this source code is governed by a BSD-style license that can be
; found in the LICENSE file.
LIBRARY {lib}
EXPORTS
{exports}
"""
def script_relative(path):
return os.path.join(os.path.dirname(sys.argv[0]), path)
......@@ -490,13 +487,6 @@ def format_libgles_entry_point_def(cmd_name, proto, params, is_explicit_context)
explicit_context_comma = ", " if is_explicit_context and len(params) > 0 else "",
explicit_context_internal_param = "ctx" if is_explicit_context else "")
def format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context):
return libgles_entry_point_export.format(
name = cmd_name,
ordinal = ordinal,
spaces = " "*(50 - len(cmd_name)),
explicit_context_suffix = "ContextANGLE" if is_explicit_context else "")
def format_validation_proto(cmd_name, params):
internal_params = get_internal_params(cmd_name, ["Context *context"] + params)
return template_validation_proto % (cmd_name[2:], internal_params)
......@@ -504,11 +494,10 @@ def format_validation_proto(cmd_name, params):
def path_to(folder, file):
return os.path.join(script_relative(".."), "src", folder, file)
def get_entry_points(all_commands, gles_commands, ordinal, is_explicit_context):
def get_entry_points(all_commands, gles_commands, is_explicit_context):
decls = []
defs = []
export_defs = []
exports = []
validation_protos = []
for command in all_commands:
......@@ -526,12 +515,10 @@ def get_entry_points(all_commands, gles_commands, ordinal, is_explicit_context):
export_defs.append(format_libgles_entry_point_def(cmd_name, proto_text, param_text,
is_explicit_context))
exports.append(format_libgles_entry_point_export(cmd_name, ordinal, is_explicit_context))
ordinal = ordinal + 1
validation_protos.append(format_validation_proto(cmd_name, param_text))
return decls, defs, export_defs, exports, validation_protos
return decls, defs, export_defs, validation_protos
def get_gles1_decls(all_commands, gles_commands):
decls = []
......@@ -591,7 +578,6 @@ def get_glext_decls(all_commands, gles_commands, version, is_explicit_context):
return glext_ptrs, glext_protos
def write_file(annotation, comment, template, entry_points, suffix, includes, file):
content = template.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = file,
......@@ -609,8 +595,7 @@ def write_file(annotation, comment, template, entry_points, suffix, includes, fi
out.write(content)
out.close()
def write_export_files(entry_points, includes, exports):
def write_export_files(entry_points, includes):
content = template_libgles_entry_point_source.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml and gl_angle_ext.xml",
......@@ -624,20 +609,7 @@ def write_export_files(entry_points, includes, exports):
out.write(content)
out.close()
content = template_libgles_entry_point_export.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = "gl.xml and gl_angle_ext.xml",
exports = exports,
year = date.today().year)
path = path_to("libGLESv2", "libGLESv2_autogen.def")
with open(path, "w") as out:
out.write(content)
out.close()
def write_context_api_decls(annotation, template, decls):
interface_lines = []
for i in decls['core']:
......@@ -694,6 +666,24 @@ def write_validation_header(annotation, comment, protos):
out.write(content)
out.close()
def write_windows_def_file(data_source_name, lib, exports):
content = template_windows_def_file.format(
script_name = os.path.basename(sys.argv[0]),
data_source_name = data_source_name,
exports = "\n".join(exports),
year = date.today().year,
lib = lib)
path = path_to(lib, "%s_autogen.def" % lib)
with open(path, "w") as out:
out.write(content)
out.close()
def get_exports(commands, suffix = ""):
return [" %s%s" % (cmd, suffix) for cmd in sorted(commands)]
def append_angle_extensions(base_root):
angle_ext_tree = etree.parse(script_relative('gl_angle_ext.xml'))
angle_ext_root = angle_ext_tree.getroot()
......@@ -742,8 +732,6 @@ gles1decls['exts'] = {}
libgles_ep_defs = []
libgles_ep_exports = []
ordinal_start = 1
# First run through the main GLES entry points. Since ES2+ is the primary use
# case, we go through those first and then add ES1-only APIs at the end.
for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]:
......@@ -763,18 +751,15 @@ for major_version, minor_version in [[2, 0], [3, 0], [3, 1], [1, 0]]:
all_cmd_names.add_commands(annotation, gles_commands)
decls, defs, libgles_defs, libgles_exports, validation_protos = get_entry_points(
all_commands, gles_commands, ordinal_start, False)
# Increment the ordinal before inserting the version comment
ordinal_start += len(libgles_exports)
decls, defs, libgles_defs, validation_protos = get_entry_points(
all_commands, gles_commands, False)
# Write the version as a comment before the first EP.
libgles_defs.insert(0, "\n// OpenGL ES {}.{}".format(major_version, minor_version))
libgles_exports.insert(0, "\n ; OpenGL ES {}.{}".format(major_version, minor_version))
libgles_defs.insert(0, "\n// OpenGL ES %s" % comment)
libgles_ep_exports.append("\n ; OpenGL ES %s" % comment)
libgles_ep_defs += libgles_defs
libgles_ep_exports += libgles_exports
libgles_ep_exports += get_exports(gles_commands)
major_if_not_one = major_version if major_version != 1 else ""
minor_if_not_zero = minor_version if minor_version != 0 else ""
......@@ -855,23 +840,20 @@ for extension_name, ext_cmd_names in sorted(ext_data.iteritems()):
else:
all_cmd_names.add_commands("gl2ext", ext_cmd_names)
decls, defs, libgles_defs, libgles_exports, validation_protos = get_entry_points(
all_commands, ext_cmd_names, ordinal_start, False)
decls, defs, libgles_defs, validation_protos = get_entry_points(
all_commands, ext_cmd_names, False)
# Avoid writing out entry points defined by a prior extension.
for dupe in dupes:
msg = "// {} is already defined.\n".format(dupe[2:])
defs.append(msg)
# Increment starting ordinal before adding extension comment
ordinal_start += len(libgles_exports)
# Write the extension name as a comment before the first EP.
comment = "\n// {}".format(extension_name)
defs.insert(0, comment)
decls.insert(0, comment)
libgles_defs.insert(0, comment)
libgles_exports.insert(0, "\n ; {}".format(extension_name))
libgles_ep_exports.append("\n ; %s" % extension_name)
extension_defs += defs
extension_decls += decls
......@@ -879,7 +861,7 @@ for extension_name, ext_cmd_names in sorted(ext_data.iteritems()):
ext_validation_protos += [comment] + validation_protos
libgles_ep_defs += libgles_defs
libgles_ep_exports += libgles_exports
libgles_ep_exports += get_exports(ext_cmd_names)
if extension_name in gles1_extensions:
if extension_name not in gles1_no_context_decl_extensions:
......@@ -893,15 +875,17 @@ if support_EGL_ANGLE_explicit_context:
libgles_ep_defs.append(comment)
libgles_ep_exports.append("\n ; EGL_ANGLE_explicit_context")
cmds = all_cmd_names.get_all_commands()
# Get the explicit context entry points
decls, defs, libgles_defs, libgles_exports, validation_protos = get_entry_points(
all_commands, all_cmd_names.get_all_commands(), ordinal_start, True)
decls, defs, libgles_defs, validation_protos = get_entry_points(
all_commands, cmds, True)
# Append the explicit context entry points
extension_decls += decls
extension_defs += defs
libgles_ep_defs += libgles_defs
libgles_ep_exports += libgles_exports
libgles_ep_exports += get_exports(cmds, "ContextANGLE")
# Generate .inc files for extension function pointers and declarations
for major, minor in [[2, 0], [3, 0], [3, 1], [1, 0]]:
......@@ -983,4 +967,7 @@ source_includes = """
#include "common/event_tracer.h"
"""
write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes, "\n".join([item for item in libgles_ep_exports]))
write_export_files("\n".join([item for item in libgles_ep_defs]), source_includes)
everything = "Khronos and ANGLE XML files"
write_windows_def_file(everything, "libGLESv2", libgles_ep_exports)
......@@ -52,7 +52,7 @@
"GL entry point:scripts/entry_point_packed_gl_enums.json":
"0554a67f70407e82c872010014721099",
"GL entry point:scripts/generate_entry_points.py":
"de1438d762e9c737c5addc77769ad55d",
"460bbd980ec533628c5866142d22214d",
"GL entry point:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"GL entry point:scripts/gl_angle_ext.xml":
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment