mirror of
https://github.com/reactos/reactos.git
synced 2026-07-07 09:40:21 +08:00
* Add static library module type * Add build script for kjs svn path=/branches/xmlbuildsystem/; revision=12856
107 lines
2.2 KiB
C++
107 lines
2.2 KiB
C++
|
|
#include "../../pch.h"
|
|
|
|
#include "mingw.h"
|
|
|
|
using std::string;
|
|
using std::vector;
|
|
|
|
static class MingwFactory : public Backend::Factory
|
|
{
|
|
public:
|
|
MingwFactory() : Factory ( "mingw" ) {}
|
|
Backend* operator() ( Project& project )
|
|
{
|
|
return new MingwBackend ( project );
|
|
}
|
|
} factory;
|
|
|
|
|
|
MingwBackend::MingwBackend ( Project& project )
|
|
: Backend ( project )
|
|
{
|
|
}
|
|
|
|
void
|
|
MingwBackend::Process ()
|
|
{
|
|
CreateMakefile ();
|
|
GenerateHeader ();
|
|
GenerateGlobalVariables ();
|
|
GenerateAllTarget ();
|
|
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
|
|
{
|
|
Module& module = *ProjectNode.modules[i];
|
|
ProcessModule ( module );
|
|
}
|
|
CloseMakefile ();
|
|
}
|
|
|
|
void
|
|
MingwBackend::CreateMakefile ()
|
|
{
|
|
fMakefile = fopen ( ProjectNode.makefile.c_str (), "w" );
|
|
if ( !fMakefile )
|
|
throw AccessDeniedException ( ProjectNode.makefile );
|
|
}
|
|
|
|
void
|
|
MingwBackend::CloseMakefile ()
|
|
{
|
|
if (fMakefile)
|
|
fclose ( fMakefile );
|
|
}
|
|
|
|
void
|
|
MingwBackend::GenerateHeader ()
|
|
{
|
|
fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
|
|
}
|
|
|
|
void
|
|
MingwBackend::GenerateGlobalVariables ()
|
|
{
|
|
fprintf ( fMakefile, "rm = del /y\n" );
|
|
fprintf ( fMakefile, "gcc = gcc\n" );
|
|
fprintf ( fMakefile, "ld = ld\n" );
|
|
fprintf ( fMakefile, "ar = ar\n" );
|
|
fprintf ( fMakefile, "dlltool = dlltool\n" );
|
|
fprintf ( fMakefile, "\n" );
|
|
}
|
|
|
|
void
|
|
MingwBackend::GenerateAllTarget ()
|
|
{
|
|
fprintf ( fMakefile, "all:" );
|
|
for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )
|
|
{
|
|
Module& module = *ProjectNode.modules[i];
|
|
fprintf ( fMakefile,
|
|
" %s",
|
|
module.GetPath ().c_str () );
|
|
}
|
|
fprintf ( fMakefile, "\n\t\n\n" );
|
|
}
|
|
|
|
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 ( fMakefile ) );
|
|
}
|