const Builder::TargetMap &targets = builder.get_targets();
for(Builder::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
{
- const TargetList &depends = i->second->get_depends();
- for(TargetList::const_iterator j=depends.begin(); j!=depends.end(); ++j)
+ const Target::Dependencies &depends = i->second->get_depends();
+ for(Target::Dependencies::const_iterator j=depends.begin(); j!=depends.end(); ++j)
rdepends[*j].insert(i->second);
}
}
Target &cmdline = *builder.get_target("cmdline");
if(mode==RDEPS)
{
- const TargetList &deps = cmdline.get_depends();
- for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+ const Target::Dependencies &deps = cmdline.get_depends();
+ for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
build_depend_table(**i, 0);
}
else
if(!max_depth || depth<max_depth-1)
{
- TargetList depends;
+ Target::Dependencies depends;
if(mode==RDEPS)
{
const set<Target *> &rdeps = rdepends[&tgt];
depends.sort(full_paths ? target_order_full : target_order);
- for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+ for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
build_depend_table(**i, depth+1);
}
}
// Cleaning doesn't care about ordering, so a simpler method can be used
set<Target *> clean_tgts;
- TargetList queue;
+ list<Target *> queue;
queue.push_back(get_target("cmdline"));
while(!queue.empty())
if(tgt->is_buildable() && (tgt->get_package()==main_pkg || clean>=2))
clean_tgts.insert(tgt);
- const TargetList &deps = tgt->get_depends();
- for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+ const Target::Dependencies &deps = tgt->get_depends();
+ for(list<Target *>::const_iterator i=deps.begin(); i!=deps.end(); ++i)
if(!clean_tgts.count(*i))
queue.push_back(*i);
}
public:
typedef std::map<std::string, Target *> TargetMap;
+ typedef std::list<Target *> TargetList;
private:
typedef std::list<Package *> PackageList;
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() && !rebuild); ++i)
{
FileTarget *ft = dynamic_cast<FileTarget *>(*i);
if(ft && ft->get_mtime()>mtime)
argv.push_back(relative(lib.get_path(), work_dir).str());
- const TargetList &deps = lib.get_depends();
- for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+ const Target::Dependencies &deps = lib.get_depends();
+ for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
argv.push_back(relative(obj->get_path(), work_dir).str());
string command = "gcc";
- const list<Target *> &depends = target.get_depends();
- for(list<Target *>::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+ const Target::Dependencies &depends = target.get_depends();
+ for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
if(ObjectFile *obj = dynamic_cast<ObjectFile *>(*i))
{
const Tool *tool = obj->get_tool();
argv.push_back("-o");
argv.push_back(relative(bin.get_path(), work_dir).str());
- for(TargetList::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+ for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
{
Target *tgt = (*i)->get_real_target();
void ObjectFile::find_depends()
{
- for(TargetList::iterator i=new_deps.begin(); i!=new_deps.end();)
+ for(Dependencies::iterator i=new_deps.begin(); i!=new_deps.end();)
{
Target *tgt = *i;
if(tgt->get_depends_ready())
private:
const Component ∁
SourceFile &source;
- TargetList new_deps;
+ Dependencies new_deps;
public:
ObjectFile(Builder &, const Component &, SourceFile &);
FS::Path basedir = FS::basepart(FS::basename(tarball.get_path()));
IO::File out(tarball.get_path().str(), IO::M_WRITE);
- const TargetList &deps = tarball.get_depends();
- for(TargetList::const_iterator i=deps.begin(); i!=deps.end(); ++i)
+ const Target::Dependencies &deps = tarball.get_depends();
+ for(Target::Dependencies::const_iterator i=deps.begin(); i!=deps.end(); ++i)
{
FileTarget *ft = dynamic_cast<FileTarget *>(*i);
if(!ft)
return 0;
bool self_ok = !building;
- for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
+ for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
{
Target *tgt = (*i)->get_buildable_target();
if(tgt)
}
preparing = true;
- for(TargetList::iterator i=depends.begin(); i!=depends.end(); ++i)
+ for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
(*i)->prepare();
check_rebuild();
class Tool;
class Target;
-typedef std::list<Target *> TargetList;
/**
Targets make up the build graph. This class is a base for all target types and
*/
class Target
{
+public:
+ typedef std::list<Target *> Dependencies;
+
protected:
Builder &builder;
const Package *package;
bool rebuild;
std::string rebuild_reason;
- TargetList depends;
+ Dependencies depends;
bool deps_ready;
bool preparing;
bool get_rebuild() const { return rebuild; }
const std::string &get_rebuild_reason() const { return rebuild_reason; }
void add_depend(Target *);
- const TargetList &get_depends() const { return depends; }
+ const Dependencies &get_depends() const { return depends; }
bool get_depends_ready() const { return deps_ready; }
/**
void VirtualTarget::check_rebuild()
{
// Virtual targets are only rebuilt if their dependencies need rebuilding.
- for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
+ for(Dependencies::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
if((*i)->get_rebuild())
mark_rebuild((*i)->get_name()+" needs rebuilding");
}