From 728b2f65fadd5fb5f000d908efa414027123f964 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 7 Sep 2012 20:29:46 +0300 Subject: [PATCH] Give import libraries their own class --- source/gnulinker.cpp | 6 ++++++ source/importlibrary.cpp | 8 ++++++++ source/importlibrary.h | 18 ++++++++++++++++++ source/virtualfilesystem.cpp | 7 +++++-- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 source/importlibrary.cpp create mode 100644 source/importlibrary.h diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 92971da..ce51c44 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -10,6 +10,7 @@ #include "externaltask.h" #include "gnucompiler.h" #include "gnulinker.h" +#include "importlibrary.h" #include "installedfile.h" #include "objectfile.h" #include "sharedlibrary.h" @@ -191,6 +192,11 @@ Task *GnuLinker::Linker::run(const Target &target) const argv.push_back("-l"+shlib->get_libname()); static_link_ok = false; } + else if(ImportLibrary *imp = dynamic_cast(tgt)) + { + argv.push_back(imp->get_path().str()); + static_link_ok = false; + } } if(static_link_ok) diff --git a/source/importlibrary.cpp b/source/importlibrary.cpp new file mode 100644 index 0000000..60e5511 --- /dev/null +++ b/source/importlibrary.cpp @@ -0,0 +1,8 @@ +#include +#include "importlibrary.h" + +using namespace Msp; + +ImportLibrary::ImportLibrary(Builder &b, const FS::Path &p): + FileTarget(b, p) +{ } diff --git a/source/importlibrary.h b/source/importlibrary.h new file mode 100644 index 0000000..86d26f4 --- /dev/null +++ b/source/importlibrary.h @@ -0,0 +1,18 @@ +#ifndef IMPORTLIBRARY_H_ +#define IMPORTLIBRARY_H_ + +#include "filetarget.h" + +/** +A special case of static library which pulls in a shared library. Used on +platforms with no true dynamic linking support. +*/ +class ImportLibrary: public FileTarget +{ +public: + ImportLibrary(Builder &, const Msp::FS::Path &); + + virtual const char *get_type() const { return "ImportLibrary"; } +}; + +#endif diff --git a/source/virtualfilesystem.cpp b/source/virtualfilesystem.cpp index f1a0adb..2f4ee64 100644 --- a/source/virtualfilesystem.cpp +++ b/source/virtualfilesystem.cpp @@ -6,6 +6,7 @@ #include "builder.h" #include "csourcefile.h" #include "executable.h" +#include "importlibrary.h" #include "sharedlibrary.h" #include "staticlibrary.h" #include "tool.h" @@ -104,9 +105,11 @@ FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath builder.get_logger().log("vfs", format("Library %s (%s) found in %s", lib, *j, i->str())); if(cur_names==&shared_names) { - // XXX Hack: create StaticLibrary targets for import libraries + /* XXX Hack: create ImportLibraries here; they should be handled + separately, but I need a more generic way of handling all these + filename patterns */ if(FS::extpart(*j)==".a") - return new StaticLibrary(builder, filename); + return new ImportLibrary(builder, filename); return new SharedLibrary(builder, filename); } else -- 2.45.2