[ros-diffs] [cwittich] 24992: check for compiler version

cwittich at svn.reactos.org cwittich at svn.reactos.org
Thu Nov 30 16:11:27 CET 2006


Author: cwittich
Date: Thu Nov 30 18:11:26 2006
New Revision: 24992

URL: http://svn.reactos.org/svn/reactos?rev=24992&view=rev
Log:
check for compiler version

Modified:
    trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
    trunk/reactos/tools/rbuild/backend/mingw/mingw.h

Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp?rev=24992&r1=24991&r2=24992&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.cpp Thu Nov 30 18:11:26 2006
@@ -685,10 +685,23 @@
 		compilerCommand = compilerPrefix + "-gcc";
 		detectedCompiler = TryToDetectThisCompiler ( compilerCommand );
 	}
+
 	if ( detectedCompiler )
-		printf ( "detected (%s)\n", compilerCommand.c_str () );
+	{
+		string compilerVersion = GetCompilerVersion ( compilerCommand );
+		if ( IsSupportedCompilerVersion ( compilerVersion ) )
+			printf ( "detected (%s %s)\n", compilerCommand.c_str (), compilerVersion.c_str() );
+		else
+		{
+			printf ( "detected (%s), but with unsupported version (%s)\n",
+			         compilerCommand.c_str (),
+			         compilerVersion.c_str () );
+			throw UnsupportedBuildToolException ( compilerCommand, compilerVersion );
+		}
+	}
 	else
 		printf ( "not detected\n" );
+
 }
 
 bool
@@ -701,6 +714,56 @@
 		NUL );
 	int exitcode = system ( command.c_str () );
 	return (exitcode == 0);
+}
+
+string
+MingwBackend::GetCompilerVersion ( const string& compilerCommand )
+{
+	FILE *fp;
+	int ch, i;
+	char buffer[81];
+
+	string versionCommand = ssprintf ( "%s --version gcc",
+	                                   compilerCommand.c_str (),
+	                                   NUL,
+	                                   NUL );
+	fp = popen ( versionCommand.c_str () , "r" );
+	for( i = 0; 
+             ( i < 80 ) && 
+                 ( feof ( fp ) == 0 && 
+                   ( ( ch = fgetc( fp ) ) != -1 ) ); 
+             i++ )
+	{
+		buffer[i] = (char) ch;
+	}
+	buffer[i] = '\0';
+	pclose ( fp );
+
+	char separators[] = " ";
+	char *token;
+	char *prevtoken = NULL;
+	
+	string version;
+
+	token = strtok ( buffer, separators );
+	while ( token != NULL )
+	{
+		prevtoken = token;
+		version = string( prevtoken );
+		if ( version.find('.') != std::string::npos )
+			break;
+		token = strtok ( NULL, separators );
+	}
+	return version;
+}
+
+bool
+MingwBackend::IsSupportedCompilerVersion ( const string& compilerVersion )
+{
+	if ( strcmp ( compilerVersion.c_str (), "3.4.5") < 0 )
+		return false;
+	else
+		return true;
 }
 
 bool

Modified: trunk/reactos/tools/rbuild/backend/mingw/mingw.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/mingw.h?rev=24992&r1=24991&r2=24992&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/mingw.h (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/mingw.h Thu Nov 30 18:11:26 2006
@@ -85,6 +85,8 @@
 	bool IncludeDirectoryTarget ( const std::string& directory ) const;
 	bool TryToDetectThisCompiler ( const std::string& compiler );
 	void DetectCompiler ();
+	std::string GetCompilerVersion ( const std::string& compilerCommand );
+	bool IsSupportedCompilerVersion ( const std::string& compilerVersion );
 	bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
 	bool TryToDetectThisBinutils ( const std::string& binutils );
 	std::string GetBinutilsVersion ( const std::string& binutilsCommand );




More information about the Ros-diffs mailing list