exe=new Executable(*this, *j, objs);
add_target(exe);
- if(i->second==default_pkg)
+ if(i->second==default_pkg && j->get_default())
{
def_tgt->add_depend(exe);
if(slib) def_tgt->add_depend(slib);
// Make the cmdline target depend on all targets mentioned on the command line
Target *cmdline=new VirtualTarget(*this, "cmdline");
add_target(cmdline);
- world->add_depend(cmdline);
+ bool build_world=false;
for(list<string>::iterator i=cmdline_targets.begin(); i!=cmdline_targets.end(); ++i)
{
Target *tgt=get_target(*i);
cerr<<"I don't know anything about "<<*i<<'\n';
return -1;
}
+ if(tgt==world)
+ build_world=true;
cmdline->add_depend(tgt);
}
- world->prepare();
+ /* 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. */
+ if(build_world)
+ cmdline->prepare();
+ else
+ {
+ world->add_depend(cmdline);
+ world->prepare();
+ }
return 0;
}
name(n),
install(false),
module_host(0),
- modular(false)
+ modular(false),
+ deflt(true)
{ }
/**
add("require", &Loader::require);
add("modular", &Loader::modular);
add("host", &Loader::host);
+ add("default", &Component::deflt);
}
void Component::Loader::source(const string &s)
void host(const std::string &);
void build_info();
};
-
+
enum Type
{
PROGRAM,
const std::string &get_install_headers() const { return install_headers; }
bool get_modular() const { return modular; }
const PkgRefList &get_requires() const { return requires; }
+ bool get_default() const { return deflt; }
void resolve_refs();
void create_build_info();
protected:
bool modular;
BuildInfo build_info;
PkgRefList requires;
+ bool deflt;
};
typedef std::list<Component> ComponentList;
void Target::add_depend(Target *dep)
{
+ if(dep==this)
+ throw InvalidParameterValue("A target can't depend on itself");
depends.push_back(dep);
dep->rdepends.push_back(this);
}