#include "sharedlibrary.h"
#include "sourcepackage.h"
#include "staticlibrary.h"
-#include "symlink.h"
#include "tarball.h"
#include "target.h"
{
Install *inst = new Install(builder, pkg, **i, inst_loc);
inst_tgt->add_depend(inst);
-
- if(type==LIBRARY)
- if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(*i))
- if(!shlib->get_soname().empty())
- inst_tgt->add_depend(new Symlink(builder, pkg, *inst, shlib->get_name()));
}
}
using namespace std;
using namespace Msp;
-Copy::Copy(Builder &b, const Package &pkg, const FS::Path &s, const FS::Path &d):
+Copy::Copy(Builder &b, const Package &pkg, const FS::Path &s, const FS::Path &d, const FS::Path &l):
InternalAction(b),
src(s),
- dest(d)
+ dest(d),
+ link(l)
{
announce(pkg.get_name(), "COPY", dest.str());
if(builder.get_verbose()>=2)
if(stat(copy.src.str().c_str(), &st)==0)
chmod(copy.dest.str().c_str(), st.st_mode&0777);
+ if(!copy.link.empty())
+ {
+ FS::Path relpath = FS::relative(copy.dest, FS::dirname(copy.link));
+ symlink(relpath.str().c_str(), copy.link.str().c_str());
+ }
+
done = true;
}
Msp::FS::Path src;
Msp::FS::Path dest;
+ Msp::FS::Path link;
public:
- Copy(Builder &, const Package &, const Msp::FS::Path &, const Msp::FS::Path &);
+ Copy(Builder &, const Package &, const Msp::FS::Path &, const Msp::FS::Path &, const Msp::FS::Path & =Msp::FS::Path());
};
#endif
{
buildable = true;
add_depend(&source);
+
+ if(const SharedLibrary *shlib = dynamic_cast<const SharedLibrary *>(&source))
+ if(!shlib->get_soname().empty())
+ link = FS::dirname(path)/FS::basename(shlib->get_path());
+
+ if(!link.empty())
+ builder.register_path(link, this);
}
Target *Install::get_real_target()
Action *Install::create_action()
{
- return new Copy(builder, *package, source.get_path(), path);
+ return new Copy(builder, *package, source.get_path(), path, link);
}
FS::Path Install::generate_target_path(const FileTarget &tgt, const std::string &loc)
{
private:
FileTarget &source;
+ Msp::FS::Path link;
public:
Install(Builder &, const SourcePackage &, FileTarget &, const std::string & =std::string());
+++ /dev/null
-#include <unistd.h>
-#include <msp/fs/utils.h>
-#include <msp/io/print.h>
-#include "builder.h"
-#include "package.h"
-#include "makesymlink.h"
-#include "symlink.h"
-
-using namespace Msp;
-
-MakeSymlink::MakeSymlink(Builder &b, const Symlink &sl):
- Action(b)
-{
- FS::Path relpath = FS::relative(sl.get_target().get_path(), FS::dirname(sl.get_path()));
-
- announce(sl.get_package()->get_name(), "LN", sl.get_path().str());
- if(builder.get_verbose()>=2)
- IO::print("%s -> %s\n", sl.get_name(), relpath.str());
-
- if(!builder.get_dry_run())
- symlink(relpath.str().c_str(), sl.get_path().str().c_str());
-}
-
-int MakeSymlink::check()
-{
- signal_done.emit();
- return 0;
-}
+++ /dev/null
-#ifndef MAKESYMLINK_H_
-#define MAKESYMLINK_H_
-
-#include "action.h"
-
-class Symlink;
-
-class MakeSymlink: public Action
-{
-public:
- MakeSymlink(Builder &, const Symlink &);
- virtual int check();
-};
-
-#endif
+++ /dev/null
-#include <msp/fs/utils.h>
-#include "makesymlink.h"
-#include "symlink.h"
-
-using namespace std;
-using namespace Msp;
-
-Symlink::Symlink(Builder &b, const Package &p, FileTarget &t, const string &n):
- FileTarget(b, &p, FS::dirname(t.get_path())/n),
- target(t)
-{
- buildable = true;
- add_depend(&target);
-}
-
-Target *Symlink::get_buildable_target()
-{
- return target.get_buildable_target();
-}
-
-Target *Symlink::get_real_target()
-{
- return target.get_real_target();
-}
-
-void Symlink::check_rebuild()
-{
- if(!mtime)
- mark_rebuild("Does not exist");
-}
-
-Action *Symlink::create_action()
-{
- return new MakeSymlink(builder, *this);
-}
+++ /dev/null
-#ifndef SYMLINK_H_
-#define SYMLINK_H_
-
-#include "filetarget.h"
-
-/**
-Symbolic link.
-*/
-class Symlink: public FileTarget
-{
-private:
- FileTarget ⌖
- bool relative;
-
-public:
- Symlink(Builder &, const Package &, FileTarget &, const std::string &);
-
- virtual const char *get_type() const { return "Symlink";}
- FileTarget &get_target() const { return target; }
- virtual Target *get_buildable_target();
- virtual Target *get_real_target();
-private:
- virtual void check_rebuild();
- virtual Action *create_action();
-};
-
-#endif