parse, but ignore, <? ?> tags - eliminated duplicate code ala FixSeparator() - fix...
authorRoyce Mitchell III <royce3@ev1.net>
Fri, 7 Jan 2005 13:48:53 +0000 (13:48 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Fri, 7 Jan 2005 13:48:53 +0000 (13:48 +0000)
svn path=/branches/xmlbuildsystem/; revision=12868

reactos/tools/rbuild/XML.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/project.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/tests/data/module.xml
reactos/tools/rbuild/tests/data/project.xml
reactos/tools/rbuild/tests/moduletest.cpp

index 8ec6a8d..df2aa72 100644 (file)
@@ -251,6 +251,14 @@ XMLFile::get_token(string& token)
                else\r
                        tokend += 3;\r
        }\r
                else\r
                        tokend += 3;\r
        }\r
+       else if ( !strncmp ( _p, "<?", 2 ) )\r
+       {\r
+               tokend = strstr ( _p, "?>" );\r
+               if ( !tokend )\r
+                       tokend = _end;\r
+               else\r
+                       tokend += 2;\r
+       }\r
        else if ( *_p == '<' )\r
        {\r
                tokend = strchr ( _p, '>' );\r
        else if ( *_p == '<' )\r
        {\r
                tokend = strchr ( _p, '>' );\r
@@ -456,7 +464,9 @@ XMLParse(XMLFile& f,
                return NULL;\r
        bool end_tag;\r
 \r
                return NULL;\r
        bool end_tag;\r
 \r
-       while ( token[0] != '<' || !strncmp ( token.c_str(), "<!--", 4 ) )\r
+       while ( token[0] != '<'\r
+               || !strncmp ( token.c_str(), "<!--", 4 )\r
+               || !strncmp ( token.c_str(), "<?", 2 ) )\r
        {\r
                if ( token[0] != '<' )\r
                        throw XMLSyntaxErrorException ( f.Location(),\r
        {\r
                if ( token[0] != '<' )\r
                        throw XMLSyntaxErrorException ( f.Location(),\r
index e1f6214..0f63b29 100644 (file)
@@ -1,5 +1,6 @@
 \r
 #include "../../pch.h"\r
 \r
 #include "../../pch.h"\r
+#include <assert.h>\r
 \r
 #include "../../rbuild.h"\r
 #include "mingw.h"\r
 \r
 #include "../../rbuild.h"\r
 #include "mingw.h"\r
@@ -162,30 +163,30 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${gcc} -Wl,--base-file,%s/base.tmp -o %s/junk.tmp %s %s\n",\r
+                 "\t${gcc} -Wl,--base-file,%s" SSEP "base.tmp -o %s" SSEP "junk.tmp %s %s\n",\r
                  workingDirectory.c_str (),\r
                  workingDirectory.c_str (),\r
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
                  workingDirectory.c_str (),\r
                  workingDirectory.c_str (),\r
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s/junk.tmp\n",\r
+                 "\t${rm} %s" SSEP "junk.tmp\n",\r
                  workingDirectory.c_str () );\r
        fprintf ( fMakefile,\r
                  workingDirectory.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${dlltool} --dllname %s --base-file %s/base.tmp --output-exp %s/temp.exp --kill-at\n",\r
+                 "\t${dlltool} --dllname %s --base-file %s" SSEP "base.tmp --output-exp %s" SSEP "temp.exp --kill-at\n",\r
                  module.GetPath ().c_str (),\r
                  workingDirectory.c_str (),\r
                  workingDirectory.c_str ());\r
        fprintf ( fMakefile,\r
                  module.GetPath ().c_str (),\r
                  workingDirectory.c_str (),\r
                  workingDirectory.c_str ());\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s/base.tmp\n",\r
+                 "\t${rm} %s" SSEP "base.tmp\n",\r
                  workingDirectory.c_str () );\r
        fprintf ( fMakefile,\r
                  workingDirectory.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${ld} -Wl,%s/temp.exp -o %s %s %s\n",\r
+                 "\t${ld} -Wl,%s" SSEP "temp.exp -o %s %s %s\n",\r
                  workingDirectory.c_str (),\r
                  module.GetPath ().c_str (),\r
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
                  workingDirectory.c_str (),\r
                  module.GetPath ().c_str (),\r
                  archiveFilename.c_str (),\r
                  importLibraryDependencies.c_str () );\r
        fprintf ( fMakefile,\r
-                 "\t${rm} %s/temp.exp\n",\r
+                 "\t${rm} %s" SSEP "temp.exp\n",\r
                  workingDirectory.c_str () );\r
        \r
        GenerateArchiveTarget ( module );\r
                  workingDirectory.c_str () );\r
        \r
        GenerateArchiveTarget ( module );\r
index cb20525..4d9b3ee 100644 (file)
@@ -8,37 +8,18 @@
 using std::string;\r
 using std::vector;\r
 \r
 using std::string;\r
 using std::vector;\r
 \r
-#ifdef WIN32\r
-#define EXEPOSTFIX ".exe"\r
-#define SEP "\\"\r
 string\r
 FixSeparator ( const string& s )\r
 {\r
        string s2(s);\r
 string\r
 FixSeparator ( const string& s )\r
 {\r
        string s2(s);\r
-       char* p = strchr ( &s2[0], '/' );\r
+       char* p = strchr ( &s2[0], CBAD_SEP );\r
        while ( p )\r
        {\r
        while ( p )\r
        {\r
-               *p++ = '\\';\r
-               p = strchr ( p, '/' );\r
+               *p++ = CSEP;\r
+               p = strchr ( p, CBAD_SEP );\r
        }\r
        return s2;\r
 }\r
        }\r
        return s2;\r
 }\r
-#else\r
-#define EXEPOSTFIX\r
-#define SEP "/"\r
-string\r
-FixSeparator ( const string& s )\r
-{\r
-       string s2(s);\r
-       char* p = strchr ( &s2[0], '\\' );\r
-       while ( p )\r
-       {\r
-               *p++ = '/';\r
-               p = strchr ( p, '\\' );\r
-       }\r
-       return s2;\r
-}\r
-#endif\r
 \r
 Module::Module ( Project* project,\r
                  const XMLElement& moduleNode,\r
 \r
 Module::Module ( Project* project,\r
                  const XMLElement& moduleNode,\r
@@ -68,7 +49,7 @@ Module::ProcessXML ( const XMLElement& e,
        string subpath ( path );\r
        if ( e.name == "file" && e.value.size () )\r
        {\r
        string subpath ( path );\r
        if ( e.name == "file" && e.value.size () )\r
        {\r
-               files.push_back ( new File ( path + "/" + e.value ) );\r
+               files.push_back ( new File ( path + CSEP + e.value ) );\r
        }\r
        else if ( e.name == "library" && e.value.size () )\r
        {\r
        }\r
        else if ( e.name == "library" && e.value.size () )\r
        {\r
@@ -78,7 +59,7 @@ Module::ProcessXML ( const XMLElement& e,
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
-               subpath = path + "/" + att->value;\r
+               subpath = path + CSEP + att->value;\r
        }\r
        for ( size_t i = 0; i < e.subElements.size (); i++ )\r
                ProcessXML ( *e.subElements[i], subpath );\r
        }\r
        for ( size_t i = 0; i < e.subElements.size (); i++ )\r
                ProcessXML ( *e.subElements[i], subpath );\r
@@ -100,7 +81,7 @@ Module::GetModuleType ( const XMLAttribute& attribute )
 string\r
 Module::GetPath ()\r
 {\r
 string\r
 Module::GetPath ()\r
 {\r
-       return FixSeparator (path) + SEP + name + EXEPOSTFIX;\r
+       return FixSeparator (path) + CSEP + name + EXEPOSTFIX;\r
 }\r
 \r
 \r
 }\r
 \r
 \r
index 9381cf0..3cfe138 100644 (file)
@@ -30,15 +30,12 @@ Project::ReadXml ()
 {\r
        Path path;\r
 \r
 {\r
        Path path;\r
 \r
-       head = XMLParse ( xmlfile, path );\r
-       if ( !head )\r
-               throw InvalidBuildFileException ( "Document contains no 'project' tag." );\r
-\r
-       if ( head->name != "project" )\r
+       do\r
        {\r
        {\r
-               throw InvalidBuildFileException ( "Expected 'project', got '%s'.",\r
-                                                     head->name.c_str());\r
-       }\r
+               head = XMLParse ( xmlfile, path );\r
+               if ( !head )\r
+                       throw InvalidBuildFileException ( "Document contains no 'project' tag." );\r
+       } while ( head->name != "project" );\r
 \r
        this->ProcessXML ( *head, "." );\r
 }\r
 \r
        this->ProcessXML ( *head, "." );\r
 }\r
@@ -73,7 +70,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
-               subpath = path + "/" + att->value;\r
+               subpath = path + CSEP + att->value;\r
        }\r
        for ( size_t i = 0; i < e.subElements.size (); i++ )\r
                ProcessXML ( *e.subElements[i], subpath );\r
        }\r
        for ( size_t i = 0; i < e.subElements.size (); i++ )\r
                ProcessXML ( *e.subElements[i], subpath );\r
index 88572ee..43d1591 100644 (file)
@@ -7,6 +7,20 @@
 #include "exception.h"\r
 #include "XML.h"\r
 \r
 #include "exception.h"\r
 #include "XML.h"\r
 \r
+#ifdef WIN32\r
+#define EXEPOSTFIX ".exe"\r
+#define CSEP '\\'\r
+#define CBAD_SEP '/'\r
+#define SSEP "\\"\r
+#define SBAD_SEP "/"\r
+#else\r
+#define EXEPOSTFIX\r
+#define CSEP '/'\r
+#define CBAD_SEP '\\'\r
+#define SSEP "/"\r
+#define SBAD_SEP "\\"\r
+#endif\r
+\r
 class Project;\r
 class Module;\r
 class File;\r
 class Project;\r
 class Module;\r
 class File;\r
@@ -78,4 +92,7 @@ public:
        Library ( const std::string& _name );\r
 };\r
 \r
        Library ( const std::string& _name );\r
 };\r
 \r
+extern std::string\r
+FixSeparator ( const std::string& s );\r
+\r
 #endif /* __RBUILD_H */\r
 #endif /* __RBUILD_H */\r
index cd29048..a2d4cea 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>\r
 <project name="Project" makefile="Makefile">\r
        <directory name="dir1">\r
                <module name="module1" type="buildtool">\r
 <project name="Project" makefile="Makefile">\r
        <directory name="dir1">\r
                <module name="module1" type="buildtool">\r
index 2413b60..472cf61 100644 (file)
@@ -1,3 +1,4 @@
+<?xml version="1.0" ?>\r
 <project name="Project" makefile="Makefile">\r
        <directory name="dir1">\r
                <module name="module1" type="buildtool">\r
 <project name="Project" makefile="Makefile">\r
        <directory name="dir1">\r
                <module name="module1" type="buildtool">\r
index 80a366b..54f1aa1 100644 (file)
@@ -11,16 +11,16 @@ void ModuleTest::Run()
        Module& module1 = *project.modules[0];\r
        IS_TRUE(module1.type == BuildTool);\r
        ARE_EQUAL(2, module1.files.size());\r
        Module& module1 = *project.modules[0];\r
        IS_TRUE(module1.type == BuildTool);\r
        ARE_EQUAL(2, module1.files.size());\r
-       ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);\r
-       ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);\r
+       ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name);\r
+       ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name);\r
 \r
        ARE_EQUAL(0, module1.libraries.size());\r
 \r
        Module& module2 = *project.modules[1];\r
        IS_TRUE(module2.type == KernelModeDLL);\r
        ARE_EQUAL(2, module2.files.size());\r
 \r
        ARE_EQUAL(0, module1.libraries.size());\r
 \r
        Module& module2 = *project.modules[1];\r
        IS_TRUE(module2.type == KernelModeDLL);\r
        ARE_EQUAL(2, module2.files.size());\r
-       ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);\r
-       ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);\r
+       ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name);\r
+       ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);\r
 \r
        ARE_EQUAL(1, module2.libraries.size());\r
        Library& library1 = *module2.libraries[0];\r
 \r
        ARE_EQUAL(1, module2.libraries.size());\r
        Library& library1 = *module2.libraries[0];\r