From: Mikko Rasa Date: Sat, 23 Jun 2012 18:46:14 +0000 (+0300) Subject: Turn the force rebuild logic around X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5eab9f87fc3203d7c2d16be312be74a63a8c8980;p=builder.git Turn the force rebuild logic around --- diff --git a/source/builder.cpp b/source/builder.cpp index 4a9370f..2c28b79 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -529,6 +529,13 @@ int Builder::create_targets() tgt->touch(); } + if(build_all) + { + for(TargetMap::iterator i=targets.begin(); i!=targets.end(); ++i) + if(i->second->is_buildable() && !i->second->needs_rebuild()) + i->second->force_rebuild(); + } + for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i) if(SourcePackage *spkg = dynamic_cast(i->second)) spkg->get_deps_cache().save(); diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 74f7833..6626db8 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -36,9 +36,7 @@ void FileTarget::check_rebuild() if(!tool) return; - if(builder.get_build_all()) - mark_rebuild("Rebuilding everything"); - else if(!mtime) + if(!mtime) mark_rebuild("Does not exist"); else { diff --git a/source/target.cpp b/source/target.cpp index 88d8b70..1aab4b1 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -47,6 +47,13 @@ void Target::set_tool(const Tool &t) tool = &t; } +void Target::force_rebuild() +{ + if(!is_buildable()) + throw logic_error("Target::force_rebuild"); + mark_rebuild("Forced rebuild"); +} + void Target::add_depend(Target *dep) { if(dep==this) diff --git a/source/target.h b/source/target.h index 0f0afc6..88642dc 100644 --- a/source/target.h +++ b/source/target.h @@ -86,6 +86,9 @@ public: the target has been prepared. */ const std::string &get_rebuild_reason() const { return rebuild_reason; } + /** Forces rebuild of the target. */ + void force_rebuild(); + bool is_installable() const { return !install_location.empty(); } const std::string &get_install_location() const { return install_location; } void add_depend(Target *);