Handle modules.

svn path=/branches/xmlbuildsystem/; revision=12836
This commit is contained in:
Casper Hornstrup 2005-01-05 19:47:10 +00:00
parent b9bffbca54
commit 222bde955c
10 changed files with 120 additions and 16 deletions

View file

@ -4,6 +4,7 @@
#include "../Rbuild.h"
#include "backend.h"
Backend::Backend ( Project& project ) : ProjectNode(project)
Backend::Backend ( Project& project )
: ProjectNode ( project )
{
}

View file

@ -6,7 +6,8 @@
class Backend
{
public:
Backend ( Project& );
Backend ( Project& project );
virtual void Process () = 0;
protected:
Project& ProjectNode;
};

View file

@ -3,7 +3,39 @@
#include "mingw.h"
MingwBackend::MingwBackend(Project& project)
: Backend(project)
using std::string;
using std::vector;
MingwBackend::MingwBackend ( Project& project )
: Backend ( project )
{
}
void MingwBackend::Process ()
{
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
{
Module& module = *ProjectNode.modules[i];
ProcessModule ( module );
}
}
void MingwBackend::ProcessModule ( Module& module )
{
MingwModuleHandlerList moduleHandlers;
GetModuleHandlers ( moduleHandlers );
for (size_t i = 0; i < moduleHandlers.size(); i++)
{
MingwModuleHandler& moduleHandler = *moduleHandlers[i];
if (moduleHandler.CanHandleModule ( module ) )
{
moduleHandler.Process ( module );
return;
}
}
}
void MingwBackend::GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers )
{
moduleHandlers.push_back ( new MingwKernelModuleHandler () );
}

View file

@ -2,11 +2,29 @@
#define MINGW_H
#include "../backend.h"
#include "modulehandler.h"
class MingwModuleHandlerList : public std::vector<MingwModuleHandler*>
{
public:
~MingwModuleHandlerList()
{
for ( size_t i = 0; i < size(); i++ )
{
delete (*this)[i];
}
}
};
class MingwBackend : public Backend
{
public:
MingwBackend ( Project& );
MingwBackend ( Project& project );
virtual void Process ();
private:
void ProcessModule ( Module& module );
void GetModuleHandlers ( MingwModuleHandlerList& moduleHandlers );
};
#endif /* MINGW_H */

View file

@ -0,0 +1,24 @@
#include "../../pch.h"
#include "../../rbuild.h"
#include "mingw.h"
#include "modulehandler.h"
MingwModuleHandler::MingwModuleHandler ()
{
}
MingwKernelModuleHandler::MingwKernelModuleHandler ()
{
}
bool MingwKernelModuleHandler::CanHandleModule ( Module& module )
{
return true;
}
void MingwKernelModuleHandler::Process ( Module& module )
{
}

View file

@ -0,0 +1,23 @@
#ifndef MINGW_MODULEHANDLER_H
#define MINGW_MODULEHANDLER_H
#include "../backend.h"
class MingwModuleHandler
{
public:
MingwModuleHandler ();
virtual bool CanHandleModule ( Module& module ) = 0;
virtual void Process ( Module& module ) = 0;
};
class MingwKernelModuleHandler : public MingwModuleHandler
{
public:
MingwKernelModuleHandler ();
virtual bool CanHandleModule ( Module& module );
virtual void Process ( Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */

View file

@ -5,7 +5,8 @@ TARGET = rbuild$(EXE_POSTFIX)
all: $(TARGET)
BACKEND_MINGW_BASE_OBJECTS = \
backend/mingw/mingw.cpp
backend/mingw/mingw.cpp \
backend/mingw/modulehandler.cpp
BACKEND_BASE_OBJECTS = \
$(BACKEND_MINGW_BASE_OBJECTS) \

View file

@ -40,21 +40,21 @@ Project::Project()
{
}
Project::Project(const string& filename)
Project::Project ( const string& filename )
{
if ( !xmlfile.open ( filename ) )
throw FileNotFoundException ( filename );
ReadXml();
}
Project::~Project()
Project::~Project ()
{
for ( size_t i = 0; i < modules.size(); i++ )
for ( size_t i = 0; i < modules.size (); i++ )
delete modules[i];
delete head;
}
void Project::ReadXml()
void Project::ReadXml ()
{
Path path;
@ -102,7 +102,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
return;
subpath = path + "/" + att->value;
}
for ( size_t i = 0; i < e.subElements.size(); i++ )
for ( size_t i = 0; i < e.subElements.size (); i++ )
ProcessXML ( *e.subElements[i], subpath );
}

View file

@ -8,6 +8,8 @@
#include <assert.h>
#include "rbuild.h"
#include "backend/backend.h"
#include "backend/mingw/mingw.h"
using std::string;
using std::vector;
@ -18,8 +20,9 @@ main ( int argc, char** argv )
try
{
string projectFilename ( "ReactOS.xml" );
Project project ( projectFilename );
project.GenerateOutput();
Project project = Project ( projectFilename );
Backend* backend = new MingwBackend ( project );
backend->Process ();
// REM TODO FIXME actually do something with Project object...
#if 0

View file

@ -20,7 +20,8 @@ public:
Project ();
Project ( const std::string& filename );
~Project ();
void ProcessXML ( const XMLElement& e, const std::string& path );
void ProcessXML ( const XMLElement& e,
const std::string& path );
bool GenerateOutput();
private:
void ReadXml ();