compilerflags can be set for compiler {ALL|CC|CPP} now (ALL is default)
authorChristoph von Wittich <christoph_vw@reactos.org>
Sat, 26 Jan 2008 18:27:37 +0000 (18:27 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sat, 26 Jan 2008 18:27:37 +0000 (18:27 +0000)
svn path=/trunk/; revision=32018

reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/compilerflag.cpp
reactos/tools/rbuild/rbuild.h

index 72386e8..0c315e0 100644 (file)
@@ -448,10 +448,13 @@ MingwBackend::GenerateProjectGccOptionsMacro ( const char* assignmentOperation,
 
        for ( i = 0; i < data.compilerFlags.size(); i++ )
        {
-               fprintf (
-                       fMakefile,
-                       " %s",
-                       data.compilerFlags[i]->flag.c_str() );
+               if ( data.compilerFlags[i]->compiler == CompilerTypeDontCare )
+               {
+                       fprintf (
+                               fMakefile,
+                               " %s",
+                               data.compilerFlags[i]->flag.c_str() );
+               }
        }
 
        fprintf ( fMakefile, "\n" );
index 195d2e2..a6ea907 100644 (file)
@@ -764,15 +764,18 @@ MingwModuleHandler::GenerateGccIncludeParameters () const
 }
 
 string
-MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags ) const
+MingwModuleHandler::GenerateCompilerParametersFromVector ( const vector<CompilerFlag*>& compilerFlags, const CompilerType type ) const
 {
        string parameters;
        for ( size_t i = 0; i < compilerFlags.size (); i++ )
        {
                CompilerFlag& compilerFlag = *compilerFlags[i];
-               if ( parameters.length () > 0 )
-                       parameters += " ";
-               parameters += compilerFlag.flag;
+               if ( compilerFlag.compiler == type )
+               {
+                       if ( parameters.length () > 0 )
+                               parameters += " ";
+                       parameters += compilerFlag.flag;
+               }
        }
        return parameters;
 }
@@ -848,7 +851,7 @@ MingwModuleHandler::GenerateMacro (
 
        if ( generatingCompilerMacro )
        {
-               string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags );
+               string compilerParameters = GenerateCompilerParametersFromVector ( data.compilerFlags , CompilerTypeDontCare );
                if ( compilerParameters.size () > 0 )
                {
                        fprintf (
@@ -1719,21 +1722,25 @@ MingwModuleHandler::GenerateCommands (
 {
        const FileLocation& sourceFile = compilationUnit.GetFilename ();
        string extension = GetExtension ( sourceFile );
+       string flags = cflagsMacro;
+       flags += " ";
        if ( extension == ".c" || extension == ".C" )
        {
+               flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCC );
                GenerateGccCommand ( &sourceFile,
                                     GetCompilationUnitDependencies ( compilationUnit ) + extraDependencies,
                                     cc,
-                                    cflagsMacro );
+                                    flags );
        }
        else if ( extension == ".cc" || extension == ".CC" ||
                  extension == ".cpp" || extension == ".CPP" ||
                  extension == ".cxx" || extension == ".CXX" )
        {
+               flags += GenerateCompilerParametersFromVector ( module.non_if_data.compilerFlags , CompilerTypeCPP );
                GenerateGccCommand ( &sourceFile,
                                     GetCompilationUnitDependencies ( compilationUnit ) + extraDependencies,
                                     cppc,
-                                    cflagsMacro );
+                                    flags );
        }
        else if ( extension == ".s" || extension == ".S" )
        {
index df7483a..46e8069 100644 (file)
@@ -130,7 +130,7 @@ private:
        std::string ConcatenatePaths ( const std::string& path1,
                                       const std::string& path2 ) const;
        std::string GenerateGccDefineParameters () const;
-       std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags ) const;
+       std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags, const CompilerType type ) const;
        std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
        std::string GenerateImportLibraryDependenciesFromVector ( const std::vector<Library*>& libraries );
        std::string GenerateLinkerParameters () const;
index 6f3a099..00c5562 100644 (file)
@@ -55,7 +55,25 @@ CompilerFlag::Initialize ()
                        node.location,
                        "<compilerflag> is empty." );
        }
+
        flag = node.value;
+       compiler = CompilerTypeDontCare;
+
+       const XMLAttribute* att = node.GetAttribute ( "compiler", false );
+       if ( att != NULL)
+       {
+               if ( att->value == "cpp" )
+                       compiler = CompilerTypeCPP;
+               else if ( att->value == "cc" )
+                       compiler = CompilerTypeCC;
+               else
+               {
+                       throw InvalidAttributeValueException (
+                               node.location,
+                               "compiler",
+                               att->value );
+               }
+       }
 }
 
 void
index 589fdfa..a67219a 100644 (file)
@@ -311,6 +311,13 @@ enum HostType
        HostDontCare,
 };
 
+enum CompilerType
+{
+       CompilerTypeDontCare,
+       CompilerTypeCC,
+       CompilerTypeCPP,
+};
+
 class FileLocation
 {
 public:
@@ -592,6 +599,7 @@ public:
        const Module* module;
        const XMLElement& node;
        std::string flag;
+       CompilerType compiler;
 
        CompilerFlag ( const Project& project,
                       const XMLElement& compilerFlagNode );