[ros-diffs] [cwittich] 24802: use the correct compiler for .c/.cpp files

cwittich at svn.reactos.org cwittich at svn.reactos.org
Wed Nov 22 21:35:12 CET 2006


Author: cwittich
Date: Wed Nov 22 23:35:11 2006
New Revision: 24802

URL: http://svn.reactos.org/svn/reactos?rev=24802&view=rev
Log:
use the correct compiler for .c/.cpp files

Modified:
    trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp

Modified: trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp?rev=24802&r1=24801&r2=24802&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp Wed Nov 22 23:35:11 2006
@@ -324,6 +324,7 @@
 	string outenv = Environment::GetOutputPath ();
 	string module_type = GetExtension(module.GetTargetName());
 	string cbproj_path = module.GetBasePath();	
+	string CompilerVar;
 
 	//bool lib = (module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a");
 	//bool dll = (module_type == ".dll") || (module_type == ".cpl");
@@ -331,8 +332,15 @@
 	//bool sys = (module_type == ".sys");
 
 	vector<string> source_files, resource_files, includes, libraries, libpaths;
-	vector<string> header_files, common_defines;
+	vector<string> header_files, common_defines, compiler_flags;
+	vector<string> vars, values;
 	
+	compiler_flags.push_back ( "-Wall" );
+
+	// Always force disabling of sibling calls optimisation for GCC
+	// (TODO: Move to version-specific once this bug is fixed in GCC)
+	compiler_flags.push_back ( "-fno-optimize-sibling-calls" );
+
 	if ( module.pch != NULL )
 	{
 		string pch_path = Path::RelativeFromDirectory (
@@ -385,6 +393,11 @@
 			libraries.push_back ( libs[i]->name );
 			libpaths.push_back ( libpath );
 		}
+		const vector<CompilerFlag*>& cflags = data.compilerFlags;
+		for ( i = 0; i < cflags.size(); i++ )
+		{
+			compiler_flags.push_back ( cflags[i]->flag );
+		}
 		const vector<Define*>& defs = data.defines;
 		for ( i = 0; i < defs.size(); i++ )
 		{
@@ -393,7 +406,16 @@
 			else
 				common_defines.push_back( defs[i]->name );
 		}
-	}
+		/*const vector<Property*>& variables = data.properties;
+		for ( i = 0; i < variables.size(); i++ )
+		{
+			vars.push_back( variables[i]->name );
+			values.push_back( variables[i]->value );
+		}*/
+	}
+
+	if ( !module.allowWarnings )
+		compiler_flags.push_back ( "-Werror" );
 
 	FILE* OUT = fopen ( cbproj_file.c_str(), "wb" );
 
@@ -408,6 +430,8 @@
 	fprintf ( OUT, "\t\t<Option virtualFolders=\"\" />\r\n" );
 	fprintf ( OUT, "\t\t<Build>\r\n" );
 
+	bool console = exe && (module.type == Win32CUI);
+
 	for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
 	{
 		const CBConfiguration& cfg = *m_configurations[icfg];
@@ -423,8 +447,6 @@
 			fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s\\%s%s\" prefix_auto=\"1\" extension_auto=\"1\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), module.name.c_str(), module_type.c_str() );
 			fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str () );
 		}
-
-		bool console = exe && (module.type == Win32CUI);
 
 		if ( console )
 			fprintf ( OUT, "\t\t\t\t<Option type=\"1\" />\r\n" );
@@ -434,6 +456,19 @@
 			
 		fprintf ( OUT, "\t\t\t\t<Option compiler=\"gcc\" />\r\n" );
 		fprintf ( OUT, "\t\t\t\t<Compiler>\r\n" );
+		
+		bool debug = ( cfg.optimization == Debug );
+
+		if ( debug )
+			fprintf ( OUT, "\t\t\t\t\t<Add option=\"-g\" />\r\n" );
+
+		/* compiler flags */
+		for ( i = 0; i < compiler_flags.size(); i++ )
+		{
+			const string& cflag = compiler_flags[i];
+			fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", cflag.c_str() );
+		}
+
 		/* defines */
 		for ( i = 0; i < common_defines.size(); i++ )
 		{
@@ -474,14 +509,30 @@
 		fprintf ( OUT, "\t\t\t</Target>\r\n" );
 
 	}
+
+	/* vars
+	fprintf ( OUT, "\t\t\t<Environment>\r\n" );
+	for ( i = 0; i < vars.size(); i++ )
+	{
+		const string& var = vars[i];
+		const string& value = values[i];
+		fprintf ( OUT, "\t\t\t\t<Variable name=\"%s\" value=\"%s\" />\r\n", var.c_str(), value.c_str()  );
+	}
+	fprintf ( OUT, "\t\t\t</Environment>\r\n" ); */
+
 	fprintf ( OUT, "\t\t</Build>\r\n" );
+
+	if ( module.cplusplus )
+		CompilerVar = "CPP";
+	else
+		CompilerVar = "CC";
 
 	/* header files */
 	for ( i = 0; i < header_files.size(); i++ )
 	{
 		const string& header_file = header_files[i];
 		fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", header_file.c_str() );
-		fprintf ( OUT, "\t\t\t<Option compilerVar=\"CPP\" />\r\n" );
+		fprintf ( OUT, "\t\t\t<Option compilerVar=\"%s\" />\r\n", CompilerVar.c_str() );
 		fprintf ( OUT, "\t\t\t<Option compile=\"0\" />\r\n" );
 		fprintf ( OUT, "\t\t\t<Option link=\"0\" />\r\n" );
 		for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
@@ -497,6 +548,7 @@
 	{
 		string source_file = DosSeparator(source_files[isrcfile]);
 		fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", source_file.c_str() );
+		fprintf ( OUT, "\t\t\t<Option compilerVar=\"%s\" />\r\n", CompilerVar.c_str() );
 		for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
 		{
 			const CBConfiguration& cfg = *m_configurations[icfg];




More information about the Ros-diffs mailing list