Author: hpoussin
Date: Fri Oct 19 17:24:06 2007
New Revision: 29681
URL:
http://svn.reactos.org/svn/reactos?rev=29681&view=rev
Log:
Support define overriding in child .rbuild files
See issue #2745 for more details.
Modified:
trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
trunk/reactos/tools/rbuild/backend/mingw/mingw.h
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Fri Oct 19 17:24:06 2007
@@ -372,35 +372,31 @@
ProjectNode.GetProjectFilename ().c_str () );
}
-string
-MingwBackend::GenerateIncludesAndDefines ( IfableData& data ) const
+void
+MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation,
+ const IfableData& data ) const
{
set<string> used_defs;
- string includeParameters = MingwModuleHandler::GenerateGccIncludeParametersFromVector (
data.includes );
- string defineParameters = MingwModuleHandler::GenerateGccDefineParametersFromVector (
data.defines, used_defs );
- return includeParameters + " " + defineParameters;
-}
-
-void
-MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation,
- IfableData& data ) const
-{
- fprintf (
- fMakefile,
- "PROJECT_CFLAGS %s",
- assignmentOperation );
-
- fprintf ( fMakefile,
- " %s",
- GenerateIncludesAndDefines ( data ).c_str() );
-
- fprintf ( fMakefile, "\n" );
+
+ if ( data.includes.size () > 0 )
+ fprintf (
+ fMakefile,
+ "PROJECT_CFLAGS %s %s\n",
+ assignmentOperation,
+ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( data.includes ).c_str
());
+
+ if ( data.defines.size () > 0 )
+ fprintf (
+ fMakefile,
+ "PROJECT_CDEFINES %s %s\n",
+ assignmentOperation,
+ MingwModuleHandler::GenerateGccDefineParametersFromVector ( data.defines, used_defs
).c_str ());
}
void
MingwBackend::GenerateGlobalCFlagsAndProperties (
const char* assignmentOperation,
- IfableData& data ) const
+ const IfableData& data ) const
{
size_t i;
@@ -420,7 +416,7 @@
for ( i = 0; i < data.ifs.size(); i++ )
{
- If& rIf = *data.ifs[i];
+ const If& rIf = *data.ifs[i];
if ( rIf.data.defines.size()
|| rIf.data.includes.size()
|| rIf.data.ifs.size() )
@@ -523,8 +519,8 @@
GenerateGlobalCFlagsAndProperties ( "=", ProjectNode.non_if_data );
GenerateProjectGccOptions ( "=", ProjectNode.non_if_data );
- fprintf ( fMakefile, "PROJECT_RCFLAGS := $(PROJECT_CFLAGS)\n" );
- fprintf ( fMakefile, "PROJECT_WIDLFLAGS := $(PROJECT_CFLAGS)\n" );
+ fprintf ( fMakefile, "PROJECT_RCFLAGS := $(PROJECT_CFLAGS)
$(PROJECT_CDEFINES)\n" );
+ fprintf ( fMakefile, "PROJECT_WIDLFLAGS := $(PROJECT_CFLAGS)
$(PROJECT_CDEFINES)\n" );
fprintf ( fMakefile, "PROJECT_LFLAGS := %s\n",
GenerateProjectLFLAGS ().c_str () );
fprintf ( fMakefile, "PROJECT_CFLAGS += -Wall\n" );
Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.h (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.h Fri Oct 19 17:24:06 2007
@@ -62,11 +62,10 @@
void CreateMakefile ();
void CloseMakefile () const;
void GenerateHeader () const;
- std::string GenerateIncludesAndDefines ( IfableData& data ) const;
void GenerateProjectCFlagsMacro ( const char* assignmentOperation,
- IfableData& data ) const;
+ const IfableData& data ) const;
void GenerateGlobalCFlagsAndProperties ( const char* op,
- IfableData& data ) const;
+ const IfableData& data ) const;
void GenerateProjectGccOptionsMacro ( const char* assignmentOperation,
IfableData& data ) const;
void GenerateProjectGccOptions ( const char* assignmentOperation,
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Fri Oct 19 17:24:06 2007
@@ -629,7 +629,7 @@
/* static */ string
MingwModuleHandler::GenerateGccDefineParametersFromVector (
const vector<Define*>& defines,
- set<string>& used_defs)
+ set<string>& used_defs)
{
string parameters;
@@ -640,8 +640,8 @@
continue;
if (parameters.length () > 0)
parameters += " ";
- if (define.name.find('(') != string::npos)
- parameters += "$(QT)";
+ if (define.name.find('(') != string::npos)
+ parameters += "$(QT)";
parameters += "-D";
parameters += define.name;
if (define.value.length () > 0)
@@ -649,8 +649,8 @@
parameters += "=";
parameters += define.value;
}
- if (define.name.find('(') != string::npos)
- parameters += "$(QT)";
+ if (define.name.find('(') != string::npos)
+ parameters += "$(QT)";
used_defs.insert(used_defs.begin(),define.name);
}
return parameters;
@@ -659,7 +659,7 @@
string
MingwModuleHandler::GenerateGccDefineParameters () const
{
- set<string> used_defs;
+ set<string> used_defs;
string parameters = GenerateGccDefineParametersFromVector (
module.project.non_if_data.defines, used_defs );
string s = GenerateGccDefineParametersFromVector ( module.non_if_data.defines, used_defs
);
if ( s.length () > 0 )
@@ -765,7 +765,8 @@
MingwModuleHandler::GenerateMacro (
const char* assignmentOperation,
const string& macro,
- const IfableData& data )
+ const IfableData& data,
+ set<string> *used_defs )
{
size_t i;
bool generateAssignment;
@@ -806,7 +807,14 @@
}
for ( i = 0; i < data.defines.size(); i++ )
{
- Define& d = *data.defines[i];
+ const Define& d = *data.defines[i];
+ if (used_defs && used_defs->find(d.name) != used_defs->end())
+ {
+ if ( backend->configuration.Verbose )
+ printf("%s define overridden in '%s' module\n",
+ d.name.c_str (), module.name.c_str () );
+ continue;
+ }
fprintf (
fMakefile,
" -D%s",
@@ -816,6 +824,8 @@
fMakefile,
"=%s",
d.value.c_str() );
+ if (used_defs)
+ used_defs->insert(used_defs->begin(), d.name);
}
if ( generateAssignment )
{
@@ -827,16 +837,19 @@
MingwModuleHandler::GenerateMacros (
const char* assignmentOperation,
const IfableData& data,
- const vector<LinkerFlag*>* linkerFlags )
+ const vector<LinkerFlag*>* linkerFlags,
+ set<string>& used_defs )
{
size_t i;
GenerateMacro ( assignmentOperation,
cflagsMacro,
- data );
+ data,
+ &used_defs );
GenerateMacro ( assignmentOperation,
windresflagsMacro,
- data );
+ data,
+ NULL );
if ( linkerFlags != NULL )
{
@@ -886,7 +899,8 @@
GenerateMacros (
"+=",
rIf.data,
- NULL );
+ NULL,
+ used_defs );
fprintf (
fMakefile,
"endif\n\n" );
@@ -2020,6 +2034,8 @@
void
MingwModuleHandler::GenerateOtherMacros ()
{
+ set<string> used_defs;
+
cflagsMacro = ssprintf ("%s_CFLAGS", module.name.c_str ());
nasmflagsMacro = ssprintf ("%s_NASMFLAGS", module.name.c_str ());
windresflagsMacro = ssprintf ("%s_RCFLAGS", module.name.c_str ());
@@ -2031,7 +2047,14 @@
GenerateMacros (
"=",
module.non_if_data,
- &module.linkerFlags );
+ &module.linkerFlags,
+ used_defs );
+
+ GenerateMacros (
+ "+=",
+ module.project.non_if_data,
+ NULL,
+ used_defs );
vector<FileLocation> s;
if ( module.importLibrary )
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h Fri Oct 19 17:24:06 2007
@@ -136,10 +136,12 @@
std::string GenerateLinkerParameters () const;
void GenerateMacro ( const char* assignmentOperation,
const std::string& macro,
- const IfableData& data );
+ const IfableData& data,
+ std::set<std::string>* used_defs );
void GenerateMacros ( const char* op,
const IfableData& data,
- const std::vector<LinkerFlag*>* linkerFlags );
+ const std::vector<LinkerFlag*>* linkerFlags,
+ std::set<std::string>& used_defs );
void GenerateSourceMacros ( const char* assignmentOperation,
const IfableData& data );
void GenerateObjectMacros ( const char* assignmentOperation,