From f618cc855dc8e6a9587f45d526efc7042ad85962 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 18 Jun 2006 19:39:13 +0000 Subject: [PATCH] Thomas Weidenmueller: RBUILD: Support generating headers from .idl files (Patch 1592) svn path=/trunk/; revision=22400 --- .../rbuild/backend/mingw/modulehandler.cpp | 99 ++++++++++++++++--- .../rbuild/backend/mingw/modulehandler.h | 12 +++ reactos/tools/rbuild/bootstrap.cpp | 1 + reactos/tools/rbuild/module.cpp | 11 ++- reactos/tools/rbuild/rbuild.h | 3 +- 5 files changed, 111 insertions(+), 15 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index b0034fd0686..83dfdf64ef2 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -253,6 +253,9 @@ MingwModuleHandler::InstanciateHandler ( case Alias: handler = new MingwAliasModuleHandler ( module ); break; + case IdlHeader: + handler = new MingwIdlHeaderModuleHandler ( module ); + break; default: throw UnknownModuleTypeException ( module.node.location, @@ -296,8 +299,10 @@ MingwModuleHandler::GetActualSourceFilename ( string newname; if ( module.type == RpcServer ) newname = basename + "_s.c"; - else + else if ( module.type == RpcClient ) newname = basename + "_c.c"; + else //if ( module.type == IdlHeader ) + newname = basename + ".h"; PassThruCacheDirectory ( NormalizeFilename ( newname ), backend->intermediateDirectory ); return new FileLocation ( backend->intermediateDirectory, NormalizeFilename ( newname ) ); @@ -314,7 +319,10 @@ MingwModuleHandler::GetExtraDependencies ( if ( extension == ".idl" || extension == ".IDL" ) { string basename = GetBasename ( filename ); - return GetRpcServerHeaderFilename ( basename ) + " " + GetRpcClientHeaderFilename ( basename ); + if ( module.type == IdlHeader ) + return GetIdlHeaderFilename ( basename ); + else + return GetRpcServerHeaderFilename ( basename ) + " " + GetRpcClientHeaderFilename ( basename ); } else return ""; @@ -363,6 +371,8 @@ MingwModuleHandler::ReferenceObjects ( return true; if ( module.type == RpcClient ) return true; + if ( module.type == IdlHeader ) + return true; return false; } @@ -478,10 +488,15 @@ MingwModuleHandler::GetObjectFilename ( newExtension = ".stubs.o"; else if ( extension == ".idl" || extension == ".IDL" ) { - if ( module.type == RpcServer ) - newExtension = "_s.o"; + if ( module.type == IdlHeader ) + newExtension = ".h"; else - newExtension = "_c.o"; + { + if ( module.type == RpcServer ) + newExtension = "_s.o"; + else + newExtension = "_c.o"; + } } else newExtension = ".o"; @@ -759,7 +774,8 @@ MingwModuleHandler::GenerateMacro ( string includeDirectory; if ( include.baseModule != NULL && ( include.baseModule->type == RpcServer || - include.baseModule->type == RpcClient ) ) + include.baseModule->type == RpcClient || + include.baseModule->type == IdlHeader) ) includeDirectory = PassThruCacheDirectory ( NormalizeFilename ( include.directory ), backend->intermediateDirectory ); else @@ -1195,6 +1211,13 @@ MingwModuleHandler::GetRpcClientHeaderFilename ( string basename ) const backend->intermediateDirectory ); } +string +MingwModuleHandler::GetIdlHeaderFilename ( string basename ) const +{ + return PassThruCacheDirectory ( basename + ".h", + backend->intermediateDirectory ); +} + void MingwModuleHandler::GenerateWidlCommandsClient ( const CompilationUnit& compilationUnit, @@ -1232,6 +1255,36 @@ MingwModuleHandler::GenerateWidlCommandsClient ( filename.c_str () ); } +void +MingwModuleHandler::GenerateWidlCommandsIdlHeader ( + const CompilationUnit& compilationUnit, + const string& widlflagsMacro ) +{ + FileLocation* sourceFileLocation = compilationUnit.GetFilename ( backend->intermediateDirectory ); + string filename = sourceFileLocation->filename; + string dependencies = filename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); + + string basename = GetBasename ( filename ); + + string generatedHeaderFilename = GetIdlHeaderFilename ( basename ); + CLEAN_FILE(generatedHeaderFilename); + + fprintf ( fMakefile, + "%s: %s $(WIDL_TARGET) | %s\n", + generatedHeaderFilename.c_str (), + dependencies.c_str (), + GetDirectory ( generatedHeaderFilename ).c_str () ); + fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); + fprintf ( fMakefile, + "\t%s %s %s -h -H %s %s\n", + "$(Q)$(WIDL_TARGET)", + GetWidlFlags ( compilationUnit ).c_str (), + widlflagsMacro.c_str (), + generatedHeaderFilename.c_str (), + filename.c_str () ); +} + void MingwModuleHandler::GenerateWidlCommands ( const CompilationUnit& compilationUnit, @@ -1240,9 +1293,12 @@ MingwModuleHandler::GenerateWidlCommands ( if ( module.type == RpcServer ) GenerateWidlCommandsServer ( compilationUnit, widlflagsMacro ); - else + else if ( module.type == RpcClient ) GenerateWidlCommandsClient ( compilationUnit, widlflagsMacro ); + else if ( module.type == IdlHeader ) + GenerateWidlCommandsIdlHeader ( compilationUnit, + widlflagsMacro ); } void @@ -1308,10 +1364,13 @@ MingwModuleHandler::GenerateCommands ( { GenerateWidlCommands ( compilationUnit, widlflagsMacro ); - GenerateGccCommand ( GetActualSourceFilename ( sourceFileLocation ), - GetExtraDependencies ( filename ), - cc, - cflagsMacro ); + if ( module.type != IdlHeader ) + { + GenerateGccCommand ( GetActualSourceFilename ( sourceFileLocation ), + GetExtraDependencies ( filename ), + cc, + cflagsMacro ); + } return; } @@ -1756,7 +1815,8 @@ MingwModuleHandler::GetRpcHeaderDependencies ( { Library& library = *module.non_if_data.libraries[i]; if ( library.importedModule->type == RpcServer || - library.importedModule->type == RpcClient ) + library.importedModule->type == RpcClient || + library.importedModule->type == IdlHeader ) { for ( size_t j = 0; j < library.importedModule->non_if_data.compilationUnits.size (); j++ ) { @@ -1770,6 +1830,8 @@ MingwModuleHandler::GetRpcHeaderDependencies ( dependencies.push_back ( GetRpcServerHeaderFilename ( basename ) ); if ( library.importedModule->type == RpcClient ) dependencies.push_back ( GetRpcClientHeaderFilename ( basename ) ); + if ( library.importedModule->type == IdlHeader ) + dependencies.push_back ( GetIdlHeaderFilename ( basename ) ); } } } @@ -3248,3 +3310,16 @@ void MingwAliasModuleHandler::Process () { } + +MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler ( + const Module& module_ ) + + : MingwModuleHandler ( module_ ) +{ +} + +void +MingwIdlHeaderModuleHandler::Process () +{ + GenerateRules (); +} diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 5d7696d1ece..a000c2ad847 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -168,6 +168,9 @@ private: void GenerateWidlCommandsClient ( const CompilationUnit& compilationUnit, const std::string& widlflagsMacro ); + void GenerateWidlCommandsIdlHeader ( + const CompilationUnit& compilationUnit, + const std::string& widlflagsMacro ); void GenerateWidlCommands ( const CompilationUnit& compilationUnit, const std::string& widlflagsMacro ); void GenerateCommands ( const CompilationUnit& compilationUnit, @@ -206,6 +209,7 @@ private: void GetRpcHeaderDependencies ( std::vector& dependencies ) const; std::string GetRpcServerHeaderFilename ( std::string basename ) const; std::string GetRpcClientHeaderFilename ( std::string basename ) const; + std::string GetIdlHeaderFilename ( std::string basename ) const; std::string GetModuleCleanTarget ( const Module& module ) const; void GetReferencedObjectLibraryModuleCleanTargets ( std::vector& moduleNames ) const; public: @@ -468,4 +472,12 @@ public: virtual void Process (); }; +class MingwIdlHeaderModuleHandler : public MingwModuleHandler +{ +public: + MingwIdlHeaderModuleHandler ( const Module& module ); + virtual HostType DefaultHost() { return HostFalse; } + virtual void Process (); +}; + #endif /* MINGW_MODULEHANDLER_H */ diff --git a/reactos/tools/rbuild/bootstrap.cpp b/reactos/tools/rbuild/bootstrap.cpp index 82101a22a7b..5657960ca13 100644 --- a/reactos/tools/rbuild/bootstrap.cpp +++ b/reactos/tools/rbuild/bootstrap.cpp @@ -64,6 +64,7 @@ Bootstrap::IsSupportedModuleType ( ModuleType type ) case RpcServer: case RpcClient: case Alias: + case IdlHeader: return false; } throw InvalidOperationException ( __FILE__, diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 3297e431e02..fd39cbe8bf2 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -746,7 +746,7 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) if ( attribute.value == "win32gui" ) return Win32GUI; if ( attribute.value == "win32scr" ) - return Win32SCR; + return Win32SCR; if ( attribute.value == "bootloader" ) return BootLoader; if ( attribute.value == "bootsector" ) @@ -765,6 +765,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute ) return RpcClient; if ( attribute.value == "alias" ) return Alias; + if ( attribute.value == "idlheader" ) + return IdlHeader; throw InvalidAttributeValueException ( location, attribute.name, attribute.value ); @@ -809,8 +811,8 @@ Module::GetDefaultModuleExtension () const case RpcClient: return ".o"; case Alias: - return ""; case BootProgram: + case IdlHeader: return ""; } throw InvalidOperationException ( __FILE__, @@ -857,6 +859,7 @@ Module::GetDefaultModuleEntrypoint () const case RpcClient: case Alias: case BootProgram: + case IdlHeader: return ""; } throw InvalidOperationException ( __FILE__, @@ -895,6 +898,7 @@ Module::GetDefaultModuleBaseaddress () const case RpcClient: case Alias: case BootProgram: + case IdlHeader: return ""; } throw InvalidOperationException ( __FILE__, @@ -935,6 +939,7 @@ Module::IsDLL () const case RpcServer: case RpcClient: case Alias: + case IdlHeader: return false; } throw InvalidOperationException ( __FILE__, @@ -969,6 +974,7 @@ Module::GenerateInOutputTree () const case RpcServer: case RpcClient: case Alias: + case IdlHeader: return false; } throw InvalidOperationException ( __FILE__, @@ -1422,6 +1428,7 @@ AutoRegister::IsSupportedModuleType ( ModuleType type ) case RpcServer: case RpcClient: case Alias: + case IdlHeader: return false; } throw InvalidOperationException ( __FILE__, diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 897661738a1..685c576d957 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -265,7 +265,8 @@ enum ModuleType Alias = 18, BootProgram = 19, Win32SCR = 20, - ExportDriver = 21 + ExportDriver = 21, + IdlHeader = 22 }; enum HostType