--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-01-15 20:28:19 UTC (rev 13067)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-01-15 22:32:01 UTC (rev 13068)
@@ -34,13 +34,13 @@
}
}
-/*static*/ void
+void
MingwModuleHandler::SetMakefile ( FILE* f )
{
fMakefile = f;
}
-/*static*/ MingwModuleHandler*
+MingwModuleHandler*
MingwModuleHandler::LookupHandler ( const string& location,
ModuleType moduletype )
{
@@ -160,8 +160,14 @@
string
MingwModuleHandler::GetObjectFilename ( const string& sourceFilename ) const
{
+ string newExtension;
+ string extension = GetExtension ( sourceFilename );
+ if ( extension == ".rc" || extension == ".RC" )
+ newExtension = ".coff";
+ else
+ newExtension = ".o";
return FixupTargetFilename ( ReplaceExtension ( sourceFilename,
- ".o" ) );
+ newExtension ) );
}
string
@@ -239,19 +245,6 @@
return parameters;
}
-void
-MingwModuleHandler::GenerateGccModuleIncludeVariable ( const Module& module ) const
-{
-#if 0
- string name ( module.name + "_CFLAGS" );
- fprintf ( fMakefile,
- "%s := %s %s\n",
- name.c_str(),
- GenerateGccDefineParameters(module).c_str(),
- GenerateGccIncludeParameters(module).c_str() );
-#endif
-}
-
string
MingwModuleHandler::GenerateGccIncludeParameters ( const Module& module ) const
{
@@ -287,6 +280,42 @@
}
void
+MingwModuleHandler::GenerateMacro ( const char* assignmentOperation,
+ const string& macro,
+ const vector<Include*>& includes,
+ const vector<Define*>& defines ) const
+{
+ size_t i;
+
+ fprintf (
+ fMakefile,
+ "%s %s",
+ macro.c_str(),
+ assignmentOperation );
+ for ( i = 0; i < includes.size(); i++ )
+ {
+ fprintf (
+ fMakefile,
+ " -I%s",
+ includes[i]->directory.c_str() );
+ }
+ for ( i = 0; i < defines.size(); i++ )
+ {
+ Define& d = *defines[i];
+ fprintf (
+ fMakefile,
+ " -D%s",
+ d.name.c_str() );
+ if ( d.value.size() )
+ fprintf (
+ fMakefile,
+ "=%s",
+ d.value.c_str() );
+ }
+ fprintf ( fMakefile, "\n" );
+}
+
+void
MingwModuleHandler::GenerateMacros (
const char* assignmentOperation,
const vector<File*>& files,
@@ -296,6 +325,7 @@
const vector<If*>& ifs,
const string& cflags_macro,
const string& nasmflags_macro,
+ const string& windresflags_macro,
const string& linkerflags_macro,
const string& objs_macro) const
{
@@ -303,32 +333,14 @@
if ( includes.size() || defines.size() )
{
- fprintf (
- fMakefile,
- "%s %s",
- cflags_macro.c_str(),
- assignmentOperation );
- for ( i = 0; i < includes.size(); i++ )
- {
- fprintf (
- fMakefile,
- " -I%s",
- includes[i]->directory.c_str() );
- }
- for ( i = 0; i < defines.size(); i++ )
- {
- Define& d = *defines[i];
- fprintf (
- fMakefile,
- " -D%s",
- d.name.c_str() );
- if ( d.value.size() )
- fprintf (
- fMakefile,
- "=%s",
- d.value.c_str() );
- }
- fprintf ( fMakefile, "\n" );
+ GenerateMacro ( assignmentOperation,
+ cflags_macro,
+ includes,
+ defines );
+ GenerateMacro ( assignmentOperation,
+ windresflags_macro,
+ includes,
+ defines );
}
if ( linkerFlags != NULL )
@@ -382,6 +394,7 @@
rIf.ifs,
cflags_macro,
nasmflags_macro,
+ windresflags_macro,
linkerflags_macro,
objs_macro );
fprintf (
@@ -396,6 +409,7 @@
const Module& module,
const string& cflags_macro,
const string& nasmflags_macro,
+ const string& windresflags_macro,
const string& linkerflags_macro,
const string& objs_macro) const
{
@@ -408,6 +422,7 @@
module.ifs,
cflags_macro,
nasmflags_macro,
+ windresflags_macro,
linkerflags_macro,
objs_macro );
fprintf ( fMakefile, "\n" );
@@ -419,6 +434,11 @@
fprintf (
fMakefile,
+ "%s += $(PROJECT_RCFLAGS)\n\n",
+ windresflags_macro.c_str () );
+
+ fprintf (
+ fMakefile,
"%s_LFLAGS += $(PROJECT_LFLAGS)\n\n",
module.name.c_str () );
}
@@ -465,11 +485,25 @@
}
string
+MingwModuleHandler::GenerateWindresCommand ( const Module& module,
+ const string& sourceFilename,
+ const string& windresflagsMacro ) const
+{
+ string objectFilename = GetObjectFilename ( sourceFilename );
+ return ssprintf ( "%s %s -o %s ${%s}\n",
+ "${windres}",
+ sourceFilename.c_str (),
+ objectFilename.c_str (),
+ windresflagsMacro.c_str () );
+}
+
+string
MingwModuleHandler::GenerateCommand ( const Module& module,
const string& sourceFilename,
const string& cc,
const string& cflagsMacro,
- const string& nasmflagsMacro ) const
+ const string& nasmflagsMacro,
+ const string& windresflagsMacro ) const
{
string extension = GetExtension ( sourceFilename );
if ( extension == ".c" || extension == ".C" )
@@ -486,6 +520,10 @@
return GenerateNasmCommand ( module,
sourceFilename,
nasmflagsMacro );
+ else if ( extension == ".rc" || extension == ".RC" )
+ return GenerateWindresCommand ( module,
+ sourceFilename,
+ windresflagsMacro );
throw InvalidOperationException ( __FILE__,
__LINE__,
@@ -517,7 +555,8 @@
const vector<If*>& ifs,
const string& cc,
const string& cflagsMacro,
- const string& nasmflagsMacro ) const
+ const string& nasmflagsMacro,
+ const string& windresflagsMacro ) const
{
size_t i;
@@ -535,20 +574,34 @@
sourceFilename,
cc,
cflagsMacro,
- nasmflagsMacro ).c_str () );
+ nasmflagsMacro,
+ windresflagsMacro ).c_str () );
}
for ( i = 0; i < ifs.size(); i++ )
- GenerateObjectFileTargets ( module, ifs[i]->files, ifs[i]->ifs, cc, cflagsMacro, nasmflagsMacro );
+ GenerateObjectFileTargets ( module,
+ ifs[i]->files,
+ ifs[i]->ifs,
+ cc,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro );
}
void
MingwModuleHandler::GenerateObjectFileTargets ( const Module& module,
const string& cc,
const string& cflagsMacro,
- const string& nasmflagsMacro ) const
+ const string& nasmflagsMacro,
+ const string& windresflagsMacro ) const
{
- GenerateObjectFileTargets ( module, module.files, module.ifs, cc, cflagsMacro, nasmflagsMacro );
+ GenerateObjectFileTargets ( module,
+ module.files,
+ module.ifs,
+ cc,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro );
fprintf ( fMakefile, "\n" );
}
@@ -609,10 +662,16 @@
{
string cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
string nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
+ string windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
string linkerFlagsMacro = ssprintf ("%s_LFLAGS", module.name.c_str ());
string objectsMacro = ssprintf ("%s_OBJS", module.name.c_str ());
- GenerateMacros ( module, cflagsMacro, nasmflagsMacro, linkerFlagsMacro, objectsMacro );
+ GenerateMacros ( module,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro,
+ linkerFlagsMacro,
+ objectsMacro );
// generate phony target for module name
fprintf ( fMakefile, ".PHONY: %s\n",
@@ -627,7 +686,11 @@
objectsMacro = ssprintf ("$(%s)", objectsMacro.c_str ());
string ar_target = GenerateArchiveTarget ( module, ar, objectsMacro );
- GenerateObjectFileTargets ( module, cc, cflagsMacro, nasmflagsMacro );
+ GenerateObjectFileTargets ( module,
+ cc,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro );
vector<string> clean_files;
clean_files.push_back ( FixupTargetFilename(module.GetPath()) );
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-01-15 20:28:19 UTC (rev 13067)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-01-15 22:32:01 UTC (rev 13068)
@@ -38,9 +38,6 @@
void GeneratePreconditionDependencies ( const Module& module ) const;
std::string GetObjectsMacro ( const Module& module ) const;
std::string GetLinkerMacro ( const Module& module ) const;
- std::string GenerateMacros ( const Module& module,
- const std::string& cflags_macro,
- const std::string& objs_macro ) const;
std::string GenerateLinkerCommand ( const Module& module,
const std::string& linker,
const std::string& linkerParameters,
@@ -54,6 +51,10 @@
std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes ) const;
std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
std::string GenerateLinkerParameters ( const Module& module ) const;
+ void GenerateMacro ( const char* assignmentOperation,
+ const std::string& macro,
+ const std::vector<Include*>& includes,
+ const std::vector<Define*>& defines ) const;
void GenerateMacros ( const char* op,
const std::vector<File*>& files,
const std::vector<Include*>& includes,
@@ -62,14 +63,15 @@
const std::vector<If*>& ifs,
const std::string& cflags_macro,
const std::string& nasmflags_macro,
+ const std::string& windresflags_macro,
const std::string& linkerflags_macro,
const std::string& objs_macro) const;
void GenerateMacros ( const Module& module,
const std::string& cflags_macro,
const std::string& nasmflags_macro,
+ const std::string& windresflags_macro,
const std::string& linkerflags_macro,
const std::string& objs_macro) const;
- void GenerateGccModuleIncludeVariable ( const Module& module ) const;
std::string GenerateGccIncludeParameters ( const Module& module ) const;
std::string GenerateGccParameters ( const Module& module ) const;
std::string GenerateNasmParameters ( const Module& module ) const;
@@ -84,21 +86,27 @@
std::string GenerateNasmCommand ( const Module& module,
const std::string& sourceFilename,
const std::string& nasmflagsMacro ) const;
+ std::string GenerateWindresCommand ( const Module& module,
+ const std::string& sourceFilename,
+ const std::string& windresflagsMacro ) const;
std::string GenerateCommand ( const Module& module,
const std::string& sourceFilename,
const std::string& cc,
const std::string& cflagsMacro,
- const std::string& nasmflagsMacro ) const;
+ const std::string& nasmflagsMacro,
+ const std::string& windresflagsMacro ) const;
void GenerateObjectFileTargets ( const Module& module,
const std::vector<File*>& files,
const std::vector<If*>& ifs,
const std::string& cc,
const std::string& cflagsMacro,
- const std::string& nasmflagsMacro ) const;
+ const std::string& nasmflagsMacro,
+ const std::string& windresflagsMacro ) const;
void GenerateObjectFileTargets ( const Module& module,
const std::string& cc,
const std::string& cflagsMacro,
- const std::string& nasmflagsMacro ) const;
+ const std::string& nasmflagsMacro,
+ const std::string& windresflagsMacro ) const;
void GetCleanTargets ( std::vector<std::string>& out,
const std::vector<File*>& files,
const std::vector<If*>& ifs ) const;