public:
DataFile(Builder &, const Component &, File &);
+private:
+ static Msp::FS::Path generate_target_path(const Component &);
+public:
virtual const char *get_type() const { return "DataFile"; }
const Component &get_component() const { return component; }
File &get_source() const { return source; }
-
-private:
- static Msp::FS::Path generate_target_path(const Component &);
};
#endif
public:
Executable(Builder &, const Msp::FS::Path &);
Executable(Builder &, const Component &, const std::list<ObjectFile *> &);
-
- virtual const char *get_type() const { return "Executable"; }
private:
static std::string generate_filename(const Component &);
+
+public:
+ virtual const char *get_type() const { return "Executable"; }
};
#endif
}
}
+string FileTarget::generate_name(const SourcePackage *pkg, const FS::Path &pth)
+{
+ if(pkg)
+ {
+ if(FS::descendant_depth(pth, pkg->get_source())>=0)
+ {
+ 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)
+ {
+ FS::Path relpath = FS::relative(pth, pkg->get_builder().get_prefix());
+ return "<prefix>"+relpath.str().substr(1);
+ }
+ }
+
+ return pth.str();
+}
+
void FileTarget::touch()
{
mtime = Time::now();
if(!needs_rebuild() && package && package->get_config().get_mtime()>mtime)
mark_rebuild("Package options changed");
}
-
-string FileTarget::generate_name(const SourcePackage *pkg, const FS::Path &pth)
-{
- if(pkg)
- {
- if(FS::descendant_depth(pth, pkg->get_source())>=0)
- {
- 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)
- {
- FS::Path relpath = FS::relative(pth, pkg->get_builder().get_prefix());
- return "<prefix>"+relpath.str().substr(1);
- }
- }
-
- return pth.str();
-}
unsigned size;
FileTarget(Builder &, const SourcePackage *, const Msp::FS::Path &);
+private:
+ static std::string generate_name(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 SourcePackage *, const Msp::FS::Path &);
};
#endif
builder.get_vfs().register_path(link, this);
}
+FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
+{
+ if(!tgt.is_installable() && loc.empty())
+ throw invalid_argument(tgt.get_name()+" is not installable");
+
+ string mid;
+ if(!loc.empty())
+ mid = loc;
+ else
+ mid = tgt.get_install_location();
+
+ return prefix/mid/FS::basename(tgt.get_path());
+}
+
Target *InstalledFile::get_real_target()
{
return source.get_real_target();
else if(source.needs_rebuild())
mark_rebuild(source.get_name()+" needs rebuilding");
}
-
-FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
-{
- if(!tgt.is_installable() && loc.empty())
- throw invalid_argument(tgt.get_name()+" is not installable");
-
- string mid;
- if(!loc.empty())
- mid = loc;
- else
- mid = tgt.get_install_location();
-
- return prefix/mid/FS::basename(tgt.get_path());
-}
public:
InstalledFile(Builder &, const SourcePackage &, FileTarget &, const std::string & =std::string());
+private:
+ static Msp::FS::Path generate_target_path(const Msp::FS::Path &, const FileTarget &i, const std::string &);
+
+public:
virtual const char *get_type() const { return "InstalledFile"; }
FileTarget &get_source() const { return source; }
const Msp::FS::Path &get_symlink() const { return link; }
virtual Target *get_real_target();
private:
virtual void check_rebuild();
-
- static Msp::FS::Path generate_target_path(const Msp::FS::Path &, const FileTarget &i, const std::string &);
};
#endif
add_depend(&source);
}
+FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
+{
+ const SourcePackage &pkg = comp.get_package();
+ string fn = FS::basepart(src)+".o";
+ if(!fn.compare(0, 2, "./"))
+ fn.erase(0, 2);
+ for(string::iterator i=fn.begin(); i!=fn.end(); ++i)
+ if(*i=='/')
+ *i = '_';
+ return pkg.get_temp_dir()/comp.get_name()/fn;
+}
+
void ObjectFile::find_depends()
{
for(Dependencies::iterator i=depends.begin(); i!=depends.end(); ++i)
}
}
-
void ObjectFile::find_depends(FileTarget *tgt)
{
FileTarget *rtgt = dynamic_cast<FileTarget *>(tgt->get_real_target());
if(find(depends.begin(), depends.end(), *i)==depends.end())
add_depend(*i);
}
-
-FS::Path ObjectFile::generate_target_path(const Component &comp, const string &src)
-{
- const SourcePackage &pkg = comp.get_package();
- string fn = FS::basepart(src)+".o";
- if(!fn.compare(0, 2, "./"))
- fn.erase(0, 2);
- for(string::iterator i=fn.begin(); i!=fn.end(); ++i)
- if(*i=='/')
- *i = '_';
- return pkg.get_temp_dir()/comp.get_name()/fn;
-}
public:
ObjectFile(Builder &, const Component &, SourceFile &);
+private:
+ static Msp::FS::Path generate_target_path(const Component &, const std::string &);
+
+public:
virtual const char *get_type() const { return "ObjectFile"; }
const Component &get_component() const { return comp; }
SourceFile &get_source() const { return source; }
private:
/** Recursively looks for header targets and adds them as dependencies. */
void find_depends(FileTarget *);
-
- static Msp::FS::Path generate_target_path(const Component &, const std::string &);
};
#endif
public:
SharedLibrary(Builder &, const Msp::FS::Path &);
SharedLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
+private:
+ static std::string generate_filename(const Component &);
+public:
virtual const char *get_type() const { return "SharedLibrary"; }
const std::string &get_libname() const { return libname; }
const std::string &get_soname() const { return soname; }
-
-private:
- static std::string generate_filename(const Component &);
};
#endif
public:
StaticLibrary(Builder &, const Msp::FS::Path &);
StaticLibrary(Builder &, const Component &, const std::list<ObjectFile *> &);
-
- virtual const char *get_type() const { return "StaticLibrary"; }
private:
static std::string generate_filename(const Component &);
+
+public:
+ virtual const char *get_type() const { return "StaticLibrary"; }
};
#endif