Remove host attribute of module element. It wasn't used and can be deduced from modul...
authorHervé Poussineau <hpoussin@reactos.org>
Tue, 9 Sep 2008 07:12:30 +0000 (07:12 +0000)
committerHervé Poussineau <hpoussin@reactos.org>
Tue, 9 Sep 2008 07:12:30 +0000 (07:12 +0000)
Remove MingwBootSectorModuleHandler class
Move module specific cflags, nasmflags and linkerflags to an array. One day, we won't be forced to create a new MingwModuleHandler each time we add a module type

svn path=/trunk/; revision=36076

reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/mingw.h
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/rbuild.h

index e86a178..7a66bc7 100644 (file)
@@ -34,42 +34,39 @@ 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
+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 ();
index 0516465..2c7e23b 100644 (file)
@@ -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 */
index 34b8554..534ce0b 100644 (file)
@@ -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_ )
index 9d9f62d..09a7b17 100644 (file)
@@ -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 ();
 };
index bac1feb..058c9ee 100644 (file)
@@ -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 );
                }
        }
index a501b93..2870754 100644 (file)
@@ -369,7 +369,6 @@ public:
        PchFile* pch;
        bool cplusplus;
        std::string prefix;
-       HostType host;
        std::string aliasedModuleName;
        bool allowWarnings;
        bool enabled;