diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 34135575bd4..5d2eb5d51d3 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -383,46 +383,27 @@ MingwBackend::GenerateHeader () const fprintf ( fMakefile, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" ); } +string +MingwBackend::GenerateIncludesAndDefines ( IfableData& data ) const +{ + string includeParameters = MingwModuleHandler::GenerateGccIncludeParametersFromVector ( data.includes ); + string defineParameters = MingwModuleHandler::GenerateGccDefineParametersFromVector ( data.defines ); + return includeParameters + " " + defineParameters; +} + void MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation, IfableData& data ) const { - size_t i; - fprintf ( fMakefile, "PROJECT_CFLAGS %s", assignmentOperation ); - for ( i = 0; i < data.compilerFlags.size(); i++ ) - { - fprintf ( - fMakefile, - " %s", - data.compilerFlags[i]->flag.c_str() ); - } + fprintf ( fMakefile, + " %s", + GenerateIncludesAndDefines ( data ).c_str() ); - for ( i = 0; i < data.includes.size(); i++ ) - { - fprintf ( - fMakefile, - " -I%s", - data.includes[i]->directory.c_str() ); - } - - for ( i = 0; i < data.defines.size(); i++ ) - { - Define& d = *data.defines[i]; - fprintf ( - fMakefile, - " -D%s", - d.name.c_str() ); - if ( d.value.size() ) - fprintf ( - fMakefile, - "=%s", - d.value.c_str() ); - } fprintf ( fMakefile, "\n" ); } @@ -441,7 +422,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties ( prop.value.c_str() ); } - if ( data.includes.size() || data.defines.size() || data.compilerFlags.size() ) + if ( data.includes.size() || data.defines.size() ) { GenerateProjectCFlagsMacro ( assignmentOperation, data ); @@ -452,7 +433,6 @@ MingwBackend::GenerateGlobalCFlagsAndProperties ( If& rIf = *data.ifs[i]; if ( rIf.data.defines.size() || rIf.data.includes.size() - || rIf.data.compilerFlags.size() || rIf.data.ifs.size() ) { fprintf ( @@ -470,6 +450,62 @@ MingwBackend::GenerateGlobalCFlagsAndProperties ( } } +void +MingwBackend::GenerateProjectGccOptionsMacro ( const char* assignmentOperation, + IfableData& data ) const +{ + size_t i; + + fprintf ( + fMakefile, + "PROJECT_GCCOPTIONS %s", + assignmentOperation ); + + for ( i = 0; i < data.compilerFlags.size(); i++ ) + { + fprintf ( + fMakefile, + " %s", + data.compilerFlags[i]->flag.c_str() ); + } + + fprintf ( fMakefile, "\n" ); +} + +void +MingwBackend::GenerateProjectGccOptions ( + const char* assignmentOperation, + IfableData& data ) const +{ + size_t i; + + if ( data.compilerFlags.size() ) + { + GenerateProjectGccOptionsMacro ( assignmentOperation, + data ); + } + + for ( i = 0; i < data.ifs.size(); i++ ) + { + If& rIf = *data.ifs[i]; + if ( rIf.data.compilerFlags.size() + || rIf.data.ifs.size() ) + { + fprintf ( + fMakefile, + "ifeq (\"$(%s)\",\"%s\")\n", + rIf.property.c_str(), + rIf.value.c_str() ); + GenerateProjectGccOptions ( + "+=", + rIf.data ); + fprintf ( + fMakefile, + "endif\n\n" ); + } + } +} + string MingwBackend::GenerateProjectLFLAGS () const { @@ -487,14 +523,14 @@ MingwBackend::GenerateProjectLFLAGS () const void MingwBackend::GenerateGlobalVariables () const { - GenerateGlobalCFlagsAndProperties ( - "=", - ProjectNode.non_if_data ); + 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_LFLAGS := %s\n", GenerateProjectLFLAGS ().c_str () ); + fprintf ( fMakefile, "PROJECT_CFLAGS += $(PROJECT_GCCOPTIONS)\n" ); fprintf ( fMakefile, "PROJECT_CFLAGS += -Wall\n" ); fprintf ( fMakefile, "\n" ); } diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index ac72c0b11fd..f19cf8238bf 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -73,10 +73,15 @@ private: void CreateMakefile (); void CloseMakefile () const; void GenerateHeader () const; + std::string GenerateIncludesAndDefines ( IfableData& data ) const; void GenerateProjectCFlagsMacro ( const char* assignmentOperation, IfableData& data ) const; void GenerateGlobalCFlagsAndProperties ( const char* op, IfableData& data ) const; + void GenerateProjectGccOptionsMacro ( const char* assignmentOperation, + IfableData& data ) const; + void GenerateProjectGccOptions ( const char* assignmentOperation, + IfableData& data ) const; std::string GenerateProjectLFLAGS () const; void GenerateDirectories (); void GenerateGlobalVariables () const; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 652cbc5b3e5..8ac571a5baf 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -488,9 +488,9 @@ MingwModuleHandler::GetObjectFilenames () return objectFilenames; } -string +/* static */ string MingwModuleHandler::GenerateGccDefineParametersFromVector ( - const vector& defines ) const + const vector& defines ) { string parameters; for ( size_t i = 0; i < defines.size (); i++ ) @@ -535,8 +535,8 @@ MingwModuleHandler::ConcatenatePaths ( return path1 + CSEP + path2; } -string -MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector& includes ) const +/* static */ string +MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector& includes ) { string parameters; for ( size_t i = 0; i < includes.size (); i++ ) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h index 751cb095934..b9f40b04a62 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.h +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h @@ -40,6 +40,9 @@ public: const Module& module, string_list* pclean_files ); + static std::string GenerateGccDefineParametersFromVector ( const std::vector& defines ); + static std::string GenerateGccIncludeParametersFromVector ( const std::vector& includes ); + std::string GetModuleTargets ( const Module& module ); void GetObjectsVector ( const IfableData& data, std::vector& objectFiles ) const; @@ -100,9 +103,7 @@ protected: private: std::string ConcatenatePaths ( const std::string& path1, const std::string& path2 ) const; - std::string GenerateGccDefineParametersFromVector ( const std::vector& defines ) const; std::string GenerateGccDefineParameters () const; - std::string GenerateGccIncludeParametersFromVector ( const std::vector& includes ) const; std::string GenerateCompilerParametersFromVector ( const std::vector& compilerFlags ) const; std::string GenerateLinkerParametersFromVector ( const std::vector& linkerFlags ) const; std::string GenerateImportLibraryDependenciesFromVector ( const std::vector& libraries );