2 #pragma warning ( disable : 4786 )
16 MSVCBackend::_generate_dsp ( const Module
& module
)
19 // TODO FIXME wine hack?
20 const bool wine
= false;
22 string dsp_file
= DspFileName(module
);
23 printf ( "Creating MSVC project: '%s'\n", dsp_file
.c_str() );
24 FILE* OUT
= fopen ( dsp_file
.c_str(), "wb" );
26 vector
<string
> imports
;
27 for ( i
= 0; i
< module
.non_if_data
.libraries
.size(); i
++ )
29 imports
.push_back ( module
.non_if_data
.libraries
[i
]->name
);
32 string module_type
= Right(module
.GetTargetName(),3);
33 bool lib
= (module_type
== "lib");
34 bool dll
= (module_type
== "dll");
35 bool exe
= (module_type
== "exe");
36 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
38 bool console
= exe
; // FIXME: Not always correct
40 // TODO FIXME - not sure if the count here is right...
42 const char* p
= strpbrk ( dsp_file
.c_str(), "/\\" );
46 p
= strpbrk ( p
+1, "/\\" );
48 string msvc_wine_dir
= "..";
50 msvc_wine_dir
+= "\\..";
52 string wine_include_dir
= msvc_wine_dir
+ "\\include";
54 //$progress_current++;
55 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
57 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
58 string dsp_path
= module
.GetBasePath();
59 vector
<string
> c_srcs
, source_files
, resource_files
, includes
;
60 vector
<const IfableData
*> ifs_list
;
61 ifs_list
.push_back ( &module
.non_if_data
);
62 while ( ifs_list
.size() )
64 const IfableData
& data
= *ifs_list
.back();
66 // TODO FIXME - refactor needed - we're discarding if conditions
67 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
68 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
69 const vector
<File
*>& files
= data
.files
;
70 for ( i
= 0; i
< files
.size(); i
++ )
72 // TODO FIXME - do we want the full path of the file here?
73 string file
= string(".") + &files
[i
]->name
[dsp_path
.size()];
75 source_files
.push_back ( file
);
76 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
77 c_srcs
.push_back ( file
);
78 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
79 resource_files
.push_back ( file
);
81 const vector
<Include
*>& incs
= data
.includes
;
82 for ( i
= 0; i
< incs
.size(); i
++ )
84 string path
= Path::RelativeFromDirectory (
86 module
.GetBasePath() );
89 includes
.push_back ( path
);
92 // TODO FIXME - we don't include header files in our build system
93 //my @header_files = @{module->{header_files}};
94 vector
<string
> header_files
;
96 // TODO FIXME - wine hack?
97 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
98 module.name !~ /^(?:gdi32)_.+?$/ &&
99 Right ( module.name, 5 ) == "_test" )
101 source_files.push_back ( module.name + ".spec" );
102 @source_files = sort(@source_files);
106 bool no_msvc_headers
= true;
107 // TODO FIXME - wine hack?
108 /*if (module.name =~ /^wine(?:runtests|test)$/
109 || Right ( module.name, 5 ) == "_test" )
111 no_msvc_headers = false;
114 std::vector
<std::string
> cfgs
;
116 cfgs
.push_back ( module
.name
+ " - Win32" );
120 std::vector
<std::string
> _cfgs
;
121 for ( i
= 0; i
< cfgs
.size(); i
++ )
123 _cfgs
.push_back ( cfgs
[i
] + " C" );
124 _cfgs
.push_back ( cfgs
[i
] + " C++" );
130 // TODO FIXME - wine hack?
133 std::vector<std::string> _cfgs;
134 for ( i = 0; i < cfgs.size(); i++ )
136 _cfgs.push_back ( cfgs[i] + " Debug" );
137 _cfgs.push_back ( cfgs[i] + " Release" );
143 if (!no_msvc_headers
)
145 std::vector
<std::string
> _cfgs
;
146 for ( i
= 0; i
< cfgs
.size(); i
++ )
148 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
149 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
155 string default_cfg
= cfgs
.back();
157 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
158 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
159 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
160 fprintf ( OUT
, "\r\n" );
164 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
168 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
172 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
174 fprintf ( OUT
, "\r\n" );
176 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
177 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
178 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
179 fprintf ( OUT
, "!MESSAGE \r\n" );
180 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
181 fprintf ( OUT
, "!MESSAGE \r\n" );
182 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
183 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
184 fprintf ( OUT
, "!MESSAGE \r\n" );
185 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
186 fprintf ( OUT
, "!MESSAGE \r\n" );
187 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
188 fprintf ( OUT
, "!MESSAGE \r\n" );
189 for ( i
= 0; i
< cfgs
.size(); i
++ )
191 const string
& cfg
= cfgs
[i
];
194 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
198 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
202 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
205 fprintf ( OUT
, "!MESSAGE \r\n" );
206 fprintf ( OUT
, "\r\n" );
208 fprintf ( OUT
, "# Begin Project\r\n" );
209 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
210 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
211 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
212 fprintf ( OUT
, "CPP=cl.exe\r\n" );
213 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
214 fprintf ( OUT
, "RSC=rc.exe\r\n" );
218 std::string output_dir
;
219 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
221 std::string
& cfg
= cfgs
[icfg
];
226 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
227 fprintf ( OUT
, "\r\n" );
231 fprintf ( OUT
, "\r\n" );
232 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
233 fprintf ( OUT
, "\r\n" );
237 bool debug
= !strstr ( cfg
.c_str(), "Release" );
238 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
240 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
244 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
248 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
251 output_dir
= Replace(cfg
,module
.name
+ " - ","");
252 output_dir
= Replace(output_dir
," ","_");
253 output_dir
= Replace(output_dir
,"C++","Cxx");
254 // TODO FIXME - wine hack?
255 //if ( output_prefix_dir.size() )
256 // output_dir = output_prefix_dir + "\\" + output_dir;
258 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
259 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
261 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
263 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
266 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
270 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
272 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
273 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
275 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
276 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
278 vector
<string
> defines
;
279 defines
.push_back ( "WINVER=0x0501" );
280 defines
.push_back ( "_WIN32_WINNT=0x0501" );
281 defines
.push_back ( "_WIN32_IE=0x0600" );
282 defines
.push_back ( "WIN32" );
283 defines
.push_back ( "_WINDOWS" );
284 defines
.push_back ( "WIN32" );
285 defines
.push_back ( "_MBCS" );
288 defines
.push_back ( "_DEBUG" );
291 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
292 defines
.push_back ( "_LIB" );
296 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
297 defines
.push_back ( "_WINDOWS" );
298 defines
.push_back ( "_USRDLL" );
299 // TODO FIXME - wine hack?
300 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
305 defines
.push_back ( "NDEBUG" );
308 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
309 defines
.push_back ( "_LIB" );
313 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
314 defines
.push_back ( "_WINDOWS" );
315 defines
.push_back ( "_USRDLL" );
316 // TODO FIXME - wine hack?
317 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
321 for ( i
= 0; i
< defines
.size(); i
++ )
323 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
325 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
326 fprintf ( OUT
, " /FD" );
329 fprintf ( OUT
, " /GZ" );
330 if ( lib
|| exe
) fprintf ( OUT
, " " );
332 fprintf ( OUT
, " /c" );
333 fprintf ( OUT
, "\r\n" );
335 vector
<string
> defines2
;
336 defines2
.push_back ( "WINVER=0x0501" );
337 defines2
.push_back ( "_WIN32_WINNT=0x0501" );
338 defines2
.push_back ( "_WIN32_IE=0x0600" );
339 defines2
.push_back ( "WIN32" );
340 defines2
.push_back ( "_WINDOWS" );
341 defines2
.push_back ( "_MBCS" );
344 defines2
.push_back ( "_DEBUG" );
347 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
348 defines2
.push_back ( "_LIB" );
352 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
353 defines2
.push_back ( "_USRDLL" );
358 defines2
.push_back ( "NDEBUG" );
361 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
362 defines2
.push_back ( "_LIB" );
366 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
367 defines2
.push_back ( "_USRDLL" );
371 // TODO FIXME - wine hack?
374 // TODO FIXME - wine hack?
375 //defines2.push_back ( string("_\U") + module.name + "\E_" );
376 // TODO FIXME - wine hack?
377 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
378 defines2.push_back ( "__WINESRC__" );*/
380 defines2
.push_back ( "__WINE_USE_NATIVE_HEADERS" );
381 string output_dir2
= Replace(output_dir
,"\\","\\\\");
382 defines2
.push_back ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
383 defines2
.push_back ( "__i386__" );
384 defines2
.push_back ( "_X86_" );
386 // TODO FIXME - wine hacks?
387 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
388 push @includes, ".." );
391 if ( strstr ( module.name.c_str(), "_test" )
393 include.push_back ( msvc_wine_dir + "\\" + output_dir );
396 if (!msvc_headers || module.name == "winetest")
398 includes.push_back ( wine_include_dir );
404 for ( i
= 0; i
< includes
.size(); i
++ )
406 const string
& include
= includes
[i
];
407 if ( strpbrk ( include
.c_str(), "[\\\"]" ) )
409 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
413 fprintf ( OUT
, " /I %s", include
.c_str() );
418 fprintf ( OUT
, " /I \".\"" );
419 for ( i
= 0; i
< defines2
.size(); i
++ )
421 const string
& define
= defines2
[i
];
422 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
424 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
428 fprintf ( OUT
, " /D %s", define
.c_str() );
431 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
432 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
434 fprintf ( OUT
, lib
? " /YX" : " /FR" );
435 fprintf ( OUT
, " /FD" );
436 if ( debug
) fprintf ( OUT
, " /GZ" );
437 if ( debug
&& lib
) fprintf ( OUT
, " " );
438 fprintf ( OUT
, " /c" );
439 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
440 fprintf ( OUT
, "\r\n" );
446 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
447 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
448 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
450 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
451 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
454 for ( i
= 0; i
< includes
.size(); i
++ )
456 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
459 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
465 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
466 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
467 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
469 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
470 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
473 for ( i
= 0; i
< includes
.size(); i
++ )
474 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
476 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
478 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
479 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
480 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
484 fprintf ( OUT
, "LINK32=link.exe\r\n" );
485 fprintf ( OUT
, "# ADD BASE LINK32 " );
486 vector
<string
> libraries
;
487 libraries
.push_back ( "kernel32.lib" );
488 libraries
.push_back ( "user32.lib" );
489 libraries
.push_back ( "gdi32.lib" );
490 libraries
.push_back ( "winspool.lib" );
491 libraries
.push_back ( "comdlg32.lib" );
492 libraries
.push_back ( "advapi32.lib" );
493 libraries
.push_back ( "shell32.lib" );
494 libraries
.push_back ( "ole32.lib" );
495 libraries
.push_back ( "oleaut32.lib" );
496 libraries
.push_back ( "uuid.lib" );
497 libraries
.push_back ( "odbc32.lib" );
498 libraries
.push_back ( "odbccp32.lib" );
499 for ( i
= 0; i
< libraries
.size(); i
++ )
501 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
503 fprintf ( OUT
, " /nologo" );
504 if ( dll
) fprintf ( OUT
, " /dll" );
505 if ( console
) fprintf ( OUT
, " /subsystem:console" );
506 if ( debug
) fprintf ( OUT
, " /debug" );
507 fprintf ( OUT
, " /machine:I386" );
508 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
509 fprintf ( OUT
, "\r\n" );
511 fprintf ( OUT
, "# ADD LINK32" );
512 fprintf ( OUT
, " /nologo" );
513 // TODO FIXME - do we need their kludge?
514 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
515 for ( i
= 0; i
< imports
.size(); i
++ )
517 const string
& import
= imports
[i
];
518 if ( import
!= "msvcrt" )
519 fprintf ( OUT
, " %s.lib", import
.c_str() );
521 if ( dll
) fprintf ( OUT
, " /dll" );
522 if ( console
) fprintf ( OUT
, " /subsystem:console" );
523 if ( debug
) fprintf ( OUT
, " /debug" );
524 fprintf ( OUT
, " /machine:I386" );
525 // TODO FIXME - do we need their kludge?
526 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
527 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
528 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
529 fprintf ( OUT
, "\r\n" );
533 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
534 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
535 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
541 if ( cfgs
.size() != 0 )
543 fprintf ( OUT
, "\r\n" );
544 fprintf ( OUT
, "!ENDIF \r\n" );
545 fprintf ( OUT
, "\r\n" );
548 if ( module
.name
== "winebuild" )
550 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
551 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
552 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
553 fprintf ( OUT
, "PostBuild_Cmds=" );
554 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
555 output_dir
.c_str() );
556 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
557 output_dir
.c_str() );
558 fprintf ( OUT
, "# End Special Build Tool\r\n" );
561 fprintf ( OUT
, "# Begin Target\r\n" );
562 fprintf ( OUT
, "\r\n" );
563 for ( i
= 0; i
< cfgs
.size(); i
++ )
565 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
568 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
569 fprintf ( OUT
, "\r\n" );
570 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
572 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
574 string source_file
= DosSeparator(source_files
[isrcfile
]);
576 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
578 source_file
= string(".\\") + source_file
;
581 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
583 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
585 // TODO FIXME - not sure what this is doing? wine hack maybe?
586 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
587 string dbg_c_file
= basename
+ ".dbg.c";
589 fprintf ( OUT
, "# Begin Source File\r\n" );
590 fprintf ( OUT
, "\r\n" );
591 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
592 fprintf ( OUT
, "# End Source File\r\n" );
595 fprintf ( OUT
, "# Begin Source File\r\n" );
596 fprintf ( OUT
, "\r\n" );
598 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
600 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
603 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
605 string spec_file
= source_file
;
606 string def_file
= basename
+ ".def";
608 // TODO FIXME - not sure what this is doing? wine hack maybe?
609 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
610 string dbg_file
= basename
+ ".dbg";
611 string dbg_c_file
= basename
+ ".dbg.c";
613 string srcdir
= "."; // FIXME: Is this really always correct?
615 fprintf ( OUT
, "# Begin Custom Build\r\n" );
616 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
617 fprintf ( OUT
, "\r\n" );
618 fprintf ( OUT
, "BuildCmds= \\\r\n" );
619 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
624 if ( module
.name
== "ntdll" )
627 for ( i
= 0; i
< c_srcs
.size(); i
++ )
629 const string
& c_src
= c_srcs
[i
];
632 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
636 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
639 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
640 output_dir
.c_str() );
641 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
649 for ( i
= 0; i
< c_srcs
.size(); i
++ )
651 const string
& c_src
= c_srcs
[i
];
652 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
654 if ( sc_srcs
.size() )
660 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
661 output_dir
.c_str() );
662 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
668 fprintf ( OUT
, "\t\r\n" );
669 fprintf ( OUT
, "\r\n" );
670 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
671 fprintf ( OUT
, " $(BuildCmds)\r\n" );
672 fprintf ( OUT
, "\r\n" );
673 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
674 fprintf ( OUT
, " $(BuildCmds)\r\n" );
675 fprintf ( OUT
, "# End Custom Build\r\n" );
678 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
682 foreach my $cfg (@cfgs) {
686 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
687 fprintf ( OUT, "\r\n" );
689 fprintf ( OUT, "\r\n" );
690 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
691 fprintf ( OUT, "\r\n" );
695 $output_dir =~ s/^$project - //;
696 $output_dir =~ s/ /_/g;
697 $output_dir =~ s/C\+\+/Cxx/g;
698 if($output_prefix_dir) {
699 $output_dir = "$output_prefix_dir\\$output_dir" );
702 fprintf ( OUT, "# Begin Custom Build\r\n" );
703 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
704 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
705 fprintf ( OUT, "\r\n" );
706 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
707 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
708 fprintf ( OUT, "\r\n" );
709 fprintf ( OUT, "# End Custom Build\r\n" );
712 if ( cfgs.size() != 0)
714 fprintf ( OUT, "\r\n" );
715 fprintf ( OUT, "!ENDIF \r\n" );
716 fprintf ( OUT, "\r\n" );
720 fprintf ( OUT
, "# End Source File\r\n" );
722 fprintf ( OUT
, "# End Group\r\n" );
723 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
724 fprintf ( OUT
, "\r\n" );
725 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
726 for ( i
= 0; i
< header_files
.size(); i
++ )
728 const string
& header_file
= header_files
[i
];
729 fprintf ( OUT
, "# Begin Source File\r\n" );
730 fprintf ( OUT
, "\r\n" );
731 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
732 fprintf ( OUT
, "# End Source File\r\n" );
734 fprintf ( OUT
, "# End Group\r\n" );
738 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
739 fprintf ( OUT
, "\r\n" );
740 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
741 for ( i
= 0; i
< resource_files
.size(); i
++ )
743 const string
& resource_file
= resource_files
[i
];
744 fprintf ( OUT
, "# Begin Source File\r\n" );
745 fprintf ( OUT
, "\r\n" );
746 fprintf ( OUT
, "SOURCE=.\\%s\r\n", resource_file
.c_str() );
747 fprintf ( OUT
, "# End Source File\r\n" );
749 fprintf ( OUT
, "# End Group\r\n" );
751 fprintf ( OUT
, "# End Target\r\n" );
752 fprintf ( OUT
, "# End Project\r\n" );
758 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
760 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
761 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
762 fprintf ( OUT
, "\r\n" );
766 MSVCBackend::_generate_dsw_project (
768 const Module
& module
,
769 std::string dsp_file
,
770 const std::vector
<Dependency
*>& dependencies
)
772 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
774 // TODO FIXME - must they be sorted?
775 //@dependencies = sort(@dependencies);
777 fprintf ( OUT
, "###############################################################################\r\n" );
778 fprintf ( OUT
, "\r\n" );
779 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
780 fprintf ( OUT
, "\r\n" );
781 fprintf ( OUT
, "Package=<5>\r\n" );
782 fprintf ( OUT
, "{{{\r\n" );
783 fprintf ( OUT
, "}}}\r\n" );
784 fprintf ( OUT
, "\r\n" );
785 fprintf ( OUT
, "Package=<4>\r\n" );
786 fprintf ( OUT
, "{{{\r\n" );
787 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
789 Dependency
& dependency
= *dependencies
[i
];
790 fprintf ( OUT
, " Begin Project Dependency\r\n" );
791 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
792 fprintf ( OUT
, " End Project Dependency\r\n" );
794 fprintf ( OUT
, "}}}\r\n" );
795 fprintf ( OUT
, "\r\n" );
799 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
801 fprintf ( OUT
, "###############################################################################\r\n" );
802 fprintf ( OUT
, "\r\n" );
803 fprintf ( OUT
, "Global:\r\n" );
804 fprintf ( OUT
, "\r\n" );
805 fprintf ( OUT
, "Package=<5>\r\n" );
806 fprintf ( OUT
, "{{{\r\n" );
807 fprintf ( OUT
, "}}}\r\n" );
808 fprintf ( OUT
, "\r\n" );
809 fprintf ( OUT
, "Package=<3>\r\n" );
810 fprintf ( OUT
, "{{{\r\n" );
811 fprintf ( OUT
, "}}}\r\n" );
812 fprintf ( OUT
, "\r\n" );
813 fprintf ( OUT
, "###############################################################################\r\n" );
814 fprintf ( OUT
, "\r\n" );
818 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
820 _generate_dsw_header(OUT
);
821 // TODO FIXME - is it necessary to sort them?
822 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
824 Module
& module
= *ProjectNode
.modules
[i
];
826 std::string dsp_file
= DspFileName ( module
);
828 // TODO FIXME - more wine hacks?
829 /*if ( module.name == "gdi32" )
831 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
833 string dir2 = gdi32_dirs[idir];
834 $dir2 =~ s%^.*?/([^/]+)$%$1%;
836 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
840 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
842 _generate_dsw_footer ( OUT
);