From 222bde955cff910ec5b47096e8f8e20123758de9 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Wed, 5 Jan 2005 19:47:10 +0000 Subject: [PATCH] Handle modules. svn path=/branches/xmlbuildsystem/; revision=12836 --- reactos/tools/rbuild/backend/backend.cpp | 3 +- reactos/tools/rbuild/backend/backend.h | 3 +- reactos/tools/rbuild/backend/mingw/mingw.cpp | 36 +++++++++++++++++-- reactos/tools/rbuild/backend/mingw/mingw.h | 20 ++++++++++- .../rbuild/backend/mingw/modulehandler.cpp | 24 +++++++++++++ .../rbuild/backend/mingw/modulehandler.h | 23 ++++++++++++ reactos/tools/rbuild/makefile | 5 +-- reactos/tools/rbuild/project.cpp | 10 +++--- reactos/tools/rbuild/rbuild.cpp | 9 +++-- reactos/tools/rbuild/rbuild.h | 3 +- 10 files changed, 120 insertions(+), 16 deletions(-) create mode 100644 reactos/tools/rbuild/backend/mingw/modulehandler.cpp create mode 100644 reactos/tools/rbuild/backend/mingw/modulehandler.h diff --git a/reactos/tools/rbuild/backend/backend.cpp b/reactos/tools/rbuild/backend/backend.cpp index 385d0ee7693..000f4fd9dd5 100644 --- a/reactos/tools/rbuild/backend/backend.cpp +++ b/reactos/tools/rbuild/backend/backend.cpp @@ -4,6 +4,7 @@ #include "../Rbuild.h" #include "backend.h" -Backend::Backend ( Project& project ) : ProjectNode(project) +Backend::Backend ( Project& project ) + : ProjectNode ( project ) { } diff --git a/reactos/tools/rbuild/backend/backend.h b/reactos/tools/rbuild/backend/backend.h index d2c434c5c57..32d4b206b97 100644 --- a/reactos/tools/rbuild/backend/backend.h +++ b/reactos/tools/rbuild/backend/backend.h @@ -6,7 +6,8 @@ class Backend { public: - Backend ( Project& ); + Backend ( Project& project ); + virtual void Process () = 0; protected: Project& ProjectNode; }; diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 1734c1ed742..df619398126 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -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 () ); +} diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index fe8c9898d2e..d720620c799 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -2,11 +2,29 @@ #define MINGW_H #include "../backend.h" +#include "modulehandler.h" + +class MingwModuleHandlerList : public std::vector +{ +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 */ diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp new file mode 100644 index 00000000000..2a539c148f4 --- /dev/null +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -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 ) +{ +} diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h new file mode 100644 index 00000000000..0294a0e9172 --- /dev/null +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -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 */ diff --git a/reactos/tools/rbuild/makefile b/reactos/tools/rbuild/makefile index a25a5da1008..6b1d693f32b 100644 --- a/reactos/tools/rbuild/makefile +++ b/reactos/tools/rbuild/makefile @@ -5,8 +5,9 @@ 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) \ backend/backend.cpp diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index 8cd9db207e1..eb33343d652 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -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 ); } diff --git a/reactos/tools/rbuild/rbuild.cpp b/reactos/tools/rbuild/rbuild.cpp index b13b1fccc65..9e335b41d5a 100644 --- a/reactos/tools/rbuild/rbuild.cpp +++ b/reactos/tools/rbuild/rbuild.cpp @@ -8,6 +8,8 @@ #include #include "rbuild.h" +#include "backend/backend.h" +#include "backend/mingw/mingw.h" using std::string; using std::vector; @@ -18,9 +20,10 @@ 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 printf ( "Found %d modules:\n", project.modules.size() ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 6fa5ab88784..c78114a6a3e 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -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 ();