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
.GetTargetName());
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
.GetBasePath();
86 vector
<string
> c_srcs
, source_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
,3).c_str(), ".rc" ) )
112 resource_files
.push_back ( file
);
114 const vector
<Include
*>& incs
= data
.includes
;
115 for ( i
= 0; i
< incs
.size(); i
++ )
118 // explicitly omit win32api directories
119 if ( !strncmp(incs
[i
]->directory
.c_str(), "w32api", 6 ) )
122 // explicitly omit include/wine directories
123 if ( !strncmp(incs
[i
]->directory
.c_str(), "include\\wine", 12 ) )
126 string path
= Path::RelativeFromDirectory (
128 module
.GetBasePath() );
129 includes
.push_back ( path
);
131 const vector
<Library
*>& libs
= data
.libraries
;
132 for ( i
= 0; i
< libs
.size(); i
++ )
134 libraries
.push_back ( libs
[i
]->name
+ ".lib" );
136 const vector
<Define
*>& defs
= data
.defines
;
137 for ( i
= 0; i
< defs
.size(); i
++ )
139 if ( defs
[i
]->value
[0] )
140 common_defines
.insert( defs
[i
]->name
+ "=" + defs
[i
]->value
);
142 common_defines
.insert( defs
[i
]->name
);
145 // TODO FIXME - we don't include header files in our build system
146 //my @header_files = @{module->{header_files}};
147 vector
<string
> header_files
;
149 // TODO FIXME - wine hack?
150 /*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
151 module.name !~ /^(?:gdi32)_.+?$/ &&
152 Right ( module.name, 5 ) == "_test" )
154 source_files.push_back ( module.name + ".spec" );
155 @source_files = sort(@source_files);
159 bool no_msvc_headers
= true;
160 // TODO FIXME - wine hack?
161 /*if (module.name =~ /^wine(?:runtests|test)$/
162 || Right ( module.name, 5 ) == "_test" )
164 no_msvc_headers = false;
167 std::vector
<std::string
> cfgs
;
169 cfgs
.push_back ( module
.name
+ " - Win32" );
173 std::vector
<std::string
> _cfgs
;
174 for ( i
= 0; i
< cfgs
.size(); i
++ )
176 _cfgs
.push_back ( cfgs
[i
] + " C" );
177 _cfgs
.push_back ( cfgs
[i
] + " C++" );
183 // TODO FIXME - wine hack?
186 std::vector<std::string> _cfgs;
187 for ( i = 0; i < cfgs.size(); i++ )
189 _cfgs.push_back ( cfgs[i] + " Debug" );
190 _cfgs.push_back ( cfgs[i] + " Release" );
196 if (!no_msvc_headers
)
198 std::vector
<std::string
> _cfgs
;
199 for ( i
= 0; i
< cfgs
.size(); i
++ )
201 _cfgs
.push_back ( cfgs
[i
] + " MSVC Headers" );
202 _cfgs
.push_back ( cfgs
[i
] + " Wine Headers" );
208 string default_cfg
= cfgs
.back();
210 fprintf ( OUT
, "# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\r\n", module
.name
.c_str() );
211 fprintf ( OUT
, "# Microsoft Developer Studio Generated Build File, Format Version 6.00\r\n" );
212 fprintf ( OUT
, "# ** DO NOT EDIT **\r\n" );
213 fprintf ( OUT
, "\r\n" );
217 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\r\n" );
221 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102\r\n" );
225 fprintf ( OUT
, "# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\r\n" );
227 fprintf ( OUT
, "\r\n" );
229 fprintf ( OUT
, "CFG=%s\r\n", default_cfg
.c_str() );
230 fprintf ( OUT
, "!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r\n" );
231 fprintf ( OUT
, "!MESSAGE use the Export Makefile command and run\r\n" );
232 fprintf ( OUT
, "!MESSAGE \r\n" );
233 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\".\r\n", module
.name
.c_str() );
234 fprintf ( OUT
, "!MESSAGE \r\n" );
235 fprintf ( OUT
, "!MESSAGE You can specify a configuration when running NMAKE\r\n" );
236 fprintf ( OUT
, "!MESSAGE by defining the macro CFG on the command line. For example:\r\n" );
237 fprintf ( OUT
, "!MESSAGE \r\n" );
238 fprintf ( OUT
, "!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s\"\r\n", module
.name
.c_str(), default_cfg
.c_str() );
239 fprintf ( OUT
, "!MESSAGE \r\n" );
240 fprintf ( OUT
, "!MESSAGE Possible choices for configuration are:\r\n" );
241 fprintf ( OUT
, "!MESSAGE \r\n" );
242 for ( i
= 0; i
< cfgs
.size(); i
++ )
244 const string
& cfg
= cfgs
[i
];
247 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Static Library\")\r\n", cfg
.c_str() );
251 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Dynamic-Link Library\")\r\n", cfg
.c_str() );
255 fprintf ( OUT
, "!MESSAGE \"%s\" (based on \"Win32 (x86) Console Application\")\r\n", cfg
.c_str() );
258 fprintf ( OUT
, "!MESSAGE \r\n" );
259 fprintf ( OUT
, "\r\n" );
261 fprintf ( OUT
, "# Begin Project\r\n" );
262 fprintf ( OUT
, "# PROP AllowPerConfigDependencies 0\r\n" );
263 fprintf ( OUT
, "# PROP Scc_ProjName \"\"\r\n" );
264 fprintf ( OUT
, "# PROP Scc_LocalPath \"\"\r\n" );
265 fprintf ( OUT
, "CPP=cl.exe\r\n" );
266 if ( !lib
&& !exe
) fprintf ( OUT
, "MTL=midl.exe\r\n" );
267 fprintf ( OUT
, "RSC=rc.exe\r\n" );
269 std::string output_dir
;
270 for ( size_t icfg
= 0; icfg
< cfgs
.size(); icfg
++ )
272 std::string
& cfg
= cfgs
[icfg
];
275 fprintf ( OUT
, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
276 fprintf ( OUT
, "\r\n" );
280 fprintf ( OUT
, "\r\n" );
281 fprintf ( OUT
, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg
.c_str() );
282 fprintf ( OUT
, "\r\n" );
285 bool debug
= !strstr ( cfg
.c_str(), "Release" );
286 bool msvc_headers
= ( 0 != strstr ( cfg
.c_str(), "MSVC Headers" ) );
288 fprintf ( OUT
, "# PROP BASE Use_MFC 0\r\n" );
292 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 1\r\n" );
296 fprintf ( OUT
, "# PROP BASE Use_Debug_Libraries 0\r\n" );
299 output_dir
= Replace(cfg
,module
.name
+ " - ","");
300 output_dir
= Replace(output_dir
," ","_");
301 output_dir
= Replace(output_dir
,"C++","Cxx");
302 // TODO FIXME - wine hack?
303 //if ( output_prefix_dir.size() )
304 // output_dir = output_prefix_dir + "\\" + output_dir;
306 fprintf ( OUT
, "# PROP BASE Output_Dir \"%s\"\r\n", output_dir
.c_str() );
307 fprintf ( OUT
, "# PROP BASE Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
309 fprintf ( OUT
, "# PROP BASE Target_Dir \"\"\r\n" );
311 fprintf ( OUT
, "# PROP Use_MFC 0\r\n" );
314 fprintf ( OUT
, "# PROP Use_Debug_Libraries 1\r\n" );
318 fprintf ( OUT
, "# PROP Use_Debug_Libraries 0\r\n" );
320 fprintf ( OUT
, "# PROP Output_Dir \"%s\"\r\n", output_dir
.c_str() );
321 fprintf ( OUT
, "# PROP Intermediate_Dir \"%s\"\r\n", output_dir
.c_str() );
323 if ( dll
) fprintf ( OUT
, "# PROP Ignore_Export_Lib 0\r\n" );
324 fprintf ( OUT
, "# PROP Target_Dir \"\"\r\n" );
326 StringSet defines
= common_defines
;
330 defines
.insert ( "_DEBUG" );
333 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
334 defines
.insert ( "_LIB" );
338 fprintf ( OUT
, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
339 defines
.insert ( "_WINDOWS" );
340 defines
.insert ( "_USRDLL" );
341 // TODO FIXME - wine hack?
342 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
347 defines
.insert ( "NDEBUG" );
350 fprintf ( OUT
, "# ADD BASE CPP /nologo /W3 /GX /O2" );
351 defines
.insert ( "_LIB" );
355 fprintf ( OUT
, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
356 defines
.insert ( "_WINDOWS" );
357 defines
.insert ( "_USRDLL" );
358 // TODO FIXME - wine hack?
359 //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
363 for ( StringSet::const_iterator it1
=defines
.begin(); it1
!=defines
.end(); it1
++ )
365 fprintf ( OUT
, " /D \"%s\"", it1
->c_str() );
367 if ( lib
|| exe
) fprintf ( OUT
, " /YX" );
368 fprintf ( OUT
, " /FD" );
371 fprintf ( OUT
, " /GZ" );
372 if ( lib
|| exe
) fprintf ( OUT
, " " );
374 fprintf ( OUT
, " /c" );
375 fprintf ( OUT
, "\r\n" );
379 defines
.insert ( "_DEBUG" );
382 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
383 defines
.insert ( "_LIB" );
387 fprintf ( OUT
, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
388 defines
.insert ( "_USRDLL" );
393 defines
.insert ( "NDEBUG" );
396 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
397 defines
.insert ( "_LIB" );
401 fprintf ( OUT
, "# ADD CPP /nologo /MT /W3 /GX /O2" );
402 defines
.insert ( "_USRDLL" );
406 // TODO FIXME - wine hack?
409 // TODO FIXME - wine hack?
410 //defines.insert ( string("_\U") + module.name + "\E_" );
411 // TODO FIXME - wine hack?
412 /*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
413 defines.insert ( "__WINESRC__" );*/
415 defines
.insert ( "__WINE_USE_NATIVE_HEADERS" );
416 string output_dir2
= Replace(output_dir
,"\\","\\\\");
417 defines
.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir
.c_str()) );
418 defines
.insert ( "__i386__" );
419 defines
.insert ( "_X86_" );
421 // TODO FIXME - wine hacks?
422 /*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
423 push @includes, ".." );
426 if ( strstr ( module.name.c_str(), "_test" )
428 include.push_back ( msvc_wine_dir + "\\" + output_dir );
431 if (!msvc_headers || module.name == "winetest")
433 includes.push_back ( wine_include_dir );
439 for ( i
= 0; i
< includes
.size(); i
++ )
441 const string
& include
= includes
[i
];
442 if ( strpbrk ( include
.c_str(), "[\\\"]" ) || !strncmp ( include
.c_str(), "../", 3 ) )
444 fprintf ( OUT
, " /I \"%s\"", include
.c_str() );
448 fprintf ( OUT
, " /I %s", include
.c_str() );
453 fprintf ( OUT
, " /I \".\"" );
454 for ( StringSet::const_iterator it2
=defines
.begin(); it2
!=defines
.end(); it2
++ )
456 const string
& define
= *it2
;
457 if ( strpbrk ( define
.c_str(), "[\\\"]" ) )
459 fprintf ( OUT
, " /D \"%s\"", define
.c_str() );
463 fprintf ( OUT
, " /D %s", define
.c_str() );
466 if ( wine
) fprintf ( OUT
, " /D inline=__inline" );
467 if ( 0 && wine
) fprintf ( OUT
, " /D \"__STDC__\"" );
469 fprintf ( OUT
, lib
? " /YX" : " /FR" );
470 fprintf ( OUT
, " /FD" );
471 if ( debug
) fprintf ( OUT
, " /GZ" );
472 if ( debug
&& lib
) fprintf ( OUT
, " " );
473 fprintf ( OUT
, " /c" );
474 if ( !no_cpp
) fprintf ( OUT
, " /TP" );
475 fprintf ( OUT
, "\r\n" );
481 fprintf ( OUT
, "# SUBTRACT CPP /X /YX\r\n" );
482 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
483 fprintf ( OUT
, "# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\r\n" );
485 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
486 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
489 for ( i
= 0; i
< includes
.size(); i
++ )
491 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
495 for ( StringSet::const_iterator it3
=defines
.begin(); it3
!=defines
.end(); it3
++ )
497 fprintf ( OUT
, " /D \"%s\"", it3
->c_str() );
499 fprintf ( OUT
, " /d \"_DEBUG\"\r\n" );
505 fprintf ( OUT
, "# SUBTRACT CPP /YX\r\n" );
506 fprintf ( OUT
, "# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
507 fprintf ( OUT
, "# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\r\n" );
509 fprintf ( OUT
, "# ADD BASE RSC /l 0x41d /d \"NDEBUG\"\r\n" );
510 fprintf ( OUT
, "# ADD RSC /l 0x41d" );
513 for ( i
= 0; i
< includes
.size(); i
++ )
514 fprintf ( OUT
, " /i \"%s\"", includes
[i
].c_str() );
517 for ( StringSet::const_iterator it4
=defines
.begin(); it4
!=defines
.end(); it4
++ )
519 fprintf ( OUT
, " /D \"%s\"", it4
->c_str() );
523 fprintf ( OUT
, "/d \"NDEBUG\"\r\n" );
525 fprintf ( OUT
, "BSC32=bscmake.exe\r\n" );
526 fprintf ( OUT
, "# ADD BASE BSC32 /nologo\r\n" );
527 fprintf ( OUT
, "# ADD BSC32 /nologo\r\n" );
531 fprintf ( OUT
, "LINK32=link.exe\r\n" );
532 fprintf ( OUT
, "# ADD BASE LINK32 " );
534 for ( i
= 0; i
< libraries
.size(); i
++ )
536 fprintf ( OUT
, "%s ", libraries
[i
].c_str() );
538 fprintf ( OUT
, " /nologo" );
539 if ( dll
) fprintf ( OUT
, " /dll" );
540 if ( console
) fprintf ( OUT
, " /subsystem:console" );
541 if ( debug
) fprintf ( OUT
, " /debug" );
542 fprintf ( OUT
, " /machine:I386" );
543 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
544 fprintf ( OUT
, "\r\n" );
546 fprintf ( OUT
, "# ADD LINK32" );
547 fprintf ( OUT
, " /nologo" );
548 // TODO FIXME - do we need their kludge?
549 //if ( module.name == "ntdll" ) fprintf ( OUT, " libcmt.lib" ); // FIXME: Kludge
550 for ( i
= 0; i
< imports
.size(); i
++ )
552 const string
& import
= imports
[i
];
553 if ( import
!= "msvcrt" )
554 fprintf ( OUT
, " %s.lib", import
.c_str() );
556 if ( dll
) fprintf ( OUT
, " /dll" );
557 if ( console
) fprintf ( OUT
, " /subsystem:console" );
558 if ( debug
) fprintf ( OUT
, " /debug" );
559 fprintf ( OUT
, " /machine:I386" );
560 // TODO FIXME - do we need their kludge?
561 //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
562 if ( dll
) fprintf ( OUT
, " /def:\"%s.def\"", module
.name
.c_str() );
563 if (( dll
) && ( module_type
== ".cpl")) fprintf ( OUT
, " /out:\"Win32\\%s%s\"", module
.name
.c_str(), module_type
.c_str() );
564 if ( debug
) fprintf ( OUT
, " /pdbtype:sept" );
565 fprintf ( OUT
, "\r\n" );
569 fprintf ( OUT
, "LIB32=link.exe -lib\r\n" );
570 fprintf ( OUT
, "# ADD BASE LIB32 /nologo\r\n" );
571 fprintf ( OUT
, "# ADD LIB32 /nologo\r\n" );
575 if ( cfgs
.size() != 0 )
577 fprintf ( OUT
, "\r\n" );
578 fprintf ( OUT
, "!ENDIF \r\n" );
579 fprintf ( OUT
, "\r\n" );
582 if ( module
.name
== "winebuild" )
584 fprintf ( OUT
, "# Begin Special Build Tool\r\n" );
585 fprintf ( OUT
, "SOURCE=\"$(InputPath)\"\r\n" );
586 fprintf ( OUT
, "PostBuild_Desc=Copying wine.dll and wine_unicode.dll ...\r\n" );
587 fprintf ( OUT
, "PostBuild_Cmds=" );
588 fprintf ( OUT
, "copy ..\\..\\library\\%s\\wine.dll $(OutDir)\t",
589 output_dir
.c_str() );
590 fprintf ( OUT
, "copy ..\\..\\unicode\\%s\\wine_unicode.dll $(OutDir)\r\n",
591 output_dir
.c_str() );
592 fprintf ( OUT
, "# End Special Build Tool\r\n" );
595 fprintf ( OUT
, "# Begin Target\r\n" );
596 fprintf ( OUT
, "\r\n" );
597 for ( i
= 0; i
< cfgs
.size(); i
++ )
599 fprintf ( OUT
, "# Name \"%s\"\r\n", cfgs
[i
].c_str() );
602 fprintf ( OUT
, "# Begin Group \"Source Files\"\r\n" );
603 fprintf ( OUT
, "\r\n" );
604 fprintf ( OUT
, "# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\r\n" );
606 for ( size_t isrcfile
= 0; isrcfile
< source_files
.size(); isrcfile
++ )
608 string source_file
= DosSeparator(source_files
[isrcfile
]);
610 if ( strncmp ( source_file
.c_str(), ".\\", 2 ) )
612 source_file
= string(".\\") + source_file
;
615 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
617 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
619 // TODO FIXME - not sure what this is doing? wine hack maybe?
620 //if ( basename !~ /\..{1,3}$/; ) basename += string(".dll");
621 string dbg_c_file
= basename
+ ".dbg.c";
623 fprintf ( OUT
, "# Begin Source File\r\n" );
624 fprintf ( OUT
, "\r\n" );
625 fprintf ( OUT
, "SOURCE=%s\r\n", dbg_c_file
.c_str() );
626 fprintf ( OUT
, "# End Source File\r\n" );
629 fprintf ( OUT
, "# Begin Source File\r\n" );
630 fprintf ( OUT
, "\r\n" );
632 fprintf ( OUT
, "SOURCE=%s\r\n", source_file
.c_str() );
634 if ( !strcmp ( &source_file
[source_file
.size()-5], ".spec" ) )
637 string basename
= string ( source_file
.c_str(), source_file
.size() - 5 );
639 string spec_file
= source_file
;
640 string def_file
= basename
+ ".def";
642 // TODO FIXME - not sure what this is doing? wine hack maybe?
643 //if ( basename !~ /\..{1,3}$/; ) basename += ".dll";
644 string dbg_file
= basename
+ ".dbg";
645 string dbg_c_file
= basename
+ ".dbg.c";
647 string srcdir
= "."; // FIXME: Is this really always correct?
649 fprintf ( OUT
, "# Begin Custom Build\r\n" );
650 fprintf ( OUT
, "InputPath=%s\r\n", spec_file
.c_str() );
651 fprintf ( OUT
, "\r\n" );
652 fprintf ( OUT
, "BuildCmds= \\\r\n" );
653 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe --def %s > %s \\\r\n",
658 if ( module
.name
== "ntdll" )
661 for ( i
= 0; i
< c_srcs
.size(); i
++ )
663 const string
& c_src
= c_srcs
[i
];
666 fprintf ( OUT
, "\techo %s >> %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
670 fprintf ( OUT
, "\techo %s > %s \\\r\n", c_src
.c_str(), dbg_file
.c_str() );
673 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
674 output_dir
.c_str() );
675 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
683 for ( i
= 0; i
< c_srcs
.size(); i
++ )
685 const string
& c_src
= c_srcs
[i
];
686 if ( !strcmp ( &c_src
[c_src
.size()-2], ".c" ) )
688 if ( sc_srcs
.size() )
694 fprintf ( OUT
, "\t..\\..\\tools\\winebuild\\%s\\winebuild.exe",
695 output_dir
.c_str() );
696 fprintf ( OUT
, " -o %s --debug -C%s %s \\\r\n",
702 fprintf ( OUT
, "\t\r\n" );
703 fprintf ( OUT
, "\r\n" );
704 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", def_file
.c_str() );
705 fprintf ( OUT
, " $(BuildCmds)\r\n" );
706 fprintf ( OUT
, "\r\n" );
707 fprintf ( OUT
, "\"%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", dbg_c_file
.c_str() );
708 fprintf ( OUT
, " $(BuildCmds)\r\n" );
709 fprintf ( OUT
, "# End Custom Build\r\n" );
712 /*else if ( source_file =~ /([^\\]*?\.h)$/ )
716 foreach my $cfg (@cfgs) {
720 fprintf ( OUT, "!IF \"$(CFG)\" == \"$cfg\"\r\n" );
721 fprintf ( OUT, "\r\n" );
723 fprintf ( OUT, "\r\n" );
724 fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"$cfg\"\r\n" );
725 fprintf ( OUT, "\r\n" );
729 $output_dir =~ s/^$project - //;
730 $output_dir =~ s/ /_/g;
731 $output_dir =~ s/C\+\+/Cxx/g;
732 if($output_prefix_dir) {
733 $output_dir = "$output_prefix_dir\\$output_dir" );
736 fprintf ( OUT, "# Begin Custom Build\r\n" );
737 fprintf ( OUT, "OutDir=%s\r\n", output_dir.c_str() );
738 fprintf ( OUT, "InputPath=%s\r\n", source_file.c_str() );
739 fprintf ( OUT, "\r\n" );
740 fprintf ( OUT, "\"$(OutDir)\\wine\\%s\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\r\n", h_file.c_str() );
741 fprintf ( OUT, "\tcopy \"$(InputPath)\" \"$(OutDir)\\wine\"\r\n" );
742 fprintf ( OUT, "\r\n" );
743 fprintf ( OUT, "# End Custom Build\r\n" );
746 if ( cfgs.size() != 0)
748 fprintf ( OUT, "\r\n" );
749 fprintf ( OUT, "!ENDIF \r\n" );
750 fprintf ( OUT, "\r\n" );
754 fprintf ( OUT
, "# End Source File\r\n" );
756 fprintf ( OUT
, "# End Group\r\n" );
757 fprintf ( OUT
, "# Begin Group \"Header Files\"\r\n" );
758 fprintf ( OUT
, "\r\n" );
759 fprintf ( OUT
, "# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\r\n" );
760 for ( i
= 0; i
< header_files
.size(); i
++ )
762 const string
& header_file
= header_files
[i
];
763 fprintf ( OUT
, "# Begin Source File\r\n" );
764 fprintf ( OUT
, "\r\n" );
765 fprintf ( OUT
, "SOURCE=.\\%s\r\n", header_file
.c_str() );
766 fprintf ( OUT
, "# End Source File\r\n" );
768 fprintf ( OUT
, "# End Group\r\n" );
772 fprintf ( OUT
, "# Begin Group \"Resource Files\"\r\n" );
773 fprintf ( OUT
, "\r\n" );
774 fprintf ( OUT
, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
775 /* for ( i = 0; i < resource_files.size(); i++ )
777 const string& resource_file = resource_files[i];
778 fprintf ( OUT, "# Begin Source File\r\n" );
779 fprintf ( OUT, "\r\n" );
780 fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
781 fprintf ( OUT, "# End Source File\r\n" );
783 */ fprintf ( OUT
, "# End Group\r\n" );
785 fprintf ( OUT
, "# End Target\r\n" );
786 fprintf ( OUT
, "# End Project\r\n" );
792 MSVCBackend::_generate_dsw_header ( FILE* OUT
)
794 fprintf ( OUT
, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
795 fprintf ( OUT
, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
796 fprintf ( OUT
, "\r\n" );
800 MSVCBackend::_generate_dsw_project (
802 const Module
& module
,
803 std::string dsp_file
,
804 const std::vector
<Dependency
*>& dependencies
)
806 dsp_file
= DosSeparator ( std::string(".\\") + dsp_file
);
808 // TODO FIXME - must they be sorted?
809 //@dependencies = sort(@dependencies);
811 fprintf ( OUT
, "###############################################################################\r\n" );
812 fprintf ( OUT
, "\r\n" );
813 fprintf ( OUT
, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module
.name
.c_str(), dsp_file
.c_str() );
814 fprintf ( OUT
, "\r\n" );
815 fprintf ( OUT
, "Package=<5>\r\n" );
816 fprintf ( OUT
, "{{{\r\n" );
817 fprintf ( OUT
, "}}}\r\n" );
818 fprintf ( OUT
, "\r\n" );
819 fprintf ( OUT
, "Package=<4>\r\n" );
820 fprintf ( OUT
, "{{{\r\n" );
821 for ( size_t i
= 0; i
< dependencies
.size(); i
++ )
823 Dependency
& dependency
= *dependencies
[i
];
824 fprintf ( OUT
, " Begin Project Dependency\r\n" );
825 fprintf ( OUT
, " Project_Dep_Name %s\r\n", dependency
.module
.name
.c_str() );
826 fprintf ( OUT
, " End Project Dependency\r\n" );
828 fprintf ( OUT
, "}}}\r\n" );
829 fprintf ( OUT
, "\r\n" );
833 MSVCBackend::_generate_dsw_footer ( FILE* OUT
)
835 fprintf ( OUT
, "###############################################################################\r\n" );
836 fprintf ( OUT
, "\r\n" );
837 fprintf ( OUT
, "Global:\r\n" );
838 fprintf ( OUT
, "\r\n" );
839 fprintf ( OUT
, "Package=<5>\r\n" );
840 fprintf ( OUT
, "{{{\r\n" );
841 fprintf ( OUT
, "}}}\r\n" );
842 fprintf ( OUT
, "\r\n" );
843 fprintf ( OUT
, "Package=<3>\r\n" );
844 fprintf ( OUT
, "{{{\r\n" );
845 fprintf ( OUT
, "}}}\r\n" );
846 fprintf ( OUT
, "\r\n" );
847 fprintf ( OUT
, "###############################################################################\r\n" );
848 fprintf ( OUT
, "\r\n" );
852 MSVCBackend::_generate_wine_dsw ( FILE* OUT
)
854 _generate_dsw_header(OUT
);
855 // TODO FIXME - is it necessary to sort them?
856 for ( size_t i
= 0; i
< ProjectNode
.modules
.size(); i
++ )
858 Module
& module
= *ProjectNode
.modules
[i
];
860 std::string dsp_file
= DspFileName ( module
);
862 // TODO FIXME - more wine hacks?
863 /*if ( module.name == "gdi32" )
865 for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
867 string dir2 = gdi32_dirs[idir];
868 $dir2 =~ s%^.*?/([^/]+)$%$1%;
870 dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
874 _generate_dsw_project ( OUT
, module
, dsp_file
, module
.dependencies
);
876 _generate_dsw_footer ( OUT
);