mirror of
https://github.com/reactos/reactos.git
synced 2024-10-15 05:37:44 +00:00
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. svn path=/trunk/; revision=28571
This commit is contained in:
parent
63872a8e79
commit
718e6afb4c
|
@ -83,7 +83,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
||||||
|
|
||||||
// TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
|
// TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
|
||||||
string dsp_path = module.GetBasePath();
|
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;
|
StringSet common_defines;
|
||||||
vector<const IfableData*> ifs_list;
|
vector<const IfableData*> ifs_list;
|
||||||
ifs_list.push_back ( &module.project.non_if_data );
|
ifs_list.push_back ( &module.project.non_if_data );
|
||||||
|
@ -108,6 +108,8 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
||||||
source_files.push_back ( file );
|
source_files.push_back ( file );
|
||||||
if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
|
if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
|
||||||
c_srcs.push_back ( file );
|
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" ) )
|
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
|
||||||
resource_files.push_back ( file );
|
resource_files.push_back ( file );
|
||||||
}
|
}
|
||||||
|
@ -144,7 +146,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
||||||
}
|
}
|
||||||
// TODO FIXME - we don't include header files in our build system
|
// TODO FIXME - we don't include header files in our build system
|
||||||
//my @header_files = @{module->{header_files}};
|
//my @header_files = @{module->{header_files}};
|
||||||
vector<string> header_files;
|
//vector<string> header_files;
|
||||||
|
|
||||||
// TODO FIXME - wine hack?
|
// TODO FIXME - wine hack?
|
||||||
/*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
|
/*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
|
||||||
|
|
|
@ -41,6 +41,14 @@ typedef set<string> StringSet;
|
||||||
#undef OUT
|
#undef OUT
|
||||||
#endif//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 )
|
MSVCConfiguration::MSVCConfiguration ( const OptimizationType optimization, const HeadersType headers, const std::string &name )
|
||||||
{
|
{
|
||||||
this->optimization = optimization;
|
this->optimization = optimization;
|
||||||
|
@ -124,7 +132,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
bool include_idl = false;
|
bool include_idl = false;
|
||||||
|
|
||||||
string vcproj_path = module.GetBasePath();
|
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;
|
StringSet common_defines;
|
||||||
vector<const IfableData*> ifs_list;
|
vector<const IfableData*> ifs_list;
|
||||||
ifs_list.push_back ( &module.project.non_if_data );
|
ifs_list.push_back ( &module.project.non_if_data );
|
||||||
|
@ -154,6 +162,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
|
|
||||||
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
|
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
|
||||||
resource_files.push_back ( file );
|
resource_files.push_back ( file );
|
||||||
|
else if ( !stricmp ( Right(file,2).c_str(), ".h" ) )
|
||||||
|
header_files.push_back ( file );
|
||||||
else
|
else
|
||||||
source_files.push_back ( file );
|
source_files.push_back ( file );
|
||||||
}
|
}
|
||||||
|
@ -211,8 +221,6 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> header_files;
|
|
||||||
|
|
||||||
string include_string;
|
string include_string;
|
||||||
|
|
||||||
fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
|
fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
|
||||||
|
@ -372,6 +380,11 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
if ( pos != string::npos )
|
if ( pos != string::npos )
|
||||||
pch_path.erase(0, pos+1);
|
pch_path.erase(0, pos+1);
|
||||||
fprintf ( OUT, "\t\t\t\tPrecompiledHeaderThrough=\"%s\"\r\n", pch_path.c_str() );
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -583,11 +596,54 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
fprintf ( OUT, "\t\t<Filter\r\n" );
|
fprintf ( OUT, "\t\t<Filter\r\n" );
|
||||||
fprintf ( OUT, "\t\t\tName=\"Source Files\"\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" );
|
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++ )
|
for ( size_t isrcfile = 0; isrcfile < source_files.size(); isrcfile++ )
|
||||||
{
|
{
|
||||||
string source_file = DosSeparator(source_files[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++ )
|
for ( size_t iconfig = 0; iconfig < m_configurations.size(); iconfig++ )
|
||||||
{
|
{
|
||||||
|
@ -596,24 +652,24 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
if (( isrcfile == 0 ) && ( module.pch != NULL ))
|
if (( isrcfile == 0 ) && ( module.pch != NULL ))
|
||||||
{
|
{
|
||||||
/* little hack to speed up PCH */
|
/* little hack to speed up PCH */
|
||||||
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\t\tName=\"" );
|
fprintf ( OUT, "%s\t\tName=\"", indent_tab.c_str() );
|
||||||
fprintf ( OUT, config.name.c_str() );
|
fprintf ( OUT, config.name.c_str() );
|
||||||
fprintf ( OUT, "|Win32\">\r\n" );
|
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() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n" );
|
fprintf ( OUT, "%s\t\t\tName=\"VCCLCompilerTool\"\r\n", indent_tab.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tUsePrecompiledHeader=\"1\"/>\r\n" );
|
fprintf ( OUT, "%s\t\t\tUsePrecompiledHeader=\"1\"/>\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() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (configuration.VSProjectVersion < "8.00") {
|
//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')))
|
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, "%s\t<FileConfiguration\r\n", indent_tab.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\tName=\"" );
|
fprintf ( OUT, "%s\t\tName=\"", indent_tab.c_str() );
|
||||||
fprintf ( OUT, config.name.c_str() );
|
fprintf ( OUT, config.name.c_str() );
|
||||||
fprintf ( OUT, "|Win32\">\r\n" );
|
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)
|
if (source_file.find(".idl") != string::npos)
|
||||||
{
|
{
|
||||||
string src = source_file.substr (0, source_file.find(".idl"));
|
string src = source_file.substr (0, source_file.find(".idl"));
|
||||||
|
@ -621,43 +677,50 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
||||||
if ( src.find (".\\") != string::npos )
|
if ( src.find (".\\") != string::npos )
|
||||||
src.erase (0, 2);
|
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 )
|
if ( module.type == RpcClient )
|
||||||
{
|
{
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"midl.exe /cstub %s_c.c /header %s_c.h /server none "$(InputPath)" /out "$(IntDir)"", src.c_str (), src.c_str () );
|
fprintf ( OUT, "%s\t\t\tCommandLine=\"midl.exe /cstub %s_c.c /header %s_c.h /server none "$(InputPath)" /out "$(IntDir)"", indent_tab.c_str(), src.c_str (), src.c_str () );
|
||||||
fprintf ( OUT, "
");
|
fprintf ( OUT, "
");
|
||||||
fprintf ( OUT, "cl.exe /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WIN32_WINNT=0x502" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"$(IntDir)\\%s.obj" /W3 /c /Wp64 /ZI /TC "$(IntDir)\\%s_c.c" /nologo /errorReport:prompt", src.c_str (), src.c_str () );
|
fprintf ( OUT, "cl.exe /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WIN32_WINNT=0x502" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"$(IntDir)\\%s.obj" /W3 /c /Wp64 /ZI /TC "$(IntDir)\\%s_c.c" /nologo /errorReport:prompt", src.c_str (), src.c_str () );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"midl.exe /sstub %s_s.c /header %s_s.h /client none "$(InputPath)" /out "$(IntDir)"", src.c_str (), src.c_str () );
|
fprintf ( OUT, "%s\t\t\tCommandLine=\"midl.exe /sstub %s_s.c /header %s_s.h /client none "$(InputPath)" /out "$(IntDir)"", indent_tab.c_str(), src.c_str (), src.c_str () );
|
||||||
fprintf ( OUT, "
");
|
fprintf ( OUT, "
");
|
||||||
fprintf ( OUT, "cl.exe /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WIN32_WINNT=0x502" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"$(IntDir)\\%s.obj" /W3 /c /Wp64 /ZI /TC "$(IntDir)\\%s_s.c" /nologo /errorReport:prompt", src.c_str (), src.c_str () );
|
fprintf ( OUT, "cl.exe /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WIN32_WINNT=0x502" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Fo"$(IntDir)\\%s.obj" /W3 /c /Wp64 /ZI /TC "$(IntDir)\\%s_s.c" /nologo /errorReport:prompt", src.c_str (), src.c_str () );
|
||||||
|
|
||||||
}
|
}
|
||||||
fprintf ( OUT, "
");
|
fprintf ( OUT, "
");
|
||||||
fprintf ( OUT, "lib.exe /OUT:"$(OutDir)\\%s.lib" "$(IntDir)\\%s.obj"
\"\r\n", module.name.c_str (), src.c_str () );
|
fprintf ( OUT, "lib.exe /OUT:"$(OutDir)\\%s.lib" "$(IntDir)\\%s.obj"
\"\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))
|
else if ((source_file.find(".asm") != string::npos))
|
||||||
{
|
{
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
|
fprintf ( OUT, "%s\t\t\tName=\"VCCustomBuildTool\"\r\n", indent_tab.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"nasmw $(InputPath) -f coff -o "$(OutDir)\\$(InputName).obj"\"\r\n");
|
fprintf ( OUT, "%s\t\t\tCommandLine=\"nasmw $(InputPath) -f coff -o "$(OutDir)\\$(InputName).obj"\"\r\n", indent_tab.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n" );
|
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'))
|
else if ((tolower(source_file.at(source_file.size() - 1)) == 's'))
|
||||||
{
|
{
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
|
fprintf ( OUT, "%s\t\t\tName=\"VCCustomBuildTool\"\r\n", indent_tab.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"cl /E "$(InputPath)" %s /D__ASM__ | as -o "$(OutDir)\\$(InputName).obj"\"\r\n",include_string.c_str() );
|
fprintf ( OUT, "%s\t\t\tCommandLine=\"cl /E "$(InputPath)" %s /D__ASM__ | as -o "$(OutDir)\\$(InputName).obj"\"\r\n", indent_tab.c_str(), include_string.c_str() );
|
||||||
fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n" );
|
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" );
|
fprintf ( OUT, "\t\t</Filter>\r\n" );
|
||||||
|
|
||||||
// Header files
|
// Header files
|
||||||
|
|
Loading…
Reference in a new issue