X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffiletarget.cpp;h=1deead060d7ff9734f50bf053a058d598d7bb3a7;hb=463a3521e27870294455373f9c69279069611975;hp=d6dcd1681c4d589cdb7976279e7acfdc032dd46c;hpb=43bd25ffcb0b4f7882773f4676b209a99cb73c04;p=builder.git diff --git a/source/filetarget.cpp b/source/filetarget.cpp index d6dcd16..1deead0 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "builder.h" #include "filetarget.h" @@ -9,11 +10,11 @@ using namespace std; using namespace Msp; FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a): - Target(b, p, FS::basename(a.str())), + Target(b, p, make_name(p, a)), path(a), size(0) { - builder.add_target(this); + builder.register_path(path, this); if(FS::Stat st = FS::lstat(path)) { @@ -58,3 +59,22 @@ void FileTarget::check_rebuild() if(!rebuild && spkg && spkg->get_config().get_mtime()>mtime) mark_rebuild("Package options changed"); } + +string FileTarget::make_name(const Package *pkg, const FS::Path &pth) +{ + if(const SourcePackage *spkg = dynamic_cast(pkg)) + { + 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 ""+relpath.str().substr(1); + } + } + + return pth.str(); +}