CoreValidation: Moved common parts of command line build script to Utilities.
diff --git a/CMSIS/Utilities/buildutils/.gitignore b/CMSIS/Utilities/buildutils/.gitignore
new file mode 100644
index 0000000..7e99e36
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/.gitignore
@@ -0,0 +1 @@
+*.pyc
\ No newline at end of file
diff --git a/CMSIS/Utilities/buildutils/__init__.py b/CMSIS/Utilities/buildutils/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/__init__.py
diff --git a/CMSIS/Utilities/buildutils/buildcmd.py b/CMSIS/Utilities/buildutils/buildcmd.py
new file mode 100644
index 0000000..ceabe64
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/buildcmd.py
@@ -0,0 +1,43 @@
+#! python
+
+from subprocess import call, Popen
+from tempfile import TemporaryFile
+
+class BuildCmd:
+ def __init__(self):
+ self._result = -1
+ self._output = TemporaryFile(mode="r+")
+
+ def getCommand(self):
+ raise NotImplementedError
+
+ def getArguments(self):
+ return []
+
+ def getOutput(self):
+ return self._output
+
+ def getLog(self):
+ return None
+
+ def isSuccess(self):
+ return self._output == 0
+
+ def run(self):
+ cmd = [ self.getCommand() ] + self.getArguments()
+ print "Running: " + ' '.join(cmd)
+ try:
+ self._result = call(cmd, stdout = self._output)
+ except:
+ print "Fatal error!"
+ self._output.seek(0)
+ print self._output.read()
+
+ logfile = self.getLog()
+ if logfile != None:
+ print logfile.read()
+
+ print "Command returned: {0}".format(self._result)
+
+ return self._result
+
\ No newline at end of file
diff --git a/CMSIS/Utilities/buildutils/dircmd.py b/CMSIS/Utilities/buildutils/dircmd.py
new file mode 100644
index 0000000..5a0f211
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/dircmd.py
@@ -0,0 +1,13 @@
+#! python
+
+from buildcmd import BuildCmd
+
+class DirCmd(BuildCmd):
+
+ def __init__(self):
+ BuildCmd.__init__(self)
+
+ def getCommand(self):
+ return "dir"
+
+
\ No newline at end of file
diff --git a/CMSIS/Utilities/buildutils/fvpcmd.py b/CMSIS/Utilities/buildutils/fvpcmd.py
new file mode 100644
index 0000000..d3a4d94
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/fvpcmd.py
@@ -0,0 +1,25 @@
+#! python
+
+from buildcmd import BuildCmd
+
+class FvpCmd(BuildCmd):
+
+ def __init__(self, model, app, **args):
+ BuildCmd.__init__(self)
+ self._model = model
+ self._app = app
+ self._args = args
+
+ def getCommand(self):
+ return self._model
+
+ def getArguments(self):
+ args = []
+ if self._args.has_key('limit'): args += [ "--cyclelimit", self._args['limit'] ]
+ if self._args.has_key('config'): args += [ "-f", self._args['config'] ]
+ if self._args.has_key('target'):
+ args += [ "-a", "{0}={1}".format(self._args['target'], self._app ) ]
+ else:
+ args += [ self._app ]
+ return args
+
\ No newline at end of file
diff --git a/CMSIS/Utilities/buildutils/testresult.py b/CMSIS/Utilities/buildutils/testresult.py
new file mode 100644
index 0000000..6e24d6d
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/testresult.py
@@ -0,0 +1,40 @@
+#! python
+
+import shutil
+from StringIO import StringIO
+from xml.etree import ElementTree
+
+class TestResult:
+
+ def _extractXml(self, log, xml):
+ dump = False
+ log.seek(0)
+ for line in log:
+ if dump:
+ xml.write(line)
+ if line.strip() == '</report>':
+ dump = False
+ else:
+ if line.strip() == '<?xml version="1.0"?>':
+ dump = True
+ xml.write(line)
+
+ def __init__(self, log):
+ self._xml = StringIO()
+ self._extractXml(log, self._xml)
+ self._xml.seek(0)
+
+ report = ElementTree.parse(self._xml).getroot()
+ summary = report[0].findall('summary')[0]
+ self._tests = summary.find('tcnt').text
+ self._executed = summary.find('exec').text
+ self._passed = summary.find('pass').text
+ self._failed = summary.find('fail').text
+
+ def saveXml(self, filename):
+ with open(filename, "w") as file:
+ self._xml.seek(0)
+ shutil.copyfileobj(self._xml, file)
+
+ def getSummary(self):
+ return self._tests, self._executed, self._passed, self._failed
\ No newline at end of file
diff --git a/CMSIS/Utilities/buildutils/uv4cmd.py b/CMSIS/Utilities/buildutils/uv4cmd.py
new file mode 100644
index 0000000..8c7f932
--- /dev/null
+++ b/CMSIS/Utilities/buildutils/uv4cmd.py
@@ -0,0 +1,29 @@
+#! python
+
+from buildcmd import BuildCmd
+from string import maketrans
+from datetime import datetime
+import mmap
+
+class Uv4Cmd(BuildCmd):
+
+ def __init__(self, project, config):
+ BuildCmd.__init__(self)
+ self._project = project
+ self._config = config
+ self._log = "UV4_{0}_{1}.log".format(self._config.translate(maketrans(" ", "_"), "()[],"), datetime.now().strftime("%Y%m%d%H%M%S"))
+
+ def getCommand(self):
+ return "UV4.exe"
+
+ def getArguments(self):
+ return [ "-t", self._config, "-cr", self._project, "-j0", "-o", self._log ]
+
+ def isSuccess(self):
+ return self._result <= 1
+
+ def getLog(self):
+ try:
+ return open(self._log, "r")
+ except:
+ return None