]> git.tdb.fi Git - builder.git/commitdiff
Build shared libraries directly to a versioned name
authorMikko Rasa <tdb@tdb.fi>
Mon, 2 Jan 2023 20:25:48 +0000 (22:25 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 2 Jan 2023 22:51:46 +0000 (00:51 +0200)
The MSVC linker does not have an equivalent to the GNU linker's soname
option, so the build filename must match the one the library will be
loaded with at runtime.

plugins/gnu/mingwdlltool.cpp
source/lib/sharedlibrary.cpp

index e93edc38b32e5ac2ffcda67e36a40cb7b5d12d2e..f0128005c67cc12b985206105d69a1c1a391fa9d 100644 (file)
@@ -94,10 +94,7 @@ Task *MingwDllTool::_run(const Target &target)
                argv.push_back(relative(exp->get_path(), work_dir).str());
 
                argv.push_back("-D");
-               if(shlib.get_install_filename().empty())
-                       argv.push_back(FS::basename(shlib.get_path()));
-               else
-                       argv.push_back(shlib.get_install_filename());
+               argv.push_back(FS::basename(shlib.get_path()));
 
                argv.push_back("-l");
                argv.push_back(relative(imp->get_path(), work_dir).str());
index aae366332c974944cf2503949a09bdab164e63aa..bd8ee260530ce6c226f54ddb74295d4f83dda3e1 100644 (file)
@@ -35,22 +35,6 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const vector<Object
        const BinaryComponent &bcomp = dynamic_cast<const BinaryComponent &>(*component);
        if(bcomp.get_type()==BinaryComponent::MODULE)
                install_location /= package->get_name();
-       else
-       {
-               const string &version = component->get_package().get_interface_version();
-               if(!version.empty())
-               {
-                       const Architecture &arch = builder.get_current_arch();
-                       if(arch.get_system()=="windows")
-                               soname = arch.create_filename<SharedLibrary>(format("%s-%s", libname, version));
-                       else if(arch.get_system()=="darwin")
-                               soname = arch.create_filename<SharedLibrary>(format("%s.%s", libname, version));
-                       else
-                               soname = format("%s.%s", arch.create_filename<SharedLibrary>(libname), version);
-
-                       install_filename = soname;
-               }
-       }
 
        for(ObjectFile *o: objects)
                o->set_used_in_shared_library(true);
@@ -63,8 +47,20 @@ string SharedLibrary::generate_filename(const Component &comp)
                return comp.get_name()+".dlm";
        else
        {
-               const Architecture &arch = comp.get_package().get_builder().get_current_arch();
-               return arch.create_filename<SharedLibrary>(comp.get_name());
+               const SourcePackage &pkg = comp.get_package();
+               const Architecture &arch = pkg.get_builder().get_current_arch();
+               const string &version = pkg.get_interface_version();
+               if(!version.empty())
+               {
+                       if(arch.get_system()=="windows")
+                               return arch.create_filename<SharedLibrary>(format("%s-%s", comp.get_name(), version));
+                       else if(arch.get_system()=="darwin")
+                               return arch.create_filename<SharedLibrary>(format("%s.%s", comp.get_name(), version));
+                       else
+                               return format("%s.%s", arch.create_filename<SharedLibrary>(comp.get_name()), version);
+               }
+               else
+                       return arch.create_filename<SharedLibrary>(comp.get_name());
        }
 }