X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=plugins%2Fmsvc%2Fmsvclinker.cpp;h=d768b236cbb5d7dd7b80812af8776ed0688295e4;hb=34c5818e80579cb1c483b5020be0b7d5291aae0b;hp=8008791569a37d2c57816d0e68a8199b6124eddf;hpb=c8e829c219c65ff8e93b6c7b66212ff0876441c5;p=builder.git diff --git a/plugins/msvc/msvclinker.cpp b/plugins/msvc/msvclinker.cpp index 8008791..d768b23 100644 --- a/plugins/msvc/msvclinker.cpp +++ b/plugins/msvc/msvclinker.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -19,8 +20,8 @@ MsvcLinker::MsvcLinker(Builder &b, const Architecture &a, const MicrosoftTools & Tool(b, &a, "LINK"), ms_tools(m) { - input_suffixes.push_back(".o"); - input_suffixes.push_back(".a"); + input_suffixes.push_back(".obj"); + input_suffixes.push_back(".lib"); processing_unit = COMPONENT; @@ -41,13 +42,34 @@ Target *MsvcLinker::create_target(const vector &sources, const string const Component &comp = *objs.front()->get_component(); Binary *bin = 0; if(arg=="shared") - bin = new SharedLibrary(builder, comp, objs); + { + SharedLibrary *shlib = new SharedLibrary(builder, comp, objs); + bin = shlib; + ImportLibrary *imp = new ImportLibrary(builder, comp, *shlib); + for(ObjectFile *o: objs) + imp->add_dependency(*o); + imp->set_tool(*this); + shlib->add_side_effect(*imp); + } else bin = new Executable(builder, comp, objs); bin->set_tool(*this); return bin; } +Target *MsvcLinker::create_install(Target &target) const +{ + if(SharedLibrary *shlib = dynamic_cast(&target)) + { + Tool © = builder.get_toolchain().get_tool("CP"); + InstalledFile *inst_tgt = dynamic_cast(copy.create_target(target)); + builder.get_build_graph().add_installed_target(*shlib->get_import_library()); + return inst_tgt; + } + else + return 0; +} + string MsvcLinker::create_build_signature(const BuildInfo &binfo) const { string result = Tool::create_build_signature(binfo); @@ -94,8 +116,13 @@ ExternalTask::Arguments MsvcLinker::_run(const Binary &bin, FS::Path &work_dir) argv.push_back(tool.get_executable()->get_path().str()); argv.push_back("/NOLOGO"); - if(dynamic_cast(&bin)) + string imp_fn; + if(const SharedLibrary *shlib = dynamic_cast(&bin)) + { argv.push_back("/DLL"); + if(const ImportLibrary *imp = shlib->get_import_library()) + imp_fn = relative(imp->get_path(), work_dir).str(); + } BuildInfo binfo; bin.collect_build_info(binfo); @@ -105,9 +132,18 @@ ExternalTask::Arguments MsvcLinker::_run(const Binary &bin, FS::Path &work_dir) if(binfo.strip) argv.push_back("/INCREMENTAL:NO"); else + { argv.push_back("/DEBUG:FULL"); + FS::Path temp_dir = bin.get_package()->get_temp_directory()/bin.get_component()->get_name(); + FS::Path ilk_path = temp_dir/(FS::basepart(FS::basename(bin.get_path()))+".ilk"); + argv.push_back("/ILK:"+relative(ilk_path, work_dir).str()); + } argv.push_back("/OUT:"+relative(bin.get_path(), work_dir).str()); + if(!imp_fn.empty()) + argv.push_back("/IMPLIB:"+imp_fn); + else + argv.push_back("/NOIMPLIB"); for(Target *d: bin.get_dependencies()) {