Detect compiler -pipe support Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-04-03 10:16:56 UTC (rev 14467) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-04-03 10:46:08 UTC (rev 14468) @@ -206,7 +206,8 @@
{ size_t i;
- DetectPCHSupport(); + DetectPipeSupport (); + DetectPCHSupport ();
CreateMakefile (); GenerateHeader (); @@ -515,31 +516,66 @@ }
void -MingwBackend::DetectPCHSupport() +MingwBackend::DetectPipeSupport () { -#ifdef WIN32 - string sNUL = "NUL"; -#else - string sNUL = "/dev/null"; -#endif + printf ( "Detecting compiler -pipe support..." ); + + string pipe_detection = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pipe_detection.c"; + string pipe_detectionObjectFilename = ReplaceExtension ( pipe_detection, + ".o" ); + string command = ssprintf ( + "gcc -pipe -c %s -o %s 2>%s", + pipe_detection.c_str (), + pipe_detectionObjectFilename.c_str (), + NUL ); + int exitcode = system ( command.c_str () ); + FILE* f = fopen ( pipe_detectionObjectFilename.c_str (), "rb" ); + if ( f ) + { + usePipe = (exitcode == 0); + fclose ( f ); + unlink ( pipe_detectionObjectFilename.c_str () ); + } + else + usePipe = false; + + if ( usePipe ) + printf ( "detected\n" ); + else + printf ( "not detected\n" ); + + // TODO FIXME - eventually check for ROS_USE_PCH env var and + // allow that to override use_pch if true +} + +void +MingwBackend::DetectPCHSupport () +{ + printf ( "Detecting compiler pre-compiled header support..." ); + string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h"; - string cmd = ssprintf( + string cmd = ssprintf ( "gcc -c %s 2>%s", path.c_str (), - sNUL.c_str () ); - system ( cmd.c_str() ); + NUL ); + system ( cmd.c_str () ); path += ".gch";
- FILE* f = fopen ( path.c_str(), "rb" ); + FILE* f = fopen ( path.c_str (), "rb" ); if ( f ) { use_pch = true; - fclose(f); - unlink ( path.c_str() ); + fclose ( f ); + unlink ( path.c_str () ); } else use_pch = false;
+ if ( use_pch ) + printf ( "detected\n" ); + else + printf ( "not detected\n" ); + // TODO FIXME - eventually check for ROS_USE_PCH env var and // allow that to override use_pch if true } _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-04-03 10:16:56 UTC (rev 14467) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h 2005-04-03 10:46:08 UTC (rev 14468) @@ -3,6 +3,12 @@
#include "../backend.h"
+#ifdef WIN32 + #define NUL "NUL" +#else + #define NUL "/dev/null" +#endif + class Directory; class MingwModuleHandler;
@@ -13,6 +19,7 @@ virtual ~MingwBackend (); virtual void Process (); std::string AddDirectoryTarget ( const std::string& directory, bool out ); + bool usePipe; private: void CreateMakefile (); void CloseMakefile () const; @@ -31,7 +38,8 @@ void GenerateXmlBuildFilesMacro() const; void CheckAutomaticDependencies (); bool IncludeDirectoryTarget ( const std::string& directory ) const; - void DetectPCHSupport(); + void DetectPipeSupport (); + void DetectPCHSupport (); FILE* fMakefile; bool use_pch; Directory *int_directories, *out_directories; _____
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp --- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-04-03 10:16:56 UTC (rev 14467) +++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler .cpp 2005-04-03 10:46:08 UTC (rev 14468) @@ -1278,10 +1278,15 @@
} }
+ string globalCflags = "-g"; + if ( backend->usePipe ) + globalCflags += " -pipe"; + fprintf ( fMakefile, - "%s += $(PROJECT_CFLAGS) -g\n", - cflagsMacro.c_str () ); + "%s += $(PROJECT_CFLAGS) %s\n", + cflagsMacro.c_str (), + globalCflags.c_str () );
fprintf ( fMakefile,