#include "analyzer.h"
#include "builder.h"
#include "objectfile.h"
-#include "package.h"
#include "sourcefile.h"
+#include "sourcepackage.h"
#include "target.h"
#include "tool.h"
Target *Copy::create_target(const list<Target *> &sources, const string &arg) const
{
FileTarget &file_tgt = dynamic_cast<FileTarget &>(*sources.front());
- const SourcePackage &pkg = dynamic_cast<const SourcePackage &>(*file_tgt.get_package());
- InstalledFile *inst = new InstalledFile(builder, pkg, file_tgt, arg);
+ InstalledFile *inst = new InstalledFile(builder, *file_tgt.get_package(), file_tgt, arg);
inst->set_tool(*this);
return inst;
}
{
public:
File(Builder &b, const Msp::FS::Path &t): FileTarget(b, 0, t) { }
- File(Builder &b, Package &p, const Msp::FS::Path &t): FileTarget(b, &p, t) { }
+ File(Builder &b, SourcePackage &p, const Msp::FS::Path &t): FileTarget(b, &p, t) { }
virtual const char *get_type() const { return "File"; }
};
using namespace std;
using namespace Msp;
-FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
+FileTarget::FileTarget(Builder &b, const SourcePackage *p, const FS::Path &a):
Target(b, generate_name(p, a)),
path(a),
size(0)
}
}
- const SourcePackage *spkg = dynamic_cast<const SourcePackage *>(package);
- if(!needs_rebuild() && spkg && spkg->get_config().get_mtime()>mtime)
+ if(!needs_rebuild() && package && package->get_config().get_mtime()>mtime)
mark_rebuild("Package options changed");
}
-string FileTarget::generate_name(const Package *pkg, const FS::Path &pth)
+string FileTarget::generate_name(const SourcePackage *pkg, const FS::Path &pth)
{
- if(const SourcePackage *spkg = dynamic_cast<const SourcePackage *>(pkg))
+ if(pkg)
{
- if(FS::descendant_depth(pth, spkg->get_source())>=0)
+ if(FS::descendant_depth(pth, pkg->get_source())>=0)
{
- FS::Path relpath = FS::relative(pth, spkg->get_source());
+ FS::Path relpath = FS::relative(pth, pkg->get_source());
return format("<%s>%s", pkg->get_name(), relpath.str().substr(1));
}
else if(FS::descendant_depth(pth, pkg->get_builder().get_prefix())>=0)
Msp::Time::TimeStamp mtime;
unsigned size;
- FileTarget(Builder &, const Package *, const Msp::FS::Path &);
+ FileTarget(Builder &, const SourcePackage *, const Msp::FS::Path &);
public:
const Msp::FS::Path &get_path() const { return path; }
const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
protected:
virtual void check_rebuild();
private:
- static std::string generate_name(const Package *, const Msp::FS::Path &);
+ static std::string generate_name(const SourcePackage *, const Msp::FS::Path &);
};
#endif
{
/* The target has been displaced by installing it. Displace any
dependencies that come from the same package as well. */
- const SourcePackage *tpkg = dynamic_cast<const SourcePackage *>(rtgt->get_package());
+ const SourcePackage *tpkg = rtgt->get_package();
for(Dependencies::const_iterator i=tdeps.begin(); i!=tdeps.end(); ++i)
{
FileTarget *file = dynamic_cast<FileTarget *>(*i);
void PkgConfigGenerator::Worker::main()
{
Builder &builder = target.get_package()->get_builder();
- const SourcePackage &spkg = dynamic_cast<const SourcePackage &>(*target.get_package());
+ const SourcePackage &spkg = *target.get_package();
IO::BufferedFile out(target.get_path().str(), IO::M_WRITE);
IO::print(out, "prefix=%s\n", builder.get_prefix().str());
{
if(!sources.front()->get_package())
throw invalid_argument("Tar::create_target");
- const SourcePackage &src_pkg = dynamic_cast<const SourcePackage &>(*sources.front()->get_package());
- TarBall *tarball = new TarBall(builder, src_pkg, arg);
+ TarBall *tarball = new TarBall(builder, *sources.front()->get_package(), arg);
for(list<Target *>::const_iterator i=sources.begin(); i!=sources.end(); ++i)
tarball->add_depend(*i);
#include <msp/strings/format.h>
#include "builder.h"
#include "filetarget.h"
-#include "package.h"
+#include "sourcepackage.h"
#include "target.h"
#include "task.h"
#include "tool.h"
class Builder;
class Component;
-class Package;
+class SourcePackage;
class Task;
class Tool;
protected:
Builder &builder;
- const Package *package;
+ const SourcePackage *package;
const Component *component;
std::string name;
virtual const char *get_type() const = 0;
const std::string &get_name() const { return name; }
- const Package *get_package() const { return package; }
+ const SourcePackage *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