add some regex to parse status information.
authorJohn Kern <johnk@symbian.org>
Thu, 03 Sep 2009 16:31:30 -0700
changeset 2 6894bf2709c0
parent 1 8e9c5760ce6f
child 3 e6d1a78b6db9
add some regex to parse status information.
BuildLogViewer/AtAGlance.cpp
BuildLogViewer/BuildStatus.cpp
BuildLogViewer/BuildStatus.h
BuildLogViewer/Makefile
BuildLogViewer/Makefile.Debug
BuildLogViewer/Makefile.Release
BuildLogViewer/readme.txt
BuildLogViewer/test_data/build_log_232.xml
--- a/BuildLogViewer/AtAGlance.cpp	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/AtAGlance.cpp	Thu Sep 03 16:31:30 2009 -0700
@@ -7,6 +7,7 @@
 
 #include <QtGlobal>
 #include <QRegExp>
+#include <QStringList>
 
 #include <QGridLayout>
 #include <QLabel>
@@ -52,6 +53,7 @@
 {
     this->traveAndPopulate(m_log->documentElement());
 }
+
 void AtAGlance::traveAndPopulate(QDomElement e)
 {
     QString name = e.tagName();
@@ -67,25 +69,58 @@
     {
         // example
         // System Definition file sf/app/organizer/package_definition.xml
-        QRegExp re("^System Definition file .*package_definition.*$");
+        QRegExp re("System*package_definition.xml");
         re.setPatternSyntax(QRegExp::Wildcard);
 
-        string blah = e.text().toStdString();
-
         if (re.exactMatch( e.text() ) )
         {
-            std::cout << "info: " << e.text().toStdString()<< std::endl;
+            QRegExp reToken("*package_definition.xml");
+            // Which regex syntax should be used? Wildcard is ...
+            reToken.setPatternSyntax(QRegExp::Wildcard);
+
+            QStringList tokens = e.text().split(" ");
+            QStringList::const_iterator constIterator;
+            for (constIterator = tokens.constBegin();
+                    constIterator != tokens.constEnd();
+                    ++constIterator)
+            {
+                if (reToken.exactMatch(*constIterator))
+                {
+                    m_buildStatus->setName((*constIterator).toLocal8Bit().constData());
+                }
+            }
         }
     }
 
     // if this is a status tag and the exit attribute is failed, the build failed.
     if (name.compare("status",Qt::CaseInsensitive)== 0 )
     {
-        m_buildStatus->setStatus(false);
+        QString rc = e.attribute("exit");
+        if (!rc.isEmpty() && (rc.compare("failed", Qt::CaseInsensitive) == 0))
+        {
+            m_buildStatus->setStatus(false);
+        }
+    }
+
+    // unforunately, the build log isn't valid xml.  The recipe tag often contains
+    // trace output from a shell program in addition to the status tag.  Sigh.
+    // So this condition looks for the status tag in the body for the recipe tag.
+    // here is what the status tag should look like:
+    //   <status exit='ok' attempt='1' />
+    if (name.compare("recipe",Qt::CaseInsensitive)== 0 )
+    {
+        QRegExp re("*status exit*fail*");
+        re.setPatternSyntax(QRegExp::Wildcard); 
+        if (re.exactMatch(e.text()))
+        {
+            m_buildStatus->setStatus(false);
+        }
     }
 
     QString text_debug;
     QDomElement e1 = e.firstChild().toElement();
+    name = e1.tagName();
+    text_debug = e1.text();
     while(!e1.isNull())
     {
         this->traveAndPopulate(e1);
@@ -100,6 +135,9 @@
     QGridLayout *layout = new QGridLayout(this);
 
     layout->addWidget(new QLabel("What: "), 1, 1);
+    layout->addWidget(new QLabel(*m_buildStatus->name()),1,2);
     layout->addWidget(new QLabel("When: "), 2, 1);
+    layout->addWidget(new QLabel(m_buildStatus->time()) ,2,2);
     layout->addWidget(new QLabel("Status: "), 3, 1);
+    layout->addWidget(new QLabel(*m_buildStatus->status()),3,2);
 }
--- a/BuildLogViewer/BuildStatus.cpp	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/BuildStatus.cpp	Thu Sep 03 16:31:30 2009 -0700
@@ -3,15 +3,17 @@
 BuildStatus::BuildStatus(QObject *parent)
 {
     setParent(parent);
+    this->m_packageName = new QString("<unknown>");
+    this->m_PresentStatus = new QString("Pass");
+    this->m_status = true;
 }
 
 void BuildStatus::setTime(QDateTime w)
 {
     this->m_when = w;
-    this->m_status = true;
 }
 
-QString BuildStatus::Time()
+QString BuildStatus::time()
 {
     return this->m_when.toString();
 }
@@ -26,7 +28,22 @@
     m_packageName = new QString(n);
 }
 
-QString BuildStatus::name()
+const QString *BuildStatus::name()
+{
+    return m_packageName;
+}
+
+void BuildStatus::setStatus (bool n )
 {
-    return *m_packageName;
+    m_status = n ;
+    if (!m_status)
+    {
+        this->m_PresentStatus = new QString("Failed");
+    }
 }
+
+
+const QString  *BuildStatus::status()
+{
+    return this->m_PresentStatus;
+}
--- a/BuildLogViewer/BuildStatus.h	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/BuildStatus.h	Thu Sep 03 16:31:30 2009 -0700
@@ -10,15 +10,15 @@
     BuildStatus(QObject *parent = 0);
 
     void setName(QString n);
-    QString name();
+    const QString *name();
 
     void setTime(QDateTime w);
-    QString Time();
+    QString time();
 
-    void setStatus (bool n ) { m_status = n ; } ;
+    void setStatus (bool n );
+    const QString *status();
 
-
-
+private:
     // What was the name of the package?
     QString *m_packageName;
     // At this time, the symbain build log doesn't have a timestamp in it.
@@ -26,6 +26,7 @@
     QDateTime m_when;
     // Did the build succeed?
     bool m_status;
+    QString *m_PresentStatus;
 };
 
 #endif // BUILDSTATUS_H
--- a/BuildLogViewer/Makefile	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/Makefile	Thu Sep 03 16:31:30 2009 -0700
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: BuildLogViewer
-# Generated by qmake (2.01a) (Qt 4.5.2) on: Wed Sep 2 11:10:47 2009
+# Generated by qmake (2.01a) (Qt 4.5.2) on: Thu Sep 3 07:51:16 2009
 # Project:  BuildLogViewer.pro
 # Template: app
 # Command: c:\Qt\2009.03\qt\bin\qmake.exe -spec ..\..\..\Qt\2009.03\qt\mkspecs\win32-g++ -win32 -o Makefile BuildLogViewer.pro
--- a/BuildLogViewer/Makefile.Debug	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/Makefile.Debug	Thu Sep 03 16:31:30 2009 -0700
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: BuildLogViewer
-# Generated by qmake (2.01a) (Qt 4.5.2) on: Wed Sep 2 11:10:46 2009
+# Generated by qmake (2.01a) (Qt 4.5.2) on: Thu Sep 3 07:51:16 2009
 # Project:  BuildLogViewer.pro
 # Template: app
 #############################################################################
--- a/BuildLogViewer/Makefile.Release	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/Makefile.Release	Thu Sep 03 16:31:30 2009 -0700
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: BuildLogViewer
-# Generated by qmake (2.01a) (Qt 4.5.2) on: Wed Sep 2 11:10:47 2009
+# Generated by qmake (2.01a) (Qt 4.5.2) on: Thu Sep 3 07:51:16 2009
 # Project:  BuildLogViewer.pro
 # Template: app
 #############################################################################
--- a/BuildLogViewer/readme.txt	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/readme.txt	Thu Sep 03 16:31:30 2009 -0700
@@ -2,17 +2,4 @@
 
 To test it out. build it with Qt Creator.  Launch it and open one of the xml files in the test_data directory. 
 
-$ hg push
-pushing to http://developer.symbian.org/oss/FCL/interim/contrib/QtExamples
-searching for changes
-http authorization required
-realm: Symbian Foundation
-user: johnk
-password:
-abort: HTTP Error 502: Bad Gateway
-
-JohnK@PC213502752220 /cygdrive/c/workspace/QtExamples
-$ hg push
-pushing to http://developer.symbian.org/oss/FCL/interim/contrib/QtExamples
-searching for changes
-no changes found
\ No newline at end of file
+Build output, in general, isn't valid xml as it must record all output to be useful. You may find trace output from scripts 
\ No newline at end of file
--- a/BuildLogViewer/test_data/build_log_232.xml	Wed Sep 02 19:04:26 2009 -0700
+++ b/BuildLogViewer/test_data/build_log_232.xml	Thu Sep 03 16:31:30 2009 -0700
@@ -1,6 +1,41 @@
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <buildlog sbs_version="2.5.2 [2009-03-06 release]" xmlns="http://symbian.com/xml/build/log" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symbian.com/xml/build/log http://symbian.com/xml/build/log/1_0.xsd">
-<info>System Definition file sf/app/organizer/package_definition.xml</info>
+<status exit='failed' attempt='1' />
+<recipe name='extension_makefile' target='c1a066120fdf384da03453f2e7613ef4_MAKMAKE' host='PC213502752220' layer='app' component='organizer' bldinf='Z:/sf/app/organizer/group/bld.inf' mmp='' config='winscw_udeb' platform='WINSCW' phase='ALL' source=''>
+<![CDATA[
++ EPOCROOT=z:
++ PLATFORM=WINSCW
++ TO_ROOT=
++ TO_BLDINF=Z:/sf/app/organizer/group
++ EPOCBLD=z:/epoc32/build/organizer/c_87eda37825f2ef06
++ CFG=udeb
++ RMDIR=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rmdir.exe
++ RM=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rm.exe
++ ERASE=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rm.exe
++ MKDIR=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/mkdir.exe
++ CP=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/cp.exe
++ MAKEFILENAME=
++ DIRECTORY=Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group
++ EXTMAKEFILENAME=indevicesearchicons.mk
++ DEPENDENCIES=
++ TOOL=
++ RVCT22LIB=
++ RVCT22INC=
++ RVCT22BIN=
++ MAKEVAR='"z:/epoc32/tools/make.exe"'
++ EXTMAKEFILETARGET=MAKMAKE
++ export 'EPOCROOT=z:\'
++ EPOCROOT='z:\'
++ export CFG=UDEB
++ CFG=UDEB
++ z:/epoc32/tools/make.exe -C 'Z:\sf\app\organizer\searchui\searchapp\plugins\indevicesearch\group' -f indevicesearchicons.mk CFG=UDEB 'EPOCBLD=z:\epoc32\build\organizer\c_87eda37825f2ef06' 'TO_BLDINF=Z:\sf\app\organizer\group' PLATFORM=WINSCW MAKMAKE
+z:\epoc32\tools\make.exe[1]: Entering directory `Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group'
+z:\epoc32\tools\make.exe[1]: Leaving directory `Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group'
+]]><time start='1250789969.765625000' elapsed='0.166' />
++ RV=0
++ set +x
+<status exit='failed' attempt='1' />
+</recipe>
 <info>sbs: version 2.5.2 [2009-03-06 release]
 </info>
 <info>SBS_HOME C:/Symbian/Tools/PDT_1.0/raptor</info>
@@ -52,6 +87,7 @@
 <info>updating configuration make with variant last</info>
 <info>Buildable configuration 'winscw_udeb'</info>
 <info>Buildable configuration 'winscw_urel'</info>
+<info>System Definition file sf/app/organizer/package_definition.xml</info>
 <info>Found 6 bld.inf references in sf/app/organizer/package_definition.xml within 1 layers:</info>
 <info>	app</info>
 <info>Found 6 bld.inf references in layer "app"</info>
@@ -622,41 +658,6 @@
 <info>NOT generating CLEAN targets as no CLEAN target was requested </info>
 <info>NOT generating WHAT targets as WHAT target not requested </info>
 <warning project='Z:/sf/app/organizer/calendarengines/caldav/group/CalDavClient.mmp' component='Z:/sf/app/organizer/group/bld.inf'>Unfrozen Exports in build for winscw/udeb</warning> 
-<recipe name='extension_makefile' target='c1a066120fdf384da03453f2e7613ef4_MAKMAKE' host='PC213502752220' layer='app' component='organizer' bldinf='Z:/sf/app/organizer/group/bld.inf' mmp='' config='winscw_udeb' platform='WINSCW' phase='ALL' source=''>
-<![CDATA[
-+ EPOCROOT=z:
-+ PLATFORM=WINSCW
-+ TO_ROOT=
-+ TO_BLDINF=Z:/sf/app/organizer/group
-+ EPOCBLD=z:/epoc32/build/organizer/c_87eda37825f2ef06
-+ CFG=udeb
-+ RMDIR=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rmdir.exe
-+ RM=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rm.exe
-+ ERASE=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/rm.exe
-+ MKDIR=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/mkdir.exe
-+ CP=C:/Symbian/Tools/PDT_1.0/raptor/win32/cygwin/bin/cp.exe
-+ MAKEFILENAME=
-+ DIRECTORY=Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group
-+ EXTMAKEFILENAME=indevicesearchicons.mk
-+ DEPENDENCIES=
-+ TOOL=
-+ RVCT22LIB=
-+ RVCT22INC=
-+ RVCT22BIN=
-+ MAKEVAR='"z:/epoc32/tools/make.exe"'
-+ EXTMAKEFILETARGET=MAKMAKE
-+ export 'EPOCROOT=z:\'
-+ EPOCROOT='z:\'
-+ export CFG=UDEB
-+ CFG=UDEB
-+ z:/epoc32/tools/make.exe -C 'Z:\sf\app\organizer\searchui\searchapp\plugins\indevicesearch\group' -f indevicesearchicons.mk CFG=UDEB 'EPOCBLD=z:\epoc32\build\organizer\c_87eda37825f2ef06' 'TO_BLDINF=Z:\sf\app\organizer\group' PLATFORM=WINSCW MAKMAKE
-z:\epoc32\tools\make.exe[1]: Entering directory `Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group'
-z:\epoc32\tools\make.exe[1]: Leaving directory `Z:/sf/app/organizer/searchui/searchapp/plugins/indevicesearch/group'
-]]><time start='1250789969.765625000' elapsed='0.166' />
-+ RV=0
-+ set +x
-<status exit='ok' attempt='1' />
-</recipe>
 <recipe name='extension_makefile' target='01c417b2e14b8cdf8b96c81af187c4f3_MAKMAKE' host='PC213502752220' layer='app' component='organizer' bldinf='Z:/sf/app/organizer/group/bld.inf' mmp='' config='winscw_udeb' platform='WINSCW' phase='ALL' source=''>
 <![CDATA[
 + EPOCROOT=z: