From e15bd086a1ef924b7986d18a1c5b3d31f54a01de Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 6 Sep 2012 17:42:32 +0300 Subject: [PATCH] Have SourcePackage generate the interface version It will be needed for import libraries in the near future as well, and it would be stupid to duplicate the generation code. This also makes it possibile for the package author to define a custom interface version. --- source/sharedlibrary.cpp | 11 +++-------- source/sourcepackage.cpp | 21 ++++++++++++++++++++- source/sourcepackage.h | 4 ++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index b1ad358..56f9b32 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -24,20 +24,15 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const listget_type()==Component::MODULE) install_location /= package->get_name(); - const string &version = component->get_package().get_version(); + const string &version = component->get_package().get_interface_version(); if(!version.empty()) { - string::size_type i = 0; - for(unsigned dots=0; i=2) - break; - const Architecture &arch = builder.get_current_arch(); const Pattern &pattern = arch.get_shared_library_patterns().front(); if(arch.get_system()=="windows") - soname = pattern.apply(format("%s-%s", component->get_name(), version.substr(0, i))); + soname = pattern.apply(format("%s-%s", component->get_name(), version)); else - soname = format("%s.%s", pattern.apply(component->get_name()), version.substr(0, i)); + soname = format("%s.%s", pattern.apply(component->get_name()), version); install_filename = soname; } diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 5c83fd7..9d8a565 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -142,7 +142,6 @@ SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions &o): void SourcePackage::Loader::init(const Config::InputOptions *o) { options = o; - add("version", &SourcePackage::version); add("description", &SourcePackage::description); add("build_info", &Loader::build_info); add("feature", &Loader::feature); @@ -153,10 +152,12 @@ void SourcePackage::Loader::init(const Config::InputOptions *o) add("module", &Loader::component); add("headers", &Loader::headers); add("install", &Loader::component); + add("interface_version", &Loader::interface_version); add("datafile", &Loader::component); add("source_tarball", &Loader::source_tarball); add("tarball", &Loader::tarball); add("tar_file", &Loader::tar_file); + add("version", &Loader::version); } void SourcePackage::Loader::finish() @@ -254,6 +255,13 @@ void SourcePackage::Loader::if_feature(const string &cond) load_sub_with(*this); } +void SourcePackage::Loader::interface_version(const string &v) +{ + obj.interface_version = v; + if(obj.version.empty()) + obj.version = v; +} + void SourcePackage::Loader::source_tarball() { load_sub(*obj.source_tarball); @@ -280,3 +288,14 @@ void SourcePackage::Loader::tar_file(const string &f) if(i->get_type()==Component::TARBALL && i->get_name()=="@src") const_cast(i->get_sources()).push_back((obj.source_dir/f).str()); } + +void SourcePackage::Loader::version(const string &v) +{ + obj.version = v; + + string::size_type i = 0; + for(unsigned dots=0; i=2) + break; + obj.interface_version = obj.version.substr(0, i); +} diff --git a/source/sourcepackage.h b/source/sourcepackage.h index 97c8d61..f0a58b7 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -47,9 +47,11 @@ public: void build_info(); void headers(const std::string &); void if_feature(const std::string &); + void interface_version(const std::string &); void source_tarball(); void tarball(const std::string &); void tar_file(const std::string &); + void version(const std::string &); }; typedef std::list ComponentList; @@ -58,6 +60,7 @@ private: typedef std::list FeatureList; std::string version; + std::string interface_version; std::string description; FileTarget *build_file; @@ -74,6 +77,7 @@ public: SourcePackage(Builder &, const std::string &, const Msp::FS::Path &); const std::string &get_version() const { return version; } + const std::string &get_interface_version() const { return interface_version; } const std::string &get_description() const { return description; } FileTarget &get_build_file() const { return *build_file; } const Msp::FS::Path &get_source_directory() const { return source_dir; } -- 2.45.2