b84d0a08a70b885d9b8daca6dff2a12a36ea3797
2 * Copyright (C) 2002 Patrik Stridvall
3 * Copyright (C) 2005 Royce Mitchell III
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #pragma warning ( disable : 4786 )
39 MSVCBackend::_generate_vcproj ( const Module
& module
)
42 // TODO FIXME wine hack?
43 //const bool wine = false;
45 string vcproj_file
= VcprojFileName(module
);
46 printf ( "Creating MSVC.NET project: '%s'\n", vcproj_file
.c_str() );
47 FILE* OUT
= fopen ( vcproj_file
.c_str(), "wb" );
49 vector
<string
> imports
;
50 for ( i
= 0; i
< module
.non_if_data
.libraries
.size(); i
++ )
52 imports
.push_back ( module
.non_if_data
.libraries
[i
]->name
);
55 string module_type
= GetExtension(module
.GetTargetName());
56 bool lib
= (module
.type
== ObjectLibrary
) || (module_type
== ".lib") || (module_type
== ".a");
57 bool dll
= (module_type
== ".dll") || (module_type
== ".cpl");
58 bool exe
= (module_type
== ".exe");
59 bool sys
= (module_type
== ".sys");
60 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
62 bool console
= exe
&& (module
.type
== Win32CUI
);
64 // TODO FIXME - not sure if the count here is right...
66 const char* p
= strpbrk ( vcproj_file
.c_str(), "/\\" );
70 p
= strpbrk ( p
+1, "/\\" );
72 string msvc_wine_dir
= "..";
74 msvc_wine_dir
+= "\\..";
76 string wine_include_dir
= msvc_wine_dir
+ "\\include";
78 //$progress_current++;
79 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
81 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
82 string vcproj_path
= module
.GetBasePath();
83 vector
<string
> c_srcs
, source_files
, resource_files
, includes
, libraries
, defines
;
84 vector
<const IfableData
*> ifs_list
;
85 ifs_list
.push_back ( &module
.project
.non_if_data
);
86 ifs_list
.push_back ( &module
.non_if_data
);
88 // this is a define in MinGW w32api, but not Microsoft's headers
89 defines
.push_back ( "_CRT_SECURE_NO_DEPRECATE" );
90 defines
.push_back ( "_CRT_NON_CONFORMING_SWPRINTFS" );
91 defines
.push_back ( "STDCALL=__stdcall" );
93 while ( ifs_list
.size() )
95 const IfableData
& data
= *ifs_list
.back();
97 // TODO FIXME - refactor needed - we're discarding if conditions
98 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
99 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
100 const vector
<File
*>& files
= data
.files
;
101 for ( i
= 0; i
< files
.size(); i
++ )
103 // TODO FIXME - do we want the full path of the file here?
104 string file
= string(".") + &files
[i
]->name
[vcproj_path
.size()];
106 source_files
.push_back ( file
);
107 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
108 c_srcs
.push_back ( file
);
109 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
110 resource_files
.push_back ( file
);
112 const vector
<Include
*>& incs
= data
.includes
;
113 for ( i
= 0; i
< incs
.size(); i
++ )
115 // explicitly omit win32api directories
116 if ( !strncmp(incs
[i
]->directory
.c_str(), "w32api", 6 ) )
119 // explicitly omit include/wine directories
120 if ( !strncmp(incs
[i
]->directory
.c_str(), "include\\wine", 12 ) )
123 string path
= Path::RelativeFromDirectory (
125 module
.GetBasePath() );
126 includes
.push_back ( path
);
128 const vector
<Library
*>& libs
= data
.libraries
;
129 for ( i
= 0; i
< libs
.size(); i
++ )
131 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
133 const vector
<Define
*>& defs
= data
.defines
;
134 for ( i
= 0; i
< defs
.size(); i
++ )
136 if ( defs
[i
]->value
[0] )
137 defines
.push_back ( defs
[i
]->name
+ "=" + defs
[i
]->value
);
139 defines
.push_back ( defs
[i
]->name
);
143 vector
<string
> header_files
;
146 bool no_msvc_headers
= true;
148 std::vector
<std::string
> cfgs
;
150 cfgs
.push_back ( "Debug" );
151 cfgs
.push_back ( "Release" );
152 cfgs
.push_back ( "Speed" );
156 std::vector
<std::string
> _cfgs
;
157 for ( i
= 0; i
< cfgs
.size(); i
++ )
159 _cfgs
.push_back ( cfgs
[i
] + " C" );
160 _cfgs
.push_back ( cfgs
[i
] + " C++" );
166 if (!no_msvc_headers
)
168 std::vector
<std::string
> _cfgs
;
169 for ( i
= 0; i
< cfgs
.size(); i
++ )
171 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
172 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
178 string default_cfg
= cfgs
.back();
179 string include_string
;
181 fprintf ( OUT
, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
182 fprintf ( OUT
, "<VisualStudioProject\r\n" );
183 fprintf ( OUT
, "\tProjectType=\"Visual C++\"\r\n" );
185 if (configuration
.VSProjectVersion
.empty())
186 configuration
.VSProjectVersion
= MS_VS_DEF_VERSION
;
188 fprintf ( OUT
, "\tVersion=\"%s\"\r\n", configuration
.VSProjectVersion
.c_str() );
189 fprintf ( OUT
, "\tName=\"%s\"\r\n", module
.name
.c_str() );
190 fprintf ( OUT
, "\tProjectGUID=\"%s\"\r\n", module
.guid
.c_str() );
191 fprintf ( OUT
, "\tKeyword=\"Win32Proj\">\r\n" );
193 fprintf ( OUT
, "\t<Platforms>\r\n" );
194 fprintf ( OUT
, "\t\t<Platform\r\n" );
195 fprintf ( OUT
, "\t\t\tName=\"Win32\"/>\r\n" );
196 fprintf ( OUT
, "\t</Platforms>\r\n" );
198 fprintf ( OUT
, "\t<ToolFiles>\r\n" );
199 fprintf ( OUT
, "\t\t<ToolFile\r\n" );
201 string path
= Path::RelativeFromDirectory ( ProjectNode
.name
, module
.GetBasePath() );
202 path
.erase(path
.find(ProjectNode
.name
, 0), ProjectNode
.name
.size() + 1);
204 fprintf ( OUT
, "\t\t\tRelativePath=\"%sgccasm.rules\"/>\r\n", path
.c_str() );
205 fprintf ( OUT
, "\t</ToolFiles>\r\n" );
209 std::string output_dir
;
211 fprintf ( OUT
, "\t<Configurations>\r\n" );
212 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
214 std::string
& cfg
= cfgs
[icfg
];
216 bool debug
= !strstr ( cfg
.c_str(), "Release" );
217 //bool msvc_headers = ( 0 != strstr ( cfg.c_str(), "MSVC Headers" ) );
219 fprintf ( OUT
, "\t\t<Configuration\r\n" );
220 fprintf ( OUT
, "\t\t\tName=\"%s|Win32\"\r\n", cfg
.c_str() );
221 fprintf ( OUT
, "\t\t\tOutputDirectory=\"%s\"\r\n", cfg
.c_str() );
222 fprintf ( OUT
, "\t\t\tIntermediateDirectory=\"%s\"\r\n", cfg
.c_str() );
223 fprintf ( OUT
, "\t\t\tConfigurationType=\"%d\"\r\n", exe
? 1 : dll
? 2 : lib
? 4 : -1 );
224 fprintf ( OUT
, "\t\t\tCharacterSet=\"2\">\r\n" );
226 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
227 fprintf ( OUT
, "\t\t\t\tName=\"VCCLCompilerTool\"\r\n" );
228 fprintf ( OUT
, "\t\t\t\tOptimization=\"%d\"\r\n", debug
? 0 : 2 );
230 fprintf ( OUT
, "\t\t\t\tAdditionalIncludeDirectories=\"" );
231 bool multiple_includes
= false;
232 fprintf ( OUT
, "./;" );
233 for ( i
= 0; i
< includes
.size(); i
++ )
235 const string
& include
= includes
[i
];
236 if ( strcmp ( include
.c_str(), "." ) )
238 if ( multiple_includes
)
239 fprintf ( OUT
, ";" );
241 fprintf ( OUT
, "%s", include
.c_str() );
242 include_string
+= " /I " + include
;
243 multiple_includes
= true;
246 fprintf ( OUT
, "\"\r\n " );
250 defines
.push_back ( "_DEBUG" );
253 defines
.push_back ( "_LIB" );
257 defines
.push_back ( "_WINDOWS" );
258 defines
.push_back ( "_USRDLL" );
263 defines
.push_back ( "NDEBUG" );
266 defines
.push_back ( "_LIB" );
270 defines
.push_back ( "_WINDOWS" );
271 defines
.push_back ( "_USRDLL" );
275 fprintf ( OUT
, "\t\t\t\tPreprocessorDefinitions=\"" );
276 for ( i
= 0; i
< defines
.size(); i
++ )
279 fprintf ( OUT
, ";" );
281 defines
[i
] = _replace_str(defines
[i
], "\"",""");
282 fprintf ( OUT
, "%s", defines
[i
].c_str() );
284 fprintf ( OUT
, "\"\r\n" );
286 fprintf ( OUT
, "\t\t\t\tMinimalRebuild=\"TRUE\"\r\n" );
287 fprintf ( OUT
, "\t\t\t\tBasicRuntimeChecks=\"3\"\r\n" );
288 fprintf ( OUT
, "\t\t\t\tRuntimeLibrary=\"5\"\r\n" );
289 fprintf ( OUT
, "\t\t\t\tBufferSecurityCheck=\"%s\"\r\n", debug
? "TRUE" : "FALSE" );
290 fprintf ( OUT
, "\t\t\t\tEnableFunctionLevelLinking=\"%s\"\r\n", debug
? "TRUE" : "FALSE" );
291 fprintf ( OUT
, "\t\t\t\tUsePrecompiledHeader=\"0\"\r\n" );
292 fprintf ( OUT
, "\t\t\t\tWarningLevel=\"1\"\r\n" );
293 fprintf ( OUT
, "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\r\n" );
294 fprintf ( OUT
, "\t\t\t\tDebugInformationFormat=\"4\"/>\r\n" );
296 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
297 fprintf ( OUT
, "\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n" );
301 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
302 fprintf ( OUT
, "\t\t\t\tName=\"VCLibrarianTool\"\r\n" );
303 fprintf ( OUT
, "\t\t\t\tOutputFile=\"$(OutDir)/%s.lib\"/>\r\n", module
.name
.c_str() );
307 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
308 fprintf ( OUT
, "\t\t\t\tName=\"VCLinkerTool\"\r\n" );
310 fprintf ( OUT
, "\t\t\t\tAdditionalDependencies=\"" );
311 for ( i
= 0; i
< libraries
.size(); i
++ )
314 fprintf ( OUT
, " " );
315 fprintf ( OUT
, "%s", libraries
[i
].c_str() );
317 fprintf ( OUT
, "\"\r\n" );
319 fprintf ( OUT
, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"\r\n", module
.name
.c_str(), module_type
.c_str() );
320 fprintf ( OUT
, "\t\t\t\tLinkIncremental=\"%d\"\r\n", debug
? 2 : 1 );
321 fprintf ( OUT
, "\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n" );
324 fprintf ( OUT
, "\t\t\t\tProgramDatabaseFile=\"$(OutDir)/%s.pdb\"\r\n", module
.name
.c_str() );
328 fprintf ( OUT
, "\t\t\t\tAdditionalOptions=\" /DRIVER /ALIGN:0x20 /subsystem:NATIVE /SECTION:INIT,D /FORCE:MULTIPLE /IGNORE:4001,4037,4039,4065,4070,4078,4087,4089,4096\"\r\n" );
329 fprintf ( OUT
, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );
330 fprintf ( OUT
, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module
.entrypoint
== "" ? "DriverEntry" : module
.entrypoint
.c_str ());
331 fprintf ( OUT
, "\t\t\t\tBaseAddress=\"%s\"\r\n", module
.baseaddress
== "" ? "0x10000" : module
.baseaddress
.c_str ());
335 if ( module
.type
== Kernel
|| module
.type
== NativeCUI
)
337 fprintf ( OUT
, "\t\t\t\tAdditionalOptions=\" /SUBSYSTEM:NATIVE /SECTION:INIT,D /ALIGN:4096 /FORCE:MULTIPLE\"\r\n" );
338 fprintf ( OUT
, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );
339 fprintf ( OUT
, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module
.entrypoint
.c_str ());
340 fprintf ( OUT
, "\t\t\t\tBaseAddress=\"%s\"\r\n", module
.baseaddress
.c_str ());
342 else if ( module
.type
== Win32CUI
|| module
.type
== Win32GUI
)
344 fprintf ( OUT
, "\t\t\t\tSubSystem=\"%d\"\r\n", console
? 1 : 2 );
349 fprintf ( OUT
, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module
.entrypoint
== "" ? "DllMain" : module
.entrypoint
.c_str ());
350 fprintf ( OUT
, "\t\t\t\tBaseAddress=\"%s\"\r\n", module
.baseaddress
== "" ? "0x40000" : module
.baseaddress
.c_str ());
352 fprintf ( OUT
, "\t\t\t\tTargetMachine=\"%d\"/>\r\n", 1 );
355 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
356 fprintf ( OUT
, "\t\t\t\tName=\"VCResourceCompilerTool\"\r\n" );
357 fprintf ( OUT
, "\t\t\t\tAdditionalIncludeDirectories=\"" );
358 multiple_includes
= false;
359 fprintf ( OUT
, "./;" );
360 for ( i
= 0; i
< includes
.size(); i
++ )
362 const string
& include
= includes
[i
];
363 if ( strcmp ( include
.c_str(), "." ) )
365 if ( multiple_includes
)
366 fprintf ( OUT
, ";" );
367 fprintf ( OUT
, "%s", include
.c_str() );
368 multiple_includes
= true;
371 fprintf ( OUT
, "\"/>\r\n " );
373 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
374 fprintf ( OUT
, "\t\t\t\tName=\"VCMIDLTool\"/>\r\n" );
375 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
376 fprintf ( OUT
, "\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n" );
377 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
378 fprintf ( OUT
, "\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n" );
379 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
380 fprintf ( OUT
, "\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n" );
381 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
382 fprintf ( OUT
, "\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n" );
383 fprintf ( OUT
, "\t\t\t<Tool\r\n" );
384 fprintf ( OUT
, "\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n" );
385 fprintf ( OUT
, "\t\t</Configuration>\r\n" );
389 fprintf ( OUT
, "\t</Configurations>\r\n" );
391 fprintf ( OUT
, "\t<Files>\r\n" );
394 fprintf ( OUT
, "\t\t<Filter\r\n" );
395 fprintf ( OUT
, "\t\t\tName=\"Source Files\"\r\n" );
396 fprintf ( OUT
, "\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;S\">\r\n" );
397 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
399 string source_file
= DosSeparator(source_files
[isrcfile
]);
400 fprintf ( OUT
, "\t\t\t<File\r\n" );
401 fprintf ( OUT
, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file
.c_str() );
403 if (configuration
.VSProjectVersion
< "8.00") {
404 for ( size_t iconfig
= 0; iconfig
< cfgs
.size(); iconfig
++ )
406 std::string
& config
= cfgs
[iconfig
];
408 if ((source_file
.find(".idl") != string::npos
) || ((source_file
.find(".asm") != string::npos
|| tolower(source_file
.at(source_file
.size() - 1)) == 's')))
410 fprintf ( OUT
, "\t\t\t\t<FileConfiguration\r\n" );
411 fprintf ( OUT
, "\t\t\t\t\tName=\"" );
412 fprintf ( OUT
, config
.c_str() );
413 fprintf ( OUT
, "|Win32\">\r\n" );
414 fprintf ( OUT
, "\t\t\t\t\t<Tool\r\n" );
415 if (source_file
.find(".idl") != string::npos
)
417 fprintf ( OUT
, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
418 fprintf ( OUT
, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\(InputName).obj\"/>\r\n" );
420 else if ((source_file
.find(".asm") != string::npos
|| tolower(source_file
.at(source_file
.size() - 1)) == 's'))
422 fprintf ( OUT
, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );
423 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() );
424 fprintf ( OUT
, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\(InputName).obj\"/>\r\n" );
426 fprintf ( OUT
, "\t\t\t\t</FileConfiguration>\r\n" );
430 fprintf ( OUT
, "\t\t\t</File>\r\n" );
432 fprintf ( OUT
, "\t\t</Filter>\r\n" );
435 fprintf ( OUT
, "\t\t<Filter\r\n" );
436 fprintf ( OUT
, "\t\t\tName=\"Header Files\"\r\n" );
437 fprintf ( OUT
, "\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\r\n" );
438 for ( i
= 0; i
< header_files
.size(); i
++ )
440 const string
& header_file
= header_files
[i
];
441 fprintf ( OUT
, "\t\t\t<File\r\n" );
442 fprintf ( OUT
, "\t\t\t\tRelativePath=\"%s\">\r\n", header_file
.c_str() );
443 fprintf ( OUT
, "\t\t\t</File>\r\n" );
445 fprintf ( OUT
, "\t\t</Filter>\r\n" );
448 fprintf ( OUT
, "\t\t<Filter\r\n" );
449 fprintf ( OUT
, "\t\t\tName=\"Resource Files\"\r\n" );
450 fprintf ( OUT
, "\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\r\n" );
451 for ( i
= 0; i
< header_files
.size(); i
++ )
453 const string
& resource_file
= resource_files
[i
];
454 fprintf ( OUT
, "\t\t\t<File\r\n" );
455 fprintf ( OUT
, "\t\t\t\tRelativePath=\"%s\">\r\n", resource_file
.c_str() );
456 fprintf ( OUT
, "\t\t\t</File>\r\n" );
458 fprintf ( OUT
, "\t\t</Filter>\r\n" );
460 fprintf ( OUT
, "\t</Files>\r\n" );
461 fprintf ( OUT
, "\t<Globals>\r\n" );
462 fprintf ( OUT
, "\t</Globals>\r\n" );
463 fprintf ( OUT
, "</VisualStudioProject>\r\n" );
468 MSVCBackend::_replace_str(std::string string1
, const std::string
&find_str
, const std::string
&replace_str
)
470 std::string::size_type pos
= string1
.find(find_str
, 0);
471 int intLen
= find_str
.length();
473 while(std::string::npos
!= pos
)
475 string1
.replace(pos
, intLen
, replace_str
);
476 pos
= string1
.find(find_str
, intLen
+ pos
);
483 MSVCBackend::_get_solution_verion ( void ) {
486 if (configuration
.VSProjectVersion
.empty())
487 configuration
.VSProjectVersion
= MS_VS_DEF_VERSION
;
489 if (configuration
.VSProjectVersion
== "7.00")
492 if (configuration
.VSProjectVersion
== "7.10")
495 if (configuration
.VSProjectVersion
== "8.00")
503 MSVCBackend::_generate_rules_file ( FILE* OUT
)
505 fprintf ( OUT
, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" );
506 fprintf ( OUT
, "<VisualStudioToolFile\r\n" );
507 fprintf ( OUT
, "\tName=\"GCC Assembler\"\r\n" );
508 fprintf ( OUT
, "\tVersion=\"%s\"\r\n", _get_solution_verion().c_str() );
509 fprintf ( OUT
, "\t>\r\n" );
510 fprintf ( OUT
, "\t<Rules>\r\n" );
511 fprintf ( OUT
, "\t\t<CustomBuildRule\r\n" );
512 fprintf ( OUT
, "\t\t\tName=\"Assembler\"\r\n" );
513 fprintf ( OUT
, "\t\t\tDisplayName=\"Assembler Files\"\r\n" );
514 fprintf ( OUT
, "\t\t\tCommandLine=\"cl /E "$(InputPath)" | as -o "$(OutDir)\\$(InputName).obj"\"\r\n" );
515 fprintf ( OUT
, "\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"\r\n" );
516 fprintf ( OUT
, "\t\t\tFileExtensions=\"*.S\"\r\n" );
517 fprintf ( OUT
, "\t\t\tExecutionDescription=\"asm\"\r\n" );
518 fprintf ( OUT
, "\t\t\t>\r\n" );
519 fprintf ( OUT
, "\t\t\t<Properties>\r\n" );
520 fprintf ( OUT
, "\t\t\t</Properties>\r\n" );
521 fprintf ( OUT
, "\t\t</CustomBuildRule>\r\n" );
522 fprintf ( OUT
, "\t</Rules>\r\n" );
523 fprintf ( OUT
, "</VisualStudioToolFile>\r\n" );
527 MSVCBackend::_generate_sln_header ( FILE* OUT
)
529 fprintf ( OUT
, "Microsoft Visual Studio Solution File, Format Version %s\r\n", _get_solution_verion().c_str() );
530 fprintf ( OUT
, "# Visual Studio 2005\r\n" );
531 fprintf ( OUT
, "\r\n" );
536 MSVCBackend::_generate_sln_project (
538 const Module
& module
,
539 std::string vcproj_file
,
540 std::string sln_guid
,
541 std::string vcproj_guid
,
542 const std::vector
<Dependency
*>& dependencies
)
544 vcproj_file
= DosSeparator ( std::string(".\\") + vcproj_file
);
546 fprintf ( OUT
, "Project(\"%s\") = \"%s\", \"%s\", \"%s\"\r\n", sln_guid
.c_str() , module
.name
.c_str(), vcproj_file
.c_str(), vcproj_guid
.c_str() );
548 //FIXME: only omit ProjectDependencies in VS 2005 when there are no dependencies
549 //NOTE: VS 2002 do not use ProjectSection; it uses GlobalSection instead
550 if ((configuration
.VSProjectVersion
== "7.10") || (dependencies
.size() > 0)) {
551 fprintf ( OUT
, "\tProjectSection(ProjectDependencies) = postProject\r\n" );
552 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
554 Dependency
& dependency
= *dependencies
[i
];
555 fprintf ( OUT
, "\t\t%s = %s\r\n", dependency
.module
.guid
.c_str(), dependency
.module
.guid
.c_str() );
557 fprintf ( OUT
, "\tEndProjectSection\r\n" );
560 fprintf ( OUT
, "EndProject\r\n" );
565 MSVCBackend::_generate_sln_footer ( FILE* OUT
)
567 fprintf ( OUT
, "Global\r\n" );
568 fprintf ( OUT
, "\tGlobalSection(SolutionConfiguration) = preSolution\r\n" );
569 fprintf ( OUT
, "\t\tDebug = Debug\r\n" );
570 fprintf ( OUT
, "\t\tRelease = Release\r\n" );
571 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
572 fprintf ( OUT
, "\tGlobalSection(ProjectConfiguration) = postSolution\r\n" );
573 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
575 Module
& module
= *ProjectNode
.modules
[i
];
576 std::string guid
= module
.guid
;
577 _generate_sln_configurations ( OUT
, guid
.c_str() );
579 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
580 fprintf ( OUT
, "\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n" );
581 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
582 fprintf ( OUT
, "\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n" );
583 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
585 if (configuration
.VSProjectVersion
== "7.00") {
586 fprintf ( OUT
, "\tGlobalSection(ProjectDependencies) = postSolution\r\n" );
587 //FIXME: Add dependencies for VS 2002
588 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
591 if (configuration
.VSProjectVersion
== "8.00") {
592 fprintf ( OUT
, "\tGlobalSection(SolutionProperties) = preSolution\r\n" );
593 fprintf ( OUT
, "\t\tHideSolutionNode = FALSE\r\n" );
594 fprintf ( OUT
, "\tEndGlobalSection\r\n" );
597 fprintf ( OUT
, "EndGlobal\r\n" );
598 fprintf ( OUT
, "\r\n" );
603 MSVCBackend::_generate_sln_configurations ( FILE* OUT
, std::string vcproj_guid
)
605 fprintf ( OUT
, "\t\t%s.Debug.ActiveCfg = Debug|Win32\r\n", vcproj_guid
.c_str() );
606 fprintf ( OUT
, "\t\t%s.Debug.Build.0 = Debug|Win32\r\n", vcproj_guid
.c_str() );
607 fprintf ( OUT
, "\t\t%s.Debug.Release.ActiveCfg = Release|Win32\r\n", vcproj_guid
.c_str() );
608 fprintf ( OUT
, "\t\t%s.Debug.Release.Build.0 = Release|Win32\r\n", vcproj_guid
.c_str() );
612 MSVCBackend::_generate_sln ( FILE* OUT
)
614 string sln_guid
= "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
615 vector
<string
> guids
;
617 _generate_sln_header(OUT
);
618 // TODO FIXME - is it necessary to sort them?
619 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
621 Module
& module
= *ProjectNode
.modules
[i
];
623 std::string vcproj_file
= VcprojFileName ( module
);
624 _generate_sln_project ( OUT
, module
, vcproj_file
, sln_guid
, module
.guid
, module
.dependencies
);
626 _generate_sln_footer ( OUT
);