using namespace Msp;
Binary::Binary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
- FileTarget(b, &c.get_package(), generate_target_path(c)),
- comp(c)
+ FileTarget(b, &c.get_package(), generate_target_path(c))
{
+ component = &c;
for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
add_depend(*i);
}
void Binary::find_depends()
{
- LibMode libmode = comp.get_package().get_library_mode();
+ if(!component)
+ return;
+
+ const SourcePackage &spkg = component->get_package();
+ LibMode libmode = spkg.get_library_mode();
if(dynamic_cast<SharedLibrary *>(this))
libmode = DYNAMIC;
list<const Component *> queue;
list<Target *> dep_libs;
- queue.push_back(&comp);
+ queue.push_back(component);
while(!queue.empty())
{
const Component *c = queue.front();
lib = lib->get_real_target();
if(StaticLibrary *stlib = dynamic_cast<StaticLibrary *>(lib))
- queue.push_back(&stlib->get_component());
+ queue.push_back(stlib->get_component());
}
else
- builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, name));
+ builder.problem(spkg.get_name(), format("Couldn't find library %s for %s", *i, name));
}
}
class Binary: public virtual FileTarget
{
protected:
- const Component ∁
-
Binary(Builder &, const Component &, const std::list<ObjectFile *> &);
public:
- const Component &get_component() const { return comp; }
virtual void find_depends();
protected:
/** Returns the path for the binary. We can't do this in the constructor
using namespace Msp;
FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
- Target(b, p, make_name(p, a)),
+ Target(b, make_name(p, a)),
path(a),
size(0)
{
+ package = p;
+
builder.get_vfs().register_path(path, this);
if(FS::Stat st = FS::lstat(path))
Task *GnuArchiver::run(const Target &target) const
{
const StaticLibrary &lib = dynamic_cast<const StaticLibrary &>(target);
- const Component &comp = lib.get_component();
+ const Component &comp = *lib.get_component();
vector<string> argv;
argv.push_back("ar");
vector<string> argv;
argv.push_back(command);
- const Component &comp = bin.get_component();
+ const Component &comp = *bin.get_component();
if(shlib)
{
soname(create_soname(c))
{
install_location = "lib";
- if(comp.get_type()==Component::MODULE)
+ if(component->get_type()==Component::MODULE)
{
install_location += '/';
install_location += package->get_name();
StaticLibrary::StaticLibrary(Builder &b, const Component &c, const list<ObjectFile *> &objs):
FileTarget(b, &c.get_package(), generate_target_path(c)),
- Library(b, package, path, c.get_name()),
- comp(c)
+ Library(b, package, path, c.get_name())
{
+ component = &c;
for(list<ObjectFile *>::const_iterator i=objs.begin(); i!=objs.end(); ++i)
add_depend(*i);
*/
class StaticLibrary: public Library
{
-private:
- const Component ∁
-
public:
StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
virtual const char *get_type() const { return "StaticLibrary"; }
- const Component &get_component() const { return comp; }
private:
static Msp::FS::Path generate_target_path(const Component &);
};
using namespace std;
using namespace Msp;
-Target::Target(Builder &b, const Package *p, const string &n):
+Target::Target(Builder &b, const string &n):
builder(b),
- package(p),
+ package(0),
+ component(0),
name(n),
tool(0),
state(INIT),
#include <msp/time/timestamp.h>
class Builder;
+class Component;
class Package;
class Task;
class Tool;
Builder &builder;
const Package *package;
+ const Component *component;
std::string name;
const Tool *tool;
Dependencies depends;
bool deps_ready;
- Target(Builder &, const Package *, const std::string &);
+ Target(Builder &, const std::string &);
public:
virtual ~Target() { }
virtual const char *get_type() const = 0;
const std::string &get_name() const { return name; }
const Package *get_package() const { return package; }
+ const Component *get_component() const { return component; }
/**
Tries to locate a target that will help getting this target built. If all
using namespace Msp;
VirtualTarget::VirtualTarget(Builder &b, const string &n):
- Target(b, 0, n)
+ Target(b, n)
{ }
void VirtualTarget::check_rebuild()