]> git.tdb.fi Git - builder.git/blobdiff - source/copy.cpp
Move the bpk files into a subdirectory and install them
[builder.git] / source / copy.cpp
index b5ac403c4d4eb72e42567122bb656d576287bb5a..24be942532b83ab52a0dcfdeb8446ad29d708edf 100644 (file)
@@ -1,4 +1,4 @@
-#include <errno.h>
+#include <unistd.h>
 #include <sys/stat.h>
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
@@ -7,7 +7,7 @@
 #include <msp/io/print.h>
 #include "builder.h"
 #include "copy.h"
-#include "install.h"
+#include "installedfile.h"
 
 using namespace std;
 using namespace Msp;
@@ -16,28 +16,25 @@ Copy::Copy(Builder &b):
        Tool(b, "CP")
 { }
 
-Target *Copy::create_target(const list<Target *> &sources, const string &arg) const
+Target *Copy::create_target(const list<Target *> &sources, const string &arg)
 {
        FileTarget &file_tgt = dynamic_cast<FileTarget &>(*sources.front());
-       const SourcePackage &pkg = dynamic_cast<const SourcePackage &>(*file_tgt.get_package());
-       Install *inst = new Install(builder, pkg, file_tgt, arg);
+       InstalledFile *inst = new InstalledFile(builder, *file_tgt.get_package(), file_tgt, arg);
        inst->set_tool(*this);
        return inst;
 }
 
 Task *Copy::run(const Target &target) const
 {
-       const Install &install = dynamic_cast<const Install &>(target);
+       const InstalledFile &install = dynamic_cast<const InstalledFile &>(target);
        Worker *worker = new Worker(install);
        return new InternalTask(worker);
 }
 
 
-Copy::Worker::Worker(const Install &t):
+Copy::Worker::Worker(const InstalledFile &t):
        target(t)
-{
-       launch();
-}
+{ }
 
 void Copy::Worker::main()
 {
@@ -90,6 +87,8 @@ void Copy::Worker::main()
        if(!link.empty())
        {
                FS::Path relpath = FS::relative(dst_path, FS::dirname(link));
+               if(FS::exists(link))
+                       FS::unlink(link);
                symlink(relpath.str().c_str(), link.str().c_str());
        }