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
->name
);
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 string dsp_path
= module
.output
->relative_path
;
86 vector
<string
> c_srcs
, source_files
, header_files
, resource_files
, includes
, libraries
;
87 StringSet common_defines
;
88 vector
<const IfableData
*> ifs_list
;
89 ifs_list
.push_back ( &module
.project
.non_if_data
);
90 ifs_list
.push_back ( &module
.non_if_data
);
92 // this is a define in MinGW w32api, but not Microsoft's headers
93 common_defines
.insert ( "STDCALL=__stdcall" );
95 while ( ifs_list
.size() )
97 const IfableData
& data
= *ifs_list
.back();
99 // TODO FIXME - refactor needed - we're discarding if conditions
100 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
101 ifs_list
.push_back ( &data
.ifs
[i
]->data
);
102 const vector
<File
*>& files
= data
.files
;
103 for ( i
= 0; i
< files
.size(); i
++ )
105 // TODO FIXME - do we want the full path of the file here?
106 string file
= string(".") + &files
[i
]->name
[dsp_path
.size()];
108 source_files
.push_back ( file
);
109 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
110 c_srcs
.push_back ( file
);
111 if ( !stricmp ( Right(file
,2).c_str(), ".h" ) )
112 header_files
.push_back ( file
);
113 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
114 resource_files
.push_back ( file
);
116 const vector
<Include
*>& incs
= data
.includes
;
117 for ( i
= 0; i
< incs
.size(); i
++ )
120 // explicitly omit win32api directories
121 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "w32api", 6 ) )
124 // explicitly omit include/wine directories
125 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "include\\wine", 12 ) )
128 string path
= Path::RelativeFromDirectory (
129 incs
[i
]->directory
->relative_path
,
130 module
.output
->relative_path
);
131 includes
.push_back ( path
);
133 const vector
<Library
*>& libs
= data
.libraries
;
134 for ( i
= 0; i
< libs
.size(); i
++ )
136 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
138 const vector
<Define
*>& defs
= data
.defines
;
139 for ( i
= 0; i
< defs
.size(); i
++ )
141 if ( defs
[i
]->value
[0] )
142 common_defines
.insert( defs
[i
]->name
+ "=" + defs
[i
]->value
);
144 common_defines
.insert( defs
[i
]->name
);
147 // TODO FIXME - we don't include header files in our build system
148 //my @header_files = @{module->{header_files}};
149 //vector<string> header_files;
151 // TODO FIXME - wine hack?
152 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
153 module.name !~ /^(?:gdi32)_.+?$/ &&
154 Right ( module.name, 5 ) == "_test" )
156 source_files.push_back ( module.name + ".spec" );
157 @source_files = sort(@source_files);
161 bool no_msvc_headers
= true;
162 // TODO FIXME - wine hack?
163 /*if (module.name =~ /^wine(?:runtests|test)$/
164 || Right ( module.name, 5 ) == "_test" )
166 no_msvc_headers = false;
169 std::vector
<std::string
> cfgs
;
171 cfgs
.push_back ( module
.name
+ " - Win32" );
175 std::vector
<std::string
> _cfgs
;
176 for ( i
= 0; i
< cfgs
.size(); i
++ )
178 _cfgs
.push_back ( cfgs
[i
] + " C" );
179 _cfgs
.push_back ( cfgs
[i
] + " C++" );
185 // TODO FIXME - wine hack?
188 std::vector<std::string> _cfgs;
189 for ( i = 0; i < cfgs.size(); i++ )
191 _cfgs.push_back ( cfgs[i] + " Debug" );
192 _cfgs.push_back ( cfgs[i] + " Release" );
198 if (!no_msvc_headers
)
200 std::vector
<std::string
> _cfgs
;
201 for ( i
= 0; i
< cfgs
.size(); i
++ )
203 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
204 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
210 string default_cfg
= cfgs
.back();
212 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
213 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
214 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
215 fprintf ( OUT
, "\r\n" );
219 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
223 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
227 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
229 fprintf ( OUT
, "\r\n" );
231 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
232 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
233 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
234 fprintf ( OUT
, "!MESSAGE \r\n" );
235 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
236 fprintf ( OUT
, "!MESSAGE \r\n" );
237 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
238 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
239 fprintf ( OUT
, "!MESSAGE \r\n" );
240 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
241 fprintf ( OUT
, "!MESSAGE \r\n" );
242 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
243 fprintf ( OUT
, "!MESSAGE \r\n" );
244 for ( i
= 0; i
< cfgs
.size(); i
++ )
246 const string
& cfg
= cfgs
[i
];
249 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
253 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
257 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
260 fprintf ( OUT
, "!MESSAGE \r\n" );
261 fprintf ( OUT
, "\r\n" );
263 fprintf ( OUT
, "# Begin Project\r\n" );
264 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
265 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
266 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
267 fprintf ( OUT
, "CPP=cl.exe\r\n" );
268 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
269 fprintf ( OUT
, "RSC=rc.exe\r\n" );
271 std::string output_dir
;
272 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
274 std::string
& cfg
= cfgs
[icfg
];
277 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
278 fprintf ( OUT
, "\r\n" );
282 fprintf ( OUT
, "\r\n" );
283 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
284 fprintf ( OUT
, "\r\n" );
287 bool debug
= !strstr ( cfg
.c_str(), "Release" );
288 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
290 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
294 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
298 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
301 output_dir
= Replace(cfg
,module
.name
+ " - ","");
302 output_dir
= Replace(output_dir
," ","_");
303 output_dir
= Replace(output_dir
,"C++","Cxx");
304 // TODO FIXME - wine hack?
305 //if ( output_prefix_dir.size() )
306 // output_dir = output_prefix_dir + "\\" + output_dir;
308 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
309 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
311 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
313 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
316 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
320 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
322 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
323 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
325 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
326 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
328 StringSet defines
= common_defines
;
332 defines
.insert ( "_DEBUG" );
335 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
336 defines
.insert ( "_LIB" );
340 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
341 defines
.insert ( "_WINDOWS" );
342 defines
.insert ( "_USRDLL" );
343 // TODO FIXME - wine hack?
344 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
349 defines
.insert ( "NDEBUG" );
352 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
353 defines
.insert ( "_LIB" );
357 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
358 defines
.insert ( "_WINDOWS" );
359 defines
.insert ( "_USRDLL" );
360 // TODO FIXME - wine hack?
361 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
365 for ( StringSet::const_iterator it1
=defines
.begin(); it1
!=defines
.end(); it1
++ )
367 fprintf ( OUT
, " /D \"%s\"", it1
->c_str() );
369 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
370 fprintf ( OUT
, " /FD" );
373 fprintf ( OUT
, " /GZ" );
374 if ( lib
|| exe
) fprintf ( OUT
, " " );
376 fprintf ( OUT
, " /c" );
377 fprintf ( OUT
, "\r\n" );
381 defines
.insert ( "_DEBUG" );
384 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
385 defines
.insert ( "_LIB" );
389 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
390 defines
.insert ( "_USRDLL" );
395 defines
.insert ( "NDEBUG" );
398 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
399 defines
.insert ( "_LIB" );
403 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
404 defines
.insert ( "_USRDLL" );
408 // TODO FIXME - wine hack?
411 // TODO FIXME - wine hack?
412 //defines.insert ( string("_\U") + module.name + "\E_" );
413 // TODO FIXME - wine hack?
414 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
415 defines.insert ( "__WINESRC__" );*/
417 defines
.insert ( "__WINE_USE_NATIVE_HEADERS" );
418 string output_dir2
= Replace(output_dir
,"\\","\\\\");
419 defines
.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
420 defines
.insert ( "__i386__" );
421 defines
.insert ( "_X86_" );
423 // TODO FIXME - wine hacks?
424 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
425 push @includes, ".." );
428 if ( strstr ( module.name.c_str(), "_test" )
430 include.push_back ( msvc_wine_dir + "\\" + output_dir );
433 if (!msvc_headers || module.name == "winetest")
435 includes.push_back ( wine_include_dir );
441 for ( i
= 0; i
< includes
.size(); i
++ )
443 const string
& include
= includes
[i
];
444 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
446 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
450 fprintf ( OUT
, " /I %s", include
.c_str() );
455 fprintf ( OUT
, " /I \".\"" );
456 for ( StringSet::const_iterator it2
=defines
.begin(); it2
!=defines
.end(); it2
++ )
458 const string
& define
= *it2
;
459 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
461 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
465 fprintf ( OUT
, " /D %s", define
.c_str() );
468 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
469 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
471 fprintf ( OUT
, lib
? " /YX" : " /FR" );
472 fprintf ( OUT
, " /FD" );
473 if ( debug
) fprintf ( OUT
, " /GZ" );
474 if ( debug
&& lib
) fprintf ( OUT
, " " );
475 fprintf ( OUT
, " /c" );
476 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
477 fprintf ( OUT
, "\r\n" );
483 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
484 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
485 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
487 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
488 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
491 for ( i
= 0; i
< includes
.size(); i
++ )
493 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
497 for ( StringSet::const_iterator it3
=defines
.begin(); it3
!=defines
.end(); it3
++ )
499 fprintf ( OUT
, " /D \"%s\"", it3
->c_str() );
501 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
507 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
508 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
509 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
511 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
512 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
515 for ( i
= 0; i
< includes
.size(); i
++ )
516 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
519 for ( StringSet::const_iterator it4
=defines
.begin(); it4
!=defines
.end(); it4
++ )
521 fprintf ( OUT
, " /D \"%s\"", it4
->c_str() );
525 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
527 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
528 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
529 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
533 fprintf ( OUT
, "LINK32=link.exe\r\n" );
534 fprintf ( OUT
, "# ADD BASE LINK32 " );
536 for ( i
= 0; i
< libraries
.size(); i
++ )
538 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
540 fprintf ( OUT
, " /nologo" );
541 if ( dll
) fprintf ( OUT
, " /dll" );
542 if ( console
) fprintf ( OUT
, " /subsystem:console" );
543 if ( debug
) fprintf ( OUT
, " /debug" );
544 fprintf ( OUT
, " /machine:I386" );
545 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
546 fprintf ( OUT
, "\r\n" );
548 fprintf ( OUT
, "# ADD LINK32" );
549 fprintf ( OUT
, " /nologo" );
550 // TODO FIXME - do we need their kludge?
551 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
552 for ( i
= 0; i
< imports
.size(); i
++ )
554 const string
& import
= imports
[i
];
555 if ( import
!= "msvcrt" )
556 fprintf ( OUT
, " %s.lib", import
.c_str() );
558 if ( dll
) fprintf ( OUT
, " /dll" );
559 if ( console
) fprintf ( OUT
, " /subsystem:console" );
560 if ( debug
) fprintf ( OUT
, " /debug" );
561 fprintf ( OUT
, " /machine:I386" );
562 // TODO FIXME - do we need their kludge?
563 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
564 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
565 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
566 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
567 fprintf ( OUT
, "\r\n" );
571 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
572 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
573 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
577 if ( cfgs
.size() != 0 )
579 fprintf ( OUT
, "\r\n" );
580 fprintf ( OUT
, "!ENDIF \r\n" );
581 fprintf ( OUT
, "\r\n" );
584 if ( module
.name
== "winebuild" )
586 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
587 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
588 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
589 fprintf ( OUT
, "PostBuild_Cmds=" );
590 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
591 output_dir
.c_str() );
592 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
593 output_dir
.c_str() );
594 fprintf ( OUT
, "# End Special Build Tool\r\n" );
597 fprintf ( OUT
, "# Begin Target\r\n" );
598 fprintf ( OUT
, "\r\n" );
599 for ( i
= 0; i
< cfgs
.size(); i
++ )
601 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
604 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
605 fprintf ( OUT
, "\r\n" );
606 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
608 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
610 string source_file
= DosSeparator(source_files
[isrcfile
]);
612 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
614 source_file
= string(".\\") + source_file
;
617 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
619 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
621 // TODO FIXME - not sure what this is doing? wine hack maybe?
622 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
623 string dbg_c_file
= basename
+ ".dbg.c";
625 fprintf ( OUT
, "# Begin Source File\r\n" );
626 fprintf ( OUT
, "\r\n" );
627 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
628 fprintf ( OUT
, "# End Source File\r\n" );
631 fprintf ( OUT
, "# Begin Source File\r\n" );
632 fprintf ( OUT
, "\r\n" );
634 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
636 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
639 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
641 string spec_file
= source_file
;
642 string def_file
= basename
+ ".def";
644 // TODO FIXME - not sure what this is doing? wine hack maybe?
645 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
646 string dbg_file
= basename
+ ".dbg";
647 string dbg_c_file
= basename
+ ".dbg.c";
649 string srcdir
= "."; // FIXME: Is this really always correct?
651 fprintf ( OUT
, "# Begin Custom Build\r\n" );
652 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
653 fprintf ( OUT
, "\r\n" );
654 fprintf ( OUT
, "BuildCmds= \\\r\n" );
655 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
660 if ( module
.name
== "ntdll" )
663 for ( i
= 0; i
< c_srcs
.size(); i
++ )
665 const string
& c_src
= c_srcs
[i
];
668 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
672 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
675 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
676 output_dir
.c_str() );
677 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
685 for ( i
= 0; i
< c_srcs
.size(); i
++ )
687 const string
& c_src
= c_srcs
[i
];
688 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
690 if ( sc_srcs
.size() )
696 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
697 output_dir
.c_str() );
698 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
704 fprintf ( OUT
, "\t\r\n" );
705 fprintf ( OUT
, "\r\n" );
706 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
707 fprintf ( OUT
, " $(BuildCmds)\r\n" );
708 fprintf ( OUT
, "\r\n" );
709 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
710 fprintf ( OUT
, " $(BuildCmds)\r\n" );
711 fprintf ( OUT
, "# End Custom Build\r\n" );
714 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
718 foreach my $cfg (@cfgs) {
722 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
723 fprintf ( OUT, "\r\n" );
725 fprintf ( OUT, "\r\n" );
726 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
727 fprintf ( OUT, "\r\n" );
731 $output_dir =~ s/^$project - //;
732 $output_dir =~ s/ /_/g;
733 $output_dir =~ s/C\+\+/Cxx/g;
734 if($output_prefix_dir) {
735 $output_dir = "$output_prefix_dir\\$output_dir" );
738 fprintf ( OUT, "# Begin Custom Build\r\n" );
739 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
740 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
741 fprintf ( OUT, "\r\n" );
742 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
743 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
744 fprintf ( OUT, "\r\n" );
745 fprintf ( OUT, "# End Custom Build\r\n" );
748 if ( cfgs.size() != 0)
750 fprintf ( OUT, "\r\n" );
751 fprintf ( OUT, "!ENDIF \r\n" );
752 fprintf ( OUT, "\r\n" );
756 fprintf ( OUT
, "# End Source File\r\n" );
758 fprintf ( OUT
, "# End Group\r\n" );
759 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
760 fprintf ( OUT
, "\r\n" );
761 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
762 for ( i
= 0; i
< header_files
.size(); i
++ )
764 const string
& header_file
= header_files
[i
];
765 fprintf ( OUT
, "# Begin Source File\r\n" );
766 fprintf ( OUT
, "\r\n" );
767 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
768 fprintf ( OUT
, "# End Source File\r\n" );
770 fprintf ( OUT
, "# End Group\r\n" );
774 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
775 fprintf ( OUT
, "\r\n" );
776 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
777 /* for ( i = 0; i < resource_files.size(); i++ )
779 const string& resource_file = resource_files[i];
780 fprintf ( OUT, "# Begin Source File\r\n" );
781 fprintf ( OUT, "\r\n" );
782 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
783 fprintf ( OUT, "# End Source File\r\n" );
785 */ fprintf ( OUT
, "# End Group\r\n" );
787 fprintf ( OUT
, "# End Target\r\n" );
788 fprintf ( OUT
, "# End Project\r\n" );
794 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
796 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
797 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
798 fprintf ( OUT
, "\r\n" );
802 MSVCBackend::_generate_dsw_project (
804 const Module
& module
,
805 std::string dsp_file
,
806 const std::vector
<Dependency
*>& dependencies
)
808 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
810 // TODO FIXME - must they be sorted?
811 //@dependencies = sort(@dependencies);
813 fprintf ( OUT
, "###############################################################################\r\n" );
814 fprintf ( OUT
, "\r\n" );
815 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
816 fprintf ( OUT
, "\r\n" );
817 fprintf ( OUT
, "Package=<5>\r\n" );
818 fprintf ( OUT
, "{{{\r\n" );
819 fprintf ( OUT
, "}}}\r\n" );
820 fprintf ( OUT
, "\r\n" );
821 fprintf ( OUT
, "Package=<4>\r\n" );
822 fprintf ( OUT
, "{{{\r\n" );
823 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
825 Dependency
& dependency
= *dependencies
[i
];
826 fprintf ( OUT
, " Begin Project Dependency\r\n" );
827 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
828 fprintf ( OUT
, " End Project Dependency\r\n" );
830 fprintf ( OUT
, "}}}\r\n" );
831 fprintf ( OUT
, "\r\n" );
835 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
837 fprintf ( OUT
, "###############################################################################\r\n" );
838 fprintf ( OUT
, "\r\n" );
839 fprintf ( OUT
, "Global:\r\n" );
840 fprintf ( OUT
, "\r\n" );
841 fprintf ( OUT
, "Package=<5>\r\n" );
842 fprintf ( OUT
, "{{{\r\n" );
843 fprintf ( OUT
, "}}}\r\n" );
844 fprintf ( OUT
, "\r\n" );
845 fprintf ( OUT
, "Package=<3>\r\n" );
846 fprintf ( OUT
, "{{{\r\n" );
847 fprintf ( OUT
, "}}}\r\n" );
848 fprintf ( OUT
, "\r\n" );
849 fprintf ( OUT
, "###############################################################################\r\n" );
850 fprintf ( OUT
, "\r\n" );
854 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
856 _generate_dsw_header(OUT
);
857 // TODO FIXME - is it necessary to sort them?
858 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
860 Module
& module
= *ProjectNode
.modules
[i
];
862 std::string dsp_file
= DspFileName ( module
);
864 // TODO FIXME - more wine hacks?
865 /*if ( module.name == "gdi32" )
867 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
869 string dir2 = gdi32_dirs[idir];
870 $dir2 =~ s%^.*?/([^/]+)$%$1%;
872 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
876 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
878 _generate_dsw_footer ( OUT
);