]> git.tdb.fi Git - builder.git/commitdiff
Improve file target naming
authorMikko Rasa <tdb@tdb.fi>
Sat, 31 Mar 2012 10:47:28 +0000 (13:47 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 31 Mar 2012 10:47:28 +0000 (13:47 +0300)
source/filetarget.cpp

index 88672317dc35cab7afa7c5fdef65a8d65edc7e57..1deead060d7ff9734f50bf053a058d598d7bb3a7 100644 (file)
@@ -64,9 +64,17 @@ string FileTarget::make_name(const Package *pkg, const FS::Path &pth)
 {
        if(const SourcePackage *spkg = dynamic_cast<const SourcePackage *>(pkg))
        {
-               FS::Path relpath = FS::relative(pth, spkg->get_source());
-               return format("<%s>%s", pkg->get_name(), relpath.str().substr(1));
+               if(FS::descendant_depth(pth, spkg->get_source())>=0)
+               {
+                       FS::Path relpath = FS::relative(pth, spkg->get_source());
+                       return format("<%s>%s", pkg->get_name(), relpath.str().substr(1));
+               }
+               else if(FS::descendant_depth(pth, pkg->get_builder().get_prefix())>=0)
+               {
+                       FS::Path relpath = FS::relative(pth, pkg->get_builder().get_prefix());
+                       return "<prefix>"+relpath.str().substr(1);
+               }
        }
-       else
-               return pth.str();
+
+       return pth.str();
 }