parse a module's files into a vector ( conditions are still a TODO )
authorRoyce Mitchell III <royce3@ev1.net>
Tue, 4 Jan 2005 14:46:06 +0000 (14:46 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Tue, 4 Jan 2005 14:46:06 +0000 (14:46 +0000)
svn path=/branches/xmlbuildsystem/; revision=12789

reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.cpp
reactos/tools/rbuild/rbuild.h

index e593f26..29cb0e8 100644 (file)
@@ -17,3 +17,34 @@ Module::Module ( const XMLElement& moduleNode,
          path(modulePath)\r
 {\r
 }\r
+\r
+Module::~Module()\r
+{\r
+       for ( size_t i = 0; i < files.size(); i++ )\r
+               delete files[i];\r
+}\r
+\r
+void\r
+Module::ProcessXML ( const XMLElement& e, const string& path )\r
+{\r
+       string subpath ( path );\r
+       if ( e.name == "file" && e.value.size() )\r
+       {\r
+               files.push_back ( new File(path + "/" + e.value) );\r
+       }\r
+       else if ( e.name == "directory" )\r
+       {\r
+               // this code is duplicated between Project::ProcessXML() and Module::ProcessXML() :(\r
+               const XMLAttribute* att = e.GetAttribute ( "name", true );\r
+               if ( !att )\r
+                       return;\r
+               subpath = path + "/" + att->value;\r
+       }\r
+       for ( size_t i = 0; i < e.subElements.size(); i++ )\r
+               ProcessXML ( *e.subElements[i], subpath );\r
+}\r
+\r
+File::File ( const std::string& _name )\r
+       : name(_name)\r
+{\r
+}\r
index 9564ae5..4a340ff 100644 (file)
@@ -552,10 +552,12 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
                        return;\r
                Module* module = new Module ( e, att->value, path );\r
                modules.push_back ( module );\r
-               return; // REM TODO FIXME no processing of modules... yet\r
+               module->ProcessXML ( e, path );\r
+               return;\r
        }\r
        else if ( e.name == "directory" )\r
        {\r
+               // this code is duplicated between Project::ProcessXML() and Module::ProcessXML() :(\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                if ( !att )\r
                        return;\r
@@ -611,6 +613,25 @@ main ( int argc, char** argv )
                        printf ( "\t%s in folder: %s\n",\r
                                 m.name.c_str(),\r
                                 m.path.c_str() );\r
+                       printf ( "\txml dependencies:\n\t\tReactOS.xml\n" );\r
+                       const XMLElement* e = &m.node;\r
+                       while ( e )\r
+                       {\r
+                               if ( e->name == "xi:include" )\r
+                               {\r
+                                       const XMLAttribute* att = e->GetAttribute("top_href",false);\r
+                                       if ( att )\r
+                                       {\r
+                                               printf ( "\t\t%s\n", att->value.c_str() );\r
+                                       }\r
+                               }\r
+                               e = e->parentElement;\r
+                       }\r
+                       printf ( "\tfiles:\n" );\r
+                       for ( size_t j = 0; j < m.files.size(); j++ )\r
+                       {\r
+                               printf ( "\t\t%s\n", m.files[j]->name.c_str() );\r
+                       }\r
                }\r
 \r
                delete proj;\r
index 14b051b..b99b6be 100644 (file)
@@ -72,6 +72,7 @@ public:
 \r
 class Project;\r
 class Module;\r
+class File;\r
 \r
 class Project\r
 {\r
@@ -89,10 +90,23 @@ public:
        const XMLElement& node;\r
        std::string name;\r
        std::string path;\r
+       std::vector<File*> files;\r
 \r
        Module ( const XMLElement& moduleNode,\r
                 const std::string& moduleName,\r
                 const std::string& modulePath );\r
+\r
+       ~Module();\r
+\r
+       void ProcessXML ( const XMLElement& e, const std::string& path );\r
+};\r
+\r
+class File\r
+{\r
+public:\r
+       std::string name;\r
+\r
+       File ( const std::string& _name );\r
 };\r
 \r
 #endif /* __RBUILD_H */\r