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 )
35 MSVCBackend::_generate_dsp ( const Module
& module
)
38 // TODO FIXME wine hack?
39 const bool wine
= false;
41 string dsp_file
= DspFileName(module
);
42 printf ( "Creating MSVC project: '%s'\n", dsp_file
.c_str() );
43 FILE* OUT
= fopen ( dsp_file
.c_str(), "wb" );
45 vector
<string
> imports
;
46 for ( i
= 0; i
< module
.non_if_data
.libraries
.size(); i
++ )
48 imports
.push_back ( module
.non_if_data
.libraries
[i
]->name
);
51 string module_type
= GetExtension(module
.GetTargetName());
52 bool lib
= (module_type
== ".lib") || (module_type
== ".a");
53 bool dll
= (module_type
== ".dll");
54 bool exe
= (module_type
== ".exe");
55 // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
57 bool console
= exe
&& (module
.type
== Win32CUI
);
59 // TODO FIXME - not sure if the count here is right...
61 const char* p
= strpbrk ( dsp_file
.c_str(), "/\\" );
65 p
= strpbrk ( p
+1, "/\\" );
67 string msvc_wine_dir
= "..";
69 msvc_wine_dir
+= "\\..";
71 string wine_include_dir
= msvc_wine_dir
+ "\\include";
73 //$progress_current++;
74 //$output->progress("$dsp_file (file $progress_current of $progress_max)");
76 // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
77 string dsp_path
= module
.GetBasePath();
78 vector
<string
> c_srcs
, source_files
, resource_files
, includes
, libraries
, defines
;
79 vector
<const IfableData
*> ifs_list
;
80 ifs_list
.push_back ( &module
.project
.non_if_data
);
81 ifs_list
.push_back ( &module
.non_if_data
);
83 // this is a define in MinGW w32api, but not Microsoft's headers
84 defines
.push_back ( "STDCALL=__stdcall" );
86 while ( ifs_list
.size() )
88 const IfableData
& data
= *ifs_list
.back();
90 // TODO FIXME - refactor needed - we're discarding if conditions
91 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
92 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
93 const vector
<File
*>& files
= data
.files
;
94 for ( i
= 0; i
< files
.size(); i
++ )
96 // TODO FIXME - do we want the full path of the file here?
97 string file
= string(".") + &files
[i
]->name
[dsp_path
.size()];
99 source_files
.push_back ( file
);
100 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
101 c_srcs
.push_back ( file
);
102 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
103 resource_files
.push_back ( file
);
105 const vector
<Include
*>& incs
= data
.includes
;
106 for ( i
= 0; i
< incs
.size(); i
++ )
108 // explicitly omit win32api directories
109 if ( !strncmp(incs
[i
]->directory
.c_str(), "w32api", 6 ) )
112 string path
= Path::RelativeFromDirectory (
114 module
.GetBasePath() );
115 includes
.push_back ( path
);
117 const vector
<Library
*>& libs
= data
.libraries
;
118 for ( i
= 0; i
< libs
.size(); i
++ )
120 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
122 const vector
<Define
*>& defs
= data
.defines
;
123 for ( i
= 0; i
< defs
.size(); i
++ )
125 if ( defs
[i
]->value
[0] )
126 defines
.push_back ( defs
[i
]->name
+ "=" + defs
[i
]->value
);
128 defines
.push_back ( defs
[i
]->name
);
131 // TODO FIXME - we don't include header files in our build system
132 //my @header_files = @{module->{header_files}};
133 vector
<string
> header_files
;
135 // TODO FIXME - wine hack?
136 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
137 module.name !~ /^(?:gdi32)_.+?$/ &&
138 Right ( module.name, 5 ) == "_test" )
140 source_files.push_back ( module.name + ".spec" );
141 @source_files = sort(@source_files);
145 bool no_msvc_headers
= true;
146 // TODO FIXME - wine hack?
147 /*if (module.name =~ /^wine(?:runtests|test)$/
148 || Right ( module.name, 5 ) == "_test" )
150 no_msvc_headers = false;
153 std::vector
<std::string
> cfgs
;
155 cfgs
.push_back ( module
.name
+ " - Win32" );
159 std::vector
<std::string
> _cfgs
;
160 for ( i
= 0; i
< cfgs
.size(); i
++ )
162 _cfgs
.push_back ( cfgs
[i
] + " C" );
163 _cfgs
.push_back ( cfgs
[i
] + " C++" );
169 // TODO FIXME - wine hack?
172 std::vector<std::string> _cfgs;
173 for ( i = 0; i < cfgs.size(); i++ )
175 _cfgs.push_back ( cfgs[i] + " Debug" );
176 _cfgs.push_back ( cfgs[i] + " Release" );
182 if (!no_msvc_headers
)
184 std::vector
<std::string
> _cfgs
;
185 for ( i
= 0; i
< cfgs
.size(); i
++ )
187 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
188 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
194 string default_cfg
= cfgs
.back();
196 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
197 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
198 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
199 fprintf ( OUT
, "\r\n" );
203 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
207 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
211 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
213 fprintf ( OUT
, "\r\n" );
215 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
216 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
217 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
218 fprintf ( OUT
, "!MESSAGE \r\n" );
219 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
220 fprintf ( OUT
, "!MESSAGE \r\n" );
221 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
222 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
223 fprintf ( OUT
, "!MESSAGE \r\n" );
224 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
225 fprintf ( OUT
, "!MESSAGE \r\n" );
226 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
227 fprintf ( OUT
, "!MESSAGE \r\n" );
228 for ( i
= 0; i
< cfgs
.size(); i
++ )
230 const string
& cfg
= cfgs
[i
];
233 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
237 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
241 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
244 fprintf ( OUT
, "!MESSAGE \r\n" );
245 fprintf ( OUT
, "\r\n" );
247 fprintf ( OUT
, "# Begin Project\r\n" );
248 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
249 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
250 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
251 fprintf ( OUT
, "CPP=cl.exe\r\n" );
252 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
253 fprintf ( OUT
, "RSC=rc.exe\r\n" );
257 std::string output_dir
;
258 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
260 std::string
& cfg
= cfgs
[icfg
];
265 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
266 fprintf ( OUT
, "\r\n" );
270 fprintf ( OUT
, "\r\n" );
271 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
272 fprintf ( OUT
, "\r\n" );
276 bool debug
= !strstr ( cfg
.c_str(), "Release" );
277 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
279 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
283 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
287 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
290 output_dir
= Replace(cfg
,module
.name
+ " - ","");
291 output_dir
= Replace(output_dir
," ","_");
292 output_dir
= Replace(output_dir
,"C++","Cxx");
293 // TODO FIXME - wine hack?
294 //if ( output_prefix_dir.size() )
295 // output_dir = output_prefix_dir + "\\" + output_dir;
297 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
298 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
300 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
302 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
305 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
309 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
311 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
312 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
314 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
315 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
319 defines
.push_back ( "_DEBUG" );
322 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
323 defines
.push_back ( "_LIB" );
327 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
328 defines
.push_back ( "_WINDOWS" );
329 defines
.push_back ( "_USRDLL" );
330 // TODO FIXME - wine hack?
331 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
336 defines
.push_back ( "NDEBUG" );
339 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
340 defines
.push_back ( "_LIB" );
344 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
345 defines
.push_back ( "_WINDOWS" );
346 defines
.push_back ( "_USRDLL" );
347 // TODO FIXME - wine hack?
348 //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
352 for ( i
= 0; i
< defines
.size(); i
++ )
354 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
356 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
357 fprintf ( OUT
, " /FD" );
360 fprintf ( OUT
, " /GZ" );
361 if ( lib
|| exe
) fprintf ( OUT
, " " );
363 fprintf ( OUT
, " /c" );
364 fprintf ( OUT
, "\r\n" );
366 vector
<string
> defines2
= defines
;
369 defines2
.push_back ( "_DEBUG" );
372 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
373 defines2
.push_back ( "_LIB" );
377 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
378 defines2
.push_back ( "_USRDLL" );
383 defines2
.push_back ( "NDEBUG" );
386 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
387 defines2
.push_back ( "_LIB" );
391 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
392 defines2
.push_back ( "_USRDLL" );
396 // TODO FIXME - wine hack?
399 // TODO FIXME - wine hack?
400 //defines2.push_back ( string("_\U") + module.name + "\E_" );
401 // TODO FIXME - wine hack?
402 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
403 defines2.push_back ( "__WINESRC__" );*/
405 defines2
.push_back ( "__WINE_USE_NATIVE_HEADERS" );
406 string output_dir2
= Replace(output_dir
,"\\","\\\\");
407 defines2
.push_back ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
408 defines2
.push_back ( "__i386__" );
409 defines2
.push_back ( "_X86_" );
411 // TODO FIXME - wine hacks?
412 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
413 push @includes, ".." );
416 if ( strstr ( module.name.c_str(), "_test" )
418 include.push_back ( msvc_wine_dir + "\\" + output_dir );
421 if (!msvc_headers || module.name == "winetest")
423 includes.push_back ( wine_include_dir );
429 for ( i
= 0; i
< includes
.size(); i
++ )
431 const string
& include
= includes
[i
];
432 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
434 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
438 fprintf ( OUT
, " /I %s", include
.c_str() );
443 fprintf ( OUT
, " /I \".\"" );
444 for ( i
= 0; i
< defines2
.size(); i
++ )
446 const string
& define
= defines2
[i
];
447 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
449 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
453 fprintf ( OUT
, " /D %s", define
.c_str() );
456 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
457 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
459 fprintf ( OUT
, lib
? " /YX" : " /FR" );
460 fprintf ( OUT
, " /FD" );
461 if ( debug
) fprintf ( OUT
, " /GZ" );
462 if ( debug
&& lib
) fprintf ( OUT
, " " );
463 fprintf ( OUT
, " /c" );
464 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
465 fprintf ( OUT
, "\r\n" );
471 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
472 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
473 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
475 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
476 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
479 for ( i
= 0; i
< includes
.size(); i
++ )
481 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
485 for ( i
= 0; i
< defines
.size(); i
++ )
487 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
489 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
495 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
496 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
497 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
499 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
500 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
503 for ( i
= 0; i
< includes
.size(); i
++ )
504 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
507 for ( i
= 0; i
< defines
.size(); i
++ )
509 fprintf ( OUT
, " /D \"%s\"", defines
[i
].c_str() );
513 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
515 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
516 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
517 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
521 fprintf ( OUT
, "LINK32=link.exe\r\n" );
522 fprintf ( OUT
, "# ADD BASE LINK32 " );
524 for ( i
= 0; i
< libraries
.size(); i
++ )
526 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
528 fprintf ( OUT
, " /nologo" );
529 if ( dll
) fprintf ( OUT
, " /dll" );
530 if ( console
) fprintf ( OUT
, " /subsystem:console" );
531 if ( debug
) fprintf ( OUT
, " /debug" );
532 fprintf ( OUT
, " /machine:I386" );
533 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
534 fprintf ( OUT
, "\r\n" );
536 fprintf ( OUT
, "# ADD LINK32" );
537 fprintf ( OUT
, " /nologo" );
538 // TODO FIXME - do we need their kludge?
539 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
540 for ( i
= 0; i
< imports
.size(); i
++ )
542 const string
& import
= imports
[i
];
543 if ( import
!= "msvcrt" )
544 fprintf ( OUT
, " %s.lib", import
.c_str() );
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 // TODO FIXME - do we need their kludge?
551 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
552 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
553 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
554 fprintf ( OUT
, "\r\n" );
558 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
559 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
560 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
566 if ( cfgs
.size() != 0 )
568 fprintf ( OUT
, "\r\n" );
569 fprintf ( OUT
, "!ENDIF \r\n" );
570 fprintf ( OUT
, "\r\n" );
573 if ( module
.name
== "winebuild" )
575 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
576 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
577 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
578 fprintf ( OUT
, "PostBuild_Cmds=" );
579 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
580 output_dir
.c_str() );
581 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
582 output_dir
.c_str() );
583 fprintf ( OUT
, "# End Special Build Tool\r\n" );
586 fprintf ( OUT
, "# Begin Target\r\n" );
587 fprintf ( OUT
, "\r\n" );
588 for ( i
= 0; i
< cfgs
.size(); i
++ )
590 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
593 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
594 fprintf ( OUT
, "\r\n" );
595 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
597 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
599 string source_file
= DosSeparator(source_files
[isrcfile
]);
601 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
603 source_file
= string(".\\") + source_file
;
606 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
608 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
610 // TODO FIXME - not sure what this is doing? wine hack maybe?
611 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
612 string dbg_c_file
= basename
+ ".dbg.c";
614 fprintf ( OUT
, "# Begin Source File\r\n" );
615 fprintf ( OUT
, "\r\n" );
616 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
617 fprintf ( OUT
, "# End Source File\r\n" );
620 fprintf ( OUT
, "# Begin Source File\r\n" );
621 fprintf ( OUT
, "\r\n" );
623 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
625 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
628 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
630 string spec_file
= source_file
;
631 string def_file
= basename
+ ".def";
633 // TODO FIXME - not sure what this is doing? wine hack maybe?
634 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
635 string dbg_file
= basename
+ ".dbg";
636 string dbg_c_file
= basename
+ ".dbg.c";
638 string srcdir
= "."; // FIXME: Is this really always correct?
640 fprintf ( OUT
, "# Begin Custom Build\r\n" );
641 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
642 fprintf ( OUT
, "\r\n" );
643 fprintf ( OUT
, "BuildCmds= \\\r\n" );
644 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
649 if ( module
.name
== "ntdll" )
652 for ( i
= 0; i
< c_srcs
.size(); i
++ )
654 const string
& c_src
= c_srcs
[i
];
657 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
661 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
664 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
665 output_dir
.c_str() );
666 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
674 for ( i
= 0; i
< c_srcs
.size(); i
++ )
676 const string
& c_src
= c_srcs
[i
];
677 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
679 if ( sc_srcs
.size() )
685 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
686 output_dir
.c_str() );
687 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
693 fprintf ( OUT
, "\t\r\n" );
694 fprintf ( OUT
, "\r\n" );
695 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
696 fprintf ( OUT
, " $(BuildCmds)\r\n" );
697 fprintf ( OUT
, "\r\n" );
698 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
699 fprintf ( OUT
, " $(BuildCmds)\r\n" );
700 fprintf ( OUT
, "# End Custom Build\r\n" );
703 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
707 foreach my $cfg (@cfgs) {
711 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
712 fprintf ( OUT, "\r\n" );
714 fprintf ( OUT, "\r\n" );
715 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
716 fprintf ( OUT, "\r\n" );
720 $output_dir =~ s/^$project - //;
721 $output_dir =~ s/ /_/g;
722 $output_dir =~ s/C\+\+/Cxx/g;
723 if($output_prefix_dir) {
724 $output_dir = "$output_prefix_dir\\$output_dir" );
727 fprintf ( OUT, "# Begin Custom Build\r\n" );
728 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
729 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
730 fprintf ( OUT, "\r\n" );
731 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
732 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
733 fprintf ( OUT, "\r\n" );
734 fprintf ( OUT, "# End Custom Build\r\n" );
737 if ( cfgs.size() != 0)
739 fprintf ( OUT, "\r\n" );
740 fprintf ( OUT, "!ENDIF \r\n" );
741 fprintf ( OUT, "\r\n" );
745 fprintf ( OUT
, "# End Source File\r\n" );
747 fprintf ( OUT
, "# End Group\r\n" );
748 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
749 fprintf ( OUT
, "\r\n" );
750 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
751 for ( i
= 0; i
< header_files
.size(); i
++ )
753 const string
& header_file
= header_files
[i
];
754 fprintf ( OUT
, "# Begin Source File\r\n" );
755 fprintf ( OUT
, "\r\n" );
756 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
757 fprintf ( OUT
, "# End Source File\r\n" );
759 fprintf ( OUT
, "# End Group\r\n" );
763 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
764 fprintf ( OUT
, "\r\n" );
765 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
766 /* for ( i = 0; i < resource_files.size(); i++ )
768 const string& resource_file = resource_files[i];
769 fprintf ( OUT, "# Begin Source File\r\n" );
770 fprintf ( OUT, "\r\n" );
771 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
772 fprintf ( OUT, "# End Source File\r\n" );
774 */ fprintf ( OUT
, "# End Group\r\n" );
776 fprintf ( OUT
, "# End Target\r\n" );
777 fprintf ( OUT
, "# End Project\r\n" );
783 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
785 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
786 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
787 fprintf ( OUT
, "\r\n" );
791 MSVCBackend::_generate_dsw_project (
793 const Module
& module
,
794 std::string dsp_file
,
795 const std::vector
<Dependency
*>& dependencies
)
797 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
799 // TODO FIXME - must they be sorted?
800 //@dependencies = sort(@dependencies);
802 fprintf ( OUT
, "###############################################################################\r\n" );
803 fprintf ( OUT
, "\r\n" );
804 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
805 fprintf ( OUT
, "\r\n" );
806 fprintf ( OUT
, "Package=<5>\r\n" );
807 fprintf ( OUT
, "{{{\r\n" );
808 fprintf ( OUT
, "}}}\r\n" );
809 fprintf ( OUT
, "\r\n" );
810 fprintf ( OUT
, "Package=<4>\r\n" );
811 fprintf ( OUT
, "{{{\r\n" );
812 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
814 Dependency
& dependency
= *dependencies
[i
];
815 fprintf ( OUT
, " Begin Project Dependency\r\n" );
816 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
817 fprintf ( OUT
, " End Project Dependency\r\n" );
819 fprintf ( OUT
, "}}}\r\n" );
820 fprintf ( OUT
, "\r\n" );
824 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
826 fprintf ( OUT
, "###############################################################################\r\n" );
827 fprintf ( OUT
, "\r\n" );
828 fprintf ( OUT
, "Global:\r\n" );
829 fprintf ( OUT
, "\r\n" );
830 fprintf ( OUT
, "Package=<5>\r\n" );
831 fprintf ( OUT
, "{{{\r\n" );
832 fprintf ( OUT
, "}}}\r\n" );
833 fprintf ( OUT
, "\r\n" );
834 fprintf ( OUT
, "Package=<3>\r\n" );
835 fprintf ( OUT
, "{{{\r\n" );
836 fprintf ( OUT
, "}}}\r\n" );
837 fprintf ( OUT
, "\r\n" );
838 fprintf ( OUT
, "###############################################################################\r\n" );
839 fprintf ( OUT
, "\r\n" );
843 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
845 _generate_dsw_header(OUT
);
846 // TODO FIXME - is it necessary to sort them?
847 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
849 Module
& module
= *ProjectNode
.modules
[i
];
851 std::string dsp_file
= DspFileName ( module
);
853 // TODO FIXME - more wine hacks?
854 /*if ( module.name == "gdi32" )
856 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
858 string dir2 = gdi32_dirs[idir];
859 $dir2 =~ s%^.*?/([^/]+)$%$1%;
861 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
865 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
867 _generate_dsw_footer ( OUT
);