#include "externaltask.h"
#include "gnucompiler.h"
#include "gnulinker.h"
+#include "installedfile.h"
#include "objectfile.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
return bin;
}
+Target *GnuLinker::create_install(Target &target) const
+{
+ if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(&target))
+ {
+ const Tool © = builder.get_toolchain().get_tool("CP");
+ InstalledFile *inst_tgt = dynamic_cast<InstalledFile *>(copy.create_target(target));
+ const Pattern &pattern = architecture->get_shared_library_patterns().front();
+ inst_tgt->set_symlink(pattern.apply(shlib->get_libname()));
+ return inst_tgt;
+ }
+ else
+ return 0;
+}
+
Task *GnuLinker::run(const Target &) const
{
throw logic_error("GnuLinker should not be run directly");
return parent.create_target(sources, arg);
}
+Target *GnuLinker::Linker::create_install(Target &target) const
+{
+ return parent.create_install(target);
+}
+
string GnuLinker::Linker::create_build_signature(const BuildInfo &binfo) const
{
string result = FS::basename(executable->get_path());
Linker(GnuLinker &, const std::string &);
virtual Target *create_target(const std::list<Target *> &, const std::string &) const;
+ virtual Target *create_install(Target &) const;
virtual std::string create_build_signature(const BuildInfo &) const;
virtual Task *run(const Target &) const;
};
~GnuLinker();
virtual Target *create_target(const std::list<Target *> &, const std::string &) const;
+ virtual Target *create_install(Target &) const;
virtual Task *run(const Target &) const;
};
source(s)
{
add_dependency(source);
-
- /* XXX Ideally, the tool should handle this (symlinks are not necessary for
- windows dlls). However, the tool that created the target being installed
- knows nothing about the InstalledFile. */
- string base_fn = FS::basename(source.get_path());
- const string &inst_fn = source.get_install_filename();
- if(!inst_fn.empty() && inst_fn!=base_fn)
- {
- link = FS::dirname(path)/base_fn;
- builder.get_vfs().register_path(link, this);
- }
}
FS::Path InstalledFile::generate_target_path(const FS::Path &prefix, const FileTarget &tgt, const string &loc)
return prefix/mid/fn;
}
+void InstalledFile::set_symlink(const FS::Path &l)
+{
+ link = FS::dirname(path)/l;
+ builder.get_vfs().register_path(link, this);
+}
+
Target *InstalledFile::get_real_target()
{
return source.get_real_target();
public:
virtual const char *get_type() const { return "InstalledFile"; }
FileTarget &get_source() const { return source; }
+
+ /** Sets a symlink for the file. A relative path will be rooted at the
+ directory the file resides in. */
+ void set_symlink(const Msp::FS::Path &);
+
const Msp::FS::Path &get_symlink() const { return link; }
+
virtual Target *get_real_target();
private:
virtual void check_rebuild();