From: Mikko Rasa Date: Mon, 2 Jan 2023 22:46:59 +0000 (+0200) Subject: Create import libraries with MSVC linker X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=353069077e5a35b5a7aa282fde939b1d1d7f68df;p=builder.git Create import libraries with MSVC linker --- diff --git a/plugins/msvc/msvclinker.cpp b/plugins/msvc/msvclinker.cpp index ca77a28..5ce9d32 100644 --- a/plugins/msvc/msvclinker.cpp +++ b/plugins/msvc/msvclinker.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/plugins/msvc/msvclinker.h b/plugins/msvc/msvclinker.h index fe98c7d..fc9e9df 100644 --- a/plugins/msvc/msvclinker.h +++ b/plugins/msvc/msvclinker.h @@ -15,6 +15,7 @@ public: MsvcLinker(Builder &, const Architecture &, const MicrosoftTools &); Target *create_target(const std::vector &, const std::string &) override; + Target *create_install(Target &) const override; std::string create_build_signature(const BuildInfo &) const override; protected: