diff --git a/reactos/tools/rbuild/XML.cpp b/reactos/tools/rbuild/XML.cpp index 833a0336af7..16767a5c402 100644 --- a/reactos/tools/rbuild/XML.cpp +++ b/reactos/tools/rbuild/XML.cpp @@ -422,7 +422,8 @@ XMLElement::GetAttribute ( const string& attribute, } if ( required ) { - throw RequiredAttributeNotFoundException ( attribute, + throw RequiredAttributeNotFoundException ( location, + attribute, name ); } return NULL; @@ -441,7 +442,8 @@ XMLElement::GetAttribute ( const string& attribute, } if ( required ) { - throw RequiredAttributeNotFoundException ( attribute, + throw RequiredAttributeNotFoundException ( location, + attribute, name ); } return NULL; diff --git a/reactos/tools/rbuild/backend/backend.cpp b/reactos/tools/rbuild/backend/backend.cpp index 566a18fe248..a54558c8184 100644 --- a/reactos/tools/rbuild/backend/backend.cpp +++ b/reactos/tools/rbuild/backend/backend.cpp @@ -8,25 +8,26 @@ using std::string; using std::vector; using std::map; -map* Backend::Factory::factories = NULL; +map* Backend::Factory::factories = NULL; Backend::Factory::Factory ( const std::string& name_ ) { string name(name_); strlwr ( &name[0] ); if ( !factories ) - factories = new map; - (*factories)[name.c_str()] = this; + factories = new map; + (*factories)[name] = this; } /*static*/ Backend* -Backend::Factory::Create ( const std::string& name, Project& project ) +Backend::Factory::Create ( const string& name, + Project& project ) { string sname ( name ); strlwr ( &sname[0] ); if ( !factories || !factories->size() ) throw Exception ( "internal tool error: no registered factories" ); - Backend::Factory* f = (*factories)[sname.c_str()]; + Backend::Factory* f = (*factories)[sname]; if ( !f ) { throw UnknownBackendException ( sname ); diff --git a/reactos/tools/rbuild/backend/backend.h b/reactos/tools/rbuild/backend/backend.h index 1b4fe9fa88e..2c7497a5610 100644 --- a/reactos/tools/rbuild/backend/backend.h +++ b/reactos/tools/rbuild/backend/backend.h @@ -12,7 +12,7 @@ class Backend public: class Factory { - static std::map* factories; + static std::map* factories; protected: @@ -22,7 +22,8 @@ public: virtual Backend* operator() ( Project& ) = 0; public: - static Backend* Create ( const std::string& name, Project& project ); + static Backend* Create ( const std::string& name, + Project& project ); private: }; diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 5ae9ea1d0d5..423c4f6066e 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -90,7 +90,9 @@ MingwBackend::GenerateAllTarget () void MingwBackend::ProcessModule ( Module& module ) { - MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.name ); + MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( + module.node.location, + module.stype ); h->Process ( module ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 02e25ad57e0..bf89db3a837 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -10,7 +10,7 @@ using std::string; using std::vector; using std::map; -map* +map* MingwModuleHandler::handler_map = NULL; FILE* @@ -21,8 +21,8 @@ MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ ) string moduletype ( moduletype_ ); strlwr ( &moduletype[0] ); if ( !handler_map ) - handler_map = new map; - (*handler_map)[moduletype.c_str()] = this; + handler_map = new map; + (*handler_map)[moduletype] = this; } /*static*/ void @@ -32,16 +32,17 @@ MingwModuleHandler::SetMakefile ( FILE* f ) } /*static*/ MingwModuleHandler* -MingwModuleHandler::LookupHandler ( const string& moduletype_ ) +MingwModuleHandler::LookupHandler ( const string& location, + const string& moduletype_ ) { string moduletype ( moduletype_ ); strlwr ( &moduletype[0] ); if ( !handler_map ) throw Exception ( "internal tool error: no registered module handlers" ); - MingwModuleHandler* h = (*handler_map)[moduletype.c_str()]; + MingwModuleHandler* h = (*handler_map)[moduletype]; if ( !h ) { - throw UnknownModuleTypeException ( moduletype ); + throw UnknownModuleTypeException ( location, moduletype ); return NULL; } return h; @@ -217,6 +218,16 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector 0 ) - { - parameters += " "; - parameters += s; - } + parameters += ssprintf(" $(%s_INCLUDES)",module.name.c_str()); return parameters; } @@ -250,6 +256,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module, if ( module.files.size () == 0 ) return; + GenerateGccModuleIncludeVariable ( module ); + for ( size_t i = 0; i < module.files.size (); i++ ) { string sourceFilename = module.files[i]->name; @@ -378,7 +386,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const { const Invoke& invoke = *module.invocations[i]; - if ( invoke.invokeModule->type != BuildTool ) + if ( invoke.invokeModule->etype != BuildTool ) throw InvalidBuildFileException ( module.node.location, "Only modules of type buildtool can be invoked." ); diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 4304a731a85..bd4839875cd 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -6,13 +6,14 @@ class MingwModuleHandler { public: - static std::map* handler_map; + static std::map* handler_map; MingwModuleHandler ( const char* moduletype_ ); virtual ~MingwModuleHandler() {} static void SetMakefile ( FILE* f ); - static MingwModuleHandler* LookupHandler ( const std::string& moduletype_ ); + static MingwModuleHandler* LookupHandler ( const std::string& location, + const std::string& moduletype_ ); virtual void Process ( const Module& module ) = 0; protected: @@ -42,6 +43,7 @@ private: std::string GenerateGccDefineParametersFromVector ( const std::vector& defines ) const; std::string GenerateGccDefineParameters ( const Module& module ) const; std::string GenerateGccIncludeParametersFromVector ( const std::vector& includes ) const; + void GenerateGccModuleIncludeVariable ( const Module& module ) const; std::string GenerateGccIncludeParameters ( const Module& module ) const; std::string GenerateGccParameters ( const Module& module ) const; void GenerateObjectFileTargets ( const Module& module, diff --git a/reactos/tools/rbuild/exception.cpp b/reactos/tools/rbuild/exception.cpp index 798773aacf0..b897fdfc1a4 100644 --- a/reactos/tools/rbuild/exception.cpp +++ b/reactos/tools/rbuild/exception.cpp @@ -93,17 +93,23 @@ XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location, } -RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName, - const string& elementName ) - : InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.", +RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( + const string& location, + const string& attributeName, + const string& elementName ) + : InvalidBuildFileException ( location, + "Required attribute '%s' not found on '%s'.", attributeName.c_str (), elementName.c_str ()) { } -InvalidAttributeValueException::InvalidAttributeValueException ( const string& name, - const string& value ) - : InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.", +InvalidAttributeValueException::InvalidAttributeValueException ( + const string& location, + const string& name, + const string& value ) + : InvalidBuildFileException ( location, + "Attribute '%s' has an invalid value '%s'.", name.c_str (), value.c_str () ) { @@ -119,12 +125,14 @@ BackendNameConflictException::BackendNameConflictException ( const string& name UnknownBackendException::UnknownBackendException ( const string& name ) : Exception ( "Unknown Backend requested: '%s'", - name.c_str() ) + name.c_str() ) { } -UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype ) - : Exception ( "module type requested: '%s'", - moduletype.c_str() ) +UnknownModuleTypeException::UnknownModuleTypeException ( const string& location, + const string& moduletype ) + : InvalidBuildFileException ( location, + "module type requested: '%s'", + moduletype.c_str() ) { } diff --git a/reactos/tools/rbuild/exception.h b/reactos/tools/rbuild/exception.h index c3c84236415..8c434a73bf7 100644 --- a/reactos/tools/rbuild/exception.h +++ b/reactos/tools/rbuild/exception.h @@ -66,7 +66,8 @@ public: class RequiredAttributeNotFoundException : public InvalidBuildFileException { public: - RequiredAttributeNotFoundException ( const std::string& attributeName, + RequiredAttributeNotFoundException ( const std::string& location, + const std::string& attributeName, const std::string& elementName ); }; @@ -74,7 +75,8 @@ public: class InvalidAttributeValueException : public InvalidBuildFileException { public: - InvalidAttributeValueException ( const std::string& name, + InvalidAttributeValueException ( const std::string& location, + const std::string& name, const std::string& value ); }; @@ -92,10 +94,11 @@ public: UnknownBackendException ( const std::string& name ); }; -class UnknownModuleTypeException : public Exception +class UnknownModuleTypeException : public InvalidBuildFileException { public: - UnknownModuleTypeException ( const std::string& moduletype ); + UnknownModuleTypeException ( const std::string& location, + const std::string& moduletype ); }; #endif /* __EXCEPTION_H */ diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 85a5dc27c98..e8ea879fdb7 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -38,7 +38,9 @@ Module::Module ( const Project& project, att = moduleNode.GetAttribute ( "type", true ); assert(att); - type = GetModuleType ( *att ); + stype = att->value; + strlwr ( &stype[0] ); + etype = GetModuleType ( node.location, *att ); att = moduleNode.GetAttribute ( "extension", false ); if (att != NULL) @@ -136,7 +138,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e, } ModuleType -Module::GetModuleType ( const XMLAttribute& attribute ) +Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) { if ( attribute.value == "buildtool" ) return BuildTool; @@ -144,14 +146,15 @@ Module::GetModuleType ( const XMLAttribute& attribute ) return StaticLibrary; if ( attribute.value == "kernelmodedll" ) return KernelModeDLL; - throw InvalidAttributeValueException ( attribute.name, + throw InvalidAttributeValueException ( location, + attribute.name, attribute.value ); } string Module::GetDefaultModuleExtension () const { - switch (type) + switch (etype) { case BuildTool: return EXEPOSTFIX; @@ -264,7 +267,7 @@ Invoke::ProcessXML() module.name.c_str(), att->value.c_str() ); } - + for ( size_t i = 0; i < node.subElements.size (); i++ ) ProcessXMLSubElement ( *node.subElements[i] ); } diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index dd78dfe8a34..7124552d2c5 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -39,7 +39,7 @@ public: std::vector modules; std::vector includes; std::vector defines; - + Project (); Project ( const std::string& filename ); ~Project (); @@ -71,19 +71,21 @@ public: std::string name; std::string extension; std::string path; - ModuleType type; + ModuleType etype; + std::string stype; std::vector files; std::vector libraries; std::vector includes; std::vector defines; std::vector invocations; std::vector dependencies; - + Module ( const Project& project, const XMLElement& moduleNode, const std::string& modulePath ); ~Module (); - ModuleType GetModuleType (const XMLAttribute& attribute ); + ModuleType GetModuleType ( const std::string& location, + const XMLAttribute& attribute ); std::string GetBasePath() const; std::string GetPath () const; std::string GetTargets () const; diff --git a/reactos/tools/rbuild/tests/moduletest.cpp b/reactos/tools/rbuild/tests/moduletest.cpp index 42777d2038c..0c7580e220e 100644 --- a/reactos/tools/rbuild/tests/moduletest.cpp +++ b/reactos/tools/rbuild/tests/moduletest.cpp @@ -9,7 +9,7 @@ void ModuleTest::Run() ARE_EQUAL(2, project.modules.size()); Module& module1 = *project.modules[0]; - IS_TRUE(module1.type == BuildTool); + IS_TRUE(module1.etype == BuildTool); ARE_EQUAL(2, module1.files.size()); ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name); ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name); @@ -17,7 +17,7 @@ void ModuleTest::Run() ARE_EQUAL(0, module1.libraries.size()); Module& module2 = *project.modules[1]; - IS_TRUE(module2.type == KernelModeDLL); + IS_TRUE(module2.etype == KernelModeDLL); ARE_EQUAL(2, module2.files.size()); ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name); ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);