TableRow row;
- string fn;
- if(full_paths)
- fn = tgt.get_name();
+ string name;
+ FileTarget *ft = dynamic_cast<FileTarget *>(&tgt);
+ if(full_paths && ft)
+ name = ft->get_path().str();
else
- fn = FS::basename(tgt.get_name());
- row.push_back(string(depth*2, ' ')+fn);
+ name = tgt.get_name();
+ row.push_back(string(depth*2, ' ')+name);
const Package *pkg = tgt.get_package();
if(pkg)
queue.push_back(&stlib->get_component());
}
else
- builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, FS::basename(name)));
+ builder.problem(comp.get_package().get_name(), format("Couldn't find library %s for %s", *i, name));
}
}
problems.push_back(Problem(p, d));
}
-void Builder::add_target(Target *t)
+void Builder::add_target(FileTarget *t)
+{
+ targets.insert(TargetMap::value_type(t->get_path().str(), t));
+ new_tgts.push_back(t);
+}
+
+void Builder::add_target(VirtualTarget *t)
{
targets.insert(TargetMap::value_type(t->get_name(), t));
new_tgts.push_back(t);
class Analyzer;
class Config;
+class FileTarget;
class Package;
class SourcePackage;
+class VirtualTarget;
/**
The main application class. Controls and owns everything. Rules the world.
/** Adds a target to both the target map and the new target queue. Called
from Target constructor. */
- void add_target(Target *);
+ void add_target(FileTarget *);
+ void add_target(VirtualTarget *);
void problem(const std::string &, const std::string &);
#include <msp/fs/stat.h>
#include <msp/fs/utils.h>
-#include "file.h"
+#include "builder.h"
+#include "filetarget.h"
using namespace std;
using namespace Msp;
FileTarget::FileTarget(Builder &b, const Package *p, const FS::Path &a):
- // XXX Builder depends on target name being its path for locating file targets
- Target(b, p, /*FS::basename*/(a.str())),
+ Target(b, p, FS::basename(a.str())),
path(a),
size(0)
{
+ builder.add_target(this);
+
struct stat st;
if(!FS::stat(path, st))
{
if(!mtime)
mark_rebuild("Does not exist");
else if(source.get_mtime()>mtime || source.get_size()!=size)
- mark_rebuild(FS::basename(source.get_name())+" has changed");
+ mark_rebuild(source.get_name()+" has changed");
else if(source.get_rebuild())
- mark_rebuild(FS::basename(source.get_name())+" needs rebuilding");
+ mark_rebuild(source.get_name()+" needs rebuilding");
}
Action *Install::create_action()
}
const SourcePackage &spkg = comp->get_package();
- string relname = FS::relative(name, spkg.get_source()).str();
+ string relname = FS::relative(path, spkg.get_source()).str();
DependencyCache &deps_cache = spkg.get_deps_cache();
bool deps_found = false;
if(mtime<deps_cache.get_mtime())
{
try
{
- IO::BufferedFile in(name);
+ IO::BufferedFile in(path.str());
if(builder.get_verbose()>=4)
- IO::print("Reading includes from %s\n", name);
+ IO::print("Reading includes from %s\n", path.str());
Regex r_include("^[ \t]*#include[ \t]+([\"<].*)[\">]");
}
catch(const IO::FileNotFound &)
{
- // XXX WTF?
+ if(builder.get_verbose()>=4)
+ IO::print("Failed to read includes from %s\n", path.str());
+ deps_ready = true;
return;
}
}
deps_ready(false),
preparing(false),
prepared(false)
-{
- builder.add_target(this);
-}
+{ }
Target *Target::get_buildable_target()
{
for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
{
if((*i)->get_mtime()>mtime)
- mark_rebuild(FS::basename((*i)->get_name())+" has changed");
+ mark_rebuild((*i)->get_name()+" has changed");
else if((*i)->get_rebuild())
- mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
+ mark_rebuild((*i)->get_name()+" needs rebuilding");
}
}
#include <msp/fs/path.h>
#include <msp/fs/utils.h>
+#include "builder.h"
#include "virtualtarget.h"
using namespace std;
using namespace Msp;
+VirtualTarget::VirtualTarget(Builder &b, const string &n):
+ Target(b, 0, n)
+{
+ builder.add_target(this);
+}
+
void VirtualTarget::check_rebuild()
{
// Virtual targets are only rebuilt if their dependencies need rebuilding.
for(TargetList::iterator i=depends.begin(); (i!=depends.end() && !rebuild); ++i)
if((*i)->get_rebuild())
- mark_rebuild(FS::basename((*i)->get_name())+" needs rebuilding");
+ mark_rebuild((*i)->get_name()+" needs rebuilding");
}
class VirtualTarget: public Target
{
public:
- VirtualTarget(Builder &b, const std::string &n): Target(b, 0, n) { }
+ VirtualTarget(Builder &, const std::string &);
virtual const char *get_type() const { return "VirtualTarget"; }
private:
virtual void check_rebuild();