remove a few of the Wine hacks
[reactos.git] / reactos / tools / rbuild / backend / msvc / msvcmaker.cpp
1 #ifdef _MSC_VER
2 #pragma warning ( disable : 4786 )
3 #endif//_MSC_VER
4
5 #include <string>
6 #include <vector>
7
8 #include <stdio.h>
9
10 #include "msvc.h"
11
12 #if 0
13
14 void _generate_dsp ( FILE* OUT, const string& module )
15 {
16 my $dsp_file = modules[module]->{dsp_file};
17 my $project = modules[module]->{project};
18 my @imports = @{modules[module]->{imports}};
19
20 my $lib = (modules[module]->{type} eq "lib");
21 my $dll = (modules[module]->{type} eq "dll");
22 my $exe = (modules[module]->{type} eq "exe");
23
24 my $console = $exe; # FIXME: Not always correct
25
26 my $msvc_wine_dir = do
27 {
28 my @parts = split(m%/%, $dsp_file);
29 if($#parts == 1) {
30 ".." );
31 } elsif($#parts == 2) {
32 "..\\.." );
33 } else {
34 "..\\..\\.." );
35 }
36 };
37 my $wine_include_dir = "$msvc_wine_dir\\include" );
38
39 $progress_current++;
40 $output->progress("$dsp_file (file $progress_current of $progress_max)");
41
42 my @c_srcs = @{modules[module]->{c_srcs}};
43 my @source_files = @{modules[module]->{source_files}};
44 my @header_files = @{modules[module]->{header_files}};
45 my @resource_files = @{modules[module]->{resource_files}};
46
47 if ($project !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
48 $project !~ /^(?:gdi32)_.+?$/ &&
49 $project !~ /_test$/)
50 {
51 push @source_files, "$project.spec" );
52 # push @source_files, "$project.spec.c" );
53 @source_files = sort(@source_files);
54 }
55
56 my $no_cpp = 1;
57 my $no_msvc_headers = 1;
58 if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
59 $no_msvc_headers = 0;
60 }
61
62 my @cfgs;
63
64 push @cfgs, "$project - Win32" );
65
66 if (!$no_cpp) {
67 my @_cfgs;
68 foreach my $cfg (@cfgs) {
69 push @_cfgs, "$cfg C" );
70 push @_cfgs, "$cfg C++" );
71 }
72 @cfgs = @_cfgs;
73 }
74
75 if (!$no_release) {
76 my @_cfgs;
77 foreach my $cfg (@cfgs) {
78 push @_cfgs, "$cfg Debug" );
79 push @_cfgs, "$cfg Release" );
80 }
81 @cfgs = @_cfgs;
82 }
83
84 if (!$no_msvc_headers) {
85 my @_cfgs;
86 foreach my $cfg (@cfgs) {
87 push @_cfgs, "$cfg MSVC Headers" );
88 push @_cfgs, "$cfg Wine Headers" );
89 }
90 @cfgs = @_cfgs;
91 }
92
93 my $default_cfg = $cfgs[$#cfgs];
94
95 fprintf ( OUT, "# Microsoft Developer Studio Project File - Name=\"$project\" - Package Owner=<4>\n" );
96 fprintf ( OUT, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n" );
97 fprintf ( OUT, "# ** DO NOT EDIT **\n" );
98 fprintf ( OUT, "\n" );
99
100 if ($lib) {
101 fprintf ( OUT, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\n" );
102 } elsif ($dll) {
103 fprintf ( OUT, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\n" );
104 } else {
105 fprintf ( OUT, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n" );
106 }
107 fprintf ( OUT, "\n" );
108
109 fprintf ( OUT, "CFG=$default_cfg\n" );
110 fprintf ( OUT, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n" );
111 fprintf ( OUT, "!MESSAGE use the Export Makefile command and run\n" );
112 fprintf ( OUT, "!MESSAGE \n" );
113 fprintf ( OUT, "!MESSAGE NMAKE /f \"$project.mak\".\n" );
114 fprintf ( OUT, "!MESSAGE \n" );
115 fprintf ( OUT, "!MESSAGE You can specify a configuration when running NMAKE\n" );
116 fprintf ( OUT, "!MESSAGE by defining the macro CFG on the command line. For example:\n" );
117 fprintf ( OUT, "!MESSAGE \n" );
118 fprintf ( OUT, "!MESSAGE NMAKE /f \"$project.mak\" CFG=\"$default_cfg\"\n" );
119 fprintf ( OUT, "!MESSAGE \n" );
120 fprintf ( OUT, "!MESSAGE Possible choices for configuration are:\n" );
121 fprintf ( OUT, "!MESSAGE \n" );
122 foreach my $cfg (@cfgs) {
123 if ($lib) {
124 fprintf ( OUT, "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Static Library\")\n" );
125 } elsif ($dll) {
126 fprintf ( OUT, "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Dynamic-Link Library\")\n" );
127 } else {
128 fprintf ( OUT, "!MESSAGE \"$cfg\" (based on \"Win32 (x86) Console Application\")\n" );
129 }
130 }
131 fprintf ( OUT, "!MESSAGE \n" );
132 fprintf ( OUT, "\n" );
133
134 fprintf ( OUT, "# Begin Project\n" );
135 fprintf ( OUT, "# PROP AllowPerConfigDependencies 0\n" );
136 fprintf ( OUT, "# PROP Scc_ProjName \"\"\n" );
137 fprintf ( OUT, "# PROP Scc_LocalPath \"\"\n" );
138 fprintf ( OUT, "CPP=cl.exe\n" );
139 fprintf ( OUT, "MTL=midl.exe\n" if !$lib && !$exe;
140 fprintf ( OUT, "RSC=rc.exe\n" );
141
142 my $n = 0;
143
144 my $output_dir;
145 foreach my $cfg (@cfgs) {
146 if($#cfgs == 0) {
147 # Nothing
148 } elsif($n == 0) {
149 fprintf ( OUT, "!IF \"\$(CFG)\" == \"$cfg\"\n" );
150 fprintf ( OUT, "\n" );
151 } else {
152 fprintf ( OUT, "\n" );
153 fprintf ( OUT, "!ELSEIF \"\$(CFG)\" == \"$cfg\"\n" );
154 fprintf ( OUT, "\n" );
155 }
156
157 my $debug = ($cfg !~ /Release/);
158 my $msvc_headers = ($cfg =~ /MSVC Headers/);
159
160 fprintf ( OUT, "# PROP BASE Use_MFC 0\n" );
161
162 if($debug) {
163 fprintf ( OUT, "# PROP BASE Use_Debug_Libraries 1\n" );
164 } else {
165 fprintf ( OUT, "# PROP BASE Use_Debug_Libraries 0\n" );
166 }
167
168 $output_dir = $cfg;
169 $output_dir =~ s/^$project - //;
170 $output_dir =~ s/ /_/g;
171 $output_dir =~ s/C\+\+/Cxx/g;
172 if($output_prefix_dir) {
173 $output_dir = "$output_prefix_dir\\$output_dir" );
174 }
175
176 fprintf ( OUT, "# PROP BASE Output_Dir \"$output_dir\"\n" );
177 fprintf ( OUT, "# PROP BASE Intermediate_Dir \"$output_dir\"\n" );
178
179 fprintf ( OUT, "# PROP BASE Target_Dir \"\"\n" );
180
181 fprintf ( OUT, "# PROP Use_MFC 0\n" );
182 if($debug) {
183 fprintf ( OUT, "# PROP Use_Debug_Libraries 1\n" );
184 } else {
185 fprintf ( OUT, "# PROP Use_Debug_Libraries 0\n" );
186 }
187 fprintf ( OUT, "# PROP Output_Dir \"$output_dir\"\n" );
188 fprintf ( OUT, "# PROP Intermediate_Dir \"$output_dir\"\n" );
189
190 fprintf ( OUT, "# PROP Ignore_Export_Lib 0\n" if $dll;
191 fprintf ( OUT, "# PROP Target_Dir \"\"\n" );
192
193 my @defines;
194 if($debug) {
195 if($lib || $exe) {
196 fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
197 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _MBCS _LIB));
198 } else {
199 fprintf ( OUT, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
200 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
201 }
202 } else {
203 if($lib || $exe) {
204 fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /GX /O2" );
205 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _MBCS _LIB));
206 } else {
207 fprintf ( OUT, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
208 @defines = (qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _USRDLL), ("\U${project}\E_EXPORTS"));
209 }
210 }
211
212 foreach my $define (@defines) {
213 fprintf ( OUT, " /D \"$define\"" );
214 }
215 fprintf ( OUT, " /YX" if $lib || $exe;
216 fprintf ( OUT, " /FD" );
217 fprintf ( OUT, " /GZ" if $debug;
218 fprintf ( OUT, " " if $debug && ($lib || $exe);
219 fprintf ( OUT, " /c" );
220 fprintf ( OUT, "\n" );
221
222 my @defines2;
223 if($debug) {
224 if($lib) {
225 fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
226 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 _DEBUG _WINDOWS _MBCS _LIB);
227 } else {
228 fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
229 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 _DEBUG WIN32 _WINDOWS _MBCS _USRDLL);
230 }
231 } else {
232 if($lib) {
233 fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" );
234 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 WIN32 NDEBUG _WINDOWS _MBCS _LIB);
235 } else {
236 fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" );
237 @defines2 = qw(WINVER=0x0501 _WIN32_WINNT=0x0501 _WIN32_IE=0x0600 NDEBUG WIN32 _WINDOWS _MBCS _USRDLL);
238 }
239 }
240
241 my @includes = ();
242 if($wine) {
243 push @defines2, "_\U${project}\E_" );
244 push @defines2, qw(__WINESRC__) if $project !~ /^(?:wine(?:build|test)|.*?_test)$/;
245 if ($msvc_headers) {
246 push @defines2, qw(__WINE_USE_NATIVE_HEADERS);
247 }
248 my $output_dir2 = $output_dir;
249 $output_dir =~ s/\\/\\\\/g;
250 push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"" );
251 push @defines2, qw(__i386__ _X86_);
252
253 if($project =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
254 push @includes, ".." );
255 }
256
257 if ($project =~ /_test$/) {
258 push @includes, "$msvc_wine_dir\\$output_dir" );
259 }
260
261 if (!$msvc_headers || $project eq "winetest") {
262 push @includes, $wine_include_dir;
263 }
264 }
265
266 if($wine) {
267 foreach my $include (@includes) {
268 if ($include !~ /[\\\"]/) {
269 fprintf ( OUT, " /I \"$include\"" );
270 } else {
271 fprintf ( OUT, " /I $include" );
272 }
273 }
274 }
275
276 foreach my $define (@defines2) {
277 if ($define !~ /[\\\"]/) {
278 fprintf ( OUT, " /D \"$define\"" );
279 } else {
280 fprintf ( OUT, " /D $define" );
281 }
282 }
283 fprintf ( OUT, " /D inline=__inline" if $wine;
284 fprintf ( OUT, " /D \"__STDC__\"" if 0 && $wine;
285
286 fprintf ( OUT, " /YX" if $lib;
287 fprintf ( OUT, " /FR" if !$lib;
288 fprintf ( OUT, " /FD" );
289 fprintf ( OUT, " /GZ" if $debug;
290 fprintf ( OUT, " " if $debug && $lib;
291 fprintf ( OUT, " /c" );
292 fprintf ( OUT, " /TP" if !$no_cpp;
293 fprintf ( OUT, "\n" );
294
295 if($debug) {
296 fprintf ( OUT, "# SUBTRACT CPP /X /YX\n" if $dll;
297 fprintf ( OUT, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\n" if $dll;
298 fprintf ( OUT, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\n" if $dll;
299 fprintf ( OUT, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\n" );
300 fprintf ( OUT, "# ADD RSC /l 0x41d" );
301 if($wine) {
302 foreach my $include (@includes) {
303 fprintf ( OUT, " /i \"$include\"" );
304 }
305 }
306 fprintf ( OUT, " /d \"_DEBUG\"\n" );
307 } else {
308 fprintf ( OUT, "# SUBTRACT CPP /YX\n" if $dll;
309 fprintf ( OUT, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\n" if $dll;
310 fprintf ( OUT, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\n" if $dll;
311 fprintf ( OUT, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\n" );
312 fprintf ( OUT, "# ADD RSC /l 0x41d" );
313 if($wine) {
314 foreach my $include (@includes) {
315 fprintf ( OUT, " /i \"$include\"" );
316 }
317 }
318 fprintf ( OUT, "/d \"NDEBUG\"\n" );
319 }
320 fprintf ( OUT, "BSC32=bscmake.exe\n" );
321 fprintf ( OUT, "# ADD BASE BSC32 /nologo\n" );
322 fprintf ( OUT, "# ADD BSC32 /nologo\n" );
323
324 if($exe || $dll) {
325 fprintf ( OUT, "LINK32=link.exe\n" );
326 fprintf ( OUT, "# ADD BASE LINK32 " );
327 my @libraries = qw(kernel32.lib user32.lib gdi32.lib winspool.lib
328 comdlg32.lib advapi32.lib shell32.lib ole32.lib
329 oleaut32.lib uuid.lib odbc32.lib odbccp32.lib);
330 foreach my $library (@libraries) {
331 fprintf ( OUT, "$library " );
332 }
333 fprintf ( OUT, " /nologo" );
334 fprintf ( OUT, " /dll" if $dll;
335 fprintf ( OUT, " /subsystem:console" if $console;
336 fprintf ( OUT, " /debug" if $debug;
337 fprintf ( OUT, " /machine:I386" );
338 fprintf ( OUT, " /pdbtype:sept" if $debug;
339 fprintf ( OUT, "\n" );
340
341 fprintf ( OUT, "# ADD LINK32" );
342 fprintf ( OUT, " /nologo" );
343 fprintf ( OUT, " libcmt.lib" if $project =~ /^ntdll$/; # FIXME: Kludge
344 foreach my $import (@imports) {
345 fprintf ( OUT, " $import.lib" if ($import ne "msvcrt");
346 }
347 fprintf ( OUT, " /dll" if $dll;
348 fprintf ( OUT, " /subsystem:console" if $console;
349 fprintf ( OUT, " /debug" if $debug;
350 fprintf ( OUT, " /machine:I386" );
351 fprintf ( OUT, " /nodefaultlib" if $project =~ /^ntdll$/; # FIXME: Kludge
352 fprintf ( OUT, " /def:\"$project.def\"" if $dll;
353 fprintf ( OUT, " /pdbtype:sept" if $debug;
354 fprintf ( OUT, "\n" );
355 } else {
356 fprintf ( OUT, "LIB32=link.exe -lib\n" );
357 fprintf ( OUT, "# ADD BASE LIB32 /nologo\n" );
358 fprintf ( OUT, "# ADD LIB32 /nologo\n" );
359 }
360
361 $n++;
362 }
363
364 if($#cfgs != 0) {
365 fprintf ( OUT, "\n" );
366 fprintf ( OUT, "!ENDIF \n" );
367 fprintf ( OUT, "\n" );
368 }
369
370 if ($project eq "winebuild") {
371 fprintf ( OUT, "# Begin Special Build Tool\n" );
372 fprintf ( OUT, "SOURCE=\"\$(InputPath)\"\n" );
373 fprintf ( OUT, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\n" );
374 fprintf ( OUT, "PostBuild_Cmds=" );
375 fprintf ( OUT, "copy ..\\..\\library\\$output_dir\\wine.dll \$(OutDir)\t" );
376 fprintf ( OUT, "copy ..\\..\\unicode\\$output_dir\\wine_unicode.dll \$(OutDir)\n" );
377 fprintf ( OUT, "# End Special Build Tool\n" );
378 }
379 fprintf ( OUT, "# Begin Target\n" );
380 fprintf ( OUT, "\n" );
381 foreach my $cfg (@cfgs) {
382 fprintf ( OUT, "# Name \"$cfg\"\n" );
383 }
384
385 fprintf ( OUT, "# Begin Group \"Source Files\"\n" );
386 fprintf ( OUT, "\n" );
387 fprintf ( OUT, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n" );
388
389 foreach my $source_file (@source_files) {
390 $source_file =~ s%/%\\%g;
391 if($source_file !~ /^\./) {
392 $source_file = ".\\$source_file" );
393 }
394
395 if($source_file =~ /^(.*?)\.spec$/) {
396 my $basename = $1;
397
398 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
399 my $dbg_c_file = "$basename.dbg.c" );
400
401 fprintf ( OUT, "# Begin Source File\n" );
402 fprintf ( OUT, "\n" );
403 fprintf ( OUT, "SOURCE=$dbg_c_file\n" );
404 fprintf ( OUT, "# End Source File\n" );
405 }
406
407 fprintf ( OUT, "# Begin Source File\n" );
408 fprintf ( OUT, "\n" );
409
410 fprintf ( OUT, "SOURCE=$source_file\n" );
411
412 if($source_file =~ /^(.*?)\.spec$/) {
413 my $basename = $1;
414
415 my $spec_file = $source_file;
416 my $def_file = "$basename.def" );
417
418 $basename = "$basename.dll" if $basename !~ /\..{1,3}$/;
419 my $dbg_file = "$basename.dbg" );
420 my $dbg_c_file = "$basename.dbg.c" );
421
422 my $srcdir = "." ); # FIXME: Is this really always correct?
423
424 fprintf ( OUT, "# Begin Custom Build\n" );
425 fprintf ( OUT, "InputPath=$spec_file\n" );
426 fprintf ( OUT, "\n" );
427 fprintf ( OUT, "BuildCmds= \\\n" );
428 fprintf ( OUT, "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe --def $spec_file > $def_file \\\n" );
429
430 if($project =~ /^ntdll$/) {
431 my $n = 0;
432 foreach my $c_src (@c_srcs) {
433 if($n++ > 0) {
434 fprintf ( OUT, "\techo $c_src >> $dbg_file \\\n" );
435 } else {
436 fprintf ( OUT, "\techo $c_src > $dbg_file \\\n" );
437 }
438 }
439 fprintf ( OUT, "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe" );
440 fprintf ( OUT, " -o $dbg_c_file --debug -C$srcdir $dbg_file \\\n" );
441 } else {
442 my $c_srcs = join(" ", grep(/\.c$/, @c_srcs));
443
444 fprintf ( OUT, "\t..\\..\\tools\\winebuild\\$output_dir\\winebuild.exe" );
445 fprintf ( OUT, " -o $dbg_c_file --debug -C$srcdir $c_srcs \\\n" );
446 }
447
448 fprintf ( OUT, "\t\n" );
449 fprintf ( OUT, "\n" );
450 fprintf ( OUT, "\"$def_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\n" );
451 fprintf ( OUT, " \$(BuildCmds)\n" );
452 fprintf ( OUT, "\n" );
453 fprintf ( OUT, "\"$dbg_c_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\n" );
454 fprintf ( OUT, " \$(BuildCmds)\n" );
455 fprintf ( OUT, "# End Custom Build\n" );
456 } elsif($source_file =~ /([^\\]*?\.h)$/) {
457 my $h_file = $1;
458
459 foreach my $cfg (@cfgs) {
460 if($#cfgs == 0) {
461 # Nothing
462 } elsif($n == 0) {
463 fprintf ( OUT, "!IF \"\$(CFG)\" == \"$cfg\"\n" );
464 fprintf ( OUT, "\n" );
465 } else {
466 fprintf ( OUT, "\n" );
467 fprintf ( OUT, "!ELSEIF \"\$(CFG)\" == \"$cfg\"\n" );
468 fprintf ( OUT, "\n" );
469 }
470
471 $output_dir = $cfg;
472 $output_dir =~ s/^$project - //;
473 $output_dir =~ s/ /_/g;
474 $output_dir =~ s/C\+\+/Cxx/g;
475 if($output_prefix_dir) {
476 $output_dir = "$output_prefix_dir\\$output_dir" );
477 }
478
479 fprintf ( OUT, "# Begin Custom Build\n" );
480 fprintf ( OUT, "OutDir=$output_dir\n" );
481 fprintf ( OUT, "InputPath=$source_file\n" );
482 fprintf ( OUT, "\n" );
483 fprintf ( OUT, "\"\$(OutDir)\\wine\\$h_file\" : \$(SOURCE) \"\$(INTDIR)\" \"\$(OUTDIR)\"\n" );
484 fprintf ( OUT, "\tcopy \"\$(InputPath)\" \"\$(OutDir)\\wine\"\n" );
485 fprintf ( OUT, "\n" );
486 fprintf ( OUT, "# End Custom Build\n" );
487 }
488
489 if($#cfgs != 0) {
490 fprintf ( OUT, "\n" );
491 fprintf ( OUT, "!ENDIF \n" );
492 fprintf ( OUT, "\n" );
493 }
494 }
495
496 fprintf ( OUT, "# End Source File\n" );
497 }
498 fprintf ( OUT, "# End Group\n" );
499
500 fprintf ( OUT, "# Begin Group \"Header Files\"\n" );
501 fprintf ( OUT, "\n" );
502 fprintf ( OUT, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n" );
503 foreach my $header_file (@header_files) {
504 fprintf ( OUT, "# Begin Source File\n" );
505 fprintf ( OUT, "\n" );
506 fprintf ( OUT, "SOURCE=.\\$header_file\n" );
507 fprintf ( OUT, "# End Source File\n" );
508 }
509 fprintf ( OUT, "# End Group\n" );
510
511
512
513 fprintf ( OUT, "# Begin Group \"Resource Files\"\n" );
514 fprintf ( OUT, "\n" );
515 fprintf ( OUT, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n" );
516 foreach my $resource_file (@resource_files) {
517 fprintf ( OUT, "# Begin Source File\n" );
518 fprintf ( OUT, "\n" );
519 fprintf ( OUT, "SOURCE=.\\$resource_file\n" );
520 fprintf ( OUT, "# End Source File\n" );
521 }
522 fprintf ( OUT, "# End Group\n" );
523
524 fprintf ( OUT, "# End Target\n" );
525 fprintf ( OUT, "# End Project\n" );
526
527 close(OUT);
528 }
529 #endif
530 void
531 MSVCBackend::_generate_dsw_header ( FILE* OUT )
532 {
533 fprintf ( OUT, "Microsoft Developer Studio Workspace File, Format Version 6.00\n" );
534 fprintf ( OUT, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n" );
535 fprintf ( OUT, "\n" );
536 }
537
538 void
539 MSVCBackend::_generate_dsw_project (
540 FILE* OUT,
541 const Module& module,
542 std::string dsp_file,
543 const std::vector<Dependency*>& dependencies )
544 {
545 dsp_file = std::string(".\\") + dsp_file;
546 // TODO FIXME - what does next line do?
547 //$dsp_file =~ y%/%\\%;
548
549 // TODO FIXME - must they be sorted?
550 //@dependencies = sort(@dependencies);
551
552 fprintf ( OUT, "###############################################################################\n" );
553 fprintf ( OUT, "\n" );
554 fprintf ( OUT, "Project: \"%s\"=%s - Package Owner=<4>\n", module.name.c_str(), dsp_file.c_str() );
555 fprintf ( OUT, "\n" );
556 fprintf ( OUT, "Package=<5>\n" );
557 fprintf ( OUT, "{{{\n" );
558 fprintf ( OUT, "}}}\n" );
559 fprintf ( OUT, "\n" );
560 fprintf ( OUT, "Package=<4>\n" );
561 fprintf ( OUT, "{{{\n" );
562 for ( size_t i = 0; i < dependencies.size(); i++ )
563 {
564 Dependency& dependency = *dependencies[i];
565 fprintf ( OUT, " Begin Project Dependency\n" );
566 fprintf ( OUT, " Project_Dep_Name %s\n", dependency.module.name.c_str() );
567 fprintf ( OUT, " End Project Dependency\n" );
568 }
569 fprintf ( OUT, "}}}\n" );
570 fprintf ( OUT, "\n" );
571 }
572
573 void
574 MSVCBackend::_generate_dsw_footer ( FILE* OUT )
575 {
576 fprintf ( OUT, "###############################################################################\n" );
577 fprintf ( OUT, "\n" );
578 fprintf ( OUT, "Global:\n" );
579 fprintf ( OUT, "\n" );
580 fprintf ( OUT, "Package=<5>\n" );
581 fprintf ( OUT, "{{{\n" );
582 fprintf ( OUT, "}}}\n" );
583 fprintf ( OUT, "\n" );
584 fprintf ( OUT, "Package=<3>\n" );
585 fprintf ( OUT, "{{{\n" );
586 fprintf ( OUT, "}}}\n" );
587 fprintf ( OUT, "\n" );
588 fprintf ( OUT, "###############################################################################\n" );
589 fprintf ( OUT, "\n" );
590 }
591
592 void
593 MSVCBackend::_generate_wine_dsw ( FILE* OUT )
594 {
595 _generate_dsw_header(OUT);
596 // TODO FIXME - is it necessary to sort them?
597 for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
598 //foreach my $module (sort(keys(%modules)))
599 {
600 Module& module = *ProjectNode.modules[i];
601
602 //my $project = modules[module]->{project};
603 std::string dsp_file = DspFileName ( module );
604
605 // TODO FIXME - more wine hacks?
606 /*if($project =~ /^gdi32$/) {
607 foreach my $dir (@gdi32_dirs) {
608 my $dir2 = $dir;
609 $dir2 =~ s%^.*?/([^/]+)$%$1%;
610
611 my $module = "gdi32_$dir2";
612 $module =~ s%/%_%g;
613 push @dependencies, $module;
614 }
615 }*/
616
617 _generate_dsw_project ( OUT, module, dsp_file, module.dependencies );
618 }
619 _generate_dsw_footer ( OUT );
620 }