X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffiletarget.cpp;h=88672317dc35cab7afa7c5fdef65a8d65edc7e57;hb=dad4c41302de525a1456e9d5b738831487c8acac;hp=061a3ae20968750a70a589d21618059cb150c913;hpb=87ea54db19306434bac3e765c9bd3464fd53f390;p=builder.git diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 061a3ae..8867231 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -1,12 +1,6 @@ -/* $Id$ - -This file is part of builder -Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include +#include #include #include "builder.h" #include "filetarget.h" @@ -16,17 +10,16 @@ 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); - struct stat st; - if(!FS::lstat(path, st)) + if(FS::Stat st = FS::lstat(path)) { - mtime = Time::TimeStamp::from_unixtime(st.st_mtime); - size = st.st_size; + mtime = st.get_modify_time(); + size = st.get_size(); } } @@ -66,3 +59,14 @@ 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)) + { + FS::Path relpath = FS::relative(pth, spkg->get_source()); + return format("<%s>%s", pkg->get_name(), relpath.str().substr(1)); + } + else + return pth.str(); +}