From 5f69cb429eb88ca7741d66a152ad7a477ae7f7f4 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Sat, 8 Jan 2005 00:25:48 +0000 Subject: [PATCH] Static library module type. svn path=/branches/xmlbuildsystem/; revision=12877 --- reactos/ReactOS.xml | 4 +- reactos/lib/kjs/module.xml | 5 +- reactos/ntoskrnl/module.xml | 12 +-- reactos/tools/rbuild/backend/mingw/mingw.cpp | 1 + .../rbuild/backend/mingw/modulehandler.cpp | 53 +++++++++++-- .../rbuild/backend/mingw/modulehandler.h | 16 +++- reactos/tools/rbuild/exception.cpp | 78 +++++++++++-------- reactos/tools/rbuild/exception.h | 34 ++++---- reactos/tools/rbuild/include.cpp | 2 +- reactos/tools/rbuild/module.cpp | 43 ++++++++-- reactos/tools/rbuild/project.cpp | 4 +- reactos/tools/rbuild/rbuild.h | 4 +- 12 files changed, 182 insertions(+), 74 deletions(-) diff --git a/reactos/ReactOS.xml b/reactos/ReactOS.xml index dfe5b49835c..ec6e3f64395 100644 --- a/reactos/ReactOS.xml +++ b/reactos/ReactOS.xml @@ -1,7 +1,7 @@ - ./include - ./w32api/include + include + w32api/include depends.c diff --git a/reactos/lib/kjs/module.xml b/reactos/lib/kjs/module.xml index d60ef2384b9..d0934a64623 100644 --- a/reactos/lib/kjs/module.xml +++ b/reactos/lib/kjs/module.xml @@ -1,7 +1,7 @@ . - ./src - ./include + src + include setjmp.S longjmp.S @@ -24,7 +24,6 @@ vmjumps.c vmswitch.c vmswt0.c - longjmp.c b_array.c diff --git a/reactos/ntoskrnl/module.xml b/reactos/ntoskrnl/module.xml index 7832e755cbb..d1b6a9001da 100644 --- a/reactos/ntoskrnl/module.xml +++ b/reactos/ntoskrnl/module.xml @@ -1,8 +1,8 @@ - - - - - + + + + + . ./include ../lib/kjs/include @@ -44,12 +44,14 @@ + kdb_stabs.c diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 5f529afc03f..4c3d515c70d 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -103,4 +103,5 @@ void MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers ) { moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) ); + moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler ( fMakefile ) ); } diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 7d5e8720a68..4acf2499888 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -128,7 +128,20 @@ MingwModuleHandler::GenerateGccDefineParameters ( Module& module ) } string -MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector includes ) +MingwModuleHandler::ConcatenatePaths ( string path1, + string path2 ) +{ + if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) ) + return path2; + if ( path1[path1.length ()] == CSEP ) + return path1 + path2; + else + return path1 + CSEP + path2; +} + +string +MingwModuleHandler::GenerateGccIncludeParametersFromVector ( string basePath, + vector includes ) { string parameters; for (size_t i = 0; i < includes.size (); i++) @@ -137,7 +150,8 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector in if (parameters.length () > 0) parameters += " "; parameters += "-I"; - parameters += include.directory; + parameters += ConcatenatePaths ( basePath, + include.directory ); } return parameters; } @@ -145,8 +159,10 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector in string MingwModuleHandler::GenerateGccIncludeParameters ( Module& module ) { - string parameters = GenerateGccIncludeParametersFromVector ( module.project->includes ); - string s = GenerateGccIncludeParametersFromVector ( module.includes ); + string parameters = GenerateGccIncludeParametersFromVector ( ".", + module.project->includes ); + string s = GenerateGccIncludeParametersFromVector ( module.path, + module.includes ); if (s.length () > 0) { parameters += " "; @@ -202,7 +218,7 @@ MingwModuleHandler::GenerateArchiveTarget ( Module& module ) fprintf ( fMakefile, "%s: %s\n", archiveFilename.c_str (), - sourceFilenames.c_str ()); + objectFilenames.c_str ()); fprintf ( fMakefile, "\t${ar} -rc %s %s\n\n", @@ -219,7 +235,7 @@ MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile ) bool MingwKernelModuleHandler::CanHandleModule ( Module& module ) { - return true; + return module.type == KernelModeDLL; } void @@ -268,3 +284,28 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module ) GenerateArchiveTarget ( module ); GenerateObjectFileTargets ( module ); } + + +MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( FILE* fMakefile ) + : MingwModuleHandler ( fMakefile ) +{ +} + +bool +MingwStaticLibraryModuleHandler::CanHandleModule ( Module& module ) +{ + return module.type == StaticLibrary; +} + +void +MingwStaticLibraryModuleHandler::Process ( Module& module ) +{ + GenerateStaticLibraryModuleTarget ( module ); +} + +void +MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( Module& module ) +{ + GenerateArchiveTarget ( module ); + GenerateObjectFileTargets ( module ); +} diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index e52991ab923..36e8c8ac04c 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -22,9 +22,12 @@ protected: void GenerateArchiveTarget ( Module& module ); FILE* fMakefile; private: + std::string ConcatenatePaths ( std::string path1, + std::string path2 ); std::string GenerateGccDefineParametersFromVector ( std::vector defines ); std::string GenerateGccDefineParameters ( Module& module ); - std::string GenerateGccIncludeParametersFromVector ( std::vector includes ); + std::string GenerateGccIncludeParametersFromVector ( std::string basePath, + std::vector includes ); std::string GenerateGccIncludeParameters ( Module& module ); std::string GenerateGccParameters ( Module& module ); }; @@ -40,4 +43,15 @@ private: void GenerateKernelModuleTarget ( Module& module ); }; + +class MingwStaticLibraryModuleHandler : public MingwModuleHandler +{ +public: + MingwStaticLibraryModuleHandler ( FILE* fMakefile ); + virtual bool CanHandleModule ( Module& module ); + virtual void Process ( Module& module ); +private: + void GenerateStaticLibraryModuleTarget ( Module& module ); +}; + #endif /* MINGW_MODULEHANDLER_H */ diff --git a/reactos/tools/rbuild/exception.cpp b/reactos/tools/rbuild/exception.cpp index db950640c6a..d04014ced66 100644 --- a/reactos/tools/rbuild/exception.cpp +++ b/reactos/tools/rbuild/exception.cpp @@ -5,58 +5,71 @@ using std::string; -Exception::Exception() +Exception::Exception () { } -Exception::Exception(const string& message) +Exception::Exception ( const string& message ) { Message = message; } -Exception::Exception(const char* format, - ...) +Exception::Exception ( const char* format, + ...) { va_list args; - va_start(args, - format); - Message = ssvprintf(format, - args); - va_end(args); + va_start ( args, + format); + Message = ssvprintf ( format, + args); + va_end ( args ); +} + +void Exception::SetMessage ( const char* message, + va_list args) +{ + Message = ssvprintf ( message, + args); } -void Exception::SetMessage(const char* message, - va_list args) + +InvalidOperationException::InvalidOperationException ( const char* filename, + const int linenumber) { - Message = ssvprintf(message, - args); + Message = ssprintf ( "%s:%d", + filename, + linenumber ); } -FileNotFoundException::FileNotFoundException(const string& filename) - : Exception ( "File '%s' not found.", filename.c_str() ) +FileNotFoundException::FileNotFoundException ( const string& filename ) + : Exception ( "File '%s' not found.", + filename.c_str() ) { Filename = filename; } -AccessDeniedException::AccessDeniedException(const string& filename) - : Exception ( "Access denied to file '%s'.", filename.c_str() ) +AccessDeniedException::AccessDeniedException ( const string& filename) + : Exception ( "Access denied to file '%s'.", + filename.c_str() ) { Filename = filename; } -InvalidBuildFileException::InvalidBuildFileException(const char* message, - ...) +InvalidBuildFileException::InvalidBuildFileException ( const char* message, + ...) { va_list args; - va_start( args, message); - SetMessage(message, args); - va_end(args); + va_start ( args, + message ); + SetMessage ( message, + args ); + va_end ( args ); } -InvalidBuildFileException::InvalidBuildFileException() +InvalidBuildFileException::InvalidBuildFileException () { } @@ -66,36 +79,39 @@ XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location, ... ) { va_list args; - va_start ( args, message ); + va_start ( args, + message ); Message = location + ": " + ssvprintf ( message, args ); va_end ( args ); } -RequiredAttributeNotFoundException::RequiredAttributeNotFoundException(const string& attributeName, - const string& elementName) +RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName, + const string& elementName ) : InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.", attributeName.c_str (), elementName.c_str ()) { } -InvalidAttributeValueException::InvalidAttributeValueException(const string& name, - const string& value) +InvalidAttributeValueException::InvalidAttributeValueException ( const string& name, + const string& value ) : InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.", name.c_str (), - value.c_str ()) + value.c_str () ) { } BackendNameConflictException::BackendNameConflictException ( const string& name ) - : Exception ( "Backend name conflict: '%s'", name.c_str() ) + : Exception ( "Backend name conflict: '%s'", + name.c_str() ) { } UnknownBackendException::UnknownBackendException ( const string& name ) - : Exception ( "Unknown Backend requested: '%s'", name.c_str() ) + : Exception ( "Unknown Backend requested: '%s'", + name.c_str() ) { } diff --git a/reactos/tools/rbuild/exception.h b/reactos/tools/rbuild/exception.h index 6746aed5648..1653a0c2909 100644 --- a/reactos/tools/rbuild/exception.h +++ b/reactos/tools/rbuild/exception.h @@ -6,21 +6,29 @@ class Exception { public: - Exception(const std::string& message); - Exception(const char* format, - ...); + Exception ( const std::string& message ); + Exception ( const char* format, + ...); std::string Message; protected: - Exception(); - void SetMessage(const char* message, - va_list args); + Exception (); + void SetMessage ( const char* message, + va_list args); +}; + + +class InvalidOperationException : public Exception +{ +public: + InvalidOperationException ( const char* filename, + const int linenumber); }; class FileNotFoundException : public Exception { public: - FileNotFoundException(const std::string& filename); + FileNotFoundException ( const std::string& filename ); std::string Filename; }; @@ -28,7 +36,7 @@ public: class AccessDeniedException : public Exception { public: - AccessDeniedException(const std::string& filename); + AccessDeniedException ( const std::string& filename ); std::string Filename; }; @@ -39,7 +47,7 @@ public: InvalidBuildFileException ( const char* message, ...); protected: - InvalidBuildFileException(); + InvalidBuildFileException (); }; @@ -55,16 +63,16 @@ public: class RequiredAttributeNotFoundException : public InvalidBuildFileException { public: - RequiredAttributeNotFoundException(const std::string& attributeName, - const std::string& elementName); + RequiredAttributeNotFoundException ( const std::string& attributeName, + const std::string& elementName ); }; class InvalidAttributeValueException : public InvalidBuildFileException { public: - InvalidAttributeValueException(const std::string& name, - const std::string& value); + InvalidAttributeValueException ( const std::string& name, + const std::string& value ); }; diff --git a/reactos/tools/rbuild/include.cpp b/reactos/tools/rbuild/include.cpp index f52e5859c00..01412031382 100644 --- a/reactos/tools/rbuild/include.cpp +++ b/reactos/tools/rbuild/include.cpp @@ -30,7 +30,7 @@ Include::~Include () void Include::Initialize ( const XMLElement& includeNode ) { - directory = includeNode.value; + directory = FixSeparator ( includeNode.value ); } void diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 5067d490716..cb5dae13b62 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -23,14 +23,25 @@ FixSeparator ( const string& s ) Module::Module ( Project* project, const XMLElement& moduleNode, - const string& moduleName, const string& modulePath ) : project(project), - node(moduleNode), - name(moduleName), - path(modulePath) + node(moduleNode) { - type = GetModuleType ( *moduleNode.GetAttribute ( "type", true ) ); + path = FixSeparator ( modulePath ); + + const XMLAttribute* att = moduleNode.GetAttribute ( "name", true ); + assert(att); + name = att->value; + + att = moduleNode.GetAttribute ( "type", true ); + assert(att); + type = GetModuleType ( *att ); + + att = moduleNode.GetAttribute ( "extension", false ); + if (att != NULL) + extension = att->value; + else + extension = GetDefaultModuleExtension (); } Module::~Module () @@ -49,7 +60,7 @@ Module::ProcessXML ( const XMLElement& e, string subpath ( path ); if ( e.name == "file" && e.value.size () ) { - files.push_back ( new File ( path + CSEP + e.value ) ); + files.push_back ( new File ( FixSeparator ( path + CSEP + e.value ) ) ); } else if ( e.name == "library" && e.value.size () ) { @@ -59,7 +70,7 @@ Module::ProcessXML ( const XMLElement& e, { const XMLAttribute* att = e.GetAttribute ( "name", true ); assert(att); - subpath = path + CSEP + att->value; + subpath = FixSeparator ( path + CSEP + att->value ); } else if ( e.name == "include" ) { @@ -90,10 +101,26 @@ Module::GetModuleType ( const XMLAttribute& attribute ) attribute.value ); } +string +Module::GetDefaultModuleExtension () +{ + switch (type) + { + case BuildTool: + return EXEPOSTFIX; + case StaticLibrary: + return ".a"; + case KernelModeDLL: + return ".dll"; + } + throw InvalidOperationException (__FILE__, + __LINE__); +} + string Module::GetPath () { - return FixSeparator (path) + CSEP + name + EXEPOSTFIX; + return FixSeparator (path) + CSEP + name + extension; } diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index fd8aacbc524..fcd3f5f0768 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -59,9 +59,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path ) } else if ( e.name == "module" ) { - att = e.GetAttribute ( "name", true ); - assert(att); - Module* module = new Module ( this, e, att->value, path ); + Module* module = new Module ( this, e, path ); modules.push_back ( module ); module->ProcessXML ( e, path ); return; diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 1622bc786fe..26c099ea139 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -64,6 +64,7 @@ public: Project* project; const XMLElement& node; std::string name; + std::string extension; std::string path; ModuleType type; std::vector files; @@ -73,12 +74,13 @@ public: Module ( Project* project, const XMLElement& moduleNode, - const std::string& moduleName, const std::string& modulePath ); ~Module (); ModuleType GetModuleType (const XMLAttribute& attribute ); std::string GetPath (); void ProcessXML ( const XMLElement& e, const std::string& path ); +private: + std::string GetDefaultModuleExtension (); }; -- 2.17.1