if(dynamic_cast<SourcePackage *>(*i))
IO::print("*");
unsigned count=0;
- unsigned ood_count=0;
+ unsigned to_be_built=0;
for(TargetMap::iterator j=targets.begin(); j!=targets.end(); ++j)
if(j->second->get_package()==*i)
{
++count;
if(j->second->get_rebuild())
- ++ood_count;
+ ++to_be_built;
}
if(count)
{
IO::print(" (%d targets", count);
- if(ood_count)
- IO::print(", %d out-of-date", ood_count);
+ if(to_be_built)
+ IO::print(", %d to be built", to_be_built);
IO::print(")");
}
IO::print("\n");
IO::print(IO::cerr, "The following problems were detected:\n");
for(ProblemList::iterator i=problems.begin(); i!=problems.end(); ++i)
IO::print(IO::cerr, " %s: %s\n", i->package, i->descr);
- IO::print(IO::cerr, "Please fix them and try again.\n");
+ if(!analyzer)
+ IO::print(IO::cerr, "Please fix them and try again.\n");
return 1;
}
cmdline->add_depend(tgt);
}
- /* If world is to be built, prepare cmdline. If not, add cmdline to world
- and prepare world. I don't really like this, but it keeps the graph
- acyclic.
-
- XXX Could we skip preparing targets we are not interested in? */
- if(build_world)
- cmdline->prepare();
- else
- {
- world->add_depend(cmdline);
- world->prepare();
- }
+ cmdline->prepare();
for(PackageMap::iterator i=packages.begin(); i!=packages.end(); ++i)
if(SourcePackage *spkg=dynamic_cast<SourcePackage *>(i->second))
{
Target *cmdline=get_target("cmdline");
- unsigned total=cmdline->count_rebuild();
+ unsigned total=0;
+ for(map<string, Target *>::const_iterator i=targets.begin(); i!=targets.end(); ++i)
+ if(i->second->is_buildable() && i->second->get_rebuild())
+ ++total;
+
if(!total)
{
IO::print("Already up to date\n");
building(false),
rebuild(false),
deps_ready(false),
- prepared(false),
- counted(false)
+ preparing(false),
+ prepared(false)
{
builder.add_target(this);
}
{
if(prepared)
return;
+ if(preparing)
+ {
+ builder.problem((package ? package->get_name() : string()), "Dependency cycle detected at "+name);
+ return;
+ }
- prepared=true;
+ preparing=true;
for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
(*i)->prepare();
check_rebuild();
-
+ preparing=false;
+ prepared=true;
}
Action *Target::build()
return action;
}
-unsigned Target::count_rebuild()
-{
- if(counted)
- return 0;
-
- counted=true;
- unsigned count=rebuild;
- for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
- count+=(*i)->count_rebuild();
- return count;
-}
-
void Target::touch()
{
mtime=Time::now();
#include <list>
#include <map>
+#include <set>
#include <string>
#include <msp/time/timestamp.h>
TargetList rdepends;
bool deps_ready;
+ bool preparing;
bool prepared;
- bool counted;
Target(Builder &, const Package *, const std::string &);
public:
*/
Action *build();
- void reset_count() { counted=false; }
-
- /**
- Returns the number of targets that need to be rebuilt in order to get this
- target up-to-date.
- */
- virtual unsigned count_rebuild();
-
/**
Changes the mtime of the target to the current time.
*/
virtual Action *create_action() =0;
/**
- Handles for the build_done signal of Action.
+ Handler for the build_done signal of Action.
*/
virtual void build_done();
};
public:
VirtualTarget(Builder &b, const std::string &n): Target(b, 0, n) { }
virtual const char *get_type() const { return "VirtualTarget"; }
- virtual unsigned count_rebuild();
private:
virtual void check_rebuild();
virtual Action *create_action() { return 0; }