[ros-diffs] [greatlrd] 28571: patch from Gregor Brunmar (gregor dot brunmar at home dot se) * Added folder support for msvc+solution generation in rbuild * map up pch .h file as include file in vc project files.

greatlrd at svn.reactos.org greatlrd at svn.reactos.org
Sun Aug 26 11:57:30 CEST 2007


Author: greatlrd
Date: Sun Aug 26 13:57:30 2007
New Revision: 28571

URL: http://svn.reactos.org/svn/reactos?rev=28571&view=rev
Log:
patch from  Gregor Brunmar (gregor dot brunmar at home dot se)
 * Added folder support for msvc+solution generation in rbuild
 * map up pch .h file as include file in vc project files.


Modified:
    trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
    trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp

Modified: trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp?rev=28571&r1=28570&r2=28571&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp Sun Aug 26 13:57:30 2007
@@ -83,7 +83,7 @@
 
 	// TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
 	string dsp_path = module.GetBasePath();
-	vector<string> c_srcs, source_files, resource_files, includes, libraries;
+	vector<string> c_srcs, source_files, header_files, resource_files, includes, libraries;
 	StringSet common_defines;
 	vector<const IfableData*> ifs_list;
 	ifs_list.push_back ( &module.project.non_if_data );
@@ -108,6 +108,8 @@
 			source_files.push_back ( file );
 			if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
 				c_srcs.push_back ( file );
+			if ( !stricmp ( Right(file,2).c_str(), ".h" ) )
+				header_files.push_back ( file );
 			if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
 				resource_files.push_back ( file );
 		}
@@ -144,7 +146,7 @@
 	}
 	// TODO FIXME - we don't include header files in our build system
 	//my @header_files = @{module->{header_files}};
-	vector<string> header_files;
+	//vector<string> header_files;
 
 	// TODO FIXME - wine hack?
 	/*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&

Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp?rev=28571&r1=28570&r2=28571&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Sun Aug 26 13:57:30 2007
@@ -41,6 +41,14 @@
 #undef OUT
 #endif//OUT
 
+struct SortFilesAscending
+{
+	bool operator()(const string& rhs, const string& lhs)
+	{
+		return rhs < lhs;
+	}
+};
+
 MSVCConfiguration::MSVCConfiguration ( const OptimizationType optimization, const HeadersType headers, const std::string &name )
 {
 	this->optimization = optimization;
@@ -124,7 +132,7 @@
 	bool include_idl = false;
 
 	string vcproj_path = module.GetBasePath();
-	vector<string> source_files, resource_files, includes, includes_ros, libraries;
+	vector<string> source_files, resource_files, header_files, includes, includes_ros, libraries;
 	StringSet common_defines;
 	vector<const IfableData*> ifs_list;
 	ifs_list.push_back ( &module.project.non_if_data );
@@ -154,6 +162,8 @@
 
 			if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
 				resource_files.push_back ( file );
+			else if ( !stricmp ( Right(file,2).c_str(), ".h" ) )
+				header_files.push_back ( file );
 			else
 				source_files.push_back ( file );
 		}
@@ -210,8 +220,6 @@
 				baseaddr = prop.value;
 		}
 	}
-
-	vector<string> header_files;
 
 	string include_string;
 
@@ -372,6 +380,11 @@
 			if ( pos != string::npos )
 				pch_path.erase(0, pos+1);         
 			fprintf ( OUT, "\t\t\t\tPrecompiledHeaderThrough=\"%s\"\r\n", pch_path.c_str() );
+
+			// Only include from the same module
+			pos = pch_path.find("../");
+			if (pos == string::npos && std::find(header_files.begin(), header_files.end(), pch_path) == header_files.end())
+				header_files.push_back(pch_path);
 		}
 		else
 		{
@@ -583,11 +596,54 @@
 	fprintf ( OUT, "\t\t<Filter\r\n" );
 	fprintf ( OUT, "\t\t\tName=\"Source Files\"\r\n" );
 	fprintf ( OUT, "\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;S\">\r\n" );
+
+	std::sort(source_files.begin(), source_files.end(), SortFilesAscending());
+	vector<string> last_folder;
+	vector<string> split_path;
+	string indent_tab("\t\t\t");
+
 	for ( size_t isrcfile = 0; isrcfile < source_files.size(); isrcfile++ )
 	{
 		string source_file = DosSeparator(source_files[isrcfile]);
-		fprintf ( OUT, "\t\t\t<File\r\n" );
-		fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file.c_str() );
+
+		Path::Split(split_path, source_file, false);
+		size_t same_folder_index = 0;
+		for ( size_t ifolder = 0; ifolder < last_folder.size(); ifolder++ )
+		{
+			if ( ifolder < split_path.size() && last_folder[ifolder] == split_path[ifolder] )
+				++same_folder_index;
+			else
+				break;
+		}
+
+		if ( same_folder_index < split_path.size() )
+		{
+			if ( split_path.size() > last_folder.size() )
+			{
+				for ( size_t ifolder = last_folder.size(); ifolder < split_path.size(); ifolder++ )
+					indent_tab.push_back('\t');
+			}
+			else if ( split_path.size() < last_folder.size() )
+			{
+				indent_tab.resize( split_path.size() + 3 );
+			}
+
+			for ( size_t ifolder = last_folder.size(); ifolder > same_folder_index; ifolder-- )
+			{
+				fprintf ( OUT, "%s</Filter>\r\n", indent_tab.substr(0, indent_tab.size() - 1).c_str() );
+			}
+
+			for ( size_t ifolder = same_folder_index; ifolder < split_path.size(); ifolder++ )
+			{
+				fprintf ( OUT, "%s<Filter\r\n", indent_tab.substr(0, indent_tab.size() - 1).c_str() );
+				fprintf ( OUT, "%sName=\"%s\">\r\n", indent_tab.c_str(), split_path[ifolder].c_str() );
+			}
+
+			last_folder = split_path;
+		}
+
+		fprintf ( OUT, "%s<File\r\n", indent_tab.c_str() );
+		fprintf ( OUT, "%s\tRelativePath=\"%s\">\r\n", indent_tab.c_str(), source_file.c_str() );
 
 		for ( size_t iconfig = 0; iconfig < m_configurations.size(); iconfig++ )
 		{
@@ -596,24 +652,24 @@
 			if (( isrcfile == 0 ) && ( module.pch != NULL ))
 			{
 				/* little hack to speed up PCH */
-				fprintf ( OUT, "\t\t\t\t<FileConfiguration\r\n" );
-				fprintf ( OUT, "\t\t\t\t\tName=\"" );
+				fprintf ( OUT, "%s\t<FileConfiguration\r\n", indent_tab.c_str() );
+				fprintf ( OUT, "%s\t\tName=\"", indent_tab.c_str() );
 				fprintf ( OUT, config.name.c_str() );
 				fprintf ( OUT, "|Win32\">\r\n" );
-				fprintf ( OUT, "\t\t\t\t\t<Tool\r\n" );
-				fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n" );
-				fprintf ( OUT, "\t\t\t\t\t\tUsePrecompiledHeader=\"1\"/>\r\n" );
-				fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );
+				fprintf ( OUT, "%s\t\t<Tool\r\n", indent_tab.c_str() );
+				fprintf ( OUT, "%s\t\t\tName=\"VCCLCompilerTool\"\r\n", indent_tab.c_str() );
+				fprintf ( OUT, "%s\t\t\tUsePrecompiledHeader=\"1\"/>\r\n", indent_tab.c_str() );
+				fprintf ( OUT, "%s\t</FileConfiguration>\r\n", indent_tab.c_str() );
 			}
 
 			//if (configuration.VSProjectVersion < "8.00") {
 				if ((source_file.find(".idl") != string::npos) || ((source_file.find(".asm") != string::npos || tolower(source_file.at(source_file.size() - 1)) == 's')))
 				{
-					fprintf ( OUT, "\t\t\t\t<FileConfiguration\r\n" );
-					fprintf ( OUT, "\t\t\t\t\tName=\"" );
+					fprintf ( OUT, "%s\t<FileConfiguration\r\n", indent_tab.c_str() );
+					fprintf ( OUT, "%s\t\tName=\"", indent_tab.c_str() );
 					fprintf ( OUT, config.name.c_str() );
 					fprintf ( OUT, "|Win32\">\r\n" );
-					fprintf ( OUT, "\t\t\t\t\t<Tool\r\n" );
+					fprintf ( OUT, "%s\t\t<Tool\r\n", indent_tab.c_str() );
 					if (source_file.find(".idl") != string::npos)
 					{
 						string src = source_file.substr (0, source_file.find(".idl"));
@@ -621,43 +677,50 @@
 						if ( src.find (".\\") != string::npos )
 							src.erase (0, 2);
 
-						fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
+						fprintf ( OUT, "%s\t\t\tName=\"VCCustomBuildTool\"\r\n", indent_tab.c_str() );
 
 						if ( module.type == RpcClient )
 						{
-							fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"midl.exe /cstub %s_c.c /header %s_c.h /server none &quot;$(InputPath)&quot; /out &quot;$(IntDir)&quot;", src.c_str (), src.c_str () );
+							fprintf ( OUT, "%s\t\t\tCommandLine=\"midl.exe /cstub %s_c.c /header %s_c.h /server none &quot;$(InputPath)&quot; /out &quot;$(IntDir)&quot;", indent_tab.c_str(), src.c_str (), src.c_str () );
 							fprintf ( OUT, "&#x0D;&#x0A;");
 							fprintf ( OUT, "cl.exe /Od /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_WINDOWS&quot; /D &quot;_WIN32_WINNT=0x502&quot; /D &quot;_UNICODE&quot; /D &quot;UNICODE&quot; /Gm /EHsc /RTC1 /MDd /Fo&quot;$(IntDir)\\%s.obj&quot; /W3 /c /Wp64 /ZI /TC &quot;$(IntDir)\\%s_c.c&quot; /nologo /errorReport:prompt", src.c_str (), src.c_str () ); 
 						}
 						else
 						{
-							fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"midl.exe /sstub %s_s.c /header %s_s.h /client none &quot;$(InputPath)&quot; /out &quot;$(IntDir)&quot;", src.c_str (), src.c_str () );
+							fprintf ( OUT, "%s\t\t\tCommandLine=\"midl.exe /sstub %s_s.c /header %s_s.h /client none &quot;$(InputPath)&quot; /out &quot;$(IntDir)&quot;", indent_tab.c_str(), src.c_str (), src.c_str () );
 							fprintf ( OUT, "&#x0D;&#x0A;");
 							fprintf ( OUT, "cl.exe /Od /D &quot;WIN32&quot; /D &quot;_DEBUG&quot; /D &quot;_WINDOWS&quot; /D &quot;_WIN32_WINNT=0x502&quot; /D &quot;_UNICODE&quot; /D &quot;UNICODE&quot; /Gm /EHsc /RTC1 /MDd /Fo&quot;$(IntDir)\\%s.obj&quot; /W3 /c /Wp64 /ZI /TC &quot;$(IntDir)\\%s_s.c&quot; /nologo /errorReport:prompt", src.c_str (), src.c_str () ); 
 
 						}
 						fprintf ( OUT, "&#x0D;&#x0A;");
 						fprintf ( OUT, "lib.exe /OUT:&quot;$(OutDir)\\%s.lib&quot; &quot;$(IntDir)\\%s.obj&quot;&#x0D;&#x0A;\"\r\n", module.name.c_str (), src.c_str () );
-						fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(IntDir)\\$(InputName).obj\"/>\r\n" );
+						fprintf ( OUT, "%s\t\t\tOutputs=\"$(IntDir)\\$(InputName).obj\"/>\r\n", indent_tab.c_str() );
 					}
 					else if ((source_file.find(".asm") != string::npos))
 					{
-						fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
-						fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"nasmw $(InputPath) -f coff -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n");
-						fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n" );
+						fprintf ( OUT, "%s\t\t\tName=\"VCCustomBuildTool\"\r\n", indent_tab.c_str() );
+						fprintf ( OUT, "%s\t\t\tCommandLine=\"nasmw $(InputPath) -f coff -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n", indent_tab.c_str() );
+						fprintf ( OUT, "%s\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n", indent_tab.c_str() );
 					}
 					else if ((tolower(source_file.at(source_file.size() - 1)) == 's'))
 					{
-						fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
-						fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; %s /D__ASM__ | as -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n",include_string.c_str() );
-						fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n" );
+						fprintf ( OUT, "%s\t\t\tName=\"VCCustomBuildTool\"\r\n", indent_tab.c_str() );
+						fprintf ( OUT, "%s\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; %s /D__ASM__ | as -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n", indent_tab.c_str(), include_string.c_str() );
+						fprintf ( OUT, "%s\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n", indent_tab.c_str() );
 					}
-					fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );
+					fprintf ( OUT, "%s\t</FileConfiguration>\r\n", indent_tab.c_str() );
 				}
 			//}
 		}
-		fprintf ( OUT, "\t\t\t</File>\r\n" );
-	}
+		fprintf ( OUT, "%s</File>\r\n", indent_tab.c_str() );
+	}
+
+	for ( size_t ifolder = last_folder.size(); ifolder > 0; ifolder-- )
+	{
+		indent_tab.resize( ifolder + 3 );
+		fprintf ( OUT, "%s</Filter>\r\n", indent_tab.c_str() );
+	}
+
 	fprintf ( OUT, "\t\t</Filter>\r\n" );
 
 	// Header files




More information about the Ros-diffs mailing list