Remove host attribute of module element. It wasn't used and can be deduced from module type

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
This commit is contained in:
Hervé Poussineau 2008-09-09 07:12:30 +00:00
parent c1c6da32a4
commit 8bfedb5a6d
6 changed files with 63 additions and 129 deletions

View file

@ -34,42 +34,39 @@ using std::map;
typedef set<string> set_string; typedef set<string> set_string;
static const struct const struct ModuleHandlerInformations ModuleHandlerInformations[] = {
{ { HostTrue, "", "", "" }, // BuildTool
HostType DefaultHost; { HostFalse, "", "", "" }, // StaticLibrary
} ModuleHandlerInformations[] = { { HostFalse, "", "", "" }, // ObjectLibrary
{ HostTrue }, // BuildTool { HostFalse, "", "", "" }, // Kernel
{ HostFalse }, // StaticLibrary { HostFalse, "", "", "" }, // KernelModeDLL
{ HostFalse }, // ObjectLibrary { HostFalse, "-D__NTDRIVER__", "", "" }, // KernelModeDriver
{ HostFalse }, // Kernel { HostFalse, "", "", "" }, // NativeDLL
{ HostFalse }, // KernelModeDLL { HostFalse, "-D__NTAPP__", "", "" }, // NativeCUI
{ HostFalse }, // KernelModeDriver { HostFalse, "", "", "" }, // Win32DLL
{ HostFalse }, // NativeDLL { HostFalse, "", "", "" }, // Win32OCX
{ HostFalse }, // NativeCUI { HostFalse, "", "", "" }, // Win32CUI
{ HostFalse }, // Win32DLL { HostFalse, "", "", "" }, // Win32GUI
{ HostFalse }, // Win32OCX { HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootLoader
{ HostFalse }, // Win32CUI { HostFalse, "", "-f bin", "" }, // BootSector
{ HostFalse }, // Win32GUI { HostFalse, "", "", "" }, // Iso
{ HostFalse }, // BootLoader { HostFalse, "", "", "" }, // LiveIso
{ HostFalse }, // BootSector { HostFalse, "", "", "" }, // Test
{ HostFalse }, // Iso { HostFalse, "", "", "" }, // RpcServer
{ HostFalse }, // LiveIso { HostFalse, "", "", "" }, // RpcClient
{ HostFalse }, // Test { HostFalse, "", "", "" }, // Alias
{ HostFalse }, // RpcServer { HostFalse, "", "", "-nostartfiles -nostdlib" }, // BootProgram
{ HostFalse }, // RpcClient { HostFalse, "", "", "" }, // Win32SCR
{ HostFalse }, // Alias { HostFalse, "", "", "" }, // IdlHeader
{ HostFalse }, // BootProgram { HostFalse, "", "", "" }, // IsoRegTest
{ HostFalse }, // Win32SCR { HostFalse, "", "", "" }, // LiveIsoRegTest
{ HostFalse }, // IdlHeader { HostFalse, "", "", "" }, // EmbeddedTypeLib
{ HostFalse }, // IsoRegTest { HostFalse, "", "", "" }, // ElfExecutable
{ HostFalse }, // LiveIsoRegTest { HostFalse, "", "", "" }, // RpcProxy
{ HostFalse }, // EmbeddedTypeLib { HostTrue, "", "", "" }, // HostStaticLibrary
{ HostFalse }, // ElfExecutable { HostFalse, "", "", "" }, // Cabinet
{ HostFalse }, // RpcProxy { HostFalse, "", "", "" }, // KeyboardLayout
{ HostTrue }, // HostStaticLibrary { HostFalse, "", "", "" }, // MessageHeader
{ HostFalse }, // Cabinet
{ HostFalse }, // KeyboardLayout
{ HostFalse }, // MessageHeader
}; };
string string
@ -269,11 +266,6 @@ MingwBackend::ProcessModules ()
h->AddImplicitLibraries ( module ); h->AddImplicitLibraries ( module );
if ( use_pch && CanEnablePreCompiledHeaderSupportForModule ( module ) ) if ( use_pch && CanEnablePreCompiledHeaderSupportForModule ( module ) )
h->EnablePreCompiledHeaderSupport (); h->EnablePreCompiledHeaderSupport ();
if ( module.host == HostDefault )
{
module.host = ModuleHandlerInformations[h->module.type].DefaultHost;
assert ( module.host != HostDefault );
}
v.push_back ( h ); v.push_back ( h );
} }
@ -343,7 +335,7 @@ MingwBackend::CheckAutomaticDependenciesForModuleOnly ()
void void
MingwBackend::ProcessNormal () MingwBackend::ProcessNormal ()
{ {
assert(sizeof(ModuleHandlerInformations)/sizeof(ModuleHandlerInformations[0]) == TypeDontCare); assert(sizeof(ModuleHandlerInformations)/sizeof(ModuleHandlerInformations[0]) == TypeDontCare);
DetectCompiler (); DetectCompiler ();
DetectBinutils (); DetectBinutils ();

View file

@ -142,4 +142,14 @@ private:
const Project& project; 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 */ #endif /* MINGW_H */

View file

@ -174,6 +174,7 @@ MingwModuleHandler::InstanciateHandler (
case MessageHeader: case MessageHeader:
case IdlHeader: case IdlHeader:
case EmbeddedTypeLib: case EmbeddedTypeLib:
case BootSector:
handler = new MingwModuleHandler( module ); handler = new MingwModuleHandler( module );
break; break;
case BuildTool: case BuildTool:
@ -211,9 +212,6 @@ MingwModuleHandler::InstanciateHandler (
case BootLoader: case BootLoader:
handler = new MingwBootLoaderModuleHandler ( module ); handler = new MingwBootLoaderModuleHandler ( module );
break; break;
case BootSector:
handler = new MingwBootSectorModuleHandler ( module );
break;
case BootProgram: case BootProgram:
handler = new MingwBootProgramModuleHandler ( module ); handler = new MingwBootProgramModuleHandler ( module );
break; break;
@ -1315,7 +1313,7 @@ MingwModuleHandler::GenerateCommands (
for ( i = 0; i < sizeof ( rules ) / sizeof ( rules[0] ); i++ ) 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; continue;
if ( rules[i].type != TypeDontCare && rules[i].type != module.type ) if ( rules[i].type != TypeDontCare && rules[i].type != module.type )
continue; continue;
@ -1638,8 +1636,8 @@ MingwModuleHandler::GenerateObjectFileTargets ()
if ( pchFilename ) if ( pchFilename )
{ {
string cc = ( module.host == HostTrue ? "${host_gcc}" : "${gcc}" ); string cc = ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ? "${host_gcc}" : "${gcc}" );
string cppc = ( module.host == HostTrue ? "${host_gpp}" : "${gpp}" ); string cppc = ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue ? "${host_gpp}" : "${gpp}" );
const FileLocation& baseHeaderFile = *module.pch->file; const FileLocation& baseHeaderFile = *module.pch->file;
CLEAN_FILE ( *pchFilename ); CLEAN_FILE ( *pchFilename );
@ -1849,7 +1847,7 @@ MingwModuleHandler::GenerateOtherMacros ()
&module.linkerFlags, &module.linkerFlags,
used_defs ); used_defs );
if ( module.host == HostFalse ) if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse )
{ {
GenerateMacros ( GenerateMacros (
"+=", "+=",
@ -1885,7 +1883,7 @@ MingwModuleHandler::GenerateOtherMacros ()
} }
string globalCflags = ""; string globalCflags = "";
if ( module.host == HostFalse ) if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse )
globalCflags += " $(PROJECT_CFLAGS)"; globalCflags += " $(PROJECT_CFLAGS)";
else else
globalCflags += " -Wall -Wpointer-arith -D__REACTOS__"; globalCflags += " -Wall -Wpointer-arith -D__REACTOS__";
@ -1894,7 +1892,7 @@ MingwModuleHandler::GenerateOtherMacros ()
globalCflags += " -pipe"; globalCflags += " -pipe";
if ( !module.allowWarnings ) if ( !module.allowWarnings )
globalCflags += " -Werror"; globalCflags += " -Werror";
if ( module.host == HostTrue ) if ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue )
{ {
if ( module.cplusplus ) if ( module.cplusplus )
globalCflags += " $(HOST_CPPFLAGS)"; globalCflags += " $(HOST_CPPFLAGS)";
@ -1922,7 +1920,7 @@ MingwModuleHandler::GenerateOtherMacros ()
cflagsMacro.c_str (), cflagsMacro.c_str (),
globalCflags.c_str () ); globalCflags.c_str () );
if ( module.host == HostFalse ) if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse )
{ {
fprintf ( fprintf (
fMakefile, fMakefile,
@ -1955,31 +1953,31 @@ MingwModuleHandler::GenerateOtherMacros ()
linkDepsMacro.c_str (), linkDepsMacro.c_str (),
libsMacro.c_str () ); libsMacro.c_str () );
string cflags = TypeSpecificCFlags(); const char *cflags = ModuleHandlerInformations[module.type].cflags;
if ( cflags.size() > 0 ) if ( strlen( cflags ) > 0 )
{ {
fprintf ( fMakefile, fprintf ( fMakefile,
"%s += %s\n\n", "%s += %s\n\n",
cflagsMacro.c_str (), cflagsMacro.c_str (),
cflags.c_str () ); cflags );
} }
string nasmflags = TypeSpecificNasmFlags(); const char* nasmflags = ModuleHandlerInformations[module.type].nasmflags;
if ( nasmflags.size () > 0 ) if ( strlen( nasmflags ) > 0 )
{ {
fprintf ( fMakefile, fprintf ( fMakefile,
"%s += %s\n\n", "%s += %s\n\n",
nasmflagsMacro.c_str (), nasmflagsMacro.c_str (),
nasmflags.c_str () ); nasmflags );
} }
string linkerflags = TypeSpecificLinkerFlags(); const char *linkerflags = ModuleHandlerInformations[module.type].linkerflags;
if ( linkerflags.size() > 0 ) if ( strlen( linkerflags ) > 0 )
{ {
fprintf ( fMakefile, fprintf ( fMakefile,
"%s += %s\n\n", "%s += %s\n\n",
linkerflagsMacro.c_str (), linkerflagsMacro.c_str (),
linkerflags.c_str () ); linkerflags );
} }
if ( IsStaticLibrary ( module ) && module.isStartupLib ) if ( IsStaticLibrary ( module ) && module.isStartupLib )
@ -2106,7 +2104,7 @@ MingwModuleHandler::GetDefaultDependencies (
string_list& dependencies ) const string_list& dependencies ) const
{ {
/* Avoid circular dependency */ /* Avoid circular dependency */
if ( module.host == HostTrue ) if ( ModuleHandlerInformations[module.type].DefaultHost == HostTrue )
return; return;
if (module.name != "psdk" && 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 ( MingwBootProgramModuleHandler::MingwBootProgramModuleHandler (
const Module& module_ ) const Module& module_ )
: MingwModuleHandler ( module_ ) : MingwModuleHandler ( module_ )

View file

@ -67,9 +67,6 @@ public:
MingwBackend* backend_ ); MingwBackend* backend_ );
void GeneratePreconditionDependencies (); void GeneratePreconditionDependencies ();
virtual void Process () { GenerateRules (); } virtual void Process () { GenerateRules (); }
virtual std::string TypeSpecificCFlags() { return ""; }
virtual std::string TypeSpecificNasmFlags() { return ""; }
virtual std::string TypeSpecificLinkerFlags() { return ""; }
void GenerateInvocations () const; void GenerateInvocations () const;
void GenerateCleanTarget () const; void GenerateCleanTarget () const;
void GenerateInstallTarget () const; void GenerateInstallTarget () const;
@ -221,7 +218,6 @@ class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
public: public:
MingwKernelModeDriverModuleHandler ( const Module& module ); MingwKernelModeDriverModuleHandler ( const Module& module );
virtual void Process (); virtual void Process ();
std::string TypeSpecificCFlags() { return "-D__NTDRIVER__"; }
void AddImplicitLibraries ( Module& module ); void AddImplicitLibraries ( Module& module );
private: private:
void GenerateKernelModeDriverModuleTarget (); void GenerateKernelModeDriverModuleTarget ();
@ -244,7 +240,6 @@ class MingwNativeCUIModuleHandler : public MingwModuleHandler
public: public:
MingwNativeCUIModuleHandler ( const Module& module ); MingwNativeCUIModuleHandler ( const Module& module );
virtual void Process (); virtual void Process ();
std::string TypeSpecificCFlags() { return "-D__NTAPP__"; }
void AddImplicitLibraries ( Module& module ); void AddImplicitLibraries ( Module& module );
private: private:
void GenerateNativeCUIModuleTarget (); void GenerateNativeCUIModuleTarget ();
@ -300,30 +295,17 @@ class MingwBootLoaderModuleHandler : public MingwModuleHandler
public: public:
MingwBootLoaderModuleHandler ( const Module& module ); MingwBootLoaderModuleHandler ( const Module& module );
virtual void Process (); virtual void Process ();
std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
private: private:
void GenerateBootLoaderModuleTarget (); 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 class MingwBootProgramModuleHandler : public MingwModuleHandler
{ {
public: public:
MingwBootProgramModuleHandler ( const Module& module ); MingwBootProgramModuleHandler ( const Module& module );
virtual void Process (); virtual void Process ();
std::string GetProgTextAddrMacro (); std::string GetProgTextAddrMacro ();
std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
private: private:
void GenerateBootProgramModuleTarget (); void GenerateBootProgramModuleTarget ();
}; };

View file

@ -245,7 +245,6 @@ Module::Module ( const Project& project,
linkerScript (NULL), linkerScript (NULL),
pch (NULL), pch (NULL),
cplusplus (false), cplusplus (false),
host (HostDefault),
output (NULL), output (NULL),
install (NULL) install (NULL)
{ {
@ -363,23 +362,6 @@ Module::Module ( const Project& project,
else else
underscoreSymbols = false; 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 ); att = moduleNode.GetAttribute ( "isstartuplib", false );
if ( att != NULL ) if ( att != NULL )
{ {
@ -392,7 +374,7 @@ Module::Module ( const Project& project,
{ {
throw InvalidAttributeValueException ( throw InvalidAttributeValueException (
moduleNode.location, moduleNode.location,
"host", "isstartuplib",
att->value ); att->value );
} }
} }

View file

@ -369,7 +369,6 @@ public:
PchFile* pch; PchFile* pch;
bool cplusplus; bool cplusplus;
std::string prefix; std::string prefix;
HostType host;
std::string aliasedModuleName; std::string aliasedModuleName;
bool allowWarnings; bool allowWarnings;
bool enabled; bool enabled;