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 )
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 // TODO FIXME - refactor needed - we're discarding if conditions
99 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
100 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
101 const vector
<File
*>& files
= data
.files
;
102 for ( i
= 0; i
< files
.size(); i
++ )
104 if (files
[i
]->file
.directory
!= SourceDirectory
)
107 // We want the full path here for directory support later on
108 string path
= Path::RelativeFromDirectory (
109 files
[i
]->file
.relative_path
,
110 module
.output
->relative_path
);
111 string file
= path
+ std::string("\\") + files
[i
]->file
.name
;
113 source_files
.push_back ( file
);
114 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
115 c_srcs
.push_back ( file
);
116 if ( !stricmp ( Right(file
,2).c_str(), ".h" ) )
117 header_files
.push_back ( file
);
118 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
119 resource_files
.push_back ( file
);
121 const vector
<Include
*>& incs
= data
.includes
;
122 for ( i
= 0; i
< incs
.size(); i
++ )
125 // explicitly omit win32api directories
126 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "w32api", 6 ) )
129 // explicitly omit include/wine directories
130 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "include\\wine", 12 ) )
133 string path
= Path::RelativeFromDirectory (
134 incs
[i
]->directory
->relative_path
,
135 module
.output
->relative_path
);
136 includes
.push_back ( path
);
138 const vector
<Library
*>& libs
= data
.libraries
;
139 for ( i
= 0; i
< libs
.size(); i
++ )
141 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
143 const vector
<Define
*>& defs
= data
.defines
;
144 for ( i
= 0; i
< defs
.size(); i
++ )
146 if ( defs
[i
]->value
[0] )
147 common_defines
.insert( defs
[i
]->name
+ "=" + defs
[i
]->value
);
149 common_defines
.insert( defs
[i
]->name
);
152 // TODO FIXME - we don't include header files in our build system
153 //my @header_files = @{module->{header_files}};
154 //vector<string> header_files;
156 // TODO FIXME - wine hack?
157 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
158 module.name !~ /^(?:gdi32)_.+?$/ &&
159 Right ( module.name, 5 ) == "_test" )
161 source_files.push_back ( module.name + ".spec" );
162 @source_files = sort(@source_files);
166 bool no_msvc_headers
= true;
167 // TODO FIXME - wine hack?
168 /*if (module.name =~ /^wine(?:runtests|test)$/
169 || Right ( module.name, 5 ) == "_test" )
171 no_msvc_headers = false;
174 std::vector
<std::string
> cfgs
;
176 cfgs
.push_back ( module
.name
+ " - Win32" );
180 std::vector
<std::string
> _cfgs
;
181 for ( i
= 0; i
< cfgs
.size(); i
++ )
183 _cfgs
.push_back ( cfgs
[i
] + " C" );
184 _cfgs
.push_back ( cfgs
[i
] + " C++" );
190 // TODO FIXME - wine hack?
193 std::vector<std::string> _cfgs;
194 for ( i = 0; i < cfgs.size(); i++ )
196 _cfgs.push_back ( cfgs[i] + " Debug" );
197 _cfgs.push_back ( cfgs[i] + " Release" );
203 if (!no_msvc_headers
)
205 std::vector
<std::string
> _cfgs
;
206 for ( i
= 0; i
< cfgs
.size(); i
++ )
208 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
209 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
215 string default_cfg
= cfgs
.back();
217 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
218 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
219 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
220 fprintf ( OUT
, "\r\n" );
224 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
228 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
232 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
234 fprintf ( OUT
, "\r\n" );
236 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
237 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
238 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
239 fprintf ( OUT
, "!MESSAGE \r\n" );
240 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
241 fprintf ( OUT
, "!MESSAGE \r\n" );
242 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
243 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
244 fprintf ( OUT
, "!MESSAGE \r\n" );
245 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
246 fprintf ( OUT
, "!MESSAGE \r\n" );
247 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
248 fprintf ( OUT
, "!MESSAGE \r\n" );
249 for ( i
= 0; i
< cfgs
.size(); i
++ )
251 const string
& cfg
= cfgs
[i
];
254 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
258 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
262 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
265 fprintf ( OUT
, "!MESSAGE \r\n" );
266 fprintf ( OUT
, "\r\n" );
268 fprintf ( OUT
, "# Begin Project\r\n" );
269 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
270 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
271 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
272 fprintf ( OUT
, "CPP=cl.exe\r\n" );
273 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
274 fprintf ( OUT
, "RSC=rc.exe\r\n" );
276 std::string output_dir
;
277 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
279 std::string
& cfg
= cfgs
[icfg
];
282 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
283 fprintf ( OUT
, "\r\n" );
287 fprintf ( OUT
, "\r\n" );
288 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
289 fprintf ( OUT
, "\r\n" );
292 bool debug
= !strstr ( cfg
.c_str(), "Release" );
293 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
295 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
299 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
303 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
306 output_dir
= Replace(cfg
,module
.name
+ " - ","");
307 output_dir
= Replace(output_dir
," ","_");
308 output_dir
= Replace(output_dir
,"C++","Cxx");
309 // TODO FIXME - wine hack?
310 //if ( output_prefix_dir.size() )
311 // output_dir = output_prefix_dir + "\\" + output_dir;
313 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
314 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
316 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
318 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
321 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
325 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
327 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
328 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
330 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
331 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
333 StringSet defines
= common_defines
;
337 defines
.insert ( "_DEBUG" );
340 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
341 defines
.insert ( "_LIB" );
345 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
346 defines
.insert ( "_WINDOWS" );
347 defines
.insert ( "_USRDLL" );
348 // TODO FIXME - wine hack?
349 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
354 defines
.insert ( "NDEBUG" );
357 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
358 defines
.insert ( "_LIB" );
362 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
363 defines
.insert ( "_WINDOWS" );
364 defines
.insert ( "_USRDLL" );
365 // TODO FIXME - wine hack?
366 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
370 for ( StringSet::const_iterator it1
=defines
.begin(); it1
!=defines
.end(); it1
++ )
372 fprintf ( OUT
, " /D \"%s\"", it1
->c_str() );
374 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
375 fprintf ( OUT
, " /FD" );
378 fprintf ( OUT
, " /GZ" );
379 if ( lib
|| exe
) fprintf ( OUT
, " " );
381 fprintf ( OUT
, " /c" );
382 fprintf ( OUT
, "\r\n" );
386 defines
.insert ( "_DEBUG" );
389 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
390 defines
.insert ( "_LIB" );
394 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
395 defines
.insert ( "_USRDLL" );
400 defines
.insert ( "NDEBUG" );
403 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
404 defines
.insert ( "_LIB" );
408 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
409 defines
.insert ( "_USRDLL" );
413 // TODO FIXME - wine hack?
416 // TODO FIXME - wine hack?
417 //defines.insert ( string("_\U") + module.name + "\E_" );
418 // TODO FIXME - wine hack?
419 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
420 defines.insert ( "__WINESRC__" );*/
422 defines
.insert ( "__WINE_USE_NATIVE_HEADERS" );
423 string output_dir2
= Replace(output_dir
,"\\","\\\\");
424 defines
.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
425 defines
.insert ( "__i386__" );
426 defines
.insert ( "_X86_" );
428 // TODO FIXME - wine hacks?
429 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
430 push @includes, ".." );
433 if ( strstr ( module.name.c_str(), "_test" )
435 include.push_back ( msvc_wine_dir + "\\" + output_dir );
438 if (!msvc_headers || module.name == "winetest")
440 includes.push_back ( wine_include_dir );
446 for ( i
= 0; i
< includes
.size(); i
++ )
448 const string
& include
= includes
[i
];
449 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
451 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
455 fprintf ( OUT
, " /I %s", include
.c_str() );
460 fprintf ( OUT
, " /I \".\"" );
461 for ( StringSet::const_iterator it2
=defines
.begin(); it2
!=defines
.end(); it2
++ )
463 const string
& define
= *it2
;
464 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
466 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
470 fprintf ( OUT
, " /D %s", define
.c_str() );
473 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
474 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
476 fprintf ( OUT
, lib
? " /YX" : " /FR" );
477 fprintf ( OUT
, " /FD" );
478 if ( debug
) fprintf ( OUT
, " /GZ" );
479 if ( debug
&& lib
) fprintf ( OUT
, " " );
480 fprintf ( OUT
, " /c" );
481 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
482 fprintf ( OUT
, "\r\n" );
488 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
489 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
490 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
492 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
493 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
496 for ( i
= 0; i
< includes
.size(); i
++ )
498 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
502 for ( StringSet::const_iterator it3
=defines
.begin(); it3
!=defines
.end(); it3
++ )
504 fprintf ( OUT
, " /D \"%s\"", it3
->c_str() );
506 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
512 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
513 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
514 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
516 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
517 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
520 for ( i
= 0; i
< includes
.size(); i
++ )
521 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
524 for ( StringSet::const_iterator it4
=defines
.begin(); it4
!=defines
.end(); it4
++ )
526 fprintf ( OUT
, " /D \"%s\"", it4
->c_str() );
530 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
532 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
533 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
534 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
538 fprintf ( OUT
, "LINK32=link.exe\r\n" );
539 fprintf ( OUT
, "# ADD BASE LINK32 " );
541 for ( i
= 0; i
< libraries
.size(); i
++ )
543 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
545 fprintf ( OUT
, " /nologo" );
546 if ( dll
) fprintf ( OUT
, " /dll" );
547 if ( console
) fprintf ( OUT
, " /subsystem:console" );
548 if ( debug
) fprintf ( OUT
, " /debug" );
549 fprintf ( OUT
, " /machine:I386" );
550 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
551 fprintf ( OUT
, "\r\n" );
553 fprintf ( OUT
, "# ADD LINK32" );
554 fprintf ( OUT
, " /nologo" );
555 // TODO FIXME - do we need their kludge?
556 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
557 for ( i
= 0; i
< imports
.size(); i
++ )
559 const string
& import
= imports
[i
];
560 if ( import
!= "msvcrt" )
561 fprintf ( OUT
, " %s.lib", import
.c_str() );
563 if ( dll
) fprintf ( OUT
, " /dll" );
564 if ( console
) fprintf ( OUT
, " /subsystem:console" );
565 if ( debug
) fprintf ( OUT
, " /debug" );
566 fprintf ( OUT
, " /machine:I386" );
567 // TODO FIXME - do we need their kludge?
568 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
569 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
570 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
571 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
572 fprintf ( OUT
, "\r\n" );
576 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
577 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
578 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
582 if ( cfgs
.size() != 0 )
584 fprintf ( OUT
, "\r\n" );
585 fprintf ( OUT
, "!ENDIF \r\n" );
586 fprintf ( OUT
, "\r\n" );
589 if ( module
.name
== "winebuild" )
591 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
592 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
593 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
594 fprintf ( OUT
, "PostBuild_Cmds=" );
595 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
596 output_dir
.c_str() );
597 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
598 output_dir
.c_str() );
599 fprintf ( OUT
, "# End Special Build Tool\r\n" );
602 fprintf ( OUT
, "# Begin Target\r\n" );
603 fprintf ( OUT
, "\r\n" );
604 for ( i
= 0; i
< cfgs
.size(); i
++ )
606 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
609 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
610 fprintf ( OUT
, "\r\n" );
611 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
613 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
615 string source_file
= DosSeparator(source_files
[isrcfile
]);
617 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
619 source_file
= string(".\\") + source_file
;
622 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
624 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
626 // TODO FIXME - not sure what this is doing? wine hack maybe?
627 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
628 string dbg_c_file
= basename
+ ".dbg.c";
630 fprintf ( OUT
, "# Begin Source File\r\n" );
631 fprintf ( OUT
, "\r\n" );
632 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
633 fprintf ( OUT
, "# End Source File\r\n" );
636 fprintf ( OUT
, "# Begin Source File\r\n" );
637 fprintf ( OUT
, "\r\n" );
639 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
641 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
644 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
646 string spec_file
= source_file
;
647 string def_file
= basename
+ ".def";
649 // TODO FIXME - not sure what this is doing? wine hack maybe?
650 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
651 string dbg_file
= basename
+ ".dbg";
652 string dbg_c_file
= basename
+ ".dbg.c";
654 string srcdir
= "."; // FIXME: Is this really always correct?
656 fprintf ( OUT
, "# Begin Custom Build\r\n" );
657 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
658 fprintf ( OUT
, "\r\n" );
659 fprintf ( OUT
, "BuildCmds= \\\r\n" );
660 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
665 if ( module
.name
== "ntdll" )
668 for ( i
= 0; i
< c_srcs
.size(); i
++ )
670 const string
& c_src
= c_srcs
[i
];
673 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
677 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
680 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
681 output_dir
.c_str() );
682 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
690 for ( i
= 0; i
< c_srcs
.size(); i
++ )
692 const string
& c_src
= c_srcs
[i
];
693 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
695 if ( sc_srcs
.size() )
701 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
702 output_dir
.c_str() );
703 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
709 fprintf ( OUT
, "\t\r\n" );
710 fprintf ( OUT
, "\r\n" );
711 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
712 fprintf ( OUT
, " $(BuildCmds)\r\n" );
713 fprintf ( OUT
, "\r\n" );
714 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
715 fprintf ( OUT
, " $(BuildCmds)\r\n" );
716 fprintf ( OUT
, "# End Custom Build\r\n" );
719 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
723 foreach my $cfg (@cfgs) {
727 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
728 fprintf ( OUT, "\r\n" );
730 fprintf ( OUT, "\r\n" );
731 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
732 fprintf ( OUT, "\r\n" );
736 $output_dir =~ s/^$project - //;
737 $output_dir =~ s/ /_/g;
738 $output_dir =~ s/C\+\+/Cxx/g;
739 if($output_prefix_dir) {
740 $output_dir = "$output_prefix_dir\\$output_dir" );
743 fprintf ( OUT, "# Begin Custom Build\r\n" );
744 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
745 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
746 fprintf ( OUT, "\r\n" );
747 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
748 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
749 fprintf ( OUT, "\r\n" );
750 fprintf ( OUT, "# End Custom Build\r\n" );
753 if ( cfgs.size() != 0)
755 fprintf ( OUT, "\r\n" );
756 fprintf ( OUT, "!ENDIF \r\n" );
757 fprintf ( OUT, "\r\n" );
761 fprintf ( OUT
, "# End Source File\r\n" );
763 fprintf ( OUT
, "# End Group\r\n" );
764 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
765 fprintf ( OUT
, "\r\n" );
766 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
767 for ( i
= 0; i
< header_files
.size(); i
++ )
769 const string
& header_file
= header_files
[i
];
770 fprintf ( OUT
, "# Begin Source File\r\n" );
771 fprintf ( OUT
, "\r\n" );
772 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
773 fprintf ( OUT
, "# End Source File\r\n" );
775 fprintf ( OUT
, "# End Group\r\n" );
779 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
780 fprintf ( OUT
, "\r\n" );
781 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
782 /* for ( i = 0; i < resource_files.size(); i++ )
784 const string& resource_file = resource_files[i];
785 fprintf ( OUT, "# Begin Source File\r\n" );
786 fprintf ( OUT, "\r\n" );
787 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
788 fprintf ( OUT, "# End Source File\r\n" );
790 */ fprintf ( OUT
, "# End Group\r\n" );
792 fprintf ( OUT
, "# End Target\r\n" );
793 fprintf ( OUT
, "# End Project\r\n" );
799 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
801 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
802 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
803 fprintf ( OUT
, "\r\n" );
807 MSVCBackend::_generate_dsw_project (
809 const Module
& module
,
810 std::string dsp_file
,
811 const std::vector
<Dependency
*>& dependencies
)
813 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
815 // TODO FIXME - must they be sorted?
816 //@dependencies = sort(@dependencies);
818 fprintf ( OUT
, "###############################################################################\r\n" );
819 fprintf ( OUT
, "\r\n" );
820 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
821 fprintf ( OUT
, "\r\n" );
822 fprintf ( OUT
, "Package=<5>\r\n" );
823 fprintf ( OUT
, "{{{\r\n" );
824 fprintf ( OUT
, "}}}\r\n" );
825 fprintf ( OUT
, "\r\n" );
826 fprintf ( OUT
, "Package=<4>\r\n" );
827 fprintf ( OUT
, "{{{\r\n" );
828 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
830 Dependency
& dependency
= *dependencies
[i
];
831 fprintf ( OUT
, " Begin Project Dependency\r\n" );
832 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
833 fprintf ( OUT
, " End Project Dependency\r\n" );
835 fprintf ( OUT
, "}}}\r\n" );
836 fprintf ( OUT
, "\r\n" );
840 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
842 fprintf ( OUT
, "###############################################################################\r\n" );
843 fprintf ( OUT
, "\r\n" );
844 fprintf ( OUT
, "Global:\r\n" );
845 fprintf ( OUT
, "\r\n" );
846 fprintf ( OUT
, "Package=<5>\r\n" );
847 fprintf ( OUT
, "{{{\r\n" );
848 fprintf ( OUT
, "}}}\r\n" );
849 fprintf ( OUT
, "\r\n" );
850 fprintf ( OUT
, "Package=<3>\r\n" );
851 fprintf ( OUT
, "{{{\r\n" );
852 fprintf ( OUT
, "}}}\r\n" );
853 fprintf ( OUT
, "\r\n" );
854 fprintf ( OUT
, "###############################################################################\r\n" );
855 fprintf ( OUT
, "\r\n" );
859 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
861 _generate_dsw_header(OUT
);
862 // TODO FIXME - is it necessary to sort them?
863 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
865 Module
& module
= *ProjectNode
.modules
[i
];
867 std::string dsp_file
= DspFileName ( module
);
869 // TODO FIXME - more wine hacks?
870 /*if ( module.name == "gdi32" )
872 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
874 string dir2 = gdi32_dirs[idir];
875 $dir2 =~ s%^.*?/([^/]+)$%$1%;
877 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
881 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
883 _generate_dsw_footer ( OUT
);