X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffiletarget.cpp;h=1c61810498937199f3ba35c6d5374febff18d151;hb=20be24789dbfb2acd3f8d2076a6b19ff6a2451ee;hp=bc4e110d8700002f822bca478d0e6aa6fde6a8be;hpb=bd2a50ecb9f582c6e9569ffc9f33d41f10363c5f;p=builder.git diff --git a/source/filetarget.cpp b/source/filetarget.cpp index bc4e110..1c61810 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -9,11 +9,13 @@ using namespace std; using namespace Msp; -FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a): - Target(b, p, make_name(p, a)), +FileTarget::FileTarget(Builder &b, const SourcePackage *p, const FS::Path &a): + Target(b, generate_name(p, a)), path(a), size(0) { + package = p; + builder.get_vfs().register_path(path, this); if(FS::Stat st = FS::lstat(path)) @@ -26,47 +28,39 @@ FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a): void FileTarget::touch() { mtime = Time::now(); + signal_bubble_rebuild.emit(); } void FileTarget::check_rebuild() { - if(!buildable) + if(!tool) return; - if(builder.get_build_all()) - mark_rebuild("Rebuilding everything"); - else if(!mtime) + if(!mtime) 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()) - 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() && package && package->get_config().get_mtime()>mtime) mark_rebuild("Package options changed"); } -string FileTarget::make_name(const Package *pkg, const FS::Path &pth) +string FileTarget::generate_name(const SourcePackage *pkg, const FS::Path &pth) { - if(const SourcePackage *spkg = dynamic_cast(pkg)) + if(pkg) { - if(FS::descendant_depth(pth, spkg->get_source())>=0) + if(FS::descendant_depth(pth, pkg->get_source())>=0) { - FS::Path relpath = FS::relative(pth, spkg->get_source()); + FS::Path relpath = FS::relative(pth, pkg->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)