mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:25:58 +00:00
add 'location' information to a couple exceptions that should have it
fixed bug I introduced in MingwBackend::ProcessModule() fixed bug in std::map usage, apparently map<const char*,...> is a bad idea let make do some work, create variables to hold include list for each module svn path=/branches/xmlbuildsystem/; revision=12901
This commit is contained in:
parent
10324ce772
commit
03e6c98e63
11 changed files with 82 additions and 50 deletions
|
@ -422,7 +422,8 @@ XMLElement::GetAttribute ( const string& attribute,
|
||||||
}
|
}
|
||||||
if ( required )
|
if ( required )
|
||||||
{
|
{
|
||||||
throw RequiredAttributeNotFoundException ( attribute,
|
throw RequiredAttributeNotFoundException ( location,
|
||||||
|
attribute,
|
||||||
name );
|
name );
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -441,7 +442,8 @@ XMLElement::GetAttribute ( const string& attribute,
|
||||||
}
|
}
|
||||||
if ( required )
|
if ( required )
|
||||||
{
|
{
|
||||||
throw RequiredAttributeNotFoundException ( attribute,
|
throw RequiredAttributeNotFoundException ( location,
|
||||||
|
attribute,
|
||||||
name );
|
name );
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -8,25 +8,26 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
map<const char*,Backend::Factory*>* Backend::Factory::factories = NULL;
|
map<string,Backend::Factory*>* Backend::Factory::factories = NULL;
|
||||||
|
|
||||||
Backend::Factory::Factory ( const std::string& name_ )
|
Backend::Factory::Factory ( const std::string& name_ )
|
||||||
{
|
{
|
||||||
string name(name_);
|
string name(name_);
|
||||||
strlwr ( &name[0] );
|
strlwr ( &name[0] );
|
||||||
if ( !factories )
|
if ( !factories )
|
||||||
factories = new map<const char*,Factory*>;
|
factories = new map<string,Factory*>;
|
||||||
(*factories)[name.c_str()] = this;
|
(*factories)[name] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ Backend*
|
/*static*/ Backend*
|
||||||
Backend::Factory::Create ( const std::string& name, Project& project )
|
Backend::Factory::Create ( const string& name,
|
||||||
|
Project& project )
|
||||||
{
|
{
|
||||||
string sname ( name );
|
string sname ( name );
|
||||||
strlwr ( &sname[0] );
|
strlwr ( &sname[0] );
|
||||||
if ( !factories || !factories->size() )
|
if ( !factories || !factories->size() )
|
||||||
throw Exception ( "internal tool error: no registered factories" );
|
throw Exception ( "internal tool error: no registered factories" );
|
||||||
Backend::Factory* f = (*factories)[sname.c_str()];
|
Backend::Factory* f = (*factories)[sname];
|
||||||
if ( !f )
|
if ( !f )
|
||||||
{
|
{
|
||||||
throw UnknownBackendException ( sname );
|
throw UnknownBackendException ( sname );
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Backend
|
||||||
public:
|
public:
|
||||||
class Factory
|
class Factory
|
||||||
{
|
{
|
||||||
static std::map<const char*,Factory*>* factories;
|
static std::map<std::string,Factory*>* factories;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -22,7 +22,8 @@ public:
|
||||||
virtual Backend* operator() ( Project& ) = 0;
|
virtual Backend* operator() ( Project& ) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Backend* Create ( const std::string& name, Project& project );
|
static Backend* Create ( const std::string& name,
|
||||||
|
Project& project );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,7 +90,9 @@ MingwBackend::GenerateAllTarget ()
|
||||||
void
|
void
|
||||||
MingwBackend::ProcessModule ( Module& module )
|
MingwBackend::ProcessModule ( Module& module )
|
||||||
{
|
{
|
||||||
MingwModuleHandler* h = MingwModuleHandler::LookupHandler ( module.name );
|
MingwModuleHandler* h = MingwModuleHandler::LookupHandler (
|
||||||
|
module.node.location,
|
||||||
|
module.stype );
|
||||||
h->Process ( module );
|
h->Process ( module );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
map<const char*,MingwModuleHandler*>*
|
map<string,MingwModuleHandler*>*
|
||||||
MingwModuleHandler::handler_map = NULL;
|
MingwModuleHandler::handler_map = NULL;
|
||||||
|
|
||||||
FILE*
|
FILE*
|
||||||
|
@ -21,8 +21,8 @@ MingwModuleHandler::MingwModuleHandler ( const char* moduletype_ )
|
||||||
string moduletype ( moduletype_ );
|
string moduletype ( moduletype_ );
|
||||||
strlwr ( &moduletype[0] );
|
strlwr ( &moduletype[0] );
|
||||||
if ( !handler_map )
|
if ( !handler_map )
|
||||||
handler_map = new map<const char*,MingwModuleHandler*>;
|
handler_map = new map<string,MingwModuleHandler*>;
|
||||||
(*handler_map)[moduletype.c_str()] = this;
|
(*handler_map)[moduletype] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
|
@ -32,16 +32,17 @@ MingwModuleHandler::SetMakefile ( FILE* f )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static*/ MingwModuleHandler*
|
/*static*/ MingwModuleHandler*
|
||||||
MingwModuleHandler::LookupHandler ( const string& moduletype_ )
|
MingwModuleHandler::LookupHandler ( const string& location,
|
||||||
|
const string& moduletype_ )
|
||||||
{
|
{
|
||||||
string moduletype ( moduletype_ );
|
string moduletype ( moduletype_ );
|
||||||
strlwr ( &moduletype[0] );
|
strlwr ( &moduletype[0] );
|
||||||
if ( !handler_map )
|
if ( !handler_map )
|
||||||
throw Exception ( "internal tool error: no registered module handlers" );
|
throw Exception ( "internal tool error: no registered module handlers" );
|
||||||
MingwModuleHandler* h = (*handler_map)[moduletype.c_str()];
|
MingwModuleHandler* h = (*handler_map)[moduletype];
|
||||||
if ( !h )
|
if ( !h )
|
||||||
{
|
{
|
||||||
throw UnknownModuleTypeException ( moduletype );
|
throw UnknownModuleTypeException ( location, moduletype );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
|
@ -217,6 +218,16 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Includ
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const
|
||||||
|
{
|
||||||
|
string name ( module.name + "_INCLUDES" );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"%s := %s\n",
|
||||||
|
name.c_str(),
|
||||||
|
GenerateGccIncludeParameters(module).c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
|
MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
|
||||||
{
|
{
|
||||||
|
@ -234,12 +245,7 @@ string
|
||||||
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
|
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
|
||||||
{
|
{
|
||||||
string parameters = GenerateGccDefineParameters ( module );
|
string parameters = GenerateGccDefineParameters ( module );
|
||||||
string s = GenerateGccIncludeParameters ( module );
|
parameters += ssprintf(" $(%s_INCLUDES)",module.name.c_str());
|
||||||
if ( s.length () > 0 )
|
|
||||||
{
|
|
||||||
parameters += " ";
|
|
||||||
parameters += s;
|
|
||||||
}
|
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +256,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
|
||||||
if ( module.files.size () == 0 )
|
if ( module.files.size () == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GenerateGccModuleIncludeVariable ( module );
|
||||||
|
|
||||||
for ( size_t i = 0; i < module.files.size (); i++ )
|
for ( size_t i = 0; i < module.files.size (); i++ )
|
||||||
{
|
{
|
||||||
string sourceFilename = module.files[i]->name;
|
string sourceFilename = module.files[i]->name;
|
||||||
|
@ -378,7 +386,7 @@ MingwModuleHandler::GenerateInvocations ( const Module& module ) const
|
||||||
{
|
{
|
||||||
const Invoke& invoke = *module.invocations[i];
|
const Invoke& invoke = *module.invocations[i];
|
||||||
|
|
||||||
if ( invoke.invokeModule->type != BuildTool )
|
if ( invoke.invokeModule->etype != BuildTool )
|
||||||
throw InvalidBuildFileException ( module.node.location,
|
throw InvalidBuildFileException ( module.node.location,
|
||||||
"Only modules of type buildtool can be invoked." );
|
"Only modules of type buildtool can be invoked." );
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
class MingwModuleHandler
|
class MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::map<const char*,MingwModuleHandler*>* handler_map;
|
static std::map<std::string,MingwModuleHandler*>* handler_map;
|
||||||
|
|
||||||
MingwModuleHandler ( const char* moduletype_ );
|
MingwModuleHandler ( const char* moduletype_ );
|
||||||
virtual ~MingwModuleHandler() {}
|
virtual ~MingwModuleHandler() {}
|
||||||
|
|
||||||
static void SetMakefile ( FILE* f );
|
static void SetMakefile ( FILE* f );
|
||||||
static MingwModuleHandler* LookupHandler ( const std::string& moduletype_ );
|
static MingwModuleHandler* LookupHandler ( const std::string& location,
|
||||||
|
const std::string& moduletype_ );
|
||||||
virtual void Process ( const Module& module ) = 0;
|
virtual void Process ( const Module& module ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -42,6 +43,7 @@ private:
|
||||||
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
|
std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines ) const;
|
||||||
std::string GenerateGccDefineParameters ( const Module& module ) const;
|
std::string GenerateGccDefineParameters ( const Module& module ) const;
|
||||||
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
|
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
|
||||||
|
void GenerateGccModuleIncludeVariable ( const Module& module ) const;
|
||||||
std::string GenerateGccIncludeParameters ( const Module& module ) const;
|
std::string GenerateGccIncludeParameters ( const Module& module ) const;
|
||||||
std::string GenerateGccParameters ( const Module& module ) const;
|
std::string GenerateGccParameters ( const Module& module ) const;
|
||||||
void GenerateObjectFileTargets ( const Module& module,
|
void GenerateObjectFileTargets ( const Module& module,
|
||||||
|
|
|
@ -93,17 +93,23 @@ XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName,
|
RequiredAttributeNotFoundException::RequiredAttributeNotFoundException (
|
||||||
const string& elementName )
|
const string& location,
|
||||||
: InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.",
|
const string& attributeName,
|
||||||
|
const string& elementName )
|
||||||
|
: InvalidBuildFileException ( location,
|
||||||
|
"Required attribute '%s' not found on '%s'.",
|
||||||
attributeName.c_str (),
|
attributeName.c_str (),
|
||||||
elementName.c_str ())
|
elementName.c_str ())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidAttributeValueException::InvalidAttributeValueException ( const string& name,
|
InvalidAttributeValueException::InvalidAttributeValueException (
|
||||||
const string& value )
|
const string& location,
|
||||||
: InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.",
|
const string& name,
|
||||||
|
const string& value )
|
||||||
|
: InvalidBuildFileException ( location,
|
||||||
|
"Attribute '%s' has an invalid value '%s'.",
|
||||||
name.c_str (),
|
name.c_str (),
|
||||||
value.c_str () )
|
value.c_str () )
|
||||||
{
|
{
|
||||||
|
@ -119,12 +125,14 @@ BackendNameConflictException::BackendNameConflictException ( const string& name
|
||||||
|
|
||||||
UnknownBackendException::UnknownBackendException ( const string& name )
|
UnknownBackendException::UnknownBackendException ( const string& name )
|
||||||
: Exception ( "Unknown Backend requested: '%s'",
|
: Exception ( "Unknown Backend requested: '%s'",
|
||||||
name.c_str() )
|
name.c_str() )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UnknownModuleTypeException::UnknownModuleTypeException ( const string& moduletype )
|
UnknownModuleTypeException::UnknownModuleTypeException ( const string& location,
|
||||||
: Exception ( "module type requested: '%s'",
|
const string& moduletype )
|
||||||
moduletype.c_str() )
|
: InvalidBuildFileException ( location,
|
||||||
|
"module type requested: '%s'",
|
||||||
|
moduletype.c_str() )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ public:
|
||||||
class RequiredAttributeNotFoundException : public InvalidBuildFileException
|
class RequiredAttributeNotFoundException : public InvalidBuildFileException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RequiredAttributeNotFoundException ( const std::string& attributeName,
|
RequiredAttributeNotFoundException ( const std::string& location,
|
||||||
|
const std::string& attributeName,
|
||||||
const std::string& elementName );
|
const std::string& elementName );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +75,8 @@ public:
|
||||||
class InvalidAttributeValueException : public InvalidBuildFileException
|
class InvalidAttributeValueException : public InvalidBuildFileException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InvalidAttributeValueException ( const std::string& name,
|
InvalidAttributeValueException ( const std::string& location,
|
||||||
|
const std::string& name,
|
||||||
const std::string& value );
|
const std::string& value );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,10 +94,11 @@ public:
|
||||||
UnknownBackendException ( const std::string& name );
|
UnknownBackendException ( const std::string& name );
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnknownModuleTypeException : public Exception
|
class UnknownModuleTypeException : public InvalidBuildFileException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UnknownModuleTypeException ( const std::string& moduletype );
|
UnknownModuleTypeException ( const std::string& location,
|
||||||
|
const std::string& moduletype );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __EXCEPTION_H */
|
#endif /* __EXCEPTION_H */
|
||||||
|
|
|
@ -38,7 +38,9 @@ Module::Module ( const Project& project,
|
||||||
|
|
||||||
att = moduleNode.GetAttribute ( "type", true );
|
att = moduleNode.GetAttribute ( "type", true );
|
||||||
assert(att);
|
assert(att);
|
||||||
type = GetModuleType ( *att );
|
stype = att->value;
|
||||||
|
strlwr ( &stype[0] );
|
||||||
|
etype = GetModuleType ( node.location, *att );
|
||||||
|
|
||||||
att = moduleNode.GetAttribute ( "extension", false );
|
att = moduleNode.GetAttribute ( "extension", false );
|
||||||
if (att != NULL)
|
if (att != NULL)
|
||||||
|
@ -136,7 +138,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleType
|
ModuleType
|
||||||
Module::GetModuleType ( const XMLAttribute& attribute )
|
Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
|
||||||
{
|
{
|
||||||
if ( attribute.value == "buildtool" )
|
if ( attribute.value == "buildtool" )
|
||||||
return BuildTool;
|
return BuildTool;
|
||||||
|
@ -144,14 +146,15 @@ Module::GetModuleType ( const XMLAttribute& attribute )
|
||||||
return StaticLibrary;
|
return StaticLibrary;
|
||||||
if ( attribute.value == "kernelmodedll" )
|
if ( attribute.value == "kernelmodedll" )
|
||||||
return KernelModeDLL;
|
return KernelModeDLL;
|
||||||
throw InvalidAttributeValueException ( attribute.name,
|
throw InvalidAttributeValueException ( location,
|
||||||
|
attribute.name,
|
||||||
attribute.value );
|
attribute.value );
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
Module::GetDefaultModuleExtension () const
|
Module::GetDefaultModuleExtension () const
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (etype)
|
||||||
{
|
{
|
||||||
case BuildTool:
|
case BuildTool:
|
||||||
return EXEPOSTFIX;
|
return EXEPOSTFIX;
|
||||||
|
|
|
@ -71,7 +71,8 @@ public:
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string extension;
|
std::string extension;
|
||||||
std::string path;
|
std::string path;
|
||||||
ModuleType type;
|
ModuleType etype;
|
||||||
|
std::string stype;
|
||||||
std::vector<File*> files;
|
std::vector<File*> files;
|
||||||
std::vector<Library*> libraries;
|
std::vector<Library*> libraries;
|
||||||
std::vector<Include*> includes;
|
std::vector<Include*> includes;
|
||||||
|
@ -83,7 +84,8 @@ public:
|
||||||
const XMLElement& moduleNode,
|
const XMLElement& moduleNode,
|
||||||
const std::string& modulePath );
|
const std::string& modulePath );
|
||||||
~Module ();
|
~Module ();
|
||||||
ModuleType GetModuleType (const XMLAttribute& attribute );
|
ModuleType GetModuleType ( const std::string& location,
|
||||||
|
const XMLAttribute& attribute );
|
||||||
std::string GetBasePath() const;
|
std::string GetBasePath() const;
|
||||||
std::string GetPath () const;
|
std::string GetPath () const;
|
||||||
std::string GetTargets () const;
|
std::string GetTargets () const;
|
||||||
|
|
|
@ -9,7 +9,7 @@ void ModuleTest::Run()
|
||||||
ARE_EQUAL(2, project.modules.size());
|
ARE_EQUAL(2, project.modules.size());
|
||||||
|
|
||||||
Module& module1 = *project.modules[0];
|
Module& module1 = *project.modules[0];
|
||||||
IS_TRUE(module1.type == BuildTool);
|
IS_TRUE(module1.etype == BuildTool);
|
||||||
ARE_EQUAL(2, module1.files.size());
|
ARE_EQUAL(2, module1.files.size());
|
||||||
ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name);
|
ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name);
|
||||||
ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name);
|
ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name);
|
||||||
|
@ -17,7 +17,7 @@ void ModuleTest::Run()
|
||||||
ARE_EQUAL(0, module1.libraries.size());
|
ARE_EQUAL(0, module1.libraries.size());
|
||||||
|
|
||||||
Module& module2 = *project.modules[1];
|
Module& module2 = *project.modules[1];
|
||||||
IS_TRUE(module2.type == KernelModeDLL);
|
IS_TRUE(module2.etype == KernelModeDLL);
|
||||||
ARE_EQUAL(2, module2.files.size());
|
ARE_EQUAL(2, module2.files.size());
|
||||||
ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name);
|
ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name);
|
||||||
ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);
|
ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue