for(list<string>::const_iterator i=path.begin(); i!=path.end(); ++i)
update_hash(hash, *i);
- //XXX Incorporate mode into id
- string id=hash+lib;
+ string id=hash+string(1, mode)+lib;
TargetMap::iterator i=libraries.find(id);
if(i!=libraries.end())
return i->second;
deps_ready=true;
}
-Action *Executable::build()
+Action *Executable::create_action()
{
- return Target::build(new Link(builder, *this));;
+ return new Link(builder, *this);
}
/**
const char *get_type() const { return "Executable"; }
const Component &get_component() const { return comp; }
void find_depends();
- Action *build();
private:
const Component ∁
+ virtual Action *create_action();
+
static std::string generate_target_name(const Component &);
};
public:
File(Builder &, const std::string &);
virtual const char *get_type() const { return "File"; }
- virtual Action *build() { return 0; }
+private:
+ virtual Action *create_action() { return 0; }
};
#endif
}
}
-Action *Install::build()
+Action *Install::create_action()
{
- return Target::build(new Copy(builder, *package, depends.front()->get_name(), name));
+ return new Copy(builder, *package, depends.front()->get_name(), name);
}
string Install::generate_target_name(const Target &tgt)
Install(Builder &, const SourcePackage &, Target &);
const char *get_type() const { return "Install"; }
void check_rebuild();
- Action *build();
private:
- std::string generate_target_name(const Target &);
+ virtual Action *create_action();
+
+ static std::string generate_target_name(const Target &);
};
#endif
else if(SharedLibrary *shlib=dynamic_cast<SharedLibrary *>(tgt))
argv.push_back("-l"+shlib->get_libname());
else if(dynamic_cast<StaticLibrary *>(tgt))
- argv.push_back(relative((*i)->get_name(), work_dir).str());
+ argv.push_back((*i)->get_name());
else if(SystemLibrary *syslib=dynamic_cast<SystemLibrary *>(tgt))
argv.push_back("-l"+syslib->get_libname());
}
deps_ready=new_deps.empty();
}
-Action *ObjectFile::build()
-{
- return Target::build(new Compile(builder, *this));
-}
/**
Recursively looks for header targets and adds them as dependencies.
new_deps.push_back(tgt);
}
+Action *ObjectFile::create_action()
+{
+ return new Compile(builder, *this);
+}
+
string ObjectFile::generate_target_name(const Component &comp, const string &src)
{
const SourcePackage &pkg=comp.get_package();
const char *get_type() const { return "ObjectFile"; }
const Component &get_component() const { return comp; }
void find_depends();
- Action *build();
private:
const Component ∁
TargetList new_deps;
void find_depends(Target *);
void add_depend(Target *);
+ virtual Action *create_action();
static std::string generate_target_name(const Component &, const std::string &);
};
buildable=true;
}
-Action *PkgConfig::build()
+Action *PkgConfig::create_action()
{
- return Target::build(new PkgConfigAction(builder, *this));
+ return new PkgConfigAction(builder, *this);
}
public:
PkgConfig(Builder &, const SourcePackage &);
const char *get_type() const { return "PkgConfig"; }
- Action *build();
private:
const Package &pkg;
+
+ virtual Action *create_action();
};
#endif
const char *get_type() const { return "SourceFile"; }
const Component *get_component() const { return comp; }
void find_depends();
- Action *build() { return 0; }
private:
const Component *comp;
StringList includes;
+
+ virtual Action *create_action() { return 0; }
};
#endif
add_depend(*i);
}
-Action *StaticLibrary::build()
+Action *StaticLibrary::create_action()
{
- return Target::build(new Archive(builder, *this));;
+ return new Archive(builder, *this);
}
string StaticLibrary::generate_target_name(const Component &c)
StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
const char *get_type() const { return "StaticLibrary"; }
const Component &get_component() const { return comp; }
- Action *build();
private:
const Component ∁
+ virtual Action *create_action();
+
std::string generate_target_name(const Component &);
};
SystemLibrary(Builder &, const std::string &);
const char *get_type() const { return "SystemLibrary"; }
const std::string &get_libname() const { return libname; }
- Action *build() { return 0; }
private:
std::string libname;
+
+ virtual Action *create_action() { return 0; }
};
#endif
deps_ready=true;
}
-Action *TarBall::build()
+Action *TarBall::create_action()
{
- return Target::build(new Tar(builder, *this));
+ return new Tar(builder, *this);
}
string TarBall::create_target_name(const SourcePackage &pkg, const string &extra_ver)
virtual const char *get_type() const { return "TarBall"; }
const SourcePackage *get_package() const;
virtual void find_depends();
- virtual Action *build();
private:
std::string tarname;
- std::string create_target_name(const SourcePackage &, const std::string &);
+ virtual Action *create_action();
+
+ static std::string create_target_name(const SourcePackage &, const std::string &);
};
#endif
}
+Action *Target::build()
+{
+ if(!buildable)
+ {
+ rebuild=false;
+ return 0;
+ }
+
+ if(!builder.get_dry_run() && exists(name))
+ unlink(name);
+
+ Action *action=create_action();
+ if(action)
+ {
+ action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
+
+ building=true;
+ }
+
+ return action;
+}
+
/**
Returns the number of targets that need to be rebuilt in order to get this
target up-to-date.
mark_rebuild("Package options changed");
}
-/**
-Hooks the target up with the given action, then returns it. This should be
-called from the public build() function of buildable targets.
-*/
-Action *Target::build(Action *action)
-{
- building=true;
- action->signal_done.connect(sigc::mem_fun(this, &Target::build_done));
- return action;
-}
-
/**
Handles for the build_done signal of Action.
*/
/**
Creates and returns an Action suitable for building this target.
*/
- virtual Action *build()=0;
+ Action *build();
void reset_count() { counted=false; }
virtual unsigned count_rebuild();
Target(Builder &, const Package *, const std::string &);
void mark_rebuild(const std::string &);
virtual void check_rebuild();
- Action *build(Action *);
+ virtual Action *create_action() =0;
virtual void build_done();
};
public:
VirtualTarget(Builder &b, const std::string &n): Target(b, 0, n) { }
const char *get_type() const { return "VirtualTarget"; }
- Action *build() { rebuild=false; return 0; }
unsigned count_rebuild();
private:
void check_rebuild();
+ virtual Action *create_action() { return 0; }
};
#endif