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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #pragma warning ( disable : 4786 )
36 typedef set
<string
> StringSet
;
43 MSVCBackend::_generate_dsp ( const Module
& module
)
46 // TODO FIXME wine hack?
47 const bool wine
= false;
49 string dsp_file
= DspFileName(module
);
50 printf ( "Creating MSVC project: '%s'\n", dsp_file
.c_str() );
51 FILE* OUT
= fopen ( dsp_file
.c_str(), "wb" );
53 vector
<string
> imports
;
54 for ( i
= 0; i
< module
.non_if_data
.libraries
.size(); i
++ )
56 imports
.push_back ( module
.non_if_data
.libraries
[i
]->name
);
59 string module_type
= GetExtension(*module
.output
);
60 bool lib
= (module_type
== ".lib") || (module_type
== ".a");
61 bool dll
= (module_type
== ".dll") || (module_type
== ".cpl");
62 bool exe
= (module_type
== ".exe") || (module_type
== ".scr");
63 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
65 bool console
= exe
&& (module
.type
== Win32CUI
);
67 // TODO FIXME - not sure if the count here is right...
69 const char* p
= strpbrk ( dsp_file
.c_str(), "/\\" );
73 p
= strpbrk ( p
+1, "/\\" );
75 string msvc_wine_dir
= "..";
77 msvc_wine_dir
+= "\\..";
79 string wine_include_dir
= msvc_wine_dir
+ "\\include";
81 //$progress_current++;
82 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
84 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
85 vector
<string
> c_srcs
, source_files
, header_files
, resource_files
, includes
, libraries
;
86 StringSet common_defines
;
87 vector
<const IfableData
*> ifs_list
;
88 ifs_list
.push_back ( &module
.project
.non_if_data
);
89 ifs_list
.push_back ( &module
.non_if_data
);
91 // this is a define in MinGW w32api, but not Microsoft's headers
92 common_defines
.insert ( "STDCALL=__stdcall" );
94 while ( ifs_list
.size() )
96 const IfableData
& data
= *ifs_list
.back();
98 const vector
<File
*>& files
= data
.files
;
99 for ( i
= 0; i
< files
.size(); i
++ )
101 if (files
[i
]->file
.directory
!= SourceDirectory
)
104 // We want the full path here for directory support later on
105 string path
= Path::RelativeFromDirectory (
106 files
[i
]->file
.relative_path
,
107 module
.output
->relative_path
);
108 string file
= path
+ std::string("\\") + files
[i
]->file
.name
;
110 source_files
.push_back ( file
);
111 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
112 c_srcs
.push_back ( file
);
113 if ( !stricmp ( Right(file
,2).c_str(), ".h" ) )
114 header_files
.push_back ( file
);
115 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
116 resource_files
.push_back ( file
);
118 const vector
<Include
*>& incs
= data
.includes
;
119 for ( i
= 0; i
< incs
.size(); i
++ )
121 string path
= Path::RelativeFromDirectory (
122 incs
[i
]->directory
->relative_path
,
123 module
.output
->relative_path
);
124 includes
.push_back ( path
);
126 const vector
<Library
*>& libs
= data
.libraries
;
127 for ( i
= 0; i
< libs
.size(); i
++ )
129 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
131 const vector
<Define
*>& defs
= data
.defines
;
132 for ( i
= 0; i
< defs
.size(); i
++ )
134 if ( defs
[i
]->value
[0] )
135 common_defines
.insert( defs
[i
]->name
+ "=" + defs
[i
]->value
);
137 common_defines
.insert( defs
[i
]->name
);
140 // TODO FIXME - we don't include header files in our build system
141 //my @header_files = @{module->{header_files}};
142 //vector<string> header_files;
144 // TODO FIXME - wine hack?
145 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
146 module.name !~ /^(?:gdi32)_.+?$/ &&
147 Right ( module.name, 5 ) == "_test" )
149 source_files.push_back ( module.name + ".spec" );
150 @source_files = sort(@source_files);
154 bool no_msvc_headers
= true;
155 // TODO FIXME - wine hack?
156 /*if (module.name =~ /^wine(?:runtests|test)$/
157 || Right ( module.name, 5 ) == "_test" )
159 no_msvc_headers = false;
162 std::vector
<std::string
> cfgs
;
164 cfgs
.push_back ( module
.name
+ " - Win32" );
168 std::vector
<std::string
> _cfgs
;
169 for ( i
= 0; i
< cfgs
.size(); i
++ )
171 _cfgs
.push_back ( cfgs
[i
] + " C" );
172 _cfgs
.push_back ( cfgs
[i
] + " C++" );
178 // TODO FIXME - wine hack?
181 std::vector<std::string> _cfgs;
182 for ( i = 0; i < cfgs.size(); i++ )
184 _cfgs.push_back ( cfgs[i] + " Debug" );
185 _cfgs.push_back ( cfgs[i] + " Release" );
191 if (!no_msvc_headers
)
193 std::vector
<std::string
> _cfgs
;
194 for ( i
= 0; i
< cfgs
.size(); i
++ )
196 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
197 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
203 string default_cfg
= cfgs
.back();
205 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
206 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
207 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
208 fprintf ( OUT
, "\r\n" );
212 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
216 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
220 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
222 fprintf ( OUT
, "\r\n" );
224 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
225 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
226 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
227 fprintf ( OUT
, "!MESSAGE \r\n" );
228 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
229 fprintf ( OUT
, "!MESSAGE \r\n" );
230 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
231 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
232 fprintf ( OUT
, "!MESSAGE \r\n" );
233 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
234 fprintf ( OUT
, "!MESSAGE \r\n" );
235 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
236 fprintf ( OUT
, "!MESSAGE \r\n" );
237 for ( i
= 0; i
< cfgs
.size(); i
++ )
239 const string
& cfg
= cfgs
[i
];
242 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
246 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
250 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
253 fprintf ( OUT
, "!MESSAGE \r\n" );
254 fprintf ( OUT
, "\r\n" );
256 fprintf ( OUT
, "# Begin Project\r\n" );
257 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
258 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
259 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
260 fprintf ( OUT
, "CPP=cl.exe\r\n" );
261 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
262 fprintf ( OUT
, "RSC=rc.exe\r\n" );
264 std::string output_dir
;
265 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
267 std::string
& cfg
= cfgs
[icfg
];
270 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
271 fprintf ( OUT
, "\r\n" );
275 fprintf ( OUT
, "\r\n" );
276 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
277 fprintf ( OUT
, "\r\n" );
280 bool debug
= !strstr ( cfg
.c_str(), "Release" );
281 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
283 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
287 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
291 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
294 output_dir
= Replace(cfg
,module
.name
+ " - ","");
295 output_dir
= Replace(output_dir
," ","_");
296 output_dir
= Replace(output_dir
,"C++","Cxx");
297 // TODO FIXME - wine hack?
298 //if ( output_prefix_dir.size() )
299 // output_dir = output_prefix_dir + "\\" + output_dir;
301 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
302 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
304 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
306 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
309 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
313 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
315 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
316 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
318 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
319 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
321 StringSet defines
= common_defines
;
325 defines
.insert ( "_DEBUG" );
328 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
329 defines
.insert ( "_LIB" );
333 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
334 defines
.insert ( "_WINDOWS" );
335 defines
.insert ( "_USRDLL" );
336 // TODO FIXME - wine hack?
337 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
342 defines
.insert ( "NDEBUG" );
345 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
346 defines
.insert ( "_LIB" );
350 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
351 defines
.insert ( "_WINDOWS" );
352 defines
.insert ( "_USRDLL" );
353 // TODO FIXME - wine hack?
354 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
358 for ( StringSet::const_iterator it1
=defines
.begin(); it1
!=defines
.end(); it1
++ )
360 fprintf ( OUT
, " /D \"%s\"", it1
->c_str() );
362 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
363 fprintf ( OUT
, " /FD" );
366 fprintf ( OUT
, " /GZ" );
367 if ( lib
|| exe
) fprintf ( OUT
, " " );
369 fprintf ( OUT
, " /c" );
370 fprintf ( OUT
, "\r\n" );
374 defines
.insert ( "_DEBUG" );
377 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
378 defines
.insert ( "_LIB" );
382 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
383 defines
.insert ( "_USRDLL" );
388 defines
.insert ( "NDEBUG" );
391 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
392 defines
.insert ( "_LIB" );
396 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
397 defines
.insert ( "_USRDLL" );
401 // TODO FIXME - wine hack?
404 // TODO FIXME - wine hack?
405 //defines.insert ( string("_\U") + module.name + "\E_" );
406 // TODO FIXME - wine hack?
407 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
408 defines.insert ( "__WINESRC__" );*/
410 defines
.insert ( "__WINE_USE_NATIVE_HEADERS" );
411 string output_dir2
= Replace(output_dir
,"\\","\\\\");
412 defines
.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
413 defines
.insert ( "__i386__" );
414 defines
.insert ( "_X86_" );
416 // TODO FIXME - wine hacks?
417 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
418 push @includes, ".." );
421 if ( strstr ( module.name.c_str(), "_test" )
423 include.push_back ( msvc_wine_dir + "\\" + output_dir );
426 if (!msvc_headers || module.name == "winetest")
428 includes.push_back ( wine_include_dir );
434 for ( i
= 0; i
< includes
.size(); i
++ )
436 const string
& include
= includes
[i
];
437 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
439 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
443 fprintf ( OUT
, " /I %s", include
.c_str() );
448 fprintf ( OUT
, " /I \".\"" );
449 for ( StringSet::const_iterator it2
=defines
.begin(); it2
!=defines
.end(); it2
++ )
451 const string
& define
= *it2
;
452 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
454 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
458 fprintf ( OUT
, " /D %s", define
.c_str() );
461 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
462 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
464 fprintf ( OUT
, lib
? " /YX" : " /FR" );
465 fprintf ( OUT
, " /FD" );
466 if ( debug
) fprintf ( OUT
, " /GZ" );
467 if ( debug
&& lib
) fprintf ( OUT
, " " );
468 fprintf ( OUT
, " /c" );
469 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
470 fprintf ( OUT
, "\r\n" );
476 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
477 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
478 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
480 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
481 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
484 for ( i
= 0; i
< includes
.size(); i
++ )
486 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
490 for ( StringSet::const_iterator it3
=defines
.begin(); it3
!=defines
.end(); it3
++ )
492 fprintf ( OUT
, " /D \"%s\"", it3
->c_str() );
494 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
500 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
501 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
502 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
504 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
505 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
508 for ( i
= 0; i
< includes
.size(); i
++ )
509 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
512 for ( StringSet::const_iterator it4
=defines
.begin(); it4
!=defines
.end(); it4
++ )
514 fprintf ( OUT
, " /D \"%s\"", it4
->c_str() );
518 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
520 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
521 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
522 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
526 fprintf ( OUT
, "LINK32=link.exe\r\n" );
527 fprintf ( OUT
, "# ADD BASE LINK32 " );
529 for ( i
= 0; i
< libraries
.size(); i
++ )
531 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
533 fprintf ( OUT
, " /nologo" );
534 if ( dll
) fprintf ( OUT
, " /dll" );
535 if ( console
) fprintf ( OUT
, " /subsystem:console" );
536 if ( debug
) fprintf ( OUT
, " /debug" );
537 fprintf ( OUT
, " /machine:I386" );
538 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
539 fprintf ( OUT
, "\r\n" );
541 fprintf ( OUT
, "# ADD LINK32" );
542 fprintf ( OUT
, " /nologo" );
543 // TODO FIXME - do we need their kludge?
544 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
545 for ( i
= 0; i
< imports
.size(); i
++ )
547 const string
& import
= imports
[i
];
548 if ( import
!= "msvcrt" )
549 fprintf ( OUT
, " %s.lib", import
.c_str() );
551 if ( dll
) fprintf ( OUT
, " /dll" );
552 if ( console
) fprintf ( OUT
, " /subsystem:console" );
553 if ( debug
) fprintf ( OUT
, " /debug" );
554 fprintf ( OUT
, " /machine:I386" );
555 // TODO FIXME - do we need their kludge?
556 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
557 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
558 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
559 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
560 fprintf ( OUT
, "\r\n" );
564 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
565 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
566 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
570 if ( cfgs
.size() != 0 )
572 fprintf ( OUT
, "\r\n" );
573 fprintf ( OUT
, "!ENDIF \r\n" );
574 fprintf ( OUT
, "\r\n" );
577 if ( module
.name
== "winebuild" )
579 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
580 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
581 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
582 fprintf ( OUT
, "PostBuild_Cmds=" );
583 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
584 output_dir
.c_str() );
585 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
586 output_dir
.c_str() );
587 fprintf ( OUT
, "# End Special Build Tool\r\n" );
590 fprintf ( OUT
, "# Begin Target\r\n" );
591 fprintf ( OUT
, "\r\n" );
592 for ( i
= 0; i
< cfgs
.size(); i
++ )
594 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
597 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
598 fprintf ( OUT
, "\r\n" );
599 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
601 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
603 string source_file
= DosSeparator(source_files
[isrcfile
]);
605 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
607 source_file
= string(".\\") + source_file
;
610 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
612 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
614 // TODO FIXME - not sure what this is doing? wine hack maybe?
615 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
616 string dbg_c_file
= basename
+ ".dbg.c";
618 fprintf ( OUT
, "# Begin Source File\r\n" );
619 fprintf ( OUT
, "\r\n" );
620 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
621 fprintf ( OUT
, "# End Source File\r\n" );
624 fprintf ( OUT
, "# Begin Source File\r\n" );
625 fprintf ( OUT
, "\r\n" );
627 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
629 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
632 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
634 string spec_file
= source_file
;
635 string def_file
= basename
+ ".def";
637 // TODO FIXME - not sure what this is doing? wine hack maybe?
638 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
639 string dbg_file
= basename
+ ".dbg";
640 string dbg_c_file
= basename
+ ".dbg.c";
642 string srcdir
= "."; // FIXME: Is this really always correct?
644 fprintf ( OUT
, "# Begin Custom Build\r\n" );
645 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
646 fprintf ( OUT
, "\r\n" );
647 fprintf ( OUT
, "BuildCmds= \\\r\n" );
648 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
653 if ( module
.name
== "ntdll" )
656 for ( i
= 0; i
< c_srcs
.size(); i
++ )
658 const string
& c_src
= c_srcs
[i
];
661 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
665 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
668 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
669 output_dir
.c_str() );
670 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
678 for ( i
= 0; i
< c_srcs
.size(); i
++ )
680 const string
& c_src
= c_srcs
[i
];
681 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
683 if ( sc_srcs
.size() )
689 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
690 output_dir
.c_str() );
691 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
697 fprintf ( OUT
, "\t\r\n" );
698 fprintf ( OUT
, "\r\n" );
699 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
700 fprintf ( OUT
, " $(BuildCmds)\r\n" );
701 fprintf ( OUT
, "\r\n" );
702 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
703 fprintf ( OUT
, " $(BuildCmds)\r\n" );
704 fprintf ( OUT
, "# End Custom Build\r\n" );
707 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
711 foreach my $cfg (@cfgs) {
715 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
716 fprintf ( OUT, "\r\n" );
718 fprintf ( OUT, "\r\n" );
719 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
720 fprintf ( OUT, "\r\n" );
724 $output_dir =~ s/^$project - //;
725 $output_dir =~ s/ /_/g;
726 $output_dir =~ s/C\+\+/Cxx/g;
727 if($output_prefix_dir) {
728 $output_dir = "$output_prefix_dir\\$output_dir" );
731 fprintf ( OUT, "# Begin Custom Build\r\n" );
732 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
733 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
734 fprintf ( OUT, "\r\n" );
735 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
736 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
737 fprintf ( OUT, "\r\n" );
738 fprintf ( OUT, "# End Custom Build\r\n" );
741 if ( cfgs.size() != 0)
743 fprintf ( OUT, "\r\n" );
744 fprintf ( OUT, "!ENDIF \r\n" );
745 fprintf ( OUT, "\r\n" );
749 fprintf ( OUT
, "# End Source File\r\n" );
751 fprintf ( OUT
, "# End Group\r\n" );
752 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
753 fprintf ( OUT
, "\r\n" );
754 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
755 for ( i
= 0; i
< header_files
.size(); i
++ )
757 const string
& header_file
= header_files
[i
];
758 fprintf ( OUT
, "# Begin Source File\r\n" );
759 fprintf ( OUT
, "\r\n" );
760 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
761 fprintf ( OUT
, "# End Source File\r\n" );
763 fprintf ( OUT
, "# End Group\r\n" );
767 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
768 fprintf ( OUT
, "\r\n" );
769 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
770 /* for ( i = 0; i < resource_files.size(); i++ )
772 const string& resource_file = resource_files[i];
773 fprintf ( OUT, "# Begin Source File\r\n" );
774 fprintf ( OUT, "\r\n" );
775 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
776 fprintf ( OUT, "# End Source File\r\n" );
778 */ fprintf ( OUT
, "# End Group\r\n" );
780 fprintf ( OUT
, "# End Target\r\n" );
781 fprintf ( OUT
, "# End Project\r\n" );
787 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
789 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
790 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
791 fprintf ( OUT
, "\r\n" );
795 MSVCBackend::_generate_dsw_project (
797 const Module
& module
,
798 std::string dsp_file
,
799 const std::vector
<Dependency
*>& dependencies
)
801 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
803 // TODO FIXME - must they be sorted?
804 //@dependencies = sort(@dependencies);
806 fprintf ( OUT
, "###############################################################################\r\n" );
807 fprintf ( OUT
, "\r\n" );
808 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
809 fprintf ( OUT
, "\r\n" );
810 fprintf ( OUT
, "Package=<5>\r\n" );
811 fprintf ( OUT
, "{{{\r\n" );
812 fprintf ( OUT
, "}}}\r\n" );
813 fprintf ( OUT
, "\r\n" );
814 fprintf ( OUT
, "Package=<4>\r\n" );
815 fprintf ( OUT
, "{{{\r\n" );
816 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
818 Dependency
& dependency
= *dependencies
[i
];
819 fprintf ( OUT
, " Begin Project Dependency\r\n" );
820 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
821 fprintf ( OUT
, " End Project Dependency\r\n" );
823 fprintf ( OUT
, "}}}\r\n" );
824 fprintf ( OUT
, "\r\n" );
828 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
830 fprintf ( OUT
, "###############################################################################\r\n" );
831 fprintf ( OUT
, "\r\n" );
832 fprintf ( OUT
, "Global:\r\n" );
833 fprintf ( OUT
, "\r\n" );
834 fprintf ( OUT
, "Package=<5>\r\n" );
835 fprintf ( OUT
, "{{{\r\n" );
836 fprintf ( OUT
, "}}}\r\n" );
837 fprintf ( OUT
, "\r\n" );
838 fprintf ( OUT
, "Package=<3>\r\n" );
839 fprintf ( OUT
, "{{{\r\n" );
840 fprintf ( OUT
, "}}}\r\n" );
841 fprintf ( OUT
, "\r\n" );
842 fprintf ( OUT
, "###############################################################################\r\n" );
843 fprintf ( OUT
, "\r\n" );
847 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
849 _generate_dsw_header(OUT
);
850 // TODO FIXME - is it necessary to sort them?
851 for( std::map
<std::string
, Module
*>::const_iterator p
= ProjectNode
.modules
.begin(); p
!= ProjectNode
.modules
.end(); ++ p
)
853 Module
& module
= *p
->second
;
855 std::string dsp_file
= DspFileName ( module
);
857 // TODO FIXME - more wine hacks?
858 /*if ( module.name == "gdi32" )
860 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
862 string dir2 = gdi32_dirs[idir];
863 $dir2 =~ s%^.*?/([^/]+)$%$1%;
865 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
869 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
871 _generate_dsw_footer ( OUT
);