X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffiletarget.cpp;h=2a60c2986bac2ec89f1454995f89283fe5d973da;hb=632361796a7ddadf8a726526c937fab22281fb7b;hp=061a3ae20968750a70a589d21618059cb150c913;hpb=87ea54db19306434bac3e765c9bd3464fd53f390;p=builder.git diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 061a3ae..2a60c29 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,18 @@ 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, make_name(p, a)), path(a), size(0) { - builder.add_target(this); + package = p; - struct stat st; - if(!FS::lstat(path, st)) + builder.get_vfs().register_path(path, this); + + 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(); } } @@ -37,7 +32,7 @@ void FileTarget::touch() void FileTarget::check_rebuild() { - if(!buildable) + if(!tool) return; if(builder.get_build_all()) @@ -46,23 +41,42 @@ void FileTarget::check_rebuild() mark_rebuild("Does not exist"); else { - for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i) + for(Dependencies::iterator i=depends.begin(); (i!=depends.end() && !needs_rebuild()); ++i) { FileTarget *ft = dynamic_cast(*i); if(ft && ft->get_mtime()>mtime) mark_rebuild((*i)->get_name()+" has changed"); - else if((*i)->get_rebuild()) + else if((*i)->needs_rebuild()) mark_rebuild((*i)->get_name()+" needs rebuilding"); else { Target *real = ft->get_real_target(); - if(real->get_rebuild()) + if(real->needs_rebuild()) mark_rebuild(real->get_name()+" needs rebuilding"); } } } const SourcePackage *spkg = dynamic_cast(package); - if(!rebuild && spkg && spkg->get_config().get_mtime()>mtime) + if(!needs_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(); +}