Static library module type.

svn path=/branches/xmlbuildsystem/; revision=12877
This commit is contained in:
Casper Hornstrup 2005-01-08 00:25:48 +00:00
parent 49a2dd8017
commit 5f69cb429e
12 changed files with 182 additions and 74 deletions

View file

@ -1,7 +1,7 @@
<project name="ReactOS" makefile="Makefile.auto">
<define name="_M_IX86"></define>
<include>./include</include>
<include>./w32api/include</include>
<include>include</include>
<include>w32api/include</include>
<directory name="tools">
<module name="depends" type="buildtool">
<file>depends.c</file>

View file

@ -1,7 +1,7 @@
<module name="kjs" type="staticlibrary">
<include>.</include>
<include>./src</include>
<include>./include</include>
<include>src</include>
<include>include</include>
<directory name="ksrc">
<file>setjmp.S</file>
<file>longjmp.S</file>
@ -24,7 +24,6 @@
<file>vmjumps.c</file>
<file>vmswitch.c</file>
<file>vmswt0.c</file>
<file>longjmp.c</file>
</directory>
<directory name="src">
<file>b_array.c</file>

View file

@ -1,8 +1,8 @@
<module name="ntoskrnl" type="kernelmodedll">
<define name="_SEH_NO_NATIVE_NLG"></define>
<define name="_DISABLE_TIDENTS"></define>
<define name="__NTOSKRNL__"></define>
<define name="__3GB__"></define>
<module name="ntoskrnl" type="kernelmodedll" extension=".exe">
<define name="_SEH_NO_NATIVE_NLG" />
<define name="_DISABLE_TIDENTS" />
<define name="__NTOSKRNL__" />
<define name="__3GB__" />
<include>.</include>
<include>./include</include>
<include>../lib/kjs/include</include>
@ -44,12 +44,14 @@
</group>
</if>
<or>
<!--
<if property="kdbg" value="true">
<group>
<file>kdb_stabs.c</file>
<file>kdb_symbols.c</file>
</group>
</if>
-->
<if property="dbg" value="true">
<group>
<file>kdb_stabs.c</file>

View file

@ -103,4 +103,5 @@ void
MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers )
{
moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) );
moduleHandlers.push_back ( new MingwStaticLibraryModuleHandler ( fMakefile ) );
}

View file

@ -128,7 +128,20 @@ MingwModuleHandler::GenerateGccDefineParameters ( Module& module )
}
string
MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector<Include*> includes )
MingwModuleHandler::ConcatenatePaths ( string path1,
string path2 )
{
if ( ( path1.length () == 0 ) || ( path1 == "." ) || ( path1 == "./" ) )
return path2;
if ( path1[path1.length ()] == CSEP )
return path1 + path2;
else
return path1 + CSEP + path2;
}
string
MingwModuleHandler::GenerateGccIncludeParametersFromVector ( string basePath,
vector<Include*> includes )
{
string parameters;
for (size_t i = 0; i < includes.size (); i++)
@ -137,7 +150,8 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector<Include*> in
if (parameters.length () > 0)
parameters += " ";
parameters += "-I";
parameters += include.directory;
parameters += ConcatenatePaths ( basePath,
include.directory );
}
return parameters;
}
@ -145,8 +159,10 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( vector<Include*> in
string
MingwModuleHandler::GenerateGccIncludeParameters ( Module& module )
{
string parameters = GenerateGccIncludeParametersFromVector ( module.project->includes );
string s = GenerateGccIncludeParametersFromVector ( module.includes );
string parameters = GenerateGccIncludeParametersFromVector ( ".",
module.project->includes );
string s = GenerateGccIncludeParametersFromVector ( module.path,
module.includes );
if (s.length () > 0)
{
parameters += " ";
@ -202,7 +218,7 @@ MingwModuleHandler::GenerateArchiveTarget ( Module& module )
fprintf ( fMakefile,
"%s: %s\n",
archiveFilename.c_str (),
sourceFilenames.c_str ());
objectFilenames.c_str ());
fprintf ( fMakefile,
"\t${ar} -rc %s %s\n\n",
@ -219,7 +235,7 @@ MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile )
bool
MingwKernelModuleHandler::CanHandleModule ( Module& module )
{
return true;
return module.type == KernelModeDLL;
}
void
@ -268,3 +284,28 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
GenerateArchiveTarget ( module );
GenerateObjectFileTargets ( module );
}
MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ( FILE* fMakefile )
: MingwModuleHandler ( fMakefile )
{
}
bool
MingwStaticLibraryModuleHandler::CanHandleModule ( Module& module )
{
return module.type == StaticLibrary;
}
void
MingwStaticLibraryModuleHandler::Process ( Module& module )
{
GenerateStaticLibraryModuleTarget ( module );
}
void
MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( Module& module )
{
GenerateArchiveTarget ( module );
GenerateObjectFileTargets ( module );
}

View file

@ -22,9 +22,12 @@ protected:
void GenerateArchiveTarget ( Module& module );
FILE* fMakefile;
private:
std::string ConcatenatePaths ( std::string path1,
std::string path2 );
std::string GenerateGccDefineParametersFromVector ( std::vector<Define*> defines );
std::string GenerateGccDefineParameters ( Module& module );
std::string GenerateGccIncludeParametersFromVector ( std::vector<Include*> includes );
std::string GenerateGccIncludeParametersFromVector ( std::string basePath,
std::vector<Include*> includes );
std::string GenerateGccIncludeParameters ( Module& module );
std::string GenerateGccParameters ( Module& module );
};
@ -40,4 +43,15 @@ private:
void GenerateKernelModuleTarget ( Module& module );
};
class MingwStaticLibraryModuleHandler : public MingwModuleHandler
{
public:
MingwStaticLibraryModuleHandler ( FILE* fMakefile );
virtual bool CanHandleModule ( Module& module );
virtual void Process ( Module& module );
private:
void GenerateStaticLibraryModuleTarget ( Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */

View file

@ -5,58 +5,71 @@
using std::string;
Exception::Exception()
Exception::Exception ()
{
}
Exception::Exception(const string& message)
Exception::Exception ( const string& message )
{
Message = message;
}
Exception::Exception(const char* format,
...)
Exception::Exception ( const char* format,
...)
{
va_list args;
va_start(args,
format);
Message = ssvprintf(format,
args);
va_end(args);
va_start ( args,
format);
Message = ssvprintf ( format,
args);
va_end ( args );
}
void Exception::SetMessage(const char* message,
va_list args)
void Exception::SetMessage ( const char* message,
va_list args)
{
Message = ssvprintf(message,
args);
Message = ssvprintf ( message,
args);
}
FileNotFoundException::FileNotFoundException(const string& filename)
: Exception ( "File '%s' not found.", filename.c_str() )
InvalidOperationException::InvalidOperationException ( const char* filename,
const int linenumber)
{
Message = ssprintf ( "%s:%d",
filename,
linenumber );
}
FileNotFoundException::FileNotFoundException ( const string& filename )
: Exception ( "File '%s' not found.",
filename.c_str() )
{
Filename = filename;
}
AccessDeniedException::AccessDeniedException(const string& filename)
: Exception ( "Access denied to file '%s'.", filename.c_str() )
AccessDeniedException::AccessDeniedException ( const string& filename)
: Exception ( "Access denied to file '%s'.",
filename.c_str() )
{
Filename = filename;
}
InvalidBuildFileException::InvalidBuildFileException(const char* message,
...)
InvalidBuildFileException::InvalidBuildFileException ( const char* message,
...)
{
va_list args;
va_start( args, message);
SetMessage(message, args);
va_end(args);
va_start ( args,
message );
SetMessage ( message,
args );
va_end ( args );
}
InvalidBuildFileException::InvalidBuildFileException()
InvalidBuildFileException::InvalidBuildFileException ()
{
}
@ -66,36 +79,39 @@ XMLSyntaxErrorException::XMLSyntaxErrorException ( const string& location,
... )
{
va_list args;
va_start ( args, message );
va_start ( args,
message );
Message = location + ": " + ssvprintf ( message, args );
va_end ( args );
}
RequiredAttributeNotFoundException::RequiredAttributeNotFoundException(const string& attributeName,
const string& elementName)
RequiredAttributeNotFoundException::RequiredAttributeNotFoundException ( const string& attributeName,
const string& elementName )
: InvalidBuildFileException ( "Required attribute '%s' not found on '%s'.",
attributeName.c_str (),
elementName.c_str ())
{
}
InvalidAttributeValueException::InvalidAttributeValueException(const string& name,
const string& value)
InvalidAttributeValueException::InvalidAttributeValueException ( const string& name,
const string& value )
: InvalidBuildFileException ( "Attribute '%s' has an invalid value '%s'.",
name.c_str (),
value.c_str ())
value.c_str () )
{
}
BackendNameConflictException::BackendNameConflictException ( const string& name )
: Exception ( "Backend name conflict: '%s'", name.c_str() )
: Exception ( "Backend name conflict: '%s'",
name.c_str() )
{
}
UnknownBackendException::UnknownBackendException ( const string& name )
: Exception ( "Unknown Backend requested: '%s'", name.c_str() )
: Exception ( "Unknown Backend requested: '%s'",
name.c_str() )
{
}

View file

@ -6,21 +6,29 @@
class Exception
{
public:
Exception(const std::string& message);
Exception(const char* format,
...);
Exception ( const std::string& message );
Exception ( const char* format,
...);
std::string Message;
protected:
Exception();
void SetMessage(const char* message,
va_list args);
Exception ();
void SetMessage ( const char* message,
va_list args);
};
class InvalidOperationException : public Exception
{
public:
InvalidOperationException ( const char* filename,
const int linenumber);
};
class FileNotFoundException : public Exception
{
public:
FileNotFoundException(const std::string& filename);
FileNotFoundException ( const std::string& filename );
std::string Filename;
};
@ -28,7 +36,7 @@ public:
class AccessDeniedException : public Exception
{
public:
AccessDeniedException(const std::string& filename);
AccessDeniedException ( const std::string& filename );
std::string Filename;
};
@ -39,7 +47,7 @@ public:
InvalidBuildFileException ( const char* message,
...);
protected:
InvalidBuildFileException();
InvalidBuildFileException ();
};
@ -55,16 +63,16 @@ public:
class RequiredAttributeNotFoundException : public InvalidBuildFileException
{
public:
RequiredAttributeNotFoundException(const std::string& attributeName,
const std::string& elementName);
RequiredAttributeNotFoundException ( const std::string& attributeName,
const std::string& elementName );
};
class InvalidAttributeValueException : public InvalidBuildFileException
{
public:
InvalidAttributeValueException(const std::string& name,
const std::string& value);
InvalidAttributeValueException ( const std::string& name,
const std::string& value );
};

View file

@ -30,7 +30,7 @@ Include::~Include ()
void
Include::Initialize ( const XMLElement& includeNode )
{
directory = includeNode.value;
directory = FixSeparator ( includeNode.value );
}
void

View file

@ -23,14 +23,25 @@ FixSeparator ( const string& s )
Module::Module ( Project* project,
const XMLElement& moduleNode,
const string& moduleName,
const string& modulePath )
: project(project),
node(moduleNode),
name(moduleName),
path(modulePath)
node(moduleNode)
{
type = GetModuleType ( *moduleNode.GetAttribute ( "type", true ) );
path = FixSeparator ( modulePath );
const XMLAttribute* att = moduleNode.GetAttribute ( "name", true );
assert(att);
name = att->value;
att = moduleNode.GetAttribute ( "type", true );
assert(att);
type = GetModuleType ( *att );
att = moduleNode.GetAttribute ( "extension", false );
if (att != NULL)
extension = att->value;
else
extension = GetDefaultModuleExtension ();
}
Module::~Module ()
@ -49,7 +60,7 @@ Module::ProcessXML ( const XMLElement& e,
string subpath ( path );
if ( e.name == "file" && e.value.size () )
{
files.push_back ( new File ( path + CSEP + e.value ) );
files.push_back ( new File ( FixSeparator ( path + CSEP + e.value ) ) );
}
else if ( e.name == "library" && e.value.size () )
{
@ -59,7 +70,7 @@ Module::ProcessXML ( const XMLElement& e,
{
const XMLAttribute* att = e.GetAttribute ( "name", true );
assert(att);
subpath = path + CSEP + att->value;
subpath = FixSeparator ( path + CSEP + att->value );
}
else if ( e.name == "include" )
{
@ -90,10 +101,26 @@ Module::GetModuleType ( const XMLAttribute& attribute )
attribute.value );
}
string
Module::GetDefaultModuleExtension ()
{
switch (type)
{
case BuildTool:
return EXEPOSTFIX;
case StaticLibrary:
return ".a";
case KernelModeDLL:
return ".dll";
}
throw InvalidOperationException (__FILE__,
__LINE__);
}
string
Module::GetPath ()
{
return FixSeparator (path) + CSEP + name + EXEPOSTFIX;
return FixSeparator (path) + CSEP + name + extension;
}

View file

@ -59,9 +59,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
}
else if ( e.name == "module" )
{
att = e.GetAttribute ( "name", true );
assert(att);
Module* module = new Module ( this, e, att->value, path );
Module* module = new Module ( this, e, path );
modules.push_back ( module );
module->ProcessXML ( e, path );
return;

View file

@ -64,6 +64,7 @@ public:
Project* project;
const XMLElement& node;
std::string name;
std::string extension;
std::string path;
ModuleType type;
std::vector<File*> files;
@ -73,12 +74,13 @@ public:
Module ( Project* project,
const XMLElement& moduleNode,
const std::string& moduleName,
const std::string& modulePath );
~Module ();
ModuleType GetModuleType (const XMLAttribute& attribute );
std::string GetPath ();
void ProcessXML ( const XMLElement& e, const std::string& path );
private:
std::string GetDefaultModuleExtension ();
};