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 // We want the full path here for directory support later on
105 string path
= Path::RelativeFromDirectory (
106 files
[i
]->file
.relative_path
,
107 module
.output
->relative_path
);
108 string file
= path
+ std::string("\\") + files
[i
]->file
.name
;
110 source_files
.push_back ( file
);
111 if ( !stricmp ( Right(file
,2).c_str(), ".c" ) )
112 c_srcs
.push_back ( file
);
113 if ( !stricmp ( Right(file
,2).c_str(), ".h" ) )
114 header_files
.push_back ( file
);
115 if ( !stricmp ( Right(file
,3).c_str(), ".rc" ) )
116 resource_files
.push_back ( file
);
118 const vector
<Include
*>& incs
= data
.includes
;
119 for ( i
= 0; i
< incs
.size(); i
++ )
122 // explicitly omit win32api directories
123 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "w32api", 6 ) )
126 // explicitly omit include/wine directories
127 if ( !strncmp(incs
[i
]->directory
->relative_path
.c_str(), "include\\wine", 12 ) )
130 string path
= Path::RelativeFromDirectory (
131 incs
[i
]->directory
->relative_path
,
132 module
.output
->relative_path
);
133 includes
.push_back ( path
);
135 const vector
<Library
*>& libs
= data
.libraries
;
136 for ( i
= 0; i
< libs
.size(); i
++ )
138 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
140 const vector
<Define
*>& defs
= data
.defines
;
141 for ( i
= 0; i
< defs
.size(); i
++ )
143 if ( defs
[i
]->value
[0] )
144 common_defines
.insert( defs
[i
]->name
+ "=" + defs
[i
]->value
);
146 common_defines
.insert( defs
[i
]->name
);
149 // TODO FIXME - we don't include header files in our build system
150 //my @header_files = @{module->{header_files}};
151 //vector<string> header_files;
153 // TODO FIXME - wine hack?
154 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
155 module.name !~ /^(?:gdi32)_.+?$/ &&
156 Right ( module.name, 5 ) == "_test" )
158 source_files.push_back ( module.name + ".spec" );
159 @source_files = sort(@source_files);
163 bool no_msvc_headers
= true;
164 // TODO FIXME - wine hack?
165 /*if (module.name =~ /^wine(?:runtests|test)$/
166 || Right ( module.name, 5 ) == "_test" )
168 no_msvc_headers = false;
171 std::vector
<std::string
> cfgs
;
173 cfgs
.push_back ( module
.name
+ " - Win32" );
177 std::vector
<std::string
> _cfgs
;
178 for ( i
= 0; i
< cfgs
.size(); i
++ )
180 _cfgs
.push_back ( cfgs
[i
] + " C" );
181 _cfgs
.push_back ( cfgs
[i
] + " C++" );
187 // TODO FIXME - wine hack?
190 std::vector<std::string> _cfgs;
191 for ( i = 0; i < cfgs.size(); i++ )
193 _cfgs.push_back ( cfgs[i] + " Debug" );
194 _cfgs.push_back ( cfgs[i] + " Release" );
200 if (!no_msvc_headers
)
202 std::vector
<std::string
> _cfgs
;
203 for ( i
= 0; i
< cfgs
.size(); i
++ )
205 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
206 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
212 string default_cfg
= cfgs
.back();
214 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
215 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
216 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
217 fprintf ( OUT
, "\r\n" );
221 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
225 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
229 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
231 fprintf ( OUT
, "\r\n" );
233 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
234 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
235 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
236 fprintf ( OUT
, "!MESSAGE \r\n" );
237 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
238 fprintf ( OUT
, "!MESSAGE \r\n" );
239 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
240 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
241 fprintf ( OUT
, "!MESSAGE \r\n" );
242 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
243 fprintf ( OUT
, "!MESSAGE \r\n" );
244 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
245 fprintf ( OUT
, "!MESSAGE \r\n" );
246 for ( i
= 0; i
< cfgs
.size(); i
++ )
248 const string
& cfg
= cfgs
[i
];
251 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
255 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
259 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
262 fprintf ( OUT
, "!MESSAGE \r\n" );
263 fprintf ( OUT
, "\r\n" );
265 fprintf ( OUT
, "# Begin Project\r\n" );
266 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
267 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
268 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
269 fprintf ( OUT
, "CPP=cl.exe\r\n" );
270 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
271 fprintf ( OUT
, "RSC=rc.exe\r\n" );
273 std::string output_dir
;
274 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
276 std::string
& cfg
= cfgs
[icfg
];
279 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
280 fprintf ( OUT
, "\r\n" );
284 fprintf ( OUT
, "\r\n" );
285 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
286 fprintf ( OUT
, "\r\n" );
289 bool debug
= !strstr ( cfg
.c_str(), "Release" );
290 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
292 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
296 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
300 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
303 output_dir
= Replace(cfg
,module
.name
+ " - ","");
304 output_dir
= Replace(output_dir
," ","_");
305 output_dir
= Replace(output_dir
,"C++","Cxx");
306 // TODO FIXME - wine hack?
307 //if ( output_prefix_dir.size() )
308 // output_dir = output_prefix_dir + "\\" + output_dir;
310 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
311 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
313 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
315 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
318 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
322 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
324 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
325 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
327 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
328 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
330 StringSet defines
= common_defines
;
334 defines
.insert ( "_DEBUG" );
337 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
338 defines
.insert ( "_LIB" );
342 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
343 defines
.insert ( "_WINDOWS" );
344 defines
.insert ( "_USRDLL" );
345 // TODO FIXME - wine hack?
346 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
351 defines
.insert ( "NDEBUG" );
354 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
355 defines
.insert ( "_LIB" );
359 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
360 defines
.insert ( "_WINDOWS" );
361 defines
.insert ( "_USRDLL" );
362 // TODO FIXME - wine hack?
363 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
367 for ( StringSet::const_iterator it1
=defines
.begin(); it1
!=defines
.end(); it1
++ )
369 fprintf ( OUT
, " /D \"%s\"", it1
->c_str() );
371 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
372 fprintf ( OUT
, " /FD" );
375 fprintf ( OUT
, " /GZ" );
376 if ( lib
|| exe
) fprintf ( OUT
, " " );
378 fprintf ( OUT
, " /c" );
379 fprintf ( OUT
, "\r\n" );
383 defines
.insert ( "_DEBUG" );
386 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
387 defines
.insert ( "_LIB" );
391 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
392 defines
.insert ( "_USRDLL" );
397 defines
.insert ( "NDEBUG" );
400 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
401 defines
.insert ( "_LIB" );
405 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
406 defines
.insert ( "_USRDLL" );
410 // TODO FIXME - wine hack?
413 // TODO FIXME - wine hack?
414 //defines.insert ( string("_\U") + module.name + "\E_" );
415 // TODO FIXME - wine hack?
416 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
417 defines.insert ( "__WINESRC__" );*/
419 defines
.insert ( "__WINE_USE_NATIVE_HEADERS" );
420 string output_dir2
= Replace(output_dir
,"\\","\\\\");
421 defines
.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
422 defines
.insert ( "__i386__" );
423 defines
.insert ( "_X86_" );
425 // TODO FIXME - wine hacks?
426 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
427 push @includes, ".." );
430 if ( strstr ( module.name.c_str(), "_test" )
432 include.push_back ( msvc_wine_dir + "\\" + output_dir );
435 if (!msvc_headers || module.name == "winetest")
437 includes.push_back ( wine_include_dir );
443 for ( i
= 0; i
< includes
.size(); i
++ )
445 const string
& include
= includes
[i
];
446 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
448 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
452 fprintf ( OUT
, " /I %s", include
.c_str() );
457 fprintf ( OUT
, " /I \".\"" );
458 for ( StringSet::const_iterator it2
=defines
.begin(); it2
!=defines
.end(); it2
++ )
460 const string
& define
= *it2
;
461 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
463 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
467 fprintf ( OUT
, " /D %s", define
.c_str() );
470 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
471 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
473 fprintf ( OUT
, lib
? " /YX" : " /FR" );
474 fprintf ( OUT
, " /FD" );
475 if ( debug
) fprintf ( OUT
, " /GZ" );
476 if ( debug
&& lib
) fprintf ( OUT
, " " );
477 fprintf ( OUT
, " /c" );
478 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
479 fprintf ( OUT
, "\r\n" );
485 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
486 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
487 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
489 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
490 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
493 for ( i
= 0; i
< includes
.size(); i
++ )
495 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
499 for ( StringSet::const_iterator it3
=defines
.begin(); it3
!=defines
.end(); it3
++ )
501 fprintf ( OUT
, " /D \"%s\"", it3
->c_str() );
503 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
509 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
510 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
511 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
513 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
514 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
517 for ( i
= 0; i
< includes
.size(); i
++ )
518 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
521 for ( StringSet::const_iterator it4
=defines
.begin(); it4
!=defines
.end(); it4
++ )
523 fprintf ( OUT
, " /D \"%s\"", it4
->c_str() );
527 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
529 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
530 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
531 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
535 fprintf ( OUT
, "LINK32=link.exe\r\n" );
536 fprintf ( OUT
, "# ADD BASE LINK32 " );
538 for ( i
= 0; i
< libraries
.size(); i
++ )
540 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
542 fprintf ( OUT
, " /nologo" );
543 if ( dll
) fprintf ( OUT
, " /dll" );
544 if ( console
) fprintf ( OUT
, " /subsystem:console" );
545 if ( debug
) fprintf ( OUT
, " /debug" );
546 fprintf ( OUT
, " /machine:I386" );
547 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
548 fprintf ( OUT
, "\r\n" );
550 fprintf ( OUT
, "# ADD LINK32" );
551 fprintf ( OUT
, " /nologo" );
552 // TODO FIXME - do we need their kludge?
553 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
554 for ( i
= 0; i
< imports
.size(); i
++ )
556 const string
& import
= imports
[i
];
557 if ( import
!= "msvcrt" )
558 fprintf ( OUT
, " %s.lib", import
.c_str() );
560 if ( dll
) fprintf ( OUT
, " /dll" );
561 if ( console
) fprintf ( OUT
, " /subsystem:console" );
562 if ( debug
) fprintf ( OUT
, " /debug" );
563 fprintf ( OUT
, " /machine:I386" );
564 // TODO FIXME - do we need their kludge?
565 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
566 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
567 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
568 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
569 fprintf ( OUT
, "\r\n" );
573 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
574 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
575 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
579 if ( cfgs
.size() != 0 )
581 fprintf ( OUT
, "\r\n" );
582 fprintf ( OUT
, "!ENDIF \r\n" );
583 fprintf ( OUT
, "\r\n" );
586 if ( module
.name
== "winebuild" )
588 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
589 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
590 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
591 fprintf ( OUT
, "PostBuild_Cmds=" );
592 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
593 output_dir
.c_str() );
594 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
595 output_dir
.c_str() );
596 fprintf ( OUT
, "# End Special Build Tool\r\n" );
599 fprintf ( OUT
, "# Begin Target\r\n" );
600 fprintf ( OUT
, "\r\n" );
601 for ( i
= 0; i
< cfgs
.size(); i
++ )
603 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
606 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
607 fprintf ( OUT
, "\r\n" );
608 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
610 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
612 string source_file
= DosSeparator(source_files
[isrcfile
]);
614 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
616 source_file
= string(".\\") + source_file
;
619 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
621 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
623 // TODO FIXME - not sure what this is doing? wine hack maybe?
624 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
625 string dbg_c_file
= basename
+ ".dbg.c";
627 fprintf ( OUT
, "# Begin Source File\r\n" );
628 fprintf ( OUT
, "\r\n" );
629 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
630 fprintf ( OUT
, "# End Source File\r\n" );
633 fprintf ( OUT
, "# Begin Source File\r\n" );
634 fprintf ( OUT
, "\r\n" );
636 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
638 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
641 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
643 string spec_file
= source_file
;
644 string def_file
= basename
+ ".def";
646 // TODO FIXME - not sure what this is doing? wine hack maybe?
647 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
648 string dbg_file
= basename
+ ".dbg";
649 string dbg_c_file
= basename
+ ".dbg.c";
651 string srcdir
= "."; // FIXME: Is this really always correct?
653 fprintf ( OUT
, "# Begin Custom Build\r\n" );
654 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
655 fprintf ( OUT
, "\r\n" );
656 fprintf ( OUT
, "BuildCmds= \\\r\n" );
657 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
662 if ( module
.name
== "ntdll" )
665 for ( i
= 0; i
< c_srcs
.size(); i
++ )
667 const string
& c_src
= c_srcs
[i
];
670 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
674 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
677 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
678 output_dir
.c_str() );
679 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
687 for ( i
= 0; i
< c_srcs
.size(); i
++ )
689 const string
& c_src
= c_srcs
[i
];
690 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
692 if ( sc_srcs
.size() )
698 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
699 output_dir
.c_str() );
700 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
706 fprintf ( OUT
, "\t\r\n" );
707 fprintf ( OUT
, "\r\n" );
708 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
709 fprintf ( OUT
, " $(BuildCmds)\r\n" );
710 fprintf ( OUT
, "\r\n" );
711 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
712 fprintf ( OUT
, " $(BuildCmds)\r\n" );
713 fprintf ( OUT
, "# End Custom Build\r\n" );
716 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
720 foreach my $cfg (@cfgs) {
724 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
725 fprintf ( OUT, "\r\n" );
727 fprintf ( OUT, "\r\n" );
728 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
729 fprintf ( OUT, "\r\n" );
733 $output_dir =~ s/^$project - //;
734 $output_dir =~ s/ /_/g;
735 $output_dir =~ s/C\+\+/Cxx/g;
736 if($output_prefix_dir) {
737 $output_dir = "$output_prefix_dir\\$output_dir" );
740 fprintf ( OUT, "# Begin Custom Build\r\n" );
741 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
742 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
743 fprintf ( OUT, "\r\n" );
744 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
745 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
746 fprintf ( OUT, "\r\n" );
747 fprintf ( OUT, "# End Custom Build\r\n" );
750 if ( cfgs.size() != 0)
752 fprintf ( OUT, "\r\n" );
753 fprintf ( OUT, "!ENDIF \r\n" );
754 fprintf ( OUT, "\r\n" );
758 fprintf ( OUT
, "# End Source File\r\n" );
760 fprintf ( OUT
, "# End Group\r\n" );
761 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
762 fprintf ( OUT
, "\r\n" );
763 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
764 for ( i
= 0; i
< header_files
.size(); i
++ )
766 const string
& header_file
= header_files
[i
];
767 fprintf ( OUT
, "# Begin Source File\r\n" );
768 fprintf ( OUT
, "\r\n" );
769 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
770 fprintf ( OUT
, "# End Source File\r\n" );
772 fprintf ( OUT
, "# End Group\r\n" );
776 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
777 fprintf ( OUT
, "\r\n" );
778 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
779 /* for ( i = 0; i < resource_files.size(); i++ )
781 const string& resource_file = resource_files[i];
782 fprintf ( OUT, "# Begin Source File\r\n" );
783 fprintf ( OUT, "\r\n" );
784 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
785 fprintf ( OUT, "# End Source File\r\n" );
787 */ fprintf ( OUT
, "# End Group\r\n" );
789 fprintf ( OUT
, "# End Target\r\n" );
790 fprintf ( OUT
, "# End Project\r\n" );
796 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
798 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
799 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
800 fprintf ( OUT
, "\r\n" );
804 MSVCBackend::_generate_dsw_project (
806 const Module
& module
,
807 std::string dsp_file
,
808 const std::vector
<Dependency
*>& dependencies
)
810 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
812 // TODO FIXME - must they be sorted?
813 //@dependencies = sort(@dependencies);
815 fprintf ( OUT
, "###############################################################################\r\n" );
816 fprintf ( OUT
, "\r\n" );
817 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
818 fprintf ( OUT
, "\r\n" );
819 fprintf ( OUT
, "Package=<5>\r\n" );
820 fprintf ( OUT
, "{{{\r\n" );
821 fprintf ( OUT
, "}}}\r\n" );
822 fprintf ( OUT
, "\r\n" );
823 fprintf ( OUT
, "Package=<4>\r\n" );
824 fprintf ( OUT
, "{{{\r\n" );
825 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
827 Dependency
& dependency
= *dependencies
[i
];
828 fprintf ( OUT
, " Begin Project Dependency\r\n" );
829 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
830 fprintf ( OUT
, " End Project Dependency\r\n" );
832 fprintf ( OUT
, "}}}\r\n" );
833 fprintf ( OUT
, "\r\n" );
837 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
839 fprintf ( OUT
, "###############################################################################\r\n" );
840 fprintf ( OUT
, "\r\n" );
841 fprintf ( OUT
, "Global:\r\n" );
842 fprintf ( OUT
, "\r\n" );
843 fprintf ( OUT
, "Package=<5>\r\n" );
844 fprintf ( OUT
, "{{{\r\n" );
845 fprintf ( OUT
, "}}}\r\n" );
846 fprintf ( OUT
, "\r\n" );
847 fprintf ( OUT
, "Package=<3>\r\n" );
848 fprintf ( OUT
, "{{{\r\n" );
849 fprintf ( OUT
, "}}}\r\n" );
850 fprintf ( OUT
, "\r\n" );
851 fprintf ( OUT
, "###############################################################################\r\n" );
852 fprintf ( OUT
, "\r\n" );
856 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
858 _generate_dsw_header(OUT
);
859 // TODO FIXME - is it necessary to sort them?
860 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
862 Module
& module
= *ProjectNode
.modules
[i
];
864 std::string dsp_file
= DspFileName ( module
);
866 // TODO FIXME - more wine hacks?
867 /*if ( module.name == "gdi32" )
869 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
871 string dir2 = gdi32_dirs[idir];
872 $dir2 =~ s%^.*?/([^/]+)$%$1%;
874 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
878 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
880 _generate_dsw_footer ( OUT
);