add support for <if> and <property> Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-13 02:46:38 UTC (rev 13014) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-01-13 02:46:46 UTC (rev 13015) @@ -62,8 +62,9 @@
string MingwBackend::GenerateProjectCFLAGS () { + size_t i; string clags; - for ( size_t i = 0; i < ProjectNode.includes.size (); i++ ) + for ( i = 0; i < ProjectNode.includes.size (); i++ ) { Include& include = *ProjectNode.includes[i]; if (clags.length () > 0) @@ -71,7 +72,7 @@ clags += "-I" + include.directory; } - for ( size_t i = 0; i < ProjectNode.defines.size (); i++ ) + for ( i = 0; i < ProjectNode.defines.size (); i++ ) { Define& define = *ProjectNode.defines[i]; if ( clags.length () > 0 ) @@ -89,6 +90,8 @@ void MingwBackend::GenerateGlobalVariables () { + size_t i; + fprintf ( fMakefile, "host_gcc = gcc\n" ); fprintf ( fMakefile, "host_ar = ar\n" ); fprintf ( fMakefile, "host_ld = ld\n" ); @@ -98,6 +101,13 @@ fprintf ( fMakefile, "ar = ar\n" ); fprintf ( fMakefile, "dlltool = dlltool\n" ); fprintf ( fMakefile, "PROJECT_CFLAGS = %s\n", GenerateProjectCFLAGS ().c_str () ); + for ( i = 0; i < ProjectNode.properties.size(); i++ ) + { + Property& prop = *ProjectNode.properties[i]; + fprintf ( fMakefile, "%s := %s\n", + prop.name.c_str(), + prop.value.c_str() ); + } fprintf ( fMakefile, "\n" ); }
_____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-13 02:46:38 UTC (rev 13014) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-01-13 02:46:46 UTC (rev 13015) @@ -323,7 +323,7 @@
if ( ifs && ifs->size() ) { - for ( size_t i = 0; i < module.ifs.size(); i++ ) + for ( size_t i = 0; i < ifs->size(); i++ ) { If& rIf = *(*ifs)[i]; if ( rIf.defines.size() || rIf.files.size() || rIf.ifs.size() ) @@ -377,7 +377,7 @@ { fprintf ( fMakefile, - "ifeq ($(%s),"%s")\n", + "ifeq ("$(%s)","%s")\n", rIf.property.c_str(), rIf.value.c_str() ); GenerateMacros ( @@ -395,11 +395,10 @@ "endif\n\n" ); } } - fprintf ( fMakefile, - "%s_CFLAGS += $(PROJECT_CFLAGS)\n\n", - module.name.c_str () ); + "%s += $(PROJECT_CFLAGS)\n\n", + cflags_macro.c_str () ); }
string _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-13 02:46:38 UTC (rev 13014) +++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-01-13 02:46:46 UTC (rev 13015) @@ -171,10 +171,20 @@
} else if ( e.name == "if" ) { - pIf = new If ( e, *this ); - ifs.push_back ( pIf ); + If* pOldIf = pIf; + pIf = new If ( e, project, this ); + if ( pOldIf ) + pOldIf->ifs.push_back ( pIf ); + else + ifs.push_back ( pIf ); subs_invalid = false; } + else if ( e.name == "property" ) + { + throw InvalidBuildFileException ( + e.location, + "<property> is not a valid sub-element of <module>" ); + } if ( subs_invalid && e.subElements.size() > 0 ) throw InvalidBuildFileException ( e.location, @@ -482,8 +492,10 @@ }
-If::If ( const XMLElement& node_, const Module& module_ ) - : node(node_), module(module_) +If::If ( const XMLElement& node_, + const Project& project_, + const Module* module_ ) + : node(node_), project(project_), module(module_) { const XMLAttribute* att;
@@ -511,3 +523,25 @@ If::ProcessXML() { } + + +Property::Property ( const XMLElement& node_, + const Project& project_, + const Module* module_ ) + : node(node_), project(project_), module(module_) +{ + const XMLAttribute* att; + + att = node.GetAttribute ( "name", true ); + assert(att); + name = att->value; + + att = node.GetAttribute ( "value", true ); + assert(att); + value = att->value; +} + +void +Property::ProcessXML() +{ +} _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp 2005-01-13 02:46:38 UTC (rev 13014) +++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp 2005-01-13 02:46:46 UTC (rev 13015) @@ -27,6 +27,10 @@
delete includes[i]; for ( i = 0; i < defines.size(); i++ ) delete defines[i]; + for ( i = 0; i < properties.size(); i++ ) + delete properties[i]; + for ( i = 0; i < ifs.size(); i++ ) + delete ifs[i]; delete head; }
@@ -77,10 +81,16 @@ includes[i]->ProcessXML(); for ( i = 0; i < defines.size(); i++ ) defines[i]->ProcessXML(); + for ( i = 0; i < properties.size(); i++ ) + properties[i]->ProcessXML(); + for ( i = 0; i < ifs.size(); i++ ) + ifs[i]->ProcessXML(); }
void -Project::ProcessXMLSubElement ( const XMLElement& e, const string& path ) +Project::ProcessXMLSubElement ( const XMLElement& e, + const string& path, + If* pIf /*= NULL*/ ) { bool subs_invalid = false; string subpath(path); @@ -109,16 +119,38 @@ } else if ( e.name == "define" ) { - defines.push_back ( new Define ( *this, e ) ); + Define* define = new Define ( *this, e ); + if ( pIf ) + pIf->defines.push_back ( define ); + else + defines.push_back ( define ); subs_invalid = true; } + else if ( e.name == "if" ) + { + If* pOldIf = pIf; + pIf = new If ( e, *this, NULL ); + if ( pOldIf ) + pOldIf->ifs.push_back ( pIf ); + else + ifs.push_back ( pIf ); + subs_invalid = false; + } + else if ( e.name == "property" ) + { + Property* property = new Property ( e, *this, NULL ); + if ( pIf ) + pIf->properties.push_back ( property ); + else + properties.push_back ( property ); + } if ( subs_invalid && e.subElements.size() ) throw InvalidBuildFileException ( e.location, "<%s> cannot have sub-elements", e.name.c_str() ); for ( size_t i = 0; i < e.subElements.size (); i++ ) - ProcessXMLSubElement ( *e.subElements[i], subpath ); + ProcessXMLSubElement ( *e.subElements[i], subpath, pIf ); }
Module* _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h --- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-13 02:46:38 UTC (rev 13014) +++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-01-13 02:46:46 UTC (rev 13015) @@ -32,6 +32,7 @@
class Dependency; class ImportLibrary; class If; +class Property;
class Project { @@ -43,6 +44,8 @@ std::vector<Module*> modules; std::vector<Include*> includes; std::vector<Define*> defines; + std::vector<Property*> properties; + std::vector<If*> ifs;
//Project (); Project ( const std::string& filename ); @@ -53,7 +56,8 @@ private: void ReadXml (); void ProcessXMLSubElement ( const XMLElement& e, - const std::string& path ); + const std::string& path, + If* pIf = NULL );
// disable copy semantics Project ( const Project& ); @@ -248,19 +252,37 @@ { public: const XMLElement& node; - const Module& module; + const Project& project; + const Module* module; std::string property, value; std::vector<File*> files; std::vector<Define*> defines; + std::vector<Property*> properties; std::vector<If*> ifs;
If ( const XMLElement& node_, - const Module& module_ ); + const Project& project_, + const Module* module_ ); ~If();
void ProcessXML(); };
+class Property +{ +public: + const XMLElement& node; + const Project& project; + const Module* module; + std::string name, value; + + Property ( const XMLElement& node_, + const Project& project_, + const Module* module_ ); + + void ProcessXML(); +}; + extern std::string FixSeparator ( const std::string& s );