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 )
39 MSVCBackend::_generate_dsp ( const Module
& module
)
42 // TODO FIXME wine hack?
43 const bool wine
= false;
45 string dsp_file
= DspFileName(module
);
46 printf ( "Creating MSVC project: '%s'\n", dsp_file
.c_str() );
47 FILE* OUT
= fopen ( dsp_file
.c_str(), "wb" );
49 vector
<string
> imports
;
50 for ( i
= 0; i
< module
.non_if_data
.libraries
.size(); i
++ )
52 imports
.push_back ( module
.non_if_data
.libraries
[i
]->name
);
55 string module_type
= GetExtension(module
.GetTargetName());
56 bool lib
= (module_type
== ".lib") || (module_type
== ".a");
57 bool dll
= (module_type
== ".dll") || (module_type
== ".cpl");
58 bool exe
= (module_type
== ".exe");
59 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
61 bool console
= exe
&& (module
.type
== Win32CUI
);
63 // TODO FIXME - not sure if the count here is right...
65 const char* p
= strpbrk ( dsp_file
.c_str(), "/\\" );
69 p
= strpbrk ( p
+1, "/\\" );
71 string msvc_wine_dir
= "..";
73 msvc_wine_dir
+= "\\..";
75 string wine_include_dir
= msvc_wine_dir
+ "\\include";
77 //$progress_current++;
78 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
80 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
81 string dsp_path
= module
.GetBasePath();
82 vector
<string
> c_srcs
, source_files
, resource_files
, includes
, libraries
, defines
;
83 vector
<const IfableData
*> ifs_list
;
84 ifs_list
.push_back ( &module
.project
.non_if_data
);
85 ifs_list
.push_back ( &module
.non_if_data
);
87 // this is a define in MinGW w32api, but not Microsoft's headers
88 defines
.push_back ( "STDCALL=__stdcall" );
90 while ( ifs_list
.size() )
92 const IfableData
& data
= *ifs_list
.back();
94 // TODO FIXME - refactor needed - we're discarding if conditions
95 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
96 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
97 const vector
<File
*>& files
= data
.files
;
98 for ( i
= 0; i
< files
.size(); i
++ )
100 // TODO FIXME - do we want the full path of the file here?
101 string file
= string(".") + &files
[i
]->name
[dsp_path
.size()];
103 source_files
.push_back ( file
);
104 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
105 c_srcs
.push_back ( file
);
106 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
107 resource_files
.push_back ( file
);
109 const vector
<Include
*>& incs
= data
.includes
;
110 for ( i
= 0; i
< incs
.size(); i
++ )
113 // explicitly omit win32api directories
114 if ( !strncmp(incs
[i
]->directory
.c_str(), "w32api", 6 ) )
117 // explicitly omit include/wine directories
118 if ( !strncmp(incs
[i
]->directory
.c_str(), "include\\wine", 12 ) )
121 string path
= Path::RelativeFromDirectory (
123 module
.GetBasePath() );
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 defines
.push_back ( defs
[i
]->name
+ "=" + defs
[i
]->value
);
137 defines
.push_back ( 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" );
323 defines
.push_back ( "_DEBUG" );
326 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
327 defines
.push_back ( "_LIB" );
331 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
332 defines
.push_back ( "_WINDOWS" );
333 defines
.push_back ( "_USRDLL" );
334 // TODO FIXME - wine hack?
335 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
340 defines
.push_back ( "NDEBUG" );
343 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
344 defines
.push_back ( "_LIB" );
348 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
349 defines
.push_back ( "_WINDOWS" );
350 defines
.push_back ( "_USRDLL" );
351 // TODO FIXME - wine hack?
352 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
356 for ( i
= 0; i
< defines
.size(); i
++ )
358 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
360 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
361 fprintf ( OUT
, " /FD" );
364 fprintf ( OUT
, " /GZ" );
365 if ( lib
|| exe
) fprintf ( OUT
, " " );
367 fprintf ( OUT
, " /c" );
368 fprintf ( OUT
, "\r\n" );
370 vector
<string
> defines2
= defines
;
373 defines2
.push_back ( "_DEBUG" );
376 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
377 defines2
.push_back ( "_LIB" );
381 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
382 defines2
.push_back ( "_USRDLL" );
387 defines2
.push_back ( "NDEBUG" );
390 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
391 defines2
.push_back ( "_LIB" );
395 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
396 defines2
.push_back ( "_USRDLL" );
400 // TODO FIXME - wine hack?
403 // TODO FIXME - wine hack?
404 //defines2.push_back ( string("_\U") + module.name + "\E_" );
405 // TODO FIXME - wine hack?
406 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
407 defines2.push_back ( "__WINESRC__" );*/
409 defines2
.push_back ( "__WINE_USE_NATIVE_HEADERS" );
410 string output_dir2
= Replace(output_dir
,"\\","\\\\");
411 defines2
.push_back ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
412 defines2
.push_back ( "__i386__" );
413 defines2
.push_back ( "_X86_" );
415 // TODO FIXME - wine hacks?
416 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
417 push @includes, ".." );
420 if ( strstr ( module.name.c_str(), "_test" )
422 include.push_back ( msvc_wine_dir + "\\" + output_dir );
425 if (!msvc_headers || module.name == "winetest")
427 includes.push_back ( wine_include_dir );
433 for ( i
= 0; i
< includes
.size(); i
++ )
435 const string
& include
= includes
[i
];
436 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
438 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
442 fprintf ( OUT
, " /I %s", include
.c_str() );
447 fprintf ( OUT
, " /I \".\"" );
448 for ( i
= 0; i
< defines2
.size(); i
++ )
450 const string
& define
= defines2
[i
];
451 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
453 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
457 fprintf ( OUT
, " /D %s", define
.c_str() );
460 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
461 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
463 fprintf ( OUT
, lib
? " /YX" : " /FR" );
464 fprintf ( OUT
, " /FD" );
465 if ( debug
) fprintf ( OUT
, " /GZ" );
466 if ( debug
&& lib
) fprintf ( OUT
, " " );
467 fprintf ( OUT
, " /c" );
468 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
469 fprintf ( OUT
, "\r\n" );
475 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
476 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
477 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
479 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
480 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
483 for ( i
= 0; i
< includes
.size(); i
++ )
485 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
489 for ( i
= 0; i
< defines
.size(); i
++ )
491 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
493 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
499 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
500 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
501 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
503 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
504 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
507 for ( i
= 0; i
< includes
.size(); i
++ )
508 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
511 for ( i
= 0; i
< defines
.size(); i
++ )
513 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
517 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
519 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
520 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
521 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
525 fprintf ( OUT
, "LINK32=link.exe\r\n" );
526 fprintf ( OUT
, "# ADD BASE LINK32 " );
528 for ( i
= 0; i
< libraries
.size(); i
++ )
530 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
532 fprintf ( OUT
, " /nologo" );
533 if ( dll
) fprintf ( OUT
, " /dll" );
534 if ( console
) fprintf ( OUT
, " /subsystem:console" );
535 if ( debug
) fprintf ( OUT
, " /debug" );
536 fprintf ( OUT
, " /machine:I386" );
537 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
538 fprintf ( OUT
, "\r\n" );
540 fprintf ( OUT
, "# ADD LINK32" );
541 fprintf ( OUT
, " /nologo" );
542 // TODO FIXME - do we need their kludge?
543 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
544 for ( i
= 0; i
< imports
.size(); i
++ )
546 const string
& import
= imports
[i
];
547 if ( import
!= "msvcrt" )
548 fprintf ( OUT
, " %s.lib", import
.c_str() );
550 if ( dll
) fprintf ( OUT
, " /dll" );
551 if ( console
) fprintf ( OUT
, " /subsystem:console" );
552 if ( debug
) fprintf ( OUT
, " /debug" );
553 fprintf ( OUT
, " /machine:I386" );
554 // TODO FIXME - do we need their kludge?
555 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
556 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
557 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
558 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
559 fprintf ( OUT
, "\r\n" );
563 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
564 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
565 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
569 if ( cfgs
.size() != 0 )
571 fprintf ( OUT
, "\r\n" );
572 fprintf ( OUT
, "!ENDIF \r\n" );
573 fprintf ( OUT
, "\r\n" );
576 if ( module
.name
== "winebuild" )
578 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
579 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
580 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
581 fprintf ( OUT
, "PostBuild_Cmds=" );
582 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
583 output_dir
.c_str() );
584 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
585 output_dir
.c_str() );
586 fprintf ( OUT
, "# End Special Build Tool\r\n" );
589 fprintf ( OUT
, "# Begin Target\r\n" );
590 fprintf ( OUT
, "\r\n" );
591 for ( i
= 0; i
< cfgs
.size(); i
++ )
593 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
596 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
597 fprintf ( OUT
, "\r\n" );
598 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
600 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
602 string source_file
= DosSeparator(source_files
[isrcfile
]);
604 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
606 source_file
= string(".\\") + source_file
;
609 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
611 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
613 // TODO FIXME - not sure what this is doing? wine hack maybe?
614 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
615 string dbg_c_file
= basename
+ ".dbg.c";
617 fprintf ( OUT
, "# Begin Source File\r\n" );
618 fprintf ( OUT
, "\r\n" );
619 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
620 fprintf ( OUT
, "# End Source File\r\n" );
623 fprintf ( OUT
, "# Begin Source File\r\n" );
624 fprintf ( OUT
, "\r\n" );
626 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
628 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
631 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
633 string spec_file
= source_file
;
634 string def_file
= basename
+ ".def";
636 // TODO FIXME - not sure what this is doing? wine hack maybe?
637 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
638 string dbg_file
= basename
+ ".dbg";
639 string dbg_c_file
= basename
+ ".dbg.c";
641 string srcdir
= "."; // FIXME: Is this really always correct?
643 fprintf ( OUT
, "# Begin Custom Build\r\n" );
644 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
645 fprintf ( OUT
, "\r\n" );
646 fprintf ( OUT
, "BuildCmds= \\\r\n" );
647 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
652 if ( module
.name
== "ntdll" )
655 for ( i
= 0; i
< c_srcs
.size(); i
++ )
657 const string
& c_src
= c_srcs
[i
];
660 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
664 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
667 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
668 output_dir
.c_str() );
669 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
677 for ( i
= 0; i
< c_srcs
.size(); i
++ )
679 const string
& c_src
= c_srcs
[i
];
680 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
682 if ( sc_srcs
.size() )
688 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
689 output_dir
.c_str() );
690 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
696 fprintf ( OUT
, "\t\r\n" );
697 fprintf ( OUT
, "\r\n" );
698 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
699 fprintf ( OUT
, " $(BuildCmds)\r\n" );
700 fprintf ( OUT
, "\r\n" );
701 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
702 fprintf ( OUT
, " $(BuildCmds)\r\n" );
703 fprintf ( OUT
, "# End Custom Build\r\n" );
706 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
710 foreach my $cfg (@cfgs) {
714 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
715 fprintf ( OUT, "\r\n" );
717 fprintf ( OUT, "\r\n" );
718 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
719 fprintf ( OUT, "\r\n" );
723 $output_dir =~ s/^$project - //;
724 $output_dir =~ s/ /_/g;
725 $output_dir =~ s/C\+\+/Cxx/g;
726 if($output_prefix_dir) {
727 $output_dir = "$output_prefix_dir\\$output_dir" );
730 fprintf ( OUT, "# Begin Custom Build\r\n" );
731 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
732 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
733 fprintf ( OUT, "\r\n" );
734 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
735 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
736 fprintf ( OUT, "\r\n" );
737 fprintf ( OUT, "# End Custom Build\r\n" );
740 if ( cfgs.size() != 0)
742 fprintf ( OUT, "\r\n" );
743 fprintf ( OUT, "!ENDIF \r\n" );
744 fprintf ( OUT, "\r\n" );
748 fprintf ( OUT
, "# End Source File\r\n" );
750 fprintf ( OUT
, "# End Group\r\n" );
751 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
752 fprintf ( OUT
, "\r\n" );
753 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
754 for ( i
= 0; i
< header_files
.size(); i
++ )
756 const string
& header_file
= header_files
[i
];
757 fprintf ( OUT
, "# Begin Source File\r\n" );
758 fprintf ( OUT
, "\r\n" );
759 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
760 fprintf ( OUT
, "# End Source File\r\n" );
762 fprintf ( OUT
, "# End Group\r\n" );
766 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
767 fprintf ( OUT
, "\r\n" );
768 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
769 /* for ( i = 0; i < resource_files.size(); i++ )
771 const string& resource_file = resource_files[i];
772 fprintf ( OUT, "# Begin Source File\r\n" );
773 fprintf ( OUT, "\r\n" );
774 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
775 fprintf ( OUT, "# End Source File\r\n" );
777 */ fprintf ( OUT
, "# End Group\r\n" );
779 fprintf ( OUT
, "# End Target\r\n" );
780 fprintf ( OUT
, "# End Project\r\n" );
786 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
788 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
789 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
790 fprintf ( OUT
, "\r\n" );
794 MSVCBackend::_generate_dsw_project (
796 const Module
& module
,
797 std::string dsp_file
,
798 const std::vector
<Dependency
*>& dependencies
)
800 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
802 // TODO FIXME - must they be sorted?
803 //@dependencies = sort(@dependencies);
805 fprintf ( OUT
, "###############################################################################\r\n" );
806 fprintf ( OUT
, "\r\n" );
807 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
808 fprintf ( OUT
, "\r\n" );
809 fprintf ( OUT
, "Package=<5>\r\n" );
810 fprintf ( OUT
, "{{{\r\n" );
811 fprintf ( OUT
, "}}}\r\n" );
812 fprintf ( OUT
, "\r\n" );
813 fprintf ( OUT
, "Package=<4>\r\n" );
814 fprintf ( OUT
, "{{{\r\n" );
815 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
817 Dependency
& dependency
= *dependencies
[i
];
818 fprintf ( OUT
, " Begin Project Dependency\r\n" );
819 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
820 fprintf ( OUT
, " End Project Dependency\r\n" );
822 fprintf ( OUT
, "}}}\r\n" );
823 fprintf ( OUT
, "\r\n" );
827 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
829 fprintf ( OUT
, "###############################################################################\r\n" );
830 fprintf ( OUT
, "\r\n" );
831 fprintf ( OUT
, "Global:\r\n" );
832 fprintf ( OUT
, "\r\n" );
833 fprintf ( OUT
, "Package=<5>\r\n" );
834 fprintf ( OUT
, "{{{\r\n" );
835 fprintf ( OUT
, "}}}\r\n" );
836 fprintf ( OUT
, "\r\n" );
837 fprintf ( OUT
, "Package=<3>\r\n" );
838 fprintf ( OUT
, "{{{\r\n" );
839 fprintf ( OUT
, "}}}\r\n" );
840 fprintf ( OUT
, "\r\n" );
841 fprintf ( OUT
, "###############################################################################\r\n" );
842 fprintf ( OUT
, "\r\n" );
846 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
848 _generate_dsw_header(OUT
);
849 // TODO FIXME - is it necessary to sort them?
850 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
852 Module
& module
= *ProjectNode
.modules
[i
];
854 std::string dsp_file
= DspFileName ( module
);
856 // TODO FIXME - more wine hacks?
857 /*if ( module.name == "gdi32" )
859 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
861 string dir2 = gdi32_dirs[idir];
862 $dir2 =~ s%^.*?/([^/]+)$%$1%;
864 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
868 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
870 _generate_dsw_footer ( OUT
);