SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
Binary(b, c, generate_filename(c), objs),
- libname(c.get_name()),
- soname(create_soname(c))
+ libname(c.get_name())
{
install_location = "lib";
if(component->get_type()==Component::MODULE)
install_location += '/';
install_location += package->get_name();
}
+
+ const string &version = component->get_package().get_version();
+ if(!version.empty())
+ {
+ string::size_type i = 0;
+ for(unsigned dots=0; i<version.size(); ++i)
+ if(version[i]=='.' && ++dots>=2)
+ break;
+
+ soname = format("%s.%s", FS::basename(path), version.substr(0, i));
+ }
}
string SharedLibrary::generate_filename(const Component &comp)
return arch.get_shared_library_patterns().front().apply(comp.get_name());
}
}
-
-string SharedLibrary::create_soname(const Component &c)
-{
- const string &ver = c.get_package().get_version();
- if(ver.empty())
- return string();
-
- unsigned dots = 0;
- unsigned i = 0;
- for(; i<ver.size(); ++i)
- if(ver[i]=='.')
- {
- ++dots;
- if(dots>=2)
- break;
- }
-
- return format("%s.%s", FS::basename(path), ver.substr(0, i));
-}