From ef764f615ed7b18c8c6c8546d9100b8567a49407 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 20 Nov 2007 07:51:53 +0000 Subject: [PATCH] autogenerate module definition files for msvc svn path=/trunk/; revision=30585 --- reactos/tools/rbuild/backend/msvc/msvc.h | 1 + .../tools/rbuild/backend/msvc/vcprojmaker.cpp | 60 ++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/reactos/tools/rbuild/backend/msvc/msvc.h b/reactos/tools/rbuild/backend/msvc/msvc.h index 725b9d1e7be..c8fe5468b6c 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.h +++ b/reactos/tools/rbuild/backend/msvc/msvc.h @@ -112,6 +112,7 @@ class MSVCBackend : public Backend // functions in vcprojmaker.cpp: + std::string _strip_gcc_deffile(std::string Filename, std::string sourcedir, std::string objdir); std::string _get_solution_version ( void ); std::string _gen_guid(); std::string _replace_str( diff --git a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp index 3c60a746e8d..dd18c17262b 100644 --- a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include @@ -82,6 +84,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) string vcproj_file = VcprojFileName(module); string computername; string username; + string intermediatedir = ""; if (getenv ( "USERNAME" ) != NULL) username = getenv ( "USERNAME" ); @@ -264,6 +267,14 @@ MSVCBackend::_generate_vcproj ( const Module& module ) int n = 0; std::string output_dir; + string importLib; + + // don't do the work m_configurations.size() times + if (module.importLibrary != NULL) + { + intermediatedir = intdir + "\\" + module.output->relative_path + vcdir; + importLib = _strip_gcc_deffile(module.importLibrary->source->name, module.importLibrary->source->relative_path, intermediatedir); + } fprintf ( OUT, "\t\r\n" ); for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) @@ -449,7 +460,7 @@ MSVCBackend::_generate_vcproj ( const Module& module ) } if (module.importLibrary != NULL) - fprintf ( OUT, "\t\t\t\tModuleDefinitionFile=\"%s\"\r\n", module.importLibrary->source->name.c_str ()); + fprintf ( OUT, "\t\t\t\tModuleDefinitionFile=\"%s\"\r\n", importLib.c_str()); fprintf ( OUT, "\t\t\t\tAdditionalDependencies=\"" ); bool use_msvcrt_lib = false; @@ -831,6 +842,53 @@ MSVCBackend::_generate_vcproj ( const Module& module ) } +std::string +MSVCBackend::_strip_gcc_deffile(std::string Filename, std::string sourcedir, std::string objdir) +{ + std::string NewFilename = objdir + "\\" + Filename; + // we don't like infinite loops - so replace it in two steps + NewFilename = _replace_str(NewFilename, ".def", "_msvc.de"); + NewFilename = _replace_str(NewFilename, "_msvc.de", "_msvc.def"); + Filename = sourcedir + "\\" + Filename; + + std::fstream in_file(Filename.c_str(), std::ios::in); + std::fstream out_file(NewFilename.c_str(), std::ios::out); + std::string::size_type pos; + DWORD i = 0; + + std::string line; + while (std::getline(in_file, line)) + { + pos = line.find("@", 0); + while (std::string::npos != pos) + { + if (pos > 1) + { + // make sure it is stdcall and no ordinal + if (line[pos -1] != ' ') + { + i = 0; + while (true) + { + i++; + if ((line[pos + i] < '0') || (line[pos + i] > '9')) + break; + } + line.replace(pos, i, ""); + } + } + pos = line.find("@", pos + 1); + } + + line += "\n"; + out_file << line; + } + in_file.close(); + out_file.close(); + + return NewFilename; +} + std::string MSVCBackend::_replace_str(std::string string1, const std::string &find_str, const std::string &replace_str) {