Commit 2de70fe2 authored by José Fonseca's avatar José Fonseca

mapi/glapi: Use ElementTree instead of libxml2.

It is quite hard to meet the dependency of the libxml2 python bindings
outside Linux, and in particularly on MacOSX; whereas ElementTree is
part of Python's standard library.  ElementTree is more limited than
libxml2: no DTD verification, defaults from DTD, or XInclude support,
but none of these limitations is serious enough to justify using
libxml2.

In fact, it was easier to refactor the code to use ElementTree than to
try to get libxml2 python bindings.

In the process, gl_item_factory class was refactored so that there is
one method for each kind of object to be created, as it simplifies
things substantially.

I confirmed that precisely the same output is generated for GL/GLX/GLES.

v2: Remove m4/ax_python_module.m4 as suggested by Matt Turner.
Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
parent b761dfa0
......@@ -59,13 +59,6 @@ else:
Help(opts.GenerateHelpText(env))
# fail early for a common error on windows
if env['gles']:
try:
import libxml2
except ImportError:
raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
#######################################################################
# Environment setup
......
......@@ -54,7 +54,6 @@ AM_PROG_CC_C_O
AM_PROG_AS
AC_CHECK_PROGS([MAKE], [gmake make])
AC_CHECK_PROGS([PYTHON2], [python2 python])
AX_PYTHON_MODULE([libxml2], [needed])
AC_PROG_SED
AC_PROG_MKDIR_P
......
......@@ -36,17 +36,15 @@ Recipe
Building on windows requires several open-source packages. These are
steps that work as of this writing.
1) install python 2.7
2) install scons (latest)
3) install mingw, flex, and bison
4) install libxml2 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
get libxml2-python-2.9.1.win-amd64-py2.7.exe
5) install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
- install python 2.7
- install scons (latest)
- install mingw, flex, and bison
- install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs
get pywin32-218.4.win-amd64-py2.7.exe
6) install git
7) download mesa from git
- install git
- download mesa from git
see http://www.mesa3d.org/repository.html
8) run scons
- run scons
General
-------
......
......@@ -44,10 +44,6 @@ On Windows with MinGW, install flex and bison with:
</li>
<li>python - Python is needed for building the Gallium components.
Version 2.6.4 or later should work.
<br>
<br>
To build OpenGL ES 1.1 and 2.0 you'll also need
<a href="http://xmlsoft.org/sources/win32/python/libxml2-python-2.7.7.win32-py2.7.exe">libxml2-python</a>.
</li>
</ul>
......
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_python_module.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PYTHON_MODULE(modname[, fatal])
#
# DESCRIPTION
#
# Checks for Python module.
#
# If fatal is non-empty then absence of a module will trigger an error.
#
# LICENSE
#
# Copyright (c) 2008 Andrew Collier
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 6
AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
AC_DEFUN([AX_PYTHON_MODULE],[
if test -z $PYTHON2;
then
PYTHON2="python"
fi
PYTHON_NAME=`basename $PYTHON2`
AC_MSG_CHECKING($PYTHON_NAME module: $1)
$PYTHON2 -c "import $1" 2>/dev/null
if test $? -eq 0;
then
AC_MSG_RESULT(yes)
eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
else
AC_MSG_RESULT(no)
eval AS_TR_CPP(HAVE_PYMOD_$1)=no
#
if test -n "$2"
then
AC_MSG_ERROR(failed to find required module $1)
exit 1
fi
fi
])
......@@ -33,29 +33,27 @@ import sys, getopt, string
class glx_item_factory(gl_XML.gl_item_factory):
"""Factory to create GLX protocol oriented objects derived from gl_item."""
def create_item(self, name, element, context):
if name == "function":
return glx_function(element, context)
elif name == "enum":
return glx_enum(element, context)
elif name == "api":
return glx_api(self)
else:
return gl_XML.gl_item_factory.create_item(self, name, element, context)
def create_function(self, element, context):
return glx_function(element, context)
def create_enum(self, element, context, category):
return glx_enum(element, context, category)
def create_api(self):
return glx_api(self)
class glx_enum(gl_XML.gl_enum):
def __init__(self, element, context):
gl_XML.gl_enum.__init__(self, element, context)
def __init__(self, element, context, category):
gl_XML.gl_enum.__init__(self, element, context, category)
self.functions = {}
child = element.children
while child:
if child.type == "element" and child.name == "size":
n = child.nsProp( "name", None )
c = child.nsProp( "count", None )
m = child.nsProp( "mode", None )
for child in element.getchildren():
if child.tag == "size":
n = child.get( "name" )
c = child.get( "count" )
m = child.get( "mode", "set" )
if not c:
c = self.default_count
......@@ -70,8 +68,6 @@ class glx_enum(gl_XML.gl_enum):
if not self.functions.has_key(n):
self.functions[ n ] = [c, mode]
child = child.next
return
......@@ -120,10 +116,10 @@ class glx_function(gl_XML.gl_function):
# appears after the function that it aliases.
if not self.vectorequiv:
self.vectorequiv = element.nsProp("vectorequiv", None)
self.vectorequiv = element.get("vectorequiv")
name = element.nsProp("name", None)
name = element.get("name")
if name == self.name:
for param in self.parameters:
self.parameters_by_name[ param.name ] = param
......@@ -135,12 +131,11 @@ class glx_function(gl_XML.gl_function):
self.counter_list.append(param.counter)
child = element.children
while child:
if child.type == "element" and child.name == "glx":
rop = child.nsProp( 'rop', None )
sop = child.nsProp( 'sop', None )
vop = child.nsProp( 'vendorpriv', None )
for child in element.getchildren():
if child.tag == "glx":
rop = child.get( 'rop' )
sop = child.get( 'sop' )
vop = child.get( 'vendorpriv' )
if rop:
self.glx_rop = int(rop)
......@@ -152,12 +147,12 @@ class glx_function(gl_XML.gl_function):
self.glx_vendorpriv = int(vop)
self.glx_vendorpriv_names.append(name)
self.img_reset = child.nsProp( 'img_reset', None )
self.img_reset = child.get( 'img_reset' )
# The 'handcode' attribute can be one of 'true',
# 'false', 'client', or 'server'.
handcode = child.nsProp( 'handcode', None )
handcode = child.get( 'handcode', 'false' )
if handcode == "false":
self.server_handcode = 0
self.client_handcode = 0
......@@ -179,8 +174,6 @@ class glx_function(gl_XML.gl_function):
self.reply_always_array = gl_XML.is_attr_true( child, 'always_array' )
self.dimensions_in_reply = gl_XML.is_attr_true( child, 'dimensions_in_reply' )
child = child.next
# Do some validation of the GLX protocol information. As
# new tests are discovered, they should be added here.
......
......@@ -32,18 +32,15 @@ import string
class glx_proto_item_factory(glX_XML.glx_item_factory):
"""Factory to create GLX protocol oriented objects derived from gl_item."""
def create_item(self, name, element, context):
if name == "type":
return glx_proto_type(element, context)
else:
return glX_XML.glx_item_factory.create_item(self, name, element, context)
def create_type(self, element, context, category):
return glx_proto_type(element, context, category)
class glx_proto_type(gl_XML.gl_type):
def __init__(self, element, context):
gl_XML.gl_type.__init__(self, element, context)
def __init__(self, element, context, category):
gl_XML.gl_type.__init__(self, element, context, category)
self.glx_name = element.nsProp( "glx_name", None )
self.glx_name = element.get( "glx_name" )
return
......
This diff is collapsed.
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