mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Add Rule class, which writes to Makefile how to handle a source file
Later, hardcoded rules should be read from .rbuild files svn path=/trunk/; revision=32226
This commit is contained in:
parent
1086d26c56
commit
1d39ac6bc4
5 changed files with 250 additions and 221 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "../../rbuild.h"
|
#include "../../rbuild.h"
|
||||||
#include "mingw.h"
|
#include "mingw.h"
|
||||||
#include "modulehandler.h"
|
#include "modulehandler.h"
|
||||||
|
#include "rule.h"
|
||||||
|
|
||||||
using std::set;
|
using std::set;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -1245,6 +1246,43 @@ MingwModuleHandler::GetPrecompiledHeaderFilename () const
|
||||||
ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) );
|
ReplaceExtension ( module.pch->file.name, "_" + module.name + ".gch" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rule gasRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
|
||||||
|
"\t$(ECHO_GAS)\n"
|
||||||
|
"\t${gcc} -x assembler-with-cpp -c $< -o $@ -D__ASM__ $($(module_name)_CFLAGS)\n",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
|
||||||
|
Rule bootRule ( "$(module_output): $(source) $(module_rbuild) | $(OUTPUT)$(SEP)$(source_dir)\n"
|
||||||
|
"\t$(ECHO_NASM)\n"
|
||||||
|
"\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
|
||||||
|
"$(OUTPUT)$(SEP)$(source_dir)$(SEP)", NULL );
|
||||||
|
Rule nasmRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o: $(source) $(module_rbuild) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
|
||||||
|
"\t$(ECHO_NASM)\n"
|
||||||
|
"\t$(Q)${nasm} -f win32 $< -o $@ $($(module_name)_NASMFLAGS)\n",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).o",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
|
||||||
|
Rule windresRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff: $(source) $(module_rbuild) $(WRC_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
|
||||||
|
"\t$(ECHO_WRC)\n"
|
||||||
|
"\t${gcc} -xc -E -DRC_INVOKED ${$(module_name)_RCFLAGS} $(source) > $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp\n"
|
||||||
|
"\t$(Q)$(WRC_TARGET) ${$(module_name)_RCFLAGS} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp\n"
|
||||||
|
"\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).rci.tmp 2>$(NUL)\n"
|
||||||
|
"\t${windres} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp -o $@\n"
|
||||||
|
"\t-@${rm} $(TEMPORARY)$(SEP)$(module_name).$(source_name_noext).res.tmp 2>$(NUL)\n",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext)_$(module_name).coff",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
|
||||||
|
Rule wmcRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h: $(WMC_TARGET) $(source)\n"
|
||||||
|
"\t$(ECHO_WMC)\n"
|
||||||
|
"\t$(Q)$(WMC_TARGET) -i -H $(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h -o $(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc $(source)\n",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).rc", "$(INTERMEDIATE)$(SEP)include$(SEP)reactos$(SEP)$(source_name_noext).h", NULL );
|
||||||
|
Rule winebuildRule ( "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def: $(source) $(module_rbuild) $(WINEBUILD_TARGET) | $(INTERMEDIATE)$(SEP)$(source_dir)\n"
|
||||||
|
"\t$(ECHO_WINEBLD)\n"
|
||||||
|
"\t$(Q)$(WINEBUILD_TARGET) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).spec.def --def -E $(source_path)$(SEP)$(source_name_noext).spec\n"
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c: $(source_path)$(SEP)$(source_name_noext).spec $(WINEBUILD_TARGET)\n"
|
||||||
|
"\t$(ECHO_WINEBLD)\n"
|
||||||
|
"\t$(Q)$(WINEBUILD_TARGET) -o $(INTERMEDIATE)$(SEP)$(source_path)$(SEP)$(source_name_noext).stubs.c --pedll $(source_path)$(SEP)$(source_name_noext).spec\n",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
|
||||||
|
"$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwModuleHandler::GenerateGccCommand (
|
MingwModuleHandler::GenerateGccCommand (
|
||||||
const FileLocation* sourceFile,
|
const FileLocation* sourceFile,
|
||||||
|
@ -1286,175 +1324,7 @@ MingwModuleHandler::GenerateGccCommand (
|
||||||
delete pchFilename;
|
delete pchFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
const std::string&
|
||||||
MingwModuleHandler::GenerateGccAssemblerCommand (
|
|
||||||
const FileLocation* sourceFile,
|
|
||||||
const string& cc,
|
|
||||||
const string& cflagsMacro )
|
|
||||||
{
|
|
||||||
string dependencies = backend->GetFullName ( *sourceFile );
|
|
||||||
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
|
|
||||||
|
|
||||||
const FileLocation *objectFilename = GetObjectFilename (
|
|
||||||
sourceFile, module, &clean_files );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s: %s | %s\n",
|
|
||||||
backend->GetFullName ( *objectFilename ).c_str (),
|
|
||||||
dependencies.c_str (),
|
|
||||||
backend->GetFullPath ( *objectFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_GAS)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t%s -x assembler-with-cpp -c $< -o $@ -D__ASM__ %s\n",
|
|
||||||
cc.c_str (),
|
|
||||||
cflagsMacro.c_str () );
|
|
||||||
|
|
||||||
delete objectFilename;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MingwModuleHandler::GenerateNasmCommand (
|
|
||||||
const FileLocation* sourceFile,
|
|
||||||
const string& nasmflagsMacro )
|
|
||||||
{
|
|
||||||
string dependencies = backend->GetFullName ( *sourceFile );
|
|
||||||
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
|
|
||||||
|
|
||||||
const FileLocation *objectFilename = GetObjectFilename (
|
|
||||||
sourceFile, module, &clean_files );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s: %s | %s\n",
|
|
||||||
backend->GetFullName ( *objectFilename ).c_str (),
|
|
||||||
dependencies.c_str (),
|
|
||||||
backend->GetFullPath ( *objectFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t%s -f win32 $< -o $@ %s\n",
|
|
||||||
"$(Q)${nasm}",
|
|
||||||
nasmflagsMacro.c_str () );
|
|
||||||
|
|
||||||
delete objectFilename;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MingwModuleHandler::GenerateWindresCommand (
|
|
||||||
const FileLocation* sourceFile,
|
|
||||||
const string& windresflagsMacro )
|
|
||||||
{
|
|
||||||
string dependencies = backend->GetFullName ( *sourceFile );
|
|
||||||
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
|
|
||||||
|
|
||||||
const FileLocation *objectFilename = GetObjectFilename ( sourceFile, module, &clean_files );
|
|
||||||
|
|
||||||
string sourceFilenamePart = module.name + "." + ReplaceExtension ( sourceFile->name, "" );
|
|
||||||
FileLocation rciFilename ( TemporaryDirectory,
|
|
||||||
"",
|
|
||||||
sourceFilenamePart + ".rci.tmp" );
|
|
||||||
FileLocation resFilename ( TemporaryDirectory,
|
|
||||||
"",
|
|
||||||
sourceFilenamePart + ".res.tmp" );
|
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s: %s $(WRC_TARGET) | %s\n",
|
|
||||||
backend->GetFullName ( *objectFilename ).c_str (),
|
|
||||||
dependencies.c_str (),
|
|
||||||
backend->GetFullPath ( *objectFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_WRC)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t${gcc} -xc -E -DRC_INVOKED ${%s} %s > %s\n",
|
|
||||||
windresflagsMacro.c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str (),
|
|
||||||
backend->GetFullName ( rciFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t$(Q)$(WRC_TARGET) ${%s} %s %s\n",
|
|
||||||
windresflagsMacro.c_str (),
|
|
||||||
backend->GetFullName ( rciFilename ).c_str (),
|
|
||||||
backend->GetFullName ( resFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t-@${rm} %s 2>$(NUL)\n",
|
|
||||||
backend->GetFullName ( rciFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t${windres} %s -o $@\n",
|
|
||||||
backend->GetFullName ( resFilename ).c_str () );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t-@${rm} %s 2>$(NUL)\n",
|
|
||||||
backend->GetFullName ( resFilename ).c_str () );
|
|
||||||
|
|
||||||
delete objectFilename;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MingwModuleHandler::GenerateWinebuildCommands (
|
|
||||||
const FileLocation* sourceFile )
|
|
||||||
{
|
|
||||||
string dependencies = backend->GetFullName ( *sourceFile );
|
|
||||||
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
|
|
||||||
|
|
||||||
string basename = GetBasename ( sourceFile->name );
|
|
||||||
FileLocation def_file ( IntermediateDirectory,
|
|
||||||
sourceFile->relative_path,
|
|
||||||
basename + ".spec.def" );
|
|
||||||
CLEAN_FILE ( def_file );
|
|
||||||
|
|
||||||
const FileLocation *stub_file = GetActualSourceFilename ( sourceFile );
|
|
||||||
CLEAN_FILE ( *stub_file );
|
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s: %s $(WINEBUILD_TARGET) | %s\n",
|
|
||||||
backend->GetFullName ( def_file ).c_str (),
|
|
||||||
dependencies.c_str (),
|
|
||||||
backend->GetFullPath ( def_file ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t%s -o %s --def -E %s\n",
|
|
||||||
"$(Q)$(WINEBUILD_TARGET)",
|
|
||||||
backend->GetFullName ( def_file ).c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str () );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s: %s $(WINEBUILD_TARGET)\n",
|
|
||||||
backend->GetFullName ( *stub_file ).c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t%s -o %s --pedll %s\n",
|
|
||||||
"$(Q)$(WINEBUILD_TARGET)",
|
|
||||||
backend->GetFullName ( *stub_file ).c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str () );
|
|
||||||
|
|
||||||
delete stub_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MingwModuleHandler::GenerateWmcCommands (
|
|
||||||
const FileLocation* sourceFile )
|
|
||||||
{
|
|
||||||
string dependencies = backend->GetFullName ( *sourceFile );
|
|
||||||
dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
|
|
||||||
|
|
||||||
string basename = GetBasename ( sourceFile->name );
|
|
||||||
FileLocation rc_file ( IntermediateDirectory,
|
|
||||||
sourceFile->relative_path,
|
|
||||||
basename + ".rc" );
|
|
||||||
FileLocation h_file ( IntermediateDirectory,
|
|
||||||
"include/reactos",
|
|
||||||
basename + ".h" );
|
|
||||||
CLEAN_FILE ( rc_file );
|
|
||||||
CLEAN_FILE ( h_file );
|
|
||||||
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"%s %s: $(WMC_TARGET) %s\n",
|
|
||||||
backend->GetFullName ( rc_file ).c_str (),
|
|
||||||
backend->GetFullName ( h_file ).c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str () );
|
|
||||||
fprintf ( fMakefile, "\t$(ECHO_WMC)\n" );
|
|
||||||
fprintf ( fMakefile,
|
|
||||||
"\t%s -i -H %s -o %s %s\n",
|
|
||||||
"$(Q)$(WMC_TARGET)",
|
|
||||||
backend->GetFullName ( h_file ).c_str (),
|
|
||||||
backend->GetFullName ( rc_file ).c_str (),
|
|
||||||
backend->GetFullName ( *sourceFile ).c_str () );
|
|
||||||
}
|
|
||||||
|
|
||||||
string
|
|
||||||
MingwModuleHandler::GetWidlFlags ( const CompilationUnit& compilationUnit )
|
MingwModuleHandler::GetWidlFlags ( const CompilationUnit& compilationUnit )
|
||||||
{
|
{
|
||||||
return compilationUnit.GetSwitches ();
|
return compilationUnit.GetSwitches ();
|
||||||
|
@ -1722,9 +1592,43 @@ MingwModuleHandler::GenerateCommands (
|
||||||
{
|
{
|
||||||
const FileLocation& sourceFile = compilationUnit.GetFilename ();
|
const FileLocation& sourceFile = compilationUnit.GetFilename ();
|
||||||
string extension = GetExtension ( sourceFile );
|
string extension = GetExtension ( sourceFile );
|
||||||
|
std::transform ( extension.begin (), extension.end (), extension.begin (), tolower );
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
HostType host;
|
||||||
|
ModuleType type;
|
||||||
|
string extension;
|
||||||
|
Rule* rule;
|
||||||
|
} rules[] = {
|
||||||
|
{ HostDontCare, TypeDontCare, ".s", &gasRule },
|
||||||
|
{ HostDontCare, BootSector, ".asm", &bootRule },
|
||||||
|
{ HostDontCare, TypeDontCare, ".asm", &nasmRule },
|
||||||
|
{ HostDontCare, TypeDontCare, ".rc", &windresRule },
|
||||||
|
{ HostDontCare, TypeDontCare, ".mc", &wmcRule },
|
||||||
|
{ HostDontCare, TypeDontCare, ".spec", &winebuildRule },
|
||||||
|
};
|
||||||
|
size_t i;
|
||||||
|
Rule *customRule = NULL;
|
||||||
|
|
||||||
|
for ( i = 0; i < sizeof ( rules ) / sizeof ( rules[0] ); i++ )
|
||||||
|
{
|
||||||
|
if ( rules[i].host != HostDontCare && rules[i].host != module.host )
|
||||||
|
continue;
|
||||||
|
if ( rules[i].type != TypeDontCare && rules[i].type != module.type )
|
||||||
|
continue;
|
||||||
|
if ( rules[i].extension != extension )
|
||||||
|
continue;
|
||||||
|
customRule = rules[i].rule;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( customRule )
|
||||||
|
customRule->Execute ( fMakefile, backend, module, &sourceFile, clean_files );
|
||||||
|
|
||||||
string flags = cflagsMacro;
|
string flags = cflagsMacro;
|
||||||
flags += " ";
|
flags += " ";
|
||||||
if ( extension == ".c" || extension == ".C" )
|
if ( extension == ".c" )
|
||||||
{
|
{
|
||||||
flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCC );
|
flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCC );
|
||||||
GenerateGccCommand ( &sourceFile,
|
GenerateGccCommand ( &sourceFile,
|
||||||
|
@ -1732,9 +1636,9 @@ MingwModuleHandler::GenerateCommands (
|
||||||
cc,
|
cc,
|
||||||
flags );
|
flags );
|
||||||
}
|
}
|
||||||
else if ( extension == ".cc" || extension == ".CC" ||
|
else if ( extension == ".cc" ||
|
||||||
extension == ".cpp" || extension == ".CPP" ||
|
extension == ".cpp" ||
|
||||||
extension == ".cxx" || extension == ".CXX" )
|
extension == ".cxx" )
|
||||||
{
|
{
|
||||||
flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCPP );
|
flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCPP );
|
||||||
GenerateGccCommand ( &sourceFile,
|
GenerateGccCommand ( &sourceFile,
|
||||||
|
@ -1742,35 +1646,14 @@ MingwModuleHandler::GenerateCommands (
|
||||||
cppc,
|
cppc,
|
||||||
flags );
|
flags );
|
||||||
}
|
}
|
||||||
else if ( extension == ".s" || extension == ".S" )
|
else if ( extension == ".spec" )
|
||||||
{
|
{
|
||||||
GenerateGccAssemblerCommand ( &sourceFile,
|
|
||||||
cc,
|
|
||||||
cflagsMacro );
|
|
||||||
}
|
|
||||||
else if ( extension == ".asm" || extension == ".ASM" )
|
|
||||||
{
|
|
||||||
GenerateNasmCommand ( &sourceFile,
|
|
||||||
nasmflagsMacro );
|
|
||||||
}
|
|
||||||
else if ( extension == ".rc" || extension == ".RC" )
|
|
||||||
{
|
|
||||||
GenerateWindresCommand ( &sourceFile,
|
|
||||||
windresflagsMacro );
|
|
||||||
}
|
|
||||||
else if ( extension == ".mc" || extension == ".MC" )
|
|
||||||
{
|
|
||||||
GenerateWmcCommands ( &sourceFile );
|
|
||||||
}
|
|
||||||
else if ( extension == ".spec" || extension == ".SPEC" )
|
|
||||||
{
|
|
||||||
GenerateWinebuildCommands ( &sourceFile );
|
|
||||||
GenerateGccCommand ( &sourceFile,
|
GenerateGccCommand ( &sourceFile,
|
||||||
extraDependencies,
|
extraDependencies,
|
||||||
cc,
|
cc,
|
||||||
cflagsMacro );
|
cflagsMacro );
|
||||||
}
|
}
|
||||||
else if ( extension == ".idl" || extension == ".IDL" )
|
else if ( extension == ".idl" )
|
||||||
{
|
{
|
||||||
GenerateWidlCommands ( compilationUnit,
|
GenerateWidlCommands ( compilationUnit,
|
||||||
widlflagsMacro );
|
widlflagsMacro );
|
||||||
|
@ -1782,7 +1665,7 @@ MingwModuleHandler::GenerateCommands (
|
||||||
cflagsMacro );
|
cflagsMacro );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ( !customRule )
|
||||||
{
|
{
|
||||||
throw InvalidOperationException ( __FILE__,
|
throw InvalidOperationException ( __FILE__,
|
||||||
__LINE__,
|
__LINE__,
|
||||||
|
|
|
@ -155,16 +155,7 @@ private:
|
||||||
const std::string& extraDependencies,
|
const std::string& extraDependencies,
|
||||||
const std::string& cc,
|
const std::string& cc,
|
||||||
const std::string& cflagsMacro );
|
const std::string& cflagsMacro );
|
||||||
void GenerateGccAssemblerCommand ( const FileLocation* sourceFile,
|
const std::string& GetWidlFlags ( const CompilationUnit& compilationUnit );
|
||||||
const std::string& cc,
|
|
||||||
const std::string& cflagsMacro );
|
|
||||||
void GenerateNasmCommand ( const FileLocation* sourceFile,
|
|
||||||
const std::string& nasmflagsMacro );
|
|
||||||
void GenerateWindresCommand ( const FileLocation* sourceFile,
|
|
||||||
const std::string& windresflagsMacro );
|
|
||||||
void GenerateWinebuildCommands ( const FileLocation* sourceFile );
|
|
||||||
void GenerateWmcCommands ( const FileLocation* sourceFile);
|
|
||||||
std::string GetWidlFlags ( const CompilationUnit& compilationUnit );
|
|
||||||
void GenerateWidlCommandsServer (
|
void GenerateWidlCommandsServer (
|
||||||
const CompilationUnit& compilationUnit,
|
const CompilationUnit& compilationUnit,
|
||||||
const std::string& widlflagsMacro );
|
const std::string& widlflagsMacro );
|
||||||
|
|
117
reactos/tools/rbuild/backend/mingw/rule.cpp
Normal file
117
reactos/tools/rbuild/backend/mingw/rule.cpp
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Hervé Poussineau
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../../rbuild.h"
|
||||||
|
#include "modulehandler.h"
|
||||||
|
#include "rule.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
static void
|
||||||
|
ReplaceVariable( string& str,
|
||||||
|
const string& name,
|
||||||
|
const string& value )
|
||||||
|
{
|
||||||
|
size_t i = str.find ( name );
|
||||||
|
while ( i != string::npos )
|
||||||
|
{
|
||||||
|
str.replace ( i, name.length (), value );
|
||||||
|
i = str.find ( name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string
|
||||||
|
FixString ( const string& str, Backend *backend, const Module& module, const FileLocation *source )
|
||||||
|
{
|
||||||
|
string ret = str;
|
||||||
|
|
||||||
|
if ( source )
|
||||||
|
{
|
||||||
|
ReplaceVariable ( ret, "$(source_noext)", ReplaceExtension ( backend->GetFullName ( *source ), "" ) );
|
||||||
|
ReplaceVariable ( ret, "$(source)", backend->GetFullName ( *source ) );
|
||||||
|
ReplaceVariable ( ret, "$(source_dir)", source->relative_path );
|
||||||
|
ReplaceVariable ( ret, "$(source_name)", source->name );
|
||||||
|
ReplaceVariable ( ret, "$(source_name_noext)", ReplaceExtension ( source->name , "" ) );
|
||||||
|
ReplaceVariable ( ret, "$(source_path)", backend->GetFullPath ( *source ) );
|
||||||
|
}
|
||||||
|
ReplaceVariable ( ret, "$(module_name)", module.name );
|
||||||
|
ReplaceVariable ( ret, "$(module_rbuild)", module.xmlbuildFile );
|
||||||
|
ReplaceVariable ( ret, "$(module_output)", GetTargetMacro ( module, true ) );
|
||||||
|
ReplaceVariable ( ret, "$(SEP)", sSep );
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rule::Rule( const std::string& command, const char *generatedFile1, ... )
|
||||||
|
: command ( command )
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s = generatedFile1;
|
||||||
|
va_start ( ap, generatedFile1 );
|
||||||
|
while ( s )
|
||||||
|
{
|
||||||
|
generatedFiles.push_back ( s );
|
||||||
|
s = va_arg ( ap, const char* );
|
||||||
|
}
|
||||||
|
va_end ( ap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Rule::Execute ( FILE *outputFile,
|
||||||
|
MingwBackend *backend,
|
||||||
|
const Module& module,
|
||||||
|
const FileLocation *source,
|
||||||
|
string_list& clean_files )
|
||||||
|
{
|
||||||
|
string cmd = FixString ( command, backend, module, source );
|
||||||
|
|
||||||
|
fprintf ( outputFile, "%s", cmd.c_str () );
|
||||||
|
|
||||||
|
for ( size_t i = 0; i < generatedFiles.size (); i++ )
|
||||||
|
{
|
||||||
|
string file = FixString ( generatedFiles[i], backend, module, source );
|
||||||
|
if ( file[file.length () - 1] != cSep )
|
||||||
|
{
|
||||||
|
clean_files.push_back ( file );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( file[0] != '$' )
|
||||||
|
throw InvalidOperationException ( __FILE__,
|
||||||
|
__LINE__,
|
||||||
|
"Invalid directory %s.",
|
||||||
|
file.c_str () );
|
||||||
|
|
||||||
|
size_t pos = file.find_first_of ( cSep );
|
||||||
|
string relative_path = file.substr ( pos + 1, file.length () - pos - 2 );
|
||||||
|
string dir = file.substr ( 0, pos );
|
||||||
|
if ( dir == "$(INTERMEDIATE)" )
|
||||||
|
backend->AddDirectoryTarget ( relative_path, backend->intermediateDirectory );
|
||||||
|
else if ( dir == "$(OUTPUT)" )
|
||||||
|
backend->AddDirectoryTarget ( relative_path, backend->outputDirectory );
|
||||||
|
else if ( dir == "$(INSTALL)" )
|
||||||
|
backend->AddDirectoryTarget ( relative_path, backend->installDirectory );
|
||||||
|
else
|
||||||
|
throw InvalidOperationException ( __FILE__,
|
||||||
|
__LINE__,
|
||||||
|
"Invalid directory %s.",
|
||||||
|
dir.c_str () );
|
||||||
|
}
|
||||||
|
}
|
38
reactos/tools/rbuild/backend/mingw/rule.h
Normal file
38
reactos/tools/rbuild/backend/mingw/rule.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008 Hervé Poussineau
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MINGW_RULE_H
|
||||||
|
#define MINGW_RULE_H
|
||||||
|
|
||||||
|
#include "mingw.h"
|
||||||
|
|
||||||
|
class Rule
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Rule ( const std::string& command, const char *generatedFile1, ... );
|
||||||
|
void Execute ( FILE *outputFile,
|
||||||
|
MingwBackend *backend,
|
||||||
|
const Module& module,
|
||||||
|
const FileLocation *source,
|
||||||
|
string_list& clean_files );
|
||||||
|
private:
|
||||||
|
const std::string command;
|
||||||
|
string_list generatedFiles;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -200,6 +200,7 @@ RBUILD_BACKEND_MINGW_BASE_SOURCES = $(addprefix $(RBUILD_MINGW_BASE_), \
|
||||||
mingw.cpp \
|
mingw.cpp \
|
||||||
modulehandler.cpp \
|
modulehandler.cpp \
|
||||||
proxymakefile.cpp \
|
proxymakefile.cpp \
|
||||||
|
rule.cpp \
|
||||||
)
|
)
|
||||||
|
|
||||||
RBUILD_BACKEND_DEVCPP_BASE_SOURCES = $(addprefix $(RBUILD_DEVCPP_BASE_), \
|
RBUILD_BACKEND_DEVCPP_BASE_SOURCES = $(addprefix $(RBUILD_DEVCPP_BASE_), \
|
||||||
|
@ -239,7 +240,7 @@ RBUILD_BACKEND_SOURCES = \
|
||||||
$(RBUILD_BACKEND_MSBUILD_BASE_SOURCES) \
|
$(RBUILD_BACKEND_MSBUILD_BASE_SOURCES) \
|
||||||
$(RBUILD_BACKEND_BASE_)backend.cpp
|
$(RBUILD_BACKEND_BASE_)backend.cpp
|
||||||
|
|
||||||
RBUILD_COMMON_SOURCES = \
|
RBUILD_SOURCES = \
|
||||||
$(RBUILD_BACKEND_SOURCES) \
|
$(RBUILD_BACKEND_SOURCES) \
|
||||||
$(addprefix $(RBUILD_BASE_), \
|
$(addprefix $(RBUILD_BASE_), \
|
||||||
global.cpp \
|
global.cpp \
|
||||||
|
@ -261,28 +262,18 @@ RBUILD_COMMON_SOURCES = \
|
||||||
linkerscript.cpp \
|
linkerscript.cpp \
|
||||||
module.cpp \
|
module.cpp \
|
||||||
project.cpp \
|
project.cpp \
|
||||||
|
rbuild.cpp \
|
||||||
stubbedcomponent.cpp \
|
stubbedcomponent.cpp \
|
||||||
syssetupgenerator.cpp \
|
syssetupgenerator.cpp \
|
||||||
testsupportcode.cpp \
|
testsupportcode.cpp \
|
||||||
xmlnode.cpp \
|
xmlnode.cpp \
|
||||||
)
|
)
|
||||||
|
|
||||||
RBUILD_SPECIAL_SOURCES = \
|
|
||||||
$(RBUILD_BASE_)rbuild.cpp
|
|
||||||
|
|
||||||
RBUILD_SOURCES = \
|
|
||||||
$(RBUILD_COMMON_SOURCES) \
|
|
||||||
$(RBUILD_SPECIAL_SOURCES)
|
|
||||||
|
|
||||||
RBUILD_COMMON_OBJECTS = \
|
|
||||||
$(addprefix $(INTERMEDIATE_), $(RBUILD_COMMON_SOURCES:.cpp=.o))
|
|
||||||
|
|
||||||
RBUILD_SPECIAL_OBJECTS = \
|
RBUILD_SPECIAL_OBJECTS = \
|
||||||
$(addprefix $(INTERMEDIATE_), $(RBUILD_SPECIAL_SOURCES:.cpp=.o))
|
$(addprefix $(INTERMEDIATE_), $(RBUILD_SPECIAL_SOURCES:.cpp=.o))
|
||||||
|
|
||||||
RBUILD_OBJECTS = \
|
RBUILD_OBJECTS = \
|
||||||
$(RBUILD_COMMON_OBJECTS) \
|
$(addprefix $(INTERMEDIATE_), $(RBUILD_SOURCES:.cpp=.o))
|
||||||
$(RBUILD_SPECIAL_OBJECTS)
|
|
||||||
|
|
||||||
RBUILD_BACKEND_DEVCPP_HEADERS = \
|
RBUILD_BACKEND_DEVCPP_HEADERS = \
|
||||||
devcpp.h
|
devcpp.h
|
||||||
|
@ -304,7 +295,8 @@ RBUILD_BACKEND_MSBUILD_HEADERS = \
|
||||||
|
|
||||||
RBUILD_BACKEND_MINGW_HEADERS = \
|
RBUILD_BACKEND_MINGW_HEADERS = \
|
||||||
mingw.h \
|
mingw.h \
|
||||||
modulehandler.h
|
modulehandler.h \
|
||||||
|
rule.h
|
||||||
|
|
||||||
RBUILD_BACKEND_HEADERS = \
|
RBUILD_BACKEND_HEADERS = \
|
||||||
backend.h \
|
backend.h \
|
||||||
|
@ -447,6 +439,10 @@ $(RBUILD_INT_)rbuild.o: $(RBUILD_BASE_)rbuild.cpp $(RBUILD_HEADERS) | $(RBUILD_I
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(RBUILD_INT_)rule.o: $(RBUILD_BASE_)rule.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_INT_)stubbedcomponent.o: $(RBUILD_BASE_)stubbedcomponent.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
$(RBUILD_INT_)stubbedcomponent.o: $(RBUILD_BASE_)stubbedcomponent.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
@ -483,6 +479,10 @@ $(RBUILD_MINGW_INT_)proxymakefile.o: $(RBUILD_MINGW_BASE_)proxymakefile.cpp $(RB
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(RBUILD_MINGW_INT_)rule.o: $(RBUILD_MINGW_BASE_)rule.cpp $(RBUILD_HEADERS) | $(RBUILD_MINGW_INT)
|
||||||
|
$(ECHO_CC)
|
||||||
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
$(RBUILD_DEVCPP_INT_)devcpp.o: $(RBUILD_DEVCPP_BASE_)devcpp.cpp $(RBUILD_HEADERS) | $(RBUILD_DEVCPP_INT)
|
$(RBUILD_DEVCPP_INT_)devcpp.o: $(RBUILD_DEVCPP_BASE_)devcpp.cpp $(RBUILD_HEADERS) | $(RBUILD_DEVCPP_INT)
|
||||||
$(ECHO_CC)
|
$(ECHO_CC)
|
||||||
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
|
||||||
|
|
Loading…
Reference in a new issue