more efficient detection of C++ modules, fixed bug in C++ pch support, always clean...
[reactos.git] / reactos / tools / rbuild / module.cpp
index 7033181..0ffae73 100644 (file)
@@ -90,7 +90,9 @@ Module::Module ( const Project& project,
        : project (project),\r
          node (moduleNode),\r
          importLibrary (NULL),\r
-         bootstrap (NULL)\r
+         bootstrap (NULL),\r
+         pch (NULL),\r
+         cplusplus (false)\r
 {\r
        if ( node.name != "module" )\r
                throw Exception ( "internal tool error: Module created with non-<module> node" );\r
@@ -141,6 +143,8 @@ Module::~Module ()
                delete compilerFlags[i];\r
        for ( i = 0; i < linkerFlags.size(); i++ )\r
                delete linkerFlags[i];\r
+       if ( pch )\r
+               delete pch;\r
 }\r
 \r
 void\r
@@ -158,6 +162,8 @@ Module::ProcessXML()
        for ( i = 0; i < linkerFlags.size(); i++ )\r
                linkerFlags[i]->ProcessXML();\r
        non_if_data.ProcessXML();\r
+       if ( pch )\r
+               pch->ProcessXML();\r
 }\r
 \r
 void\r
@@ -180,6 +186,17 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                                        e.location,\r
                                        "attribute 'first' of <file> element can only be 'true' or 'false'" );\r
                }\r
+               if ( !cplusplus )\r
+               {\r
+                       // check for c++ file\r
+                       string ext = GetExtension ( e.value );\r
+                       if ( !stricmp ( ext.c_str(), ".cpp" ) )\r
+                               cplusplus = true;\r
+                       else if ( !stricmp ( ext.c_str(), ".cc" ) )\r
+                               cplusplus = true;\r
+                       else if ( !stricmp ( ext.c_str(), ".cxx" ) )\r
+                               cplusplus = true;\r
+               }\r
                File* pFile = new File ( FixSeparator ( path + CSEP + e.value ), first );\r
                if ( pIf )\r
                        pIf->data.files.push_back ( pFile );\r
@@ -282,6 +299,20 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
                bootstrap = new Bootstrap ( project, this, e );\r
                subs_invalid = true;\r
        }\r
+       else if ( e.name == "pch" )\r
+       {\r
+               if ( pIf )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "<pch> is not a valid sub-element of <if>" );\r
+               if ( pch )\r
+                       throw InvalidBuildFileException (\r
+                               e.location,\r
+                               "Only one <pch> is valid per module" );\r
+               pch = new PchFile (\r
+                       e, *this, FixSeparator ( path + CSEP + e.value ) );\r
+               subs_invalid = true;\r
+       }\r
        if ( subs_invalid && e.subElements.size() > 0 )\r
                throw InvalidBuildFileException (\r
                        e.location,\r
@@ -806,3 +837,17 @@ void
 Property::ProcessXML()\r
 {\r
 }\r
+\r
+\r
+PchFile::PchFile (\r
+       const XMLElement& node_,\r
+       const Module& module_,\r
+       const string& header_ )\r
+       : node(node_), module(module_), header(header_)\r
+{\r
+}\r
+\r
+void\r
+PchFile::ProcessXML()\r
+{\r
+}\r