Author: hpoussin Date: Sun Jul 27 09:01:24 2008 New Revision: 34846
URL: http://svn.reactos.org/svn/reactos?rev=34846&view=rev Log: Factorize code for simple module types
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp [iso-8859-1] (original) +++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp [iso-8859-1] Sun Jul 27 09:01:24 2008 @@ -33,6 +33,44 @@ using std::map;
typedef set<string> set_string; + +static const struct +{ + HostType DefaultHost; +} ModuleHandlerInformations[] = { + { HostTrue }, // BuildTool + { HostFalse }, // StaticLibrary + { HostFalse }, // ObjectLibrary + { HostFalse }, // Kernel + { HostFalse }, // KernelModeDLL + { HostFalse }, // KernelModeDriver + { HostFalse }, // NativeDLL + { HostFalse }, // NativeCUI + { HostFalse }, // Win32DLL + { HostFalse }, // Win32OCX + { HostFalse }, // Win32CUI + { HostFalse }, // Win32GUI + { HostFalse }, // BootLoader + { HostFalse }, // BootSector + { HostFalse }, // Iso + { HostFalse }, // LiveIso + { HostFalse }, // Test + { HostFalse }, // RpcServer + { HostFalse }, // RpcClient + { HostFalse }, // Alias + { HostFalse }, // BootProgram + { HostFalse }, // Win32SCR + { HostFalse }, // IdlHeader + { HostFalse }, // IsoRegTest + { HostFalse }, // LiveIsoRegTest + { HostFalse }, // EmbeddedTypeLib + { HostFalse }, // ElfExecutable + { HostFalse }, // RpcProxy + { HostTrue }, // HostStaticLibrary + { HostFalse }, // Cabinet + { HostFalse }, // KeyboardLayout + { HostFalse }, // MessageHeader +};
string MingwBackend::GetFullPath ( const FileLocation& file ) const @@ -252,7 +290,7 @@ h->EnablePreCompiledHeaderSupport (); if ( module.host == HostDefault ) { - module.host = h->DefaultHost(); + module.host = ModuleHandlerInformations[h->module.type].DefaultHost; assert ( module.host != HostDefault ); } v.push_back ( h ); @@ -324,6 +362,8 @@ void MingwBackend::ProcessNormal () { + assert(sizeof(ModuleHandlerInformations)/sizeof(ModuleHandlerInformations[0]) == TypeDontCare); + DetectCompiler (); DetectBinutils (); DetectNetwideAssembler ();
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp [iso-8859-1] (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp [iso-8859-1] Sun Jul 27 09:01:24 2008 @@ -165,17 +165,19 @@ MingwModuleHandler* handler; switch ( module.type ) { + case StaticLibrary: + case HostStaticLibrary: + case ObjectLibrary: + case RpcServer: + case RpcClient: + case RpcProxy: + case MessageHeader: + case IdlHeader: + case EmbeddedTypeLib: + handler = new MingwModuleHandler( module ); + break; case BuildTool: handler = new MingwBuildToolModuleHandler ( module ); - break; - case StaticLibrary: - handler = new MingwStaticLibraryModuleHandler ( module ); - break; - case HostStaticLibrary: - handler = new MingwHostStaticLibraryModuleHandler ( module ); - break; - case ObjectLibrary: - handler = new MingwObjectLibraryModuleHandler ( module ); break; case Kernel: handler = new MingwKernelModuleHandler ( module ); @@ -230,29 +232,11 @@ case Test: handler = new MingwTestModuleHandler ( module ); break; - case RpcServer: - handler = new MingwRpcServerModuleHandler ( module ); - break; - case RpcClient: - handler = new MingwRpcClientModuleHandler ( module ); - break; - case RpcProxy: - handler = new MingwRpcProxyModuleHandler ( module ); - break; case Alias: handler = new MingwAliasModuleHandler ( module ); break; - case MessageHeader: - handler = new MingwMessageHeaderModuleHandler (module); - break; - case IdlHeader: - handler = new MingwIdlHeaderModuleHandler ( module ); - break; case Cabinet: handler = new MingwCabinetModuleHandler ( module ); - break; - case EmbeddedTypeLib: - handler = new MingwEmbeddedTypeLibModuleHandler ( module ); break; case ElfExecutable: handler = new MingwElfExecutableModuleHandler ( module ); @@ -2541,84 +2525,11 @@ }
-MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwStaticLibraryModuleHandler::Process () -{ - GenerateStaticLibraryModuleTarget (); -} - -void -MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget () -{ - GenerateRules (); -} - - -MingwHostStaticLibraryModuleHandler::MingwHostStaticLibraryModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwHostStaticLibraryModuleHandler::Process () -{ - GenerateHostStaticLibraryModuleTarget (); -} - -void -MingwHostStaticLibraryModuleHandler::GenerateHostStaticLibraryModuleTarget () -{ - GenerateRules (); -} - - -MingwObjectLibraryModuleHandler::MingwObjectLibraryModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwObjectLibraryModuleHandler::Process () -{ - GenerateObjectLibraryModuleTarget (); -} - -void -MingwObjectLibraryModuleHandler::GenerateObjectLibraryModuleTarget () -{ - GenerateRules (); -} - - MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ( const Module& module_ )
: MingwModuleHandler ( module_ ) { -} - -MingwEmbeddedTypeLibModuleHandler::MingwEmbeddedTypeLibModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwEmbeddedTypeLibModuleHandler::Process () -{ - GenerateRules (); }
@@ -3695,48 +3606,6 @@ }
-MingwRpcServerModuleHandler::MingwRpcServerModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwRpcServerModuleHandler::Process () -{ - GenerateRules (); -} - - -MingwRpcClientModuleHandler::MingwRpcClientModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwRpcClientModuleHandler::Process () -{ - GenerateRules (); -} - - -MingwRpcProxyModuleHandler::MingwRpcProxyModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwRpcProxyModuleHandler::Process () -{ - GenerateRules (); -} - - MingwAliasModuleHandler::MingwAliasModuleHandler ( const Module& module_ )
@@ -3749,31 +3618,6 @@ { }
-MingwMessageHeaderModuleHandler::MingwMessageHeaderModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwMessageHeaderModuleHandler::Process () -{ - GenerateRules (); -} - -MingwIdlHeaderModuleHandler::MingwIdlHeaderModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwIdlHeaderModuleHandler::Process () -{ - GenerateRules (); -}
MingwCabinetModuleHandler::MingwCabinetModuleHandler ( const Module& module_ )
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h [iso-8859-1] (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h [iso-8859-1] Sun Jul 27 09:01:24 2008 @@ -65,9 +65,8 @@
static MingwModuleHandler* InstanciateHandler ( const Module& module_, MingwBackend* backend_ ); - virtual HostType DefaultHost() = 0; void GeneratePreconditionDependencies (); - virtual void Process () = 0; + virtual void Process () { GenerateRules (); } virtual std::string TypeSpecificCFlags() { return ""; } virtual std::string TypeSpecificNasmFlags() { return ""; } virtual std::string TypeSpecificLinkerFlags() { return ""; } @@ -192,7 +191,6 @@ { public: MingwBuildToolModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostTrue; } virtual void Process (); private: void GenerateBuildToolModuleTarget (); @@ -203,51 +201,16 @@ { public: MingwKernelModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); private: void GenerateKernelModuleTarget (); };
-class MingwStaticLibraryModuleHandler : public MingwModuleHandler -{ -public: - MingwStaticLibraryModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -private: - void GenerateStaticLibraryModuleTarget (); -}; - - -class MingwHostStaticLibraryModuleHandler : public MingwModuleHandler -{ -public: - MingwHostStaticLibraryModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostTrue; } - virtual void Process (); -private: - void GenerateHostStaticLibraryModuleTarget (); -}; - - -class MingwObjectLibraryModuleHandler : public MingwModuleHandler -{ -public: - MingwObjectLibraryModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -private: - void GenerateObjectLibraryModuleTarget (); -}; - - class MingwKernelModeDLLModuleHandler : public MingwModuleHandler { public: MingwKernelModeDLLModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -259,7 +222,6 @@ { public: MingwKernelModeDriverModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); std::string TypeSpecificCFlags() { return "-D__NTDRIVER__"; } void AddImplicitLibraries ( Module& module ); @@ -272,7 +234,6 @@ { public: MingwNativeDLLModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -284,7 +245,6 @@ { public: MingwNativeCUIModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); std::string TypeSpecificCFlags() { return "-D__NTAPP__"; } void AddImplicitLibraries ( Module& module ); @@ -297,7 +257,6 @@ { public: MingwWin32DLLModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -309,7 +268,6 @@ { public: MingwWin32OCXModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -321,7 +279,6 @@ { public: MingwWin32CUIModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -333,7 +290,6 @@ { public: MingwWin32GUIModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); void AddImplicitLibraries ( Module& module ); private: @@ -345,7 +301,6 @@ { public: MingwBootLoaderModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } private: @@ -357,7 +312,6 @@ { public: MingwBootSectorModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); std::string TypeSpecificNasmFlags() { return "-f bin"; } private: @@ -369,7 +323,6 @@ { public: MingwBootProgramModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); std::string GetProgTextAddrMacro (); std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } @@ -382,7 +335,6 @@ { public: MingwIsoModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); private: void GenerateIsoModuleTarget (); @@ -401,7 +353,6 @@ { public: MingwLiveIsoModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); private: void GenerateLiveIsoModuleTarget (); @@ -420,7 +371,6 @@ { public: MingwTestModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); protected: virtual void GetModuleSpecificCompilationUnits ( std::vector<CompilationUnit*>& compilationUnits ); @@ -428,54 +378,10 @@ void GenerateTestModuleTarget (); };
- -class MingwRpcServerModuleHandler : public MingwModuleHandler -{ -public: - MingwRpcServerModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - - -class MingwRpcClientModuleHandler : public MingwModuleHandler -{ -public: - MingwRpcClientModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - - -class MingwRpcProxyModuleHandler : public MingwModuleHandler -{ -public: - MingwRpcProxyModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - -class MingwMessageHeaderModuleHandler : public MingwModuleHandler -{ -public: - MingwMessageHeaderModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - class MingwAliasModuleHandler : public MingwModuleHandler { public: MingwAliasModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - -class MingwIdlHeaderModuleHandler : public MingwModuleHandler -{ -public: - MingwIdlHeaderModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); };
@@ -483,15 +389,6 @@ { public: MingwCabinetModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } - virtual void Process (); -}; - -class MingwEmbeddedTypeLibModuleHandler : public MingwModuleHandler -{ -public: - MingwEmbeddedTypeLibModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); };
@@ -499,7 +396,6 @@ { public: MingwElfExecutableModuleHandler ( const Module& module ); - virtual HostType DefaultHost() { return HostFalse; } virtual void Process (); };
Modified: trunk/reactos/tools/rbuild/rbuild.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=3... ============================================================================== --- trunk/reactos/tools/rbuild/rbuild.h [iso-8859-1] (original) +++ trunk/reactos/tools/rbuild/rbuild.h [iso-8859-1] Sun Jul 27 09:01:24 2008 @@ -275,39 +275,39 @@
enum ModuleType { - BuildTool = 0, - StaticLibrary = 1, - ObjectLibrary = 2, - Kernel = 3, - KernelModeDLL = 4, - KernelModeDriver = 5, - NativeDLL = 6, - NativeCUI = 7, - Win32DLL = 8, - Win32OCX = 9, - Win32CUI = 10, - Win32GUI = 11, - BootLoader = 12, - BootSector = 13, - Iso = 14, - LiveIso = 15, - Test = 16, - RpcServer = 17, - RpcClient = 18, - Alias = 19, - BootProgram = 20, - Win32SCR = 21, - IdlHeader = 23, - IsoRegTest = 24, - LiveIsoRegTest = 25, - EmbeddedTypeLib = 26, - ElfExecutable = 27, + BuildTool, + StaticLibrary, + ObjectLibrary, + Kernel, + KernelModeDLL, + KernelModeDriver, + NativeDLL, + NativeCUI, + Win32DLL, + Win32OCX, + Win32CUI, + Win32GUI, + BootLoader, + BootSector, + Iso, + LiveIso, + Test, + RpcServer, + RpcClient, + Alias, + BootProgram, + Win32SCR, + IdlHeader, + IsoRegTest, + LiveIsoRegTest, + EmbeddedTypeLib, + ElfExecutable, RpcProxy, HostStaticLibrary, - TypeDontCare, Cabinet, KeyboardLayout, - MessageHeader + MessageHeader, + TypeDontCare, // always at the end };
enum HostType