diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index b526cee763f..bc8c2347368 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -62,8 +62,9 @@ MingwBackend::GenerateHeader () 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 @@ MingwBackend::GenerateProjectCFLAGS () 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 @@ MingwBackend::GenerateProjectCFLAGS () 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 @@ MingwBackend::GenerateGlobalVariables () 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" ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index e807ce0fbbc..f01f2164e60 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -323,7 +323,7 @@ MingwModuleHandler::GenerateMacros ( 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 @@ MingwModuleHandler::GenerateMacros ( { fprintf ( fMakefile, - "ifeq ($(%s),\"%s\")\n", + "ifeq (\"$(%s)\",\"%s\")\n", rIf.property.c_str(), rIf.value.c_str() ); GenerateMacros ( @@ -395,11 +395,10 @@ MingwModuleHandler::GenerateMacros ( "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 diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 1732a49509e..63fac987e15 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -171,10 +171,20 @@ Module::ProcessXMLSubElement ( const XMLElement& e, } 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, + " is not a valid sub-element of " ); + } if ( subs_invalid && e.subElements.size() > 0 ) throw InvalidBuildFileException ( e.location, @@ -482,8 +492,10 @@ ImportLibrary::ImportLibrary ( const XMLElement& _node, } -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 @@ void 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() +{ +} diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 69ffedaff24..c469f81401d 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -27,6 +27,10 @@ Project::~Project () 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 @@ Project::ProcessXML ( const string& path ) 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 @@ Project::ProcessXMLSubElement ( const XMLElement& e, const string& path ) } 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* diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index f10993be685..02ae0382e96 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -32,6 +32,7 @@ class InvokeFile; class Dependency; class ImportLibrary; class If; +class Property; class Project { @@ -43,6 +44,8 @@ public: std::vector modules; std::vector includes; std::vector defines; + std::vector properties; + std::vector ifs; //Project (); Project ( const std::string& filename ); @@ -53,7 +56,8 @@ public: 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 @@ class If { public: const XMLElement& node; - const Module& module; + const Project& project; + const Module* module; std::string property, value; std::vector files; std::vector defines; + std::vector properties; std::vector 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 );