]> git.tdb.fi Git - builder.git/commitdiff
Have SourcePackage generate the interface version
authorMikko Rasa <tdb@tdb.fi>
Thu, 6 Sep 2012 14:42:32 +0000 (17:42 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 7 Sep 2012 17:49:06 +0000 (20:49 +0300)
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
source/sourcepackage.cpp
source/sourcepackage.h

index b1ad358fdbc675a3113333a6eaae5bcbcfd8f921..56f9b32d3e09d5056717faf93d663b57d80648ec 100644 (file)
@@ -24,20 +24,15 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFi
        if(component->get_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<version.size(); ++i)
-                       if(version[i]=='.' && ++dots>=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;
        }
index 5c83fd7ec18607b4e6728a6594bbb040f017d1ee..9d8a5656935ac02a30581e715455c6bdfb5a5486 100644 (file)
@@ -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<Component::MODULE>);
        add("headers",     &Loader::headers);
        add("install",     &Loader::component<Component::INSTALL>);
+       add("interface_version", &Loader::interface_version);
        add("datafile",    &Loader::component<Component::DATAFILE>);
        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<Component::SourceList &>(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<obj.version.size(); ++i)
+               if(obj.version[i]=='.' && ++dots>=2)
+                       break;
+       obj.interface_version = obj.version.substr(0, i);
+}
index 97c8d61a6fb7914494c31475a8423e8954d3d66c..f0a58b74dc9619ed1a6fe5abfb865e61ab34d9b9 100644 (file)
@@ -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<Component> ComponentList;
@@ -58,6 +60,7 @@ private:
        typedef std::list<Feature> 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; }