feae0377bbfad1cdad3d33749ec90b3dd246e6b4
[reactos.git] / reactos / tools / rbuild / backend / msvc / vcprojmaker.cpp
1 /*
2 * Copyright (C) 2002 Patrik Stridvall
3 * Copyright (C) 2005 Royce Mitchell III
4 *
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.
9 *
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.
14 *
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.
18 */
19
20 #ifdef _MSC_VER
21 #pragma warning ( disable : 4786 )
22 #endif//_MSC_VER
23
24 #include <string>
25 #include <vector>
26
27 #include <stdio.h>
28
29 #include "msvc.h"
30
31 using std::string;
32 using std::vector;
33
34 #ifdef OUT
35 #undef OUT
36 #endif//OUT
37
38 void
39 MSVCBackend::_generate_vcproj ( const Module& module )
40 {
41 size_t i;
42 // TODO FIXME wine hack?
43 //const bool wine = false;
44
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" );
48
49 vector<string> imports;
50 for ( i = 0; i < module.non_if_data.libraries.size(); i++ )
51 {
52 imports.push_back ( module.non_if_data.libraries[i]->name );
53 }
54
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 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
60
61 bool console = exe && (module.type == Win32CUI);
62
63 // TODO FIXME - not sure if the count here is right...
64 int parts = 0;
65 const char* p = strpbrk ( vcproj_file.c_str(), "/\\" );
66 while ( p )
67 {
68 ++parts;
69 p = strpbrk ( p+1, "/\\" );
70 }
71 string msvc_wine_dir = "..";
72 while ( --parts )
73 msvc_wine_dir += "\\..";
74
75 string wine_include_dir = msvc_wine_dir + "\\include";
76
77 //$progress_current++;
78 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
79
80 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
81 string vcproj_path = module.GetBasePath();
82 vector<string> c_srcs, source_files, resource_files, includes, libraries, defines;
83 vector<const IfableData*> ifs_list;
84 ifs_list.push_back ( &module.project.non_if_data );
85 ifs_list.push_back ( &module.non_if_data );
86
87 // this is a define in MinGW w32api, but not Microsoft's headers
88 defines.push_back ( "STDCALL=__stdcall" );
89
90 while ( ifs_list.size() )
91 {
92 const IfableData& data = *ifs_list.back();
93 ifs_list.pop_back();
94 // TODO FIXME - refactor needed - we're discarding if conditions
95 for ( i = 0; i < data.ifs.size(); i++ )
96 ifs_list.push_back ( &data.ifs[i]->data );
97 const vector<File*>& files = data.files;
98 for ( i = 0; i < files.size(); i++ )
99 {
100 // TODO FIXME - do we want the full path of the file here?
101 string file = string(".") + &files[i]->name[vcproj_path.size()];
102
103 source_files.push_back ( file );
104 if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
105 c_srcs.push_back ( file );
106 if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
107 resource_files.push_back ( file );
108 }
109 const vector<Include*>& incs = data.includes;
110 for ( i = 0; i < incs.size(); i++ )
111 {
112 // explicitly omit win32api directories
113 if ( !strncmp(incs[i]->directory.c_str(), "w32api", 6 ) )
114 continue;
115
116 // explicitly omit include/wine directories
117 if ( !strncmp(incs[i]->directory.c_str(), "include\\wine", 12 ) )
118 continue;
119
120 string path = Path::RelativeFromDirectory (
121 incs[i]->directory,
122 module.GetBasePath() );
123 includes.push_back ( path );
124 }
125 const vector<Library*>& libs = data.libraries;
126 for ( i = 0; i < libs.size(); i++ )
127 {
128 libraries.push_back ( libs[i]->name + ".lib" );
129 }
130 const vector<Define*>& defs = data.defines;
131 for ( i = 0; i < defs.size(); i++ )
132 {
133 if ( defs[i]->value[0] )
134 defines.push_back ( defs[i]->name + "=" + defs[i]->value );
135 else
136 defines.push_back ( defs[i]->name );
137 }
138 }
139
140 vector<string> header_files;
141
142 bool no_cpp = true;
143 bool no_msvc_headers = true;
144
145 std::vector<std::string> cfgs;
146
147 cfgs.push_back ( "Debug" );
148 cfgs.push_back ( "Release" );
149
150 if (!no_cpp)
151 {
152 std::vector<std::string> _cfgs;
153 for ( i = 0; i < cfgs.size(); i++ )
154 {
155 _cfgs.push_back ( cfgs[i] + " C" );
156 _cfgs.push_back ( cfgs[i] + " C++" );
157 }
158 cfgs.resize(0);
159 cfgs = _cfgs;
160 }
161
162 if (!no_msvc_headers)
163 {
164 std::vector<std::string> _cfgs;
165 for ( i = 0; i < cfgs.size(); i++ )
166 {
167 _cfgs.push_back ( cfgs[i] + " MSVC Headers" );
168 _cfgs.push_back ( cfgs[i] + " Wine Headers" );
169 }
170 cfgs.resize(0);
171 cfgs = _cfgs;
172 }
173
174 string default_cfg = cfgs.back();
175
176 fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );
177 fprintf ( OUT, "<VisualStudioProject\r\n" );
178 fprintf ( OUT, "\tProjectType=\"Visual C++\"\r\n" );
179
180 if (configuration.VSProjectVersion.empty())
181 configuration.VSProjectVersion = MS_VS_DEF_VERSION;
182
183 fprintf ( OUT, "\tVersion=\"%s\"\r\n", configuration.VSProjectVersion.c_str() );
184 fprintf ( OUT, "\tName=\"%s\"\r\n", module.name.c_str() );
185 fprintf ( OUT, "\tProjectGUID=\"%s\"\r\n", module.guid.c_str() );
186 fprintf ( OUT, "\tKeyword=\"Win32Proj\">\r\n" );
187
188 fprintf ( OUT, "\t<Platforms>\r\n" );
189 fprintf ( OUT, "\t\t<Platform\r\n" );
190 fprintf ( OUT, "\t\t\tName=\"Win32\"/>\r\n" );
191 fprintf ( OUT, "\t</Platforms>\r\n" );
192
193 fprintf ( OUT, "\t<ToolFiles>\r\n" );
194 fprintf ( OUT, "\t\t<ToolFile\r\n" );
195
196 string path = Path::RelativeFromDirectory ( ProjectNode.name, module.GetBasePath() );
197 path.erase(path.find(ProjectNode.name, 0), ProjectNode.name.size() + 1);
198
199 fprintf ( OUT, "\t\t\tRelativePath=\"%s/gccasm.rules\"/>\r\n", path.c_str() );
200 fprintf ( OUT, "\t</ToolFiles>\r\n" );
201
202 int n = 0;
203
204 std::string output_dir;
205
206 fprintf ( OUT, "\t<Configurations>\r\n" );
207 for ( size_t icfg = 0; icfg < cfgs.size(); icfg++ )
208 {
209 std::string& cfg = cfgs[icfg];
210
211 bool debug = !strstr ( cfg.c_str(), "Release" );
212 //bool msvc_headers = ( 0 != strstr ( cfg.c_str(), "MSVC Headers" ) );
213
214 fprintf ( OUT, "\t\t<Configuration\r\n" );
215 fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.c_str() );
216 fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\"\r\n", cfg.c_str() );
217 fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\"\r\n", cfg.c_str() );
218 fprintf ( OUT, "\t\t\tConfigurationType=\"%d\"\r\n", exe ? 1 : dll ? 2 : lib ? 4 : -1 );
219 fprintf ( OUT, "\t\t\tCharacterSet=\"2\">\r\n" );
220
221 fprintf ( OUT, "\t\t\t<Tool\r\n" );
222 fprintf ( OUT, "\t\t\t\tName=\"VCCLCompilerTool\"\r\n" );
223 fprintf ( OUT, "\t\t\t\tOptimization=\"%d\"\r\n", debug ? 0 : 2 );
224
225 fprintf ( OUT, "\t\t\t\tAdditionalIncludeDirectories=\"" );
226 bool multiple_includes = false;
227 fprintf ( OUT, "./;" );
228 for ( i = 0; i < includes.size(); i++ )
229 {
230 const string& include = includes[i];
231 if ( strcmp ( include.c_str(), "." ) )
232 {
233 if ( multiple_includes )
234 fprintf ( OUT, ";" );
235 fprintf ( OUT, "%s", include.c_str() );
236 multiple_includes = true;
237 }
238 }
239 fprintf ( OUT, "\"\r\n " );
240
241 if ( debug )
242 {
243 defines.push_back ( "_DEBUG" );
244 if ( lib || exe )
245 {
246 defines.push_back ( "_LIB" );
247 }
248 else
249 {
250 defines.push_back ( "_WINDOWS" );
251 defines.push_back ( "_USRDLL" );
252 }
253 }
254 else
255 {
256 defines.push_back ( "NDEBUG" );
257 if ( lib || exe )
258 {
259 defines.push_back ( "_LIB" );
260 }
261 else
262 {
263 defines.push_back ( "_WINDOWS" );
264 defines.push_back ( "_USRDLL" );
265 }
266 }
267
268 fprintf ( OUT, "\t\t\t\tPreprocessorDefinitions=\"" );
269 for ( i = 0; i < defines.size(); i++ )
270 {
271 if ( i > 0 )
272 fprintf ( OUT, ";" );
273
274 defines[i] = _replace_str(defines[i], "\"","&quot;");
275 fprintf ( OUT, "%s", defines[i].c_str() );
276 }
277 fprintf ( OUT, "\"\r\n" );
278
279 fprintf ( OUT, "\t\t\t\tMinimalRebuild=\"TRUE\"\r\n" );
280 fprintf ( OUT, "\t\t\t\tBasicRuntimeChecks=\"3\"\r\n" );
281 fprintf ( OUT, "\t\t\t\tRuntimeLibrary=\"5\"\r\n" );
282 fprintf ( OUT, "\t\t\t\tBufferSecurityCheck=\"%s\"\r\n", debug ? "TRUE" : "FALSE" );
283 fprintf ( OUT, "\t\t\t\tEnableFunctionLevelLinking=\"%s\"\r\n", debug ? "TRUE" : "FALSE" );
284 fprintf ( OUT, "\t\t\t\tUsePrecompiledHeader=\"0\"\r\n" );
285 fprintf ( OUT, "\t\t\t\tWarningLevel=\"1\"\r\n" );
286 fprintf ( OUT, "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\r\n" );
287 fprintf ( OUT, "\t\t\t\tDebugInformationFormat=\"4\"/>\r\n" );
288
289 fprintf ( OUT, "\t\t\t<Tool\r\n" );
290 fprintf ( OUT, "\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n" );
291
292 if ( lib )
293 {
294 fprintf ( OUT, "\t\t\t<Tool\r\n" );
295 fprintf ( OUT, "\t\t\t\tName=\"VCLibrarianTool\"\r\n" );
296 fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"/>\r\n", module.name.c_str(), module_type.c_str() );
297 }
298 else
299 {
300 fprintf ( OUT, "\t\t\t<Tool\r\n" );
301 fprintf ( OUT, "\t\t\t\tName=\"VCLinkerTool\"\r\n" );
302
303 fprintf ( OUT, "\t\t\t\tAdditionalDependencies=\"" );
304 for ( i = 0; i < libraries.size(); i++ )
305 {
306 if ( i > 0 )
307 fprintf ( OUT, " " );
308 fprintf ( OUT, "%s", libraries[i].c_str() );
309 }
310 fprintf ( OUT, "\"\r\n" );
311
312 fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"\r\n", module.name.c_str(), module_type.c_str() );
313 fprintf ( OUT, "\t\t\t\tLinkIncremental=\"%d\"\r\n", debug ? 2 : 1 );
314 fprintf ( OUT, "\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n" );
315
316 if ( debug )
317 fprintf ( OUT, "\t\t\t\tProgramDatabaseFile=\"$(OutDir)/%s.pdb\"\r\n", module.name.c_str() );
318
319 fprintf ( OUT, "\t\t\t\tSubSystem=\"%d\"\r\n", console ? 1 : 2 );
320 fprintf ( OUT, "\t\t\t\tTargetMachine=\"%d\"/>\r\n", 1 );
321 }
322
323 fprintf ( OUT, "\t\t\t<Tool\r\n" );
324 fprintf ( OUT, "\t\t\t\tName=\"VCResourceCompilerTool\"\r\n" );
325 fprintf ( OUT, "\t\t\t\tAdditionalIncludeDirectories=\"" );
326 multiple_includes = false;
327 fprintf ( OUT, "./;" );
328 for ( i = 0; i < includes.size(); i++ )
329 {
330 const string& include = includes[i];
331 if ( strcmp ( include.c_str(), "." ) )
332 {
333 if ( multiple_includes )
334 fprintf ( OUT, ";" );
335 fprintf ( OUT, "%s", include.c_str() );
336 multiple_includes = true;
337 }
338 }
339 fprintf ( OUT, "\"/>\r\n " );
340
341 fprintf ( OUT, "\t\t\t<Tool\r\n" );
342 fprintf ( OUT, "\t\t\t\tName=\"VCMIDLTool\"/>\r\n" );
343 fprintf ( OUT, "\t\t\t<Tool\r\n" );
344 fprintf ( OUT, "\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n" );
345 fprintf ( OUT, "\t\t\t<Tool\r\n" );
346 fprintf ( OUT, "\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n" );
347 fprintf ( OUT, "\t\t\t<Tool\r\n" );
348 fprintf ( OUT, "\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n" );
349 fprintf ( OUT, "\t\t\t<Tool\r\n" );
350 fprintf ( OUT, "\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n" );
351 fprintf ( OUT, "\t\t\t<Tool\r\n" );
352 fprintf ( OUT, "\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n" );
353 fprintf ( OUT, "\t\t</Configuration>\r\n" );
354
355 n++;
356 }
357 fprintf ( OUT, "\t</Configurations>\r\n" );
358
359 fprintf ( OUT, "\t<Files>\r\n" );
360
361 // Source files
362 fprintf ( OUT, "\t\t<Filter\r\n" );
363 fprintf ( OUT, "\t\t\tName=\"Source Files\"\r\n" );
364 fprintf ( OUT, "\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;S\">\r\n" );
365 for ( size_t isrcfile = 0; isrcfile < source_files.size(); isrcfile++ )
366 {
367 const string& source_file = DosSeparator(source_files[isrcfile]);
368 fprintf ( OUT, "\t\t\t<File\r\n" );
369 fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file.c_str() );
370 fprintf ( OUT, "\t\t\t</File>\r\n" );
371 }
372 fprintf ( OUT, "\t\t</Filter>\r\n" );
373
374 // Header files
375 fprintf ( OUT, "\t\t<Filter\r\n" );
376 fprintf ( OUT, "\t\t\tName=\"Header Files\"\r\n" );
377 fprintf ( OUT, "\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\r\n" );
378 for ( i = 0; i < header_files.size(); i++ )
379 {
380 const string& header_file = header_files[i];
381 fprintf ( OUT, "\t\t\t<File\r\n" );
382 fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", header_file.c_str() );
383 fprintf ( OUT, "\t\t\t</File>\r\n" );
384 }
385 fprintf ( OUT, "\t\t</Filter>\r\n" );
386
387 // Resource files
388 fprintf ( OUT, "\t\t<Filter\r\n" );
389 fprintf ( OUT, "\t\t\tName=\"Resource Files\"\r\n" );
390 fprintf ( OUT, "\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\r\n" );
391 for ( i = 0; i < header_files.size(); i++ )
392 {
393 const string& resource_file = resource_files[i];
394 fprintf ( OUT, "\t\t\t<File\r\n" );
395 fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", resource_file.c_str() );
396 fprintf ( OUT, "\t\t\t</File>\r\n" );
397 }
398 fprintf ( OUT, "\t\t</Filter>\r\n" );
399
400 fprintf ( OUT, "\t</Files>\r\n" );
401 fprintf ( OUT, "\t<Globals>\r\n" );
402 fprintf ( OUT, "\t</Globals>\r\n" );
403 fprintf ( OUT, "</VisualStudioProject>\r\n" );
404 fclose(OUT);
405 }
406
407 std::string
408 MSVCBackend::_replace_str(std::string string1, const std::string &find_str, const std::string &replace_str)
409 {
410 std::string::size_type pos = string1.find(find_str, 0);
411 int intLen = find_str.length();
412
413 while(std::string::npos != pos)
414 {
415 string1.replace(pos, intLen, replace_str);
416 pos = string1.find(find_str, intLen + pos);
417 }
418
419 return string1;
420 }
421
422 std::string
423 MSVCBackend::_get_solution_verion ( void ) {
424 string version;
425
426 if (configuration.VSProjectVersion.empty())
427 configuration.VSProjectVersion = MS_VS_DEF_VERSION;
428
429 if (configuration.VSProjectVersion == "7.00")
430 version = "7.00";
431
432 if (configuration.VSProjectVersion == "7.10")
433 version = "8.00";
434
435 if (configuration.VSProjectVersion == "8.00")
436 version = "9.00";
437
438 return version;
439 }
440
441
442 void
443 MSVCBackend::_generate_rules_file ( FILE* OUT )
444 {
445 fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" );
446 fprintf ( OUT, "<VisualStudioToolFile\r\n" );
447 fprintf ( OUT, "\tName=\"GCC Assembler\"\r\n" );
448 fprintf ( OUT, "\tVersion=\"%s\"\r\n", _get_solution_verion().c_str() );
449 fprintf ( OUT, "\t>\r\n" );
450 fprintf ( OUT, "\t<Rules>\r\n" );
451 fprintf ( OUT, "\t\t<CustomBuildRule\r\n" );
452 fprintf ( OUT, "\t\t\tName=\"Assembler\"\r\n" );
453 fprintf ( OUT, "\t\t\tDisplayName=\"Assembler Files\"\r\n" );
454 fprintf ( OUT, "\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; | as -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n" );
455 fprintf ( OUT, "\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"\r\n" );
456 fprintf ( OUT, "\t\t\tFileExtensions=\"*.S\"\r\n" );
457 fprintf ( OUT, "\t\t\tExecutionDescription=\"asm\"\r\n" );
458 fprintf ( OUT, "\t\t\t>\r\n" );
459 fprintf ( OUT, "\t\t\t<Properties>\r\n" );
460 fprintf ( OUT, "\t\t\t</Properties>\r\n" );
461 fprintf ( OUT, "\t\t</CustomBuildRule>\r\n" );
462 fprintf ( OUT, "\t</Rules>\r\n" );
463 fprintf ( OUT, "</VisualStudioToolFile>\r\n" );
464 }
465
466 void
467 MSVCBackend::_generate_sln_header ( FILE* OUT )
468 {
469 fprintf ( OUT, "Microsoft Visual Studio Solution File, Format Version %s\r\n", _get_solution_verion().c_str() );
470 fprintf ( OUT, "# Visual Studio 2005\r\n" );
471 fprintf ( OUT, "\r\n" );
472 }
473
474
475 void
476 MSVCBackend::_generate_sln_project (
477 FILE* OUT,
478 const Module& module,
479 std::string vcproj_file,
480 std::string sln_guid,
481 std::string vcproj_guid,
482 const std::vector<Dependency*>& dependencies )
483 {
484 vcproj_file = DosSeparator ( std::string(".\\") + vcproj_file );
485
486 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() );
487
488 //FIXME: only omit ProjectDependencies in VS 2005 when there are no dependencies
489 //NOTE: VS 2002 do not use ProjectSection; it uses GlobalSection instead
490 if ((configuration.VSProjectVersion == "7.10") || (dependencies.size() > 0)) {
491 fprintf ( OUT, "\tProjectSection(ProjectDependencies) = postProject\r\n" );
492 for ( size_t i = 0; i < dependencies.size(); i++ )
493 {
494 Dependency& dependency = *dependencies[i];
495 fprintf ( OUT, "\t\t%s = %s\r\n", dependency.module.guid.c_str(), dependency.module.guid.c_str() );
496 }
497 fprintf ( OUT, "\tEndProjectSection\r\n" );
498 }
499
500 fprintf ( OUT, "EndProject\r\n" );
501 }
502
503
504 void
505 MSVCBackend::_generate_sln_footer ( FILE* OUT )
506 {
507 fprintf ( OUT, "Global\r\n" );
508 fprintf ( OUT, "\tGlobalSection(SolutionConfiguration) = preSolution\r\n" );
509 fprintf ( OUT, "\t\tDebug = Debug\r\n" );
510 fprintf ( OUT, "\t\tRelease = Release\r\n" );
511 fprintf ( OUT, "\tEndGlobalSection\r\n" );
512 fprintf ( OUT, "\tGlobalSection(ProjectConfiguration) = postSolution\r\n" );
513 for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
514 {
515 Module& module = *ProjectNode.modules[i];
516 std::string guid = module.guid;
517 _generate_sln_configurations ( OUT, guid.c_str() );
518 }
519 fprintf ( OUT, "\tEndGlobalSection\r\n" );
520 fprintf ( OUT, "\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n" );
521 fprintf ( OUT, "\tEndGlobalSection\r\n" );
522 fprintf ( OUT, "\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n" );
523 fprintf ( OUT, "\tEndGlobalSection\r\n" );
524
525 if (configuration.VSProjectVersion == "7.00") {
526 fprintf ( OUT, "\tGlobalSection(ProjectDependencies) = postSolution\r\n" );
527 //FIXME: Add dependencies for VS 2002
528 fprintf ( OUT, "\tEndGlobalSection\r\n" );
529 }
530
531 if (configuration.VSProjectVersion == "8.00") {
532 fprintf ( OUT, "\tGlobalSection(SolutionProperties) = preSolution\r\n" );
533 fprintf ( OUT, "\t\tHideSolutionNode = FALSE\r\n" );
534 fprintf ( OUT, "\tEndGlobalSection\r\n" );
535 }
536
537 fprintf ( OUT, "EndGlobal\r\n" );
538 fprintf ( OUT, "\r\n" );
539 }
540
541
542 void
543 MSVCBackend::_generate_sln_configurations ( FILE* OUT, std::string vcproj_guid )
544 {
545 fprintf ( OUT, "\t\t%s.Debug.ActiveCfg = Debug|Win32\r\n", vcproj_guid.c_str() );
546 fprintf ( OUT, "\t\t%s.Debug.Build.0 = Debug|Win32\r\n", vcproj_guid.c_str() );
547 fprintf ( OUT, "\t\t%s.Debug.Release.ActiveCfg = Release|Win32\r\n", vcproj_guid.c_str() );
548 fprintf ( OUT, "\t\t%s.Debug.Release.Build.0 = Release|Win32\r\n", vcproj_guid.c_str() );
549 }
550
551 void
552 MSVCBackend::_generate_sln ( FILE* OUT )
553 {
554 string sln_guid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}";
555 vector<string> guids;
556
557 _generate_sln_header(OUT);
558 // TODO FIXME - is it necessary to sort them?
559 for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
560 {
561 Module& module = *ProjectNode.modules[i];
562
563 std::string vcproj_file = VcprojFileName ( module );
564 _generate_sln_project ( OUT, module, vcproj_file, sln_guid, module.guid, module.dependencies );
565 }
566 _generate_sln_footer ( OUT );
567 }
568