summaryrefslogtreecommitdiff
path: root/Tools/Python/buildgen/XmlRoutines.py
diff options
context:
space:
mode:
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-22 09:59:07 +0000
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2007-01-22 09:59:07 +0000
commit2897231803d9d506f7cb7c68eeb59dcc4805084d (patch)
treeb0037ca2ff28fcb45f143987bb1168e937f0b237 /Tools/Python/buildgen/XmlRoutines.py
parent41ac48e930170db72a0c764b7b81c7a81c1f4ba7 (diff)
downloadedk2-platforms-2897231803d9d506f7cb7c68eeb59dcc4805084d.tar.xz
Python script for generating build files for platform and modules, which uses the enhanced XmlRoutines.py written by Bruce.
The functionalities include: - parse all packages(.spd) and modules(.msa) - parse active platform(.fpd). You must set active platform in target.txt otherwise nothing will be parsed. - parse tools_def.txt and target.txt - generate Ant build files for active platform and its modules. The generated build file is re-designed and can be called separately once generated. - multi-thread build The functionalities which haven't been implemented include: - AutoGen. No AutoGen.h and AutoGen.c will be generated. If you want run the build file, you have to run the "build" command in advance to generate the AutoGen.h/.c files and remove the any other intermediate files. - generate FFS and FV files. Only compiling will be done by the generated build file. Usage: - type "python ${WORKSPACE}/Tools/Python/buildgen/BuildFile.py" in shell to generate build file - goto "${WORKSPACE}/Build/${platform}/${target}_${toolchaintag}/", type "ant" to run the build file git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2278 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Python/buildgen/XmlRoutines.py')
-rw-r--r--Tools/Python/buildgen/XmlRoutines.py104
1 files changed, 104 insertions, 0 deletions
diff --git a/Tools/Python/buildgen/XmlRoutines.py b/Tools/Python/buildgen/XmlRoutines.py
new file mode 100644
index 0000000000..8d659c4372
--- /dev/null
+++ b/Tools/Python/buildgen/XmlRoutines.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2007, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+"""This is an XML API that uses a syntax similar to XPath, but it is written in
+ standard python so that no extra python packages are required to use it."""
+
+import xml.dom.minidom
+
+def XmlList(Dom, String):
+ """Get a list of XML Elements using XPath style syntax."""
+ if String == "" or Dom == None or not isinstance(Dom, xml.dom.Node):
+ return []
+
+ if String[0] == "/":
+ String = String[1:]
+
+ if Dom.nodeType==Dom.DOCUMENT_NODE:
+ Dom = Dom.documentElement
+
+ tagList = String.split('/')
+ nodes = [Dom]
+ childNodes = []
+ index = 0
+ end = len(tagList) - 1
+ while index <= end:
+ for node in nodes:
+ if node.nodeType == node.ELEMENT_NODE and node.tagName == tagList[index]:
+ if index < end:
+ childNodes.extend(node.childNodes)
+ else:
+ childNodes.append(node)
+
+ nodes = childNodes
+ childNodes = []
+ index += 1
+
+ return nodes
+
+def XmlElement (Dom, String):
+ """Return a single element that matches the String which is XPath style syntax."""
+ if String == "" or Dom == None or not isinstance(Dom, xml.dom.Node):
+ return ""
+
+ if String[0] == "/":
+ String = String[1:]
+
+ if Dom.nodeType==Dom.DOCUMENT_NODE:
+ Dom = Dom.documentElement
+
+ tagList = String.split('/')
+ childNodes = [Dom]
+ index = 0
+ end = len(tagList) - 1
+ while index <= end:
+ for node in childNodes:
+ if node.nodeType == node.ELEMENT_NODE and node.tagName == tagList[index]:
+ if index < end:
+ childNodes = node.childNodes
+ else:
+ return node
+ break
+
+ index += 1
+
+ return ""
+
+def XmlElementData (Dom):
+ """Get the text for this element."""
+ if Dom == None or Dom == '' or Dom.firstChild == None:
+ return ''
+
+ return Dom.firstChild.data.strip(' ')
+
+def XmlAttribute (Dom, String):
+ """Return a single attribute that named by String."""
+ if Dom == None or Dom == '':
+ return ''
+
+ try:
+ return Dom.getAttribute(String).strip(' ')
+ except:
+ return ''
+
+def XmlTopTag(Dom):
+ """Return the name of the Root or top tag in the XML tree."""
+ if Dom == None or Dom == '' or Dom.firstChild == None:
+ return ''
+ return Dom.firstChild.nodeName
+
+
+# This acts like the main() function for the script, unless it is 'import'ed into another
+# script.
+if __name__ == '__main__':
+
+ # Nothing to do here. Could do some unit tests.
+ pass