mirror of
https://github.com/reactos/reactos.git
synced 2025-08-13 15:15:51 +00:00
Parse libraries.
svn path=/branches/xmlbuildsystem/; revision=12840
This commit is contained in:
parent
91d97cbc91
commit
7d876c4d0c
8 changed files with 72 additions and 12 deletions
|
@ -103,5 +103,5 @@ void MingwBackend::ProcessModule ( Module& module )
|
||||||
|
|
||||||
void MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers )
|
void MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers )
|
||||||
{
|
{
|
||||||
moduleHandlers.push_back ( new MingwKernelModuleHandler () );
|
moduleHandlers.push_back ( new MingwKernelModuleHandler ( fMakefile ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,29 @@
|
||||||
#include "mingw.h"
|
#include "mingw.h"
|
||||||
#include "modulehandler.h"
|
#include "modulehandler.h"
|
||||||
|
|
||||||
MingwModuleHandler::MingwModuleHandler ()
|
using std::string;
|
||||||
|
|
||||||
|
MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile )
|
||||||
|
: fMakefile ( fMakefile )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string MingwModuleHandler::GetModuleDependencies ( Module& module )
|
||||||
|
{
|
||||||
|
string dependencies ( "" );
|
||||||
|
|
||||||
MingwKernelModuleHandler::MingwKernelModuleHandler ()
|
for ( size_t i = 0; i < module.libraries.size(); i++ )
|
||||||
|
{
|
||||||
|
if (dependencies.size () > 0)
|
||||||
|
dependencies += " ";
|
||||||
|
dependencies += module.libraries[i]->name;
|
||||||
|
}
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MingwKernelModuleHandler::MingwKernelModuleHandler ( FILE* fMakefile )
|
||||||
|
: MingwModuleHandler ( fMakefile )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,4 +38,15 @@ bool MingwKernelModuleHandler::CanHandleModule ( Module& module )
|
||||||
|
|
||||||
void MingwKernelModuleHandler::Process ( Module& module )
|
void MingwKernelModuleHandler::Process ( Module& module )
|
||||||
{
|
{
|
||||||
|
GenerateKernelModuleTarget ( module );
|
||||||
|
}
|
||||||
|
|
||||||
|
void MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
|
||||||
|
{
|
||||||
|
fprintf ( fMakefile, "%s: %s",
|
||||||
|
module.name.c_str (),
|
||||||
|
GetModuleDependencies ( module ).c_str () );
|
||||||
|
fprintf ( fMakefile, "\n" );
|
||||||
|
fprintf ( fMakefile, "\t" );
|
||||||
|
fprintf ( fMakefile, "\n\n" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
class MingwModuleHandler
|
class MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MingwModuleHandler ();
|
MingwModuleHandler ( FILE* fMakefile );
|
||||||
virtual bool CanHandleModule ( Module& module ) = 0;
|
virtual bool CanHandleModule ( Module& module ) = 0;
|
||||||
virtual void Process ( Module& module ) = 0;
|
virtual void Process ( Module& module ) = 0;
|
||||||
|
protected:
|
||||||
|
FILE* fMakefile;
|
||||||
|
std::string GetModuleDependencies ( Module& module );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MingwKernelModuleHandler : public MingwModuleHandler
|
class MingwKernelModuleHandler : public MingwModuleHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MingwKernelModuleHandler ();
|
MingwKernelModuleHandler ( FILE* fMakefile );
|
||||||
virtual bool CanHandleModule ( Module& module );
|
virtual bool CanHandleModule ( Module& module );
|
||||||
virtual void Process ( Module& module );
|
virtual void Process ( Module& module );
|
||||||
|
private:
|
||||||
|
void GenerateKernelModuleTarget ( Module& module );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MINGW_MODULEHANDLER_H */
|
#endif /* MINGW_MODULEHANDLER_H */
|
||||||
|
|
|
@ -21,6 +21,8 @@ Module::~Module ()
|
||||||
{
|
{
|
||||||
for ( size_t i = 0; i < files.size(); i++ )
|
for ( size_t i = 0; i < files.size(); i++ )
|
||||||
delete files[i];
|
delete files[i];
|
||||||
|
for ( size_t i = 0; i < libraries.size(); i++ )
|
||||||
|
delete libraries[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::ProcessXML ( const XMLElement& e,
|
void Module::ProcessXML ( const XMLElement& e,
|
||||||
|
@ -31,6 +33,10 @@ void Module::ProcessXML ( const XMLElement& e,
|
||||||
{
|
{
|
||||||
files.push_back ( new File ( path + "/" + e.value ) );
|
files.push_back ( new File ( path + "/" + e.value ) );
|
||||||
}
|
}
|
||||||
|
else if ( e.name == "library" && e.value.size () )
|
||||||
|
{
|
||||||
|
libraries.push_back ( new Library ( e.value ) );
|
||||||
|
}
|
||||||
else if ( e.name == "directory" )
|
else if ( e.name == "directory" )
|
||||||
{
|
{
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
|
@ -50,7 +56,14 @@ ModuleType Module::GetModuleType ( const XMLAttribute& attribute )
|
||||||
attribute.value );
|
attribute.value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
File::File ( const string& _name )
|
File::File ( const string& _name )
|
||||||
: name(_name)
|
: name(_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Library::Library ( const string& _name )
|
||||||
|
: name(_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -60,8 +60,6 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
|
||||||
else if ( e.name == "module" )
|
else if ( e.name == "module" )
|
||||||
{
|
{
|
||||||
att = e.GetAttribute ( "name", true );
|
att = e.GetAttribute ( "name", true );
|
||||||
if ( !att )
|
|
||||||
return;
|
|
||||||
Module* module = new Module ( e, att->value, path );
|
Module* module = new Module ( e, att->value, path );
|
||||||
modules.push_back ( module );
|
modules.push_back ( module );
|
||||||
module->ProcessXML ( e, path );
|
module->ProcessXML ( e, path );
|
||||||
|
@ -69,10 +67,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
|
||||||
}
|
}
|
||||||
else if ( e.name == "directory" )
|
else if ( e.name == "directory" )
|
||||||
{
|
{
|
||||||
// this code is duplicated between Project::ProcessXML() and Module::ProcessXML() :(
|
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
if ( !att )
|
|
||||||
return;
|
|
||||||
subpath = path + "/" + att->value;
|
subpath = path + "/" + att->value;
|
||||||
}
|
}
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
class Project;
|
class Project;
|
||||||
class Module;
|
class Module;
|
||||||
class File;
|
class File;
|
||||||
|
class Library;
|
||||||
|
|
||||||
class Project
|
class Project
|
||||||
{
|
{
|
||||||
|
@ -42,8 +43,9 @@ public:
|
||||||
const XMLElement& node;
|
const XMLElement& node;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string path;
|
std::string path;
|
||||||
std::vector<File*> files;
|
|
||||||
ModuleType type;
|
ModuleType type;
|
||||||
|
std::vector<File*> files;
|
||||||
|
std::vector<Library*> libraries;
|
||||||
|
|
||||||
Module ( const XMLElement& moduleNode,
|
Module ( const XMLElement& moduleNode,
|
||||||
const std::string& moduleName,
|
const std::string& moduleName,
|
||||||
|
@ -64,4 +66,13 @@ public:
|
||||||
File ( const std::string& _name );
|
File ( const std::string& _name );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Library
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
Library ( const std::string& _name );
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __RBUILD_H */
|
#endif /* __RBUILD_H */
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="dir2">
|
<directory name="dir2">
|
||||||
<module name="module2" type="kernelmodedll">
|
<module name="module2" type="kernelmodedll">
|
||||||
|
<library>module1</library>
|
||||||
<file>file3.c</file>
|
<file>file3.c</file>
|
||||||
<file>file4.c</file>
|
<file>file4.c</file>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -14,9 +14,16 @@ void ModuleTest::Run()
|
||||||
ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
|
ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
|
||||||
ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
|
ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
|
||||||
|
|
||||||
|
ARE_EQUAL(0, module1.libraries.size());
|
||||||
|
|
||||||
Module& module2 = *project.modules[1];
|
Module& module2 = *project.modules[1];
|
||||||
IS_TRUE(module2.type == KernelModeDLL);
|
IS_TRUE(module2.type == KernelModeDLL);
|
||||||
ARE_EQUAL(2, module2.files.size());
|
ARE_EQUAL(2, module2.files.size());
|
||||||
ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
|
ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
|
||||||
ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
|
ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
|
||||||
|
|
||||||
|
ARE_EQUAL(1, module2.libraries.size());
|
||||||
|
Library& library1 = *module2.libraries[0];
|
||||||
|
|
||||||
|
ARE_EQUAL("module1", library1.name);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue