targets.insert(TargetMap::value_type(t->get_name(), t));
}
+void Builder::add_primary_target(Target &t)
+{
+ get_target("world")->add_dependency(t);
+
+ if(t.get_package()==main_pkg && t.get_component() && t.get_component()->is_default())
+ get_target("default")->add_dependency(t);
+}
+
void Builder::usage(const char *reason, const char *argv0, bool brief)
{
if(reason)
bool get_dry_run() const { return dry_run; }
PackageManager &get_package_manager() { return package_manager; }
- SourcePackage *get_main_package() const { return main_pkg; }
/** Looks up a target by name. Returns 0 if no such target exists. */
Target *get_target(const std::string &) const;
from Target constructor. */
void add_target(Target *);
+ /** Adds a target that is a primary build goal. Such targets will be added
+ as dependencies of the "world" virtual target. If the target belongs to a
+ default component of the main package, it's also added to the "default"
+ virtual target. */
+ void add_primary_target(Target &);
+
void problem(const std::string &, const std::string &);
static void usage(const char *, const char *, bool);
{
Builder &builder = package.get_builder();
const Toolchain &toolchain = builder.get_toolchain();
- Target *world = builder.get_target("world");
- Target *def_tgt = builder.get_target("default");
PathList source_filenames = collect_source_files();
list<Target *> inst_list;
source = new File(builder, package, source_filenames.front());
Target *result = dcomp.create_target(*source);
- if(&package==builder.get_main_package() && deflt)
- def_tgt->add_dependency(*result);
- else
- world->add_dependency(*result);
+ builder.add_primary_target(*result);
if(install)
inst_list.push_back(result);
}
for(list<Target *>::const_iterator i=results.begin(); i!=results.end(); ++i)
{
- if(&package==builder.get_main_package() && deflt)
- def_tgt->add_dependency(**i);
- else
- world->add_dependency(**i);
+ builder.add_primary_target(**i);
if(install)
inst_list.push_back(*i);
}