From bb7c9038ddc74ba2015297bef1b2ece9616ec88c Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Tue, 5 Apr 2016 16:40:30 -0600 Subject: Change from using lxml to xml.etree Use xml.etree for xml parsing for greater portability. Change-Id: Ic9b3b487e9b363a89d134d048db9fa79fbd66f6f --- BUILD.md | 12 ------------ generator.py | 16 ++++++++++++---- reg.py | 4 ++-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/BUILD.md b/BUILD.md index f46f75c3..e3db0c0d 100644 --- a/BUILD.md +++ b/BUILD.md @@ -88,14 +88,6 @@ Windows 7+ with additional required software packages: - Ensure the pip module is installed (it should be by default) - Need python3.3 or later to get the Windows py.exe launcher that is used to get python3 rather than python2 if both are installed on Windows - 32 bit python works -- Python lxml package must be installed - - Download the lxml package from - http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml - 32-bit latest for Python 3.5 is: lxml-3.5.0-cp35-none-win32.whl - 64-bit latest for Python 3.5 is: lxml-3.5.0-cp35-none-win_amd64.whl - - The package can be installed with pip as follows: - pip install lxml-3.5.0-cp35-none-win32.whl - If pip is not in your path, you can find it at $PYTHON_HOME\Scripts\pip.exe, where PYTHON_HOME is the folder where you installed Python. - Git (from http://git-scm.com/download/win). - Note: If you use Cygwin, you can normally use Cygwin's "git.exe". However, in order to use the "update_external_sources.bat" script, you must have this version. - Tell the installer to allow it to be used for "Developer Prompt" as well as "Git Bash". @@ -175,10 +167,6 @@ export PATH=$HOME/homebrew/bin:$PATH brew install cmake brew install python brew install python3 -pip install --upgrade pip -pip install lxml -pip3.5 install --upgrade pip -pip3.5 install lxml ``` ### Build steps for Android Use the following to ensure the Android build works. diff --git a/generator.py b/generator.py index e489b5de..c2ee28e4 100644 --- a/generator.py +++ b/generator.py @@ -23,7 +23,7 @@ import os,re,sys from collections import namedtuple -from lxml import etree +import xml.etree.ElementTree as etree def write( *args, **kwargs ): file = kwargs.pop('file',sys.stdout) @@ -32,7 +32,7 @@ def write( *args, **kwargs ): file.write( end ) # noneStr - returns string argument, or "" if argument is None. -# Used in converting lxml Elements into text. +# Used in converting etree Elements into text. # str - string to convert def noneStr(str): if (str): @@ -679,7 +679,7 @@ class OutputGenerator: # For typedefs, add (APIENTRY *) around the name and # use the PFN_cmdnameproc naming convention. # Done by walking the tree for element by element. - # lxml.etree has elem.text followed by (elem[i], elem[i].tail) + # etree has elem.text followed by (elem[i], elem[i].tail) # for each child element and any following text # Leading text pdecl += noneStr(proto.text) @@ -3013,7 +3013,15 @@ class ParamCheckerOutputGenerator(OutputGenerator): #if value not in self.stypes: # print('WARNING: {} is not part of the VkStructureType enumeration [{}]'.format(value, typeName)) else: - value = '' + value = typeName + # Remove EXT + value = re.sub('EXT', '', value) + # Add underscore between lowercase then uppercase + value = re.sub('([a-z0-9])([A-Z])', r'\1_\2', value) + # Change to uppercase + value = value.upper() + # Add STRUCTURE_TYPE_ + value = re.sub('VK_', 'VK_STRUCTURE_TYPE_', value) # Store the required type value self.structTypes[typeName] = self.StructType(name=name, value=value) # diff --git a/reg.py b/reg.py index 8be9adf0..b10ebac3 100755 --- a/reg.py +++ b/reg.py @@ -22,7 +22,7 @@ # MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. import io,os,re,string,sys -from lxml import etree +import xml.etree.ElementTree as etree # matchAPIProfile - returns whether an API and profile # being generated matches an element's profile @@ -77,7 +77,7 @@ def matchAPIProfile(api, profile, elem): # required - should this feature be defined during header generation # (has it been removed by a profile or version)? # declared - has this feature been defined already? -# elem - lxml.etree Element for this feature +# elem - etree Element for this feature # resetState() - reset required/declared to initial values. Used # prior to generating a new API interface. class BaseInfo: -- cgit v1.2.3