void Binary::find_depends()
{
if(!component)
- {
- deps_ready = true;
return;
- }
const SourcePackage &spkg = component->get_package();
LibMode libmode = spkg.get_library_mode();
if(last)
add_depend(*i);
}
-
- deps_ready = true;
}
}
}
- // Find dependencies until no new targets are created
- while(!new_tgts.empty())
- {
- Target *tgt = new_tgts.front();
- new_tgts.erase(new_tgts.begin());
- tgt->find_depends();
- if(!tgt->get_depends_ready())
- new_tgts.push_back(tgt);
- }
-
// Apply what-ifs
+ // XXX This does not currently work with targets found during dependency discovery
for(StringList::iterator i=what_if.begin(); i!=what_if.end(); ++i)
{
FileTarget *tgt = vfs.get_target(cwd/ *i);
void CSourceFile::find_depends()
{
if(!comp)
- {
- deps_ready = true;
return;
- }
const SourcePackage &spkg = comp->get_package();
string relname = FS::relative(path, spkg.get_source()).str();
{
if(builder.get_verbose()>=4)
IO::print("Failed to read includes from %s\n", path.str());
- deps_ready = true;
return;
}
}
if(hdr)
add_depend(hdr);
}
-
- deps_ready = true;
}
void ObjectFile::find_depends()
{
- for(Dependencies::iterator i=new_deps.begin(); i!=new_deps.end();)
+ for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
{
- Target *tgt = *i;
- if(tgt->get_depends_ready())
- {
- i = new_deps.erase(i);
- find_depends(dynamic_cast<FileTarget *>(tgt));
- }
- else
- ++i;
+ (*i)->prepare();
+ find_depends(dynamic_cast<FileTarget *>(*i));
}
-
- deps_ready = new_deps.empty();
}
add_depend(*i);
}
-void ObjectFile::add_depend(Target *tgt)
-{
- Target::add_depend(tgt);
- new_deps.push_back(tgt);
-}
-
FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
{
const SourcePackage &pkg = comp.get_package();
private:
const Component ∁
SourceFile &source;
- Dependencies new_deps;
public:
ObjectFile(Builder &, const Component &, SourceFile &);
/** Recursively looks for header targets and adds them as dependencies. */
void find_depends(FileTarget *);
- /** Adds a target to the dependency list as well as the new dependencies
- list. */
- void add_depend(Target *);
-
static Msp::FS::Path generate_target_path(const Component &, const std::string &);
};
component(0),
name(n),
tool(0),
- state(INIT),
- deps_ready(false)
+ state(INIT)
{
builder.add_target(this);
}
}
state = PREPARING;
+ find_depends();
+
for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
(*i)->prepare();
std::string install_location;
Dependencies depends;
- bool deps_ready;
Target(Builder &, const std::string &);
public:
const std::string &get_install_location() const { return install_location; }
void add_depend(Target *);
const Dependencies &get_depends() const { return depends; }
- bool get_depends_ready() const { return deps_ready; }
- /**
- Finds dependencies for the target. When all dependencies have been found,
- the function should set deps_ready to true.
- */
- virtual void find_depends() { deps_ready = true; }
+ /** Finds dependencies for the target. */
+ virtual void find_depends() { }
/**
Prepares the target by recursively preparing dependencies, then checking