* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef _MSC_VER
#include <string>
#include <vector>
+#include <set>
#include <stdio.h>
using std::string;
using std::vector;
+using std::set;
+
+typedef set<string> StringSet;
+
+#ifdef OUT
+#undef OUT
+#endif//OUT
void
MSVCBackend::_generate_dsp ( const Module& module )
imports.push_back ( module.non_if_data.libraries[i]->name );
}
- string module_type = GetExtension(module.GetTargetName());
+ string module_type = GetExtension(*module.output);
bool lib = (module_type == ".lib") || (module_type == ".a");
bool dll = (module_type == ".dll") || (module_type == ".cpl");
- bool exe = (module_type == ".exe");
+ bool exe = (module_type == ".exe") || (module_type == ".scr");
// TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
bool console = exe && (module.type == Win32CUI);
//$output->progress("$dsp_file (file $progress_current of $progress_max)");
// TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?
- string dsp_path = module.GetBasePath();
- vector<string> c_srcs, source_files, resource_files, includes, libraries, defines;
+ vector<string> c_srcs, source_files, header_files, resource_files, includes, libraries;
+ StringSet common_defines;
vector<const IfableData*> ifs_list;
ifs_list.push_back ( &module.project.non_if_data );
ifs_list.push_back ( &module.non_if_data );
// this is a define in MinGW w32api, but not Microsoft's headers
- defines.push_back ( "STDCALL=__stdcall" );
+ common_defines.insert ( "STDCALL=__stdcall" );
while ( ifs_list.size() )
{
const IfableData& data = *ifs_list.back();
ifs_list.pop_back();
- // TODO FIXME - refactor needed - we're discarding if conditions
- for ( i = 0; i < data.ifs.size(); i++ )
- ifs_list.push_back ( &data.ifs[i]->data );
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
- // TODO FIXME - do we want the full path of the file here?
- string file = string(".") + &files[i]->name[dsp_path.size()];
+ if (files[i]->file.directory != SourceDirectory)
+ continue;
+
+ // We want the full path here for directory support later on
+ string path = Path::RelativeFromDirectory (
+ files[i]->file.relative_path,
+ module.output->relative_path );
+ string file = path + std::string("\\") + files[i]->file.name;
source_files.push_back ( file );
if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
c_srcs.push_back ( file );
+ if ( !stricmp ( Right(file,2).c_str(), ".h" ) )
+ header_files.push_back ( file );
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
resource_files.push_back ( file );
}
const vector<Include*>& incs = data.includes;
for ( i = 0; i < incs.size(); i++ )
{
-
- // explicitly omit win32api directories
- if ( !strncmp(incs[i]->directory.c_str(), "w32api", 6 ) )
- continue;
-
- // explicitly omit include/wine directories
- if ( !strncmp(incs[i]->directory.c_str(), "include\\wine", 12 ) )
- continue;
-
string path = Path::RelativeFromDirectory (
- incs[i]->directory,
- module.GetBasePath() );
+ incs[i]->directory->relative_path,
+ module.output->relative_path );
includes.push_back ( path );
}
const vector<Library*>& libs = data.libraries;
for ( i = 0; i < defs.size(); i++ )
{
if ( defs[i]->value[0] )
- defines.push_back ( defs[i]->name + "=" + defs[i]->value );
+ common_defines.insert( defs[i]->name + "=" + defs[i]->value );
else
- defines.push_back ( defs[i]->name );
+ common_defines.insert( defs[i]->name );
}
}
// TODO FIXME - we don't include header files in our build system
//my @header_files = @{module->{header_files}};
- vector<string> header_files;
+ //vector<string> header_files;
// TODO FIXME - wine hack?
/*if (module.name !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
if ( !lib && !exe ) fprintf ( OUT, "MTL=midl.exe\r\n" );
fprintf ( OUT, "RSC=rc.exe\r\n" );
- int n = 0;
-
std::string output_dir;
for ( size_t icfg = 0; icfg < cfgs.size(); icfg++ )
{
std::string& cfg = cfgs[icfg];
- if ( icfg )
+ if ( icfg == 0 )
{
- if ( n == 0 )
- {
- fprintf ( OUT, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg.c_str() );
- fprintf ( OUT, "\r\n" );
- }
- else
- {
- fprintf ( OUT, "\r\n" );
- fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg.c_str() );
- fprintf ( OUT, "\r\n" );
- }
+ fprintf ( OUT, "!IF \"$(CFG)\" == \"%s\"\r\n", cfg.c_str() );
+ fprintf ( OUT, "\r\n" );
+ }
+ else
+ {
+ fprintf ( OUT, "\r\n" );
+ fprintf ( OUT, "!ELSEIF \"$(CFG)\" == \"%s\"\r\n", cfg.c_str() );
+ fprintf ( OUT, "\r\n" );
}
bool debug = !strstr ( cfg.c_str(), "Release" );
if ( dll ) fprintf ( OUT, "# PROP Ignore_Export_Lib 0\r\n" );
fprintf ( OUT, "# PROP Target_Dir \"\"\r\n" );
+ StringSet defines = common_defines;
+
if ( debug )
{
- defines.push_back ( "_DEBUG" );
+ defines.insert ( "_DEBUG" );
if ( lib || exe )
{
fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od" );
- defines.push_back ( "_LIB" );
+ defines.insert ( "_LIB" );
}
else
{
fprintf ( OUT, "# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
- defines.push_back ( "_WINDOWS" );
- defines.push_back ( "_USRDLL" );
+ defines.insert ( "_WINDOWS" );
+ defines.insert ( "_USRDLL" );
// TODO FIXME - wine hack?
- //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
+ //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
}
}
else
{
- defines.push_back ( "NDEBUG" );
+ defines.insert ( "NDEBUG" );
if ( lib || exe )
{
fprintf ( OUT, "# ADD BASE CPP /nologo /W3 /GX /O2" );
- defines.push_back ( "_LIB" );
+ defines.insert ( "_LIB" );
}
else
{
fprintf ( OUT, "# ADD BASE CPP /nologo /MT /W3 /GX /O2" );
- defines.push_back ( "_WINDOWS" );
- defines.push_back ( "_USRDLL" );
+ defines.insert ( "_WINDOWS" );
+ defines.insert ( "_USRDLL" );
// TODO FIXME - wine hack?
- //defines.push_back ( string("\U") + module.name + "\E_EXPORTS" );
+ //defines.insert ( string("\U") + module.name + "\E_EXPORTS" );
}
}
- for ( i = 0; i < defines.size(); i++ )
+ for ( StringSet::const_iterator it1=defines.begin(); it1!=defines.end(); it1++ )
{
- fprintf ( OUT, " /D \"%s\"", defines[i].c_str() );
+ fprintf ( OUT, " /D \"%s\"", it1->c_str() );
}
if ( lib || exe ) fprintf ( OUT, " /YX" );
fprintf ( OUT, " /FD" );
fprintf ( OUT, " /c" );
fprintf ( OUT, "\r\n" );
- vector<string> defines2 = defines;
if ( debug )
{
- defines2.push_back ( "_DEBUG" );
+ defines.insert ( "_DEBUG" );
if(lib)
{
fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
- defines2.push_back ( "_LIB" );
+ defines.insert ( "_LIB" );
}
else
{
fprintf ( OUT, "# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od" );
- defines2.push_back ( "_USRDLL" );
+ defines.insert ( "_USRDLL" );
}
}
else
{
- defines2.push_back ( "NDEBUG" );
+ defines.insert ( "NDEBUG" );
if(lib)
{
fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" );
- defines2.push_back ( "_LIB" );
+ defines.insert ( "_LIB" );
}
else
{
fprintf ( OUT, "# ADD CPP /nologo /MT /W3 /GX /O2" );
- defines2.push_back ( "_USRDLL" );
+ defines.insert ( "_USRDLL" );
}
}
if ( wine )
{
// TODO FIXME - wine hack?
- //defines2.push_back ( string("_\U") + module.name + "\E_" );
+ //defines.insert ( string("_\U") + module.name + "\E_" );
// TODO FIXME - wine hack?
/*if ( module.name !~ /^(?:wine(?:build|test)|.*?_test)$/ )
- defines2.push_back ( "__WINESRC__" );*/
+ defines.insert ( "__WINESRC__" );*/
if ( msvc_headers )
- defines2.push_back ( "__WINE_USE_NATIVE_HEADERS" );
+ defines.insert ( "__WINE_USE_NATIVE_HEADERS" );
string output_dir2 = Replace(output_dir,"\\","\\\\");
- defines2.push_back ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir.c_str()) );
- defines2.push_back ( "__i386__" );
- defines2.push_back ( "_X86_" );
+ defines.insert ( ssprintf("__WINETEST_OUTPUT_DIR=\\\"%s\\\"",output_dir.c_str()) );
+ defines.insert ( "__i386__" );
+ defines.insert ( "_X86_" );
// TODO FIXME - wine hacks?
/*if(module.name =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
}
fprintf ( OUT, " /I \".\"" );
- for ( i = 0; i < defines2.size(); i++ )
+ for ( StringSet::const_iterator it2=defines.begin(); it2!=defines.end(); it2++ )
{
- const string& define = defines2[i];
+ const string& define = *it2;
if ( strpbrk ( define.c_str(), "[\\\"]" ) )
{
fprintf ( OUT, " /D \"%s\"", define.c_str() );
}
}
- for ( i = 0; i < defines.size(); i++ )
+ for ( StringSet::const_iterator it3=defines.begin(); it3!=defines.end(); it3++ )
{
- fprintf ( OUT, " /D \"%s\"", defines[i].c_str() );
+ fprintf ( OUT, " /D \"%s\"", it3->c_str() );
}
fprintf ( OUT, " /d \"_DEBUG\"\r\n" );
}
fprintf ( OUT, " /i \"%s\"", includes[i].c_str() );
}
- for ( i = 0; i < defines.size(); i++ )
+ for ( StringSet::const_iterator it4=defines.begin(); it4!=defines.end(); it4++ )
{
- fprintf ( OUT, " /D \"%s\"", defines[i].c_str() );
+ fprintf ( OUT, " /D \"%s\"", it4->c_str() );
}
fprintf ( OUT, "# ADD BASE LIB32 /nologo\r\n" );
fprintf ( OUT, "# ADD LIB32 /nologo\r\n" );
}
-
- n++;
}
if ( cfgs.size() != 0 )
output_dir.c_str(),
spec_file.c_str(),
def_file.c_str() );
-
+
if ( module.name == "ntdll" )
{
int n = 0;
void
MSVCBackend::_generate_dsw_header ( FILE* OUT )
{
- fprintf ( OUT, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
- fprintf ( OUT, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
- fprintf ( OUT, "\r\n" );
+ fprintf ( OUT, "Microsoft Developer Studio Workspace File, Format Version 6.00\r\n" );
+ fprintf ( OUT, "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r\n" );
+ fprintf ( OUT, "\r\n" );
}
void
std::string dsp_file,
const std::vector<Dependency*>& dependencies )
{
- dsp_file = DosSeparator ( std::string(".\\") + dsp_file );
-
+ dsp_file = DosSeparator ( std::string(".\\") + dsp_file );
+
// TODO FIXME - must they be sorted?
- //@dependencies = sort(@dependencies);
-
- fprintf ( OUT, "###############################################################################\r\n" );
- fprintf ( OUT, "\r\n" );
- fprintf ( OUT, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module.name.c_str(), dsp_file.c_str() );
- fprintf ( OUT, "\r\n" );
- fprintf ( OUT, "Package=<5>\r\n" );
- fprintf ( OUT, "{{{\r\n" );
- fprintf ( OUT, "}}}\r\n" );
- fprintf ( OUT, "\r\n" );
- fprintf ( OUT, "Package=<4>\r\n" );
- fprintf ( OUT, "{{{\r\n" );
+ //@dependencies = sort(@dependencies);
+
+ fprintf ( OUT, "###############################################################################\r\n" );
+ fprintf ( OUT, "\r\n" );
+ fprintf ( OUT, "Project: \"%s\"=%s - Package Owner=<4>\r\n", module.name.c_str(), dsp_file.c_str() );
+ fprintf ( OUT, "\r\n" );
+ fprintf ( OUT, "Package=<5>\r\n" );
+ fprintf ( OUT, "{{{\r\n" );
+ fprintf ( OUT, "}}}\r\n" );
+ fprintf ( OUT, "\r\n" );
+ fprintf ( OUT, "Package=<4>\r\n" );
+ fprintf ( OUT, "{{{\r\n" );
for ( size_t i = 0; i < dependencies.size(); i++ )
{
Dependency& dependency = *dependencies[i];
{
_generate_dsw_header(OUT);
// TODO FIXME - is it necessary to sort them?
- for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
+ for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
{
- Module& module = *ProjectNode.modules[i];
+ Module& module = *p->second;
std::string dsp_file = DspFileName ( module );
// TODO FIXME - more wine hacks?
- /*if ( module.name == "gdi32" )
+ /*if ( module.name == "gdi32" )
{
for ( size_t idir = 0; idir < gdi32_dirs.size(); idir++ )
{
dependencies.push_back ( Replace ( "gdi32_" + dir2, "/", "_" ) );
}
- }*/
+ }*/
_generate_dsw_project ( OUT, module, dsp_file, module.dependencies );
- }
- _generate_dsw_footer ( OUT );
+ }
+ _generate_dsw_footer ( OUT );
}