]> git.tdb.fi Git - builder.git/commitdiff
More generic system for installing targets under different names
authorMikko Rasa <tdb@tdb.fi>
Wed, 5 Sep 2012 16:54:45 +0000 (19:54 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 5 Sep 2012 16:54:45 +0000 (19:54 +0300)
source/filetarget.h
source/installedfile.cpp
source/sharedlibrary.cpp

index a48e1ab6d976932eb507653bc9c37a2a8fe19d91..da6b9a883d6625b9e20d87bc9880822b23aea846 100644 (file)
@@ -15,6 +15,7 @@ protected:
        Msp::Time::TimeStamp mtime;
        unsigned size;
        Msp::FS::Path install_location;
+       std::string install_filename;
 
        FileTarget(Builder &, const Msp::FS::Path &);
        FileTarget(Builder &, const SourcePackage &, const Msp::FS::Path &);
@@ -30,6 +31,7 @@ public:
 
        bool is_installable() const { return !install_location.empty(); }
        const Msp::FS::Path &get_install_location() const { return install_location; }
+       const std::string &get_install_filename() const { return install_filename; }
 
        /// Changes the mtime of the target to the current time.
        void touch();
index 76e7b69456010b8dd30d233a5d4d23f384ffbb1f..b2487537369076f705b136a1023371f9a9cf7356 100644 (file)
@@ -13,12 +13,16 @@ InstalledFile::InstalledFile(Builder &b, const SourcePackage &p, FileTarget &s,
 {
        add_dependency(source);
 
-       if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
-               if(!shlib->get_soname().empty())
-                       link = FS::dirname(path)/FS::basename(shlib->get_path());
-
-       if(!link.empty())
+       /* XXX Ideally, the tool should handle this (symlinks are not necessary for
+       windows dlls).  However, the tool that created the target being installed
+       knows nothing about the InstalledFile. */
+       string base_fn = FS::basename(source.get_path());
+       const string &inst_fn = source.get_install_filename();
+       if(!inst_fn.empty() && inst_fn!=base_fn)
+       {
+               link = FS::dirname(path)/base_fn;
                builder.get_vfs().register_path(link, this);
+       }
 }
 
 FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
@@ -34,10 +38,9 @@ FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileT
        else
                mid = tgt.get_install_location();
 
-       string fn = FS::basename(tgt.get_path());
-       if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&tgt))
-               if(!shlib->get_soname().empty())
-                       fn = shlib->get_soname();
+       string fn = tgt.get_install_filename();
+       if(fn.empty())
+               fn = FS::basename(tgt.get_path());
 
        return prefix/mid/fn;
 }
index 9b2fdbb1bd99b02bc3a99f877ec67779b4790c31..5fcbe74aa42a6a632d79303557e4bceb767e8abd 100644 (file)
@@ -33,6 +33,7 @@ SharedLibrary::SharedLibrary(Builder &b, const Component &c, const list<ObjectFi
                                break;
 
                soname = format("%s.%s", FS::basename(path), version.substr(0, i));
+               install_filename = soname;
        }
 }