Create configuration list only once (in MSVCBackend::Process) and use it everywhere.

Remove dead code

svn path=/trunk/; revision=22356
This commit is contained in:
Hervé Poussineau 2006-06-15 12:33:47 +00:00
parent 5c7452010e
commit 709fc5a971
3 changed files with 35 additions and 88 deletions

View file

@ -56,6 +56,27 @@ MSVCBackend::MSVCBackend(Project &project,
void MSVCBackend::Process()
{
// TODO FIXME wine hack?
bool only_msvc_headers = false;
while ( m_configurations.size () > 0 )
{
const MSVCConfiguration* cfg = m_configurations.back();
m_configurations.pop_back();
delete cfg;
}
m_configurations.push_back ( new MSVCConfiguration( Debug ));
m_configurations.push_back ( new MSVCConfiguration( Release ));
m_configurations.push_back ( new MSVCConfiguration( Speed ));
if (!only_msvc_headers)
{
m_configurations.push_back ( new MSVCConfiguration( Debug, WineHeaders ));
m_configurations.push_back ( new MSVCConfiguration( Release, WineHeaders ));
m_configurations.push_back ( new MSVCConfiguration( Speed, WineHeaders ));
}
if ( configuration.CleanAsYouGo ) {
_clean_project_files();
return;
@ -65,21 +86,12 @@ void MSVCBackend::Process()
return;
}
string filename_sln ( ProjectNode.name );
//string filename_rules = "gccasm.rules";
if ( configuration.VSProjectVersion == "6.00" )
filename_sln += "_auto.dsw";
else {
else
filename_sln += "_auto.sln";
//m_rulesFile = fopen ( filename_rules.c_str(), "wb" );
//if ( m_rulesFile )
//{
// _generate_rules_file ( m_rulesFile );
//}
//fclose ( m_rulesFile );
}
printf ( "Creating MSVC workspace: %s\n", filename_sln.c_str() );
ProcessModules();
@ -112,14 +124,6 @@ void MSVCBackend::ProcessModules()
_generate_dsp ( module );
else
_generate_vcproj ( module );
/*for(size_t k = 0; k < module.non_if_data.files.size(); k++)
{
File &file = *module.non_if_data.files[k];
ProcessFile(file.name);
}*/
}
}

View file

@ -86,7 +86,7 @@ class MSVCBackend : public Backend
std::string SuoFileName ( const Module& module ) const;
std::string NcbFileName ( const Module& module ) const;
std::vector<MSVCConfiguration*> m_configurations;
std::vector<FileUnit> m_fileUnits;
std::vector<std::string> m_folders;

View file

@ -100,23 +100,6 @@ MSVCBackend::_generate_vcproj ( const Module& module )
bool console = exe && (module.type == Win32CUI);
// TODO FIXME - not sure if the count here is right...
int parts = 0;
const char* p = strpbrk ( vcproj_file.c_str(), "/\\" );
while ( p )
{
++parts;
p = strpbrk ( p+1, "/\\" );
}
string msvc_wine_dir = "..";
while ( --parts )
msvc_wine_dir += "\\..";
string wine_include_dir = msvc_wine_dir + "\\include";
//$progress_current++;
//$output->progress("$dsp_file (file $progress_current of $progress_max)");
string vcproj_path = module.GetBasePath();
vector<string> source_files, resource_files, includes, includes_wine, libraries;
StringSet common_defines;
@ -194,22 +177,6 @@ MSVCBackend::_generate_vcproj ( const Module& module )
vector<string> header_files;
// TODO FIXME wine hack?
bool no_msvc_headers = true;
std::vector<MSVCConfiguration*> cfgs;
cfgs.push_back ( new MSVCConfiguration( Debug ));
cfgs.push_back ( new MSVCConfiguration( Release ));
cfgs.push_back ( new MSVCConfiguration( Speed ));
if (!no_msvc_headers)
{
cfgs.push_back ( new MSVCConfiguration( Debug, WineHeaders ));
cfgs.push_back ( new MSVCConfiguration( Release, WineHeaders ));
cfgs.push_back ( new MSVCConfiguration( Speed, WineHeaders ));
}
string include_string;
fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
@ -243,9 +210,9 @@ MSVCBackend::_generate_vcproj ( const Module& module )
std::string output_dir;
fprintf ( OUT, "\t<Configurations>\r\n" );
for ( size_t icfg = 0; icfg < cfgs.size(); icfg++ )
for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
{
const MSVCConfiguration& cfg = *cfgs[icfg];
const MSVCConfiguration& cfg = *m_configurations[icfg];
bool debug = ( cfg.optimization == Debug );
bool release = ( cfg.optimization == Release );
@ -272,7 +239,6 @@ MSVCBackend::_generate_vcproj ( const Module& module )
{
if ( multiple_includes )
fprintf ( OUT, ";" );
fprintf ( OUT, "%s", include.c_str() );
include_string += " /I " + include;
multiple_includes = true;
@ -523,9 +489,9 @@ MSVCBackend::_generate_vcproj ( const Module& module )
fprintf ( OUT, "\t\t\t<File\r\n" );
fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file.c_str() );
for ( size_t iconfig = 0; iconfig < cfgs.size(); iconfig++ )
for ( size_t iconfig = 0; iconfig < m_configurations.size(); iconfig++ )
{
const MSVCConfiguration& config = *cfgs[iconfig];
const MSVCConfiguration& config = *m_configurations[iconfig];
if (( isrcfile == 0 ) && ( module.pch != NULL ))
{
@ -635,31 +601,6 @@ MSVCBackend::_get_solution_verion ( void )
return version;
}
//void
//MSVCBackend::_generate_rules_file ( FILE* OUT )
//{
// fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" );
// fprintf ( OUT, "<VisualStudioToolFile\r\n" );
// fprintf ( OUT, "\tName=\"GCC Assembler\"\r\n" );
// fprintf ( OUT, "\tVersion=\"%s\"\r\n", _get_solution_verion().c_str() );
// fprintf ( OUT, "\t>\r\n" );
// fprintf ( OUT, "\t<Rules>\r\n" );
// fprintf ( OUT, "\t\t<CustomBuildRule\r\n" );
// fprintf ( OUT, "\t\t\tName=\"Assembler\"\r\n" );
// fprintf ( OUT, "\t\t\tDisplayName=\"Assembler Files\"\r\n" );
// fprintf ( OUT, "\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; | as -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n" );
// fprintf ( OUT, "\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"\r\n" );
// fprintf ( OUT, "\t\t\tFileExtensions=\"*.S\"\r\n" );
// fprintf ( OUT, "\t\t\tExecutionDescription=\"asm\"\r\n" );
// fprintf ( OUT, "\t\t\t>\r\n" );
// fprintf ( OUT, "\t\t\t<Properties>\r\n" );
// fprintf ( OUT, "\t\t\t</Properties>\r\n" );
// fprintf ( OUT, "\t\t</CustomBuildRule>\r\n" );
// fprintf ( OUT, "\t</Rules>\r\n" );
// fprintf ( OUT, "</VisualStudioToolFile>\r\n" );
//}
void
MSVCBackend::_generate_sln_header ( FILE* OUT )
{
@ -703,8 +644,8 @@ MSVCBackend::_generate_sln_footer ( FILE* OUT )
{
fprintf ( OUT, "Global\r\n" );
fprintf ( OUT, "\tGlobalSection(SolutionConfiguration) = preSolution\r\n" );
fprintf ( OUT, "\t\tDebug = Debug\r\n" );
fprintf ( OUT, "\t\tRelease = Release\r\n" );
for ( size_t i = 0; i < m_configurations.size(); i++ )
fprintf ( OUT, "\t\t%s = %s\r\n", m_configurations[i]->name.c_str(), m_configurations[i]->name.c_str() );
fprintf ( OUT, "\tEndGlobalSection\r\n" );
fprintf ( OUT, "\tGlobalSection(ProjectConfiguration) = postSolution\r\n" );
for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
@ -739,10 +680,12 @@ MSVCBackend::_generate_sln_footer ( FILE* OUT )
void
MSVCBackend::_generate_sln_configurations ( FILE* OUT, std::string vcproj_guid )
{
fprintf ( OUT, "\t\t%s.Debug|Win32.ActiveCfg = Debug|Win32\r\n", vcproj_guid.c_str() );
fprintf ( OUT, "\t\t%s.Debug|Win32.Build.0 = Debug|Win32\r\n", vcproj_guid.c_str() );
fprintf ( OUT, "\t\t%s.Release|Win32.ActiveCfg = Release|Win32\r\n", vcproj_guid.c_str() );
fprintf ( OUT, "\t\t%s.Release|Win32.Build.0 = Release|Win32\r\n", vcproj_guid.c_str() );
for ( size_t i = 0; i < m_configurations.size (); i++)
{
const MSVCConfiguration& cfg = *m_configurations[i];
fprintf ( OUT, "\t\t%s.%s|Win32.ActiveCfg = %s|Win32\r\n", vcproj_guid.c_str(), cfg.name.c_str(), cfg.name.c_str() );
fprintf ( OUT, "\t\t%s.%s|Win32.Build.0 = %s|Win32\r\n", vcproj_guid.c_str(), cfg.name.c_str(), cfg.name.c_str() );
}
}
void