void Analyzer::build_depend_table(Target &tgt, unsigned depth)
{
- if(mode!=REBUILD)
+ if(mode!=REBUILD && mode!=ALLDEPS)
{
if(dynamic_cast<ObjectFile *>(&tgt))
return build_depend_table(*tgt.get_depends().front(), depth);
else if(dynamic_cast<Install *>(&tgt))
return build_depend_table(*tgt.get_depends().front(), depth);
}
- else if(!tgt.get_rebuild())
+ else if(mode==REBUILD && !tgt.get_rebuild())
return;
TableRow row;
return pkg;
}
+/**
+Returns the target with the given name, or 0 if no such target exists.
+*/
Target *Builder::get_target(const string &n)
{
TargetMap::iterator i=targets.find(n);
Target *tgt=new_tgts.front();
new_tgts.erase(new_tgts.begin());
tgt->find_depends();
+ if(!tgt->get_depends_ready())
+ new_tgts.push_back(tgt);
}
Target *cmdline=new VirtualTarget(*this, "cmdline");
if(lib)
add_depend(lib);
}
+
+ deps_ready=true;
}
Action *Executable::build()
public:
SystemHeader(Builder &b, const std::string &f): Header(b,0,f) { }
const char *get_type() const { return "SystemHeader"; }
- void find_depends() { }
+ void find_depends() { deps_ready=true; }
};
#endif
public:
Install(Builder &, const Package &, Target &, const std::string &);
const char *get_type() const { return "Install"; }
- void find_depends() { }
void check_rebuild();
Action *build();
private:
+#include <msp/algo.h>
#include <msp/path/utils.h>
#include "builder.h"
#include "compile.h"
void ObjectFile::find_depends()
{
- find_depends(depends.front());
+ for(list<Target *>::iterator i=new_deps.begin(); i!=new_deps.end();)
+ {
+ Target *tgt=*i;
+ if(tgt->get_depends_ready())
+ {
+ i=new_deps.erase(i);
+ find_depends(tgt);
+ }
+ else
+ ++i;
+ }
+
+ deps_ready=new_deps.empty();
}
Action *ObjectFile::build()
void ObjectFile::find_depends(Target *tgt)
{
+ const string &tname=tgt->get_name();
+ string path=tname.substr(0, tname.rfind('/'));
+
SourceFile *src=dynamic_cast<SourceFile *>(tgt);
if(!src)
{
if(!src)
return;
- const string &sname=src->get_name();
- string path=sname.substr(0, sname.rfind('/'));
-
const list<string> &includes=src->get_includes();
for(list<string>::const_iterator i=includes.begin(); i!=includes.end(); ++i)
{
Target *hdr2=builder.get_header(*i, path, package->get_build_info().incpath);
- if(hdr2)
+ if(hdr2 && !contains(depends, hdr2))
add_depend(hdr2);
}
}
+void ObjectFile::add_depend(Target *tgt)
+{
+ Target::add_depend(tgt);
+ new_deps.push_back(tgt);
+}
+
string ObjectFile::generate_target_name(const Component &comp, const string &src)
{
return (comp.get_package().get_source()/"temp"/comp.get_name()/(Path::splitext(src.substr(src.rfind('/')+1)).base+".o")).str();
Action *build();
private:
const Component ∁
+ std::list<Target *> new_deps;
void find_depends(Target *);
+ void add_depend(Target *);
static std::string generate_target_name(const Component &, const std::string &);
};
if(hdr)
add_depend(hdr);
}
+
+ deps_ready=true;
}
public:
SystemLibrary(Builder &b, const std::string &n): Target(b,0,n) { }
const char *get_type() const { return "SystemLibrary"; }
- void find_depends() { }
Action *build() { return 0; }
};
name(n),
building(false),
rebuild(false),
+ deps_ready(false),
prepared(false),
buildable(false),
counted(false)
virtual const char *get_type() const=0;
const std::list<Target *> &get_depends() const { return depends; }
const Package *get_package() const { return package; }
+ bool get_depends_ready() const { return deps_ready; }
void add_depend(Target *);
- virtual void find_depends()=0;
+ virtual void find_depends() { deps_ready=true; }
virtual void prepare();
virtual Action *build()=0;
void reset_count() { counted=false; }
Msp::Time::TimeStamp mtime;
std::list<Target *> depends;
std::list<Target *> rdepends;
+ bool deps_ready;
bool prepared;
bool buildable;
bool counted;
public:
VirtualTarget(Builder &b, const std::string &n): Target(b,0,n) { }
const char *get_type() const { return "VirtualTarget"; }
- void find_depends() { }
Action *build() { rebuild=false; return 0; }
private:
void check_rebuild();