diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index e86a1781560..7a66bc760d8 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -34,42 +34,39 @@ using std::map; typedef set 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 +const struct ModuleHandlerInformations ModuleHandlerInformations[] = { + { HostTrue, "", "", "" }, // BuildTool + { HostFalse, "", "", "" }, // StaticLibrary + { HostFalse, "", "", "" }, // ObjectLibrary + { HostFalse, "", "", "" }, // Kernel + { HostFalse, "", "", "" }, // KernelModeDLL + { HostFalse, "-D__NTDRIVER__", "", "" }, // KernelModeDriver + { HostFalse, "", "", "" }, // NativeDLL + { HostFalse, "-D__NTAPP__", "", "" }, // NativeCUI + { HostFalse, "", "", "" }, // Win32DLL + { HostFalse, "", "", "" }, // Win32OCX + { HostFalse, "", "", "" }, // Win32CUI + { HostFalse, "", "", "" }, // Win32GUI + { HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootLoader + { HostFalse, "", "-f bin", "" }, // BootSector + { HostFalse, "", "", "" }, // Iso + { HostFalse, "", "", "" }, // LiveIso + { HostFalse, "", "", "" }, // Test + { HostFalse, "", "", "" }, // RpcServer + { HostFalse, "", "", "" }, // RpcClient + { HostFalse, "", "", "" }, // Alias + { HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootProgram + { HostFalse, "", "", "" }, // Win32SCR + { HostFalse, "", "", "" }, // IdlHeader + { HostFalse, "", "", "" }, // IsoRegTest + { HostFalse, "", "", "" }, // LiveIsoRegTest + { HostFalse, "", "", "" }, // EmbeddedTypeLib + { HostFalse, "", "", "" }, // ElfExecutable + { HostFalse, "", "", "" }, // RpcProxy + { HostTrue, "", "", "" }, // HostStaticLibrary + { HostFalse, "", "", "" }, // Cabinet + { HostFalse, "", "", "" }, // KeyboardLayout + { HostFalse, "", "", "" }, // MessageHeader }; string @@ -269,11 +266,6 @@ MingwBackend::ProcessModules () h->AddImplicitLibraries ( module ); if ( use_pch && CanEnablePreCompiledHeaderSupportForModule ( module ) ) h->EnablePreCompiledHeaderSupport (); - if ( module.host == HostDefault ) - { - module.host = ModuleHandlerInformations[h->module.type].DefaultHost; - assert ( module.host != HostDefault ); - } v.push_back ( h ); } @@ -343,7 +335,7 @@ MingwBackend::CheckAutomaticDependenciesForModuleOnly () void MingwBackend::ProcessNormal () { - assert(sizeof(ModuleHandlerInformations)/sizeof(ModuleHandlerInformations[0]) == TypeDontCare); + assert(sizeof(ModuleHandlerInformations)/sizeof(ModuleHandlerInformations[0]) == TypeDontCare); DetectCompiler (); DetectBinutils (); diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 0516465773b..2c7e23b2961 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -142,4 +142,14 @@ private: const Project& project; }; +typedef struct ModuleHandlerInformations +{ + HostType DefaultHost; + const char* cflags; + const char* nasmflags; + const char* linkerflags; +}; + +extern const struct ModuleHandlerInformations ModuleHandlerInformations[]; + #endif /* MINGW_H */ diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 34b8554a1a5..534ce0b3116 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -174,6 +174,7 @@ MingwModuleHandler::InstanciateHandler ( case MessageHeader: case IdlHeader: case EmbeddedTypeLib: + case BootSector: handler = new MingwModuleHandler( module ); break; case BuildTool: @@ -211,9 +212,6 @@ MingwModuleHandler::InstanciateHandler ( case BootLoader: handler = new MingwBootLoaderModuleHandler ( module ); break; - case BootSector: - handler = new MingwBootSectorModuleHandler ( module ); - break; case BootProgram: handler = new MingwBootProgramModuleHandler ( module ); break; @@ -1315,7 +1313,7 @@ MingwModuleHandler::GenerateCommands ( for ( i = 0; i < sizeof ( rules ) / sizeof ( rules[0] ); i++ ) { - if ( rules[i].host != HostDontCare && rules[i].host != module.host ) + if ( rules[i].host != HostDontCare && rules[i].host != ModuleHandlerInformations[module.type].DefaultHost ) continue; if ( rules[i].type != TypeDontCare && rules[i].type != module.type ) continue; @@ -1638,8 +1636,8 @@ MingwModuleHandler::GenerateObjectFileTargets () if ( pchFilename ) { - string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" ); - string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" ); + string cc = ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ? "${host_gcc}" : "${gcc}" ); + string cppc = ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ? "${host_gpp}" : "${gpp}" ); const FileLocation& baseHeaderFile = *module.pch->file; CLEAN_FILE ( *pchFilename ); @@ -1849,7 +1847,7 @@ MingwModuleHandler::GenerateOtherMacros () &module.linkerFlags, used_defs ); - if ( module.host == HostFalse ) + if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) { GenerateMacros ( "+=", @@ -1885,7 +1883,7 @@ MingwModuleHandler::GenerateOtherMacros () } string globalCflags = ""; - if ( module.host == HostFalse ) + if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) globalCflags += " $(PROJECT_CFLAGS)"; else globalCflags += " -Wall -Wpointer-arith -D__REACTOS__"; @@ -1894,7 +1892,7 @@ MingwModuleHandler::GenerateOtherMacros () globalCflags += " -pipe"; if ( !module.allowWarnings ) globalCflags += " -Werror"; - if ( module.host == HostTrue ) + if ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ) { if ( module.cplusplus ) globalCflags += " $(HOST_CPPFLAGS)"; @@ -1922,7 +1920,7 @@ MingwModuleHandler::GenerateOtherMacros () cflagsMacro.c_str (), globalCflags.c_str () ); - if ( module.host == HostFalse ) + if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) { fprintf ( fMakefile, @@ -1955,31 +1953,31 @@ MingwModuleHandler::GenerateOtherMacros () linkDepsMacro.c_str (), libsMacro.c_str () ); - string cflags = TypeSpecificCFlags(); - if ( cflags.size() > 0 ) + const char *cflags = ModuleHandlerInformations[module.type].cflags; + if ( strlen( cflags ) > 0 ) { fprintf ( fMakefile, "%s += %s\n\n", cflagsMacro.c_str (), - cflags.c_str () ); + cflags ); } - string nasmflags = TypeSpecificNasmFlags(); - if ( nasmflags.size () > 0 ) + const char* nasmflags = ModuleHandlerInformations[module.type].nasmflags; + if ( strlen( nasmflags ) > 0 ) { fprintf ( fMakefile, "%s += %s\n\n", nasmflagsMacro.c_str (), - nasmflags.c_str () ); + nasmflags ); } - string linkerflags = TypeSpecificLinkerFlags(); - if ( linkerflags.size() > 0 ) + const char *linkerflags = ModuleHandlerInformations[module.type].linkerflags; + if ( strlen( linkerflags ) > 0 ) { fprintf ( fMakefile, "%s += %s\n\n", linkerflagsMacro.c_str (), - linkerflags.c_str () ); + linkerflags ); } if ( IsStaticLibrary ( module ) && module.isStartupLib ) @@ -2106,7 +2104,7 @@ MingwModuleHandler::GetDefaultDependencies ( string_list& dependencies ) const { /* Avoid circular dependency */ - if ( module.host == HostTrue ) + if ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ) return; if (module.name != "psdk" && @@ -2960,35 +2958,6 @@ MingwBootLoaderModuleHandler::GenerateBootLoaderModuleTarget () } -MingwBootSectorModuleHandler::MingwBootSectorModuleHandler ( - const Module& module_ ) - - : MingwModuleHandler ( module_ ) -{ -} - -void -MingwBootSectorModuleHandler::Process () -{ - GenerateBootSectorModuleTarget (); -} - -void -MingwBootSectorModuleHandler::GenerateBootSectorModuleTarget () -{ - string objectsMacro = GetObjectsMacro ( module ); - - GenerateRules (); - - fprintf ( fMakefile, ".PHONY: %s\n\n", - module.name.c_str ()); - fprintf ( fMakefile, - "%s: %s\n", - module.name.c_str (), - objectsMacro.c_str () ); -} - - MingwBootProgramModuleHandler::MingwBootProgramModuleHandler ( const Module& module_ ) : MingwModuleHandler ( module_ ) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 9d9f62dccef..09a7b17115c 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -67,9 +67,6 @@ public: MingwBackend* backend_ ); void GeneratePreconditionDependencies (); virtual void Process () { GenerateRules (); } - virtual std::string TypeSpecificCFlags() { return ""; } - virtual std::string TypeSpecificNasmFlags() { return ""; } - virtual std::string TypeSpecificLinkerFlags() { return ""; } void GenerateInvocations () const; void GenerateCleanTarget () const; void GenerateInstallTarget () const; @@ -221,7 +218,6 @@ class MingwKernelModeDriverModuleHandler : public MingwModuleHandler public: MingwKernelModeDriverModuleHandler ( const Module& module ); virtual void Process (); - std::string TypeSpecificCFlags() { return "-D__NTDRIVER__"; } void AddImplicitLibraries ( Module& module ); private: void GenerateKernelModeDriverModuleTarget (); @@ -244,7 +240,6 @@ class MingwNativeCUIModuleHandler : public MingwModuleHandler public: MingwNativeCUIModuleHandler ( const Module& module ); virtual void Process (); - std::string TypeSpecificCFlags() { return "-D__NTAPP__"; } void AddImplicitLibraries ( Module& module ); private: void GenerateNativeCUIModuleTarget (); @@ -300,30 +295,17 @@ class MingwBootLoaderModuleHandler : public MingwModuleHandler public: MingwBootLoaderModuleHandler ( const Module& module ); virtual void Process (); - std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } private: void GenerateBootLoaderModuleTarget (); }; -class MingwBootSectorModuleHandler : public MingwModuleHandler -{ -public: - MingwBootSectorModuleHandler ( const Module& module ); - virtual void Process (); - std::string TypeSpecificNasmFlags() { return "-f bin"; } -private: - void GenerateBootSectorModuleTarget (); -}; - - class MingwBootProgramModuleHandler : public MingwModuleHandler { public: MingwBootProgramModuleHandler ( const Module& module ); virtual void Process (); std::string GetProgTextAddrMacro (); - std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; } private: void GenerateBootProgramModuleTarget (); }; diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index bac1feb33a6..058c9ee3777 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -245,7 +245,6 @@ Module::Module ( const Project& project, linkerScript (NULL), pch (NULL), cplusplus (false), - host (HostDefault), output (NULL), install (NULL) { @@ -363,23 +362,6 @@ Module::Module ( const Project& project, else underscoreSymbols = false; - att = moduleNode.GetAttribute ( "host", false ); - if ( att != NULL ) - { - const char* p = att->value.c_str(); - if ( !stricmp ( p, "true" ) || !stricmp ( p, "yes" ) ) - host = HostTrue; - else if ( !stricmp ( p, "false" ) || !stricmp ( p, "no" ) ) - host = HostFalse; - else - { - throw InvalidAttributeValueException ( - moduleNode.location, - "host", - att->value ); - } - } - att = moduleNode.GetAttribute ( "isstartuplib", false ); if ( att != NULL ) { @@ -392,7 +374,7 @@ Module::Module ( const Project& project, { throw InvalidAttributeValueException ( moduleNode.location, - "host", + "isstartuplib", att->value ); } } diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index a501b93a0d4..287075417d4 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -369,7 +369,6 @@ public: PchFile* pch; bool cplusplus; std::string prefix; - HostType host; std::string aliasedModuleName; bool allowWarnings; bool enabled;