]> git.tdb.fi Git - builder.git/commitdiff
Give import libraries their own class
authorMikko Rasa <tdb@tdb.fi>
Fri, 7 Sep 2012 17:29:46 +0000 (20:29 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 7 Sep 2012 17:49:13 +0000 (20:49 +0300)
source/gnulinker.cpp
source/importlibrary.cpp [new file with mode: 0644]
source/importlibrary.h [new file with mode: 0644]
source/virtualfilesystem.cpp

index 92971da7b15a6de11c0e7cc0060cc0daefdcb08b..ce51c44ae503cefb58fdefc6d026b9f7071f46ed 100644 (file)
@@ -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<ImportLibrary *>(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 (file)
index 0000000..60e5511
--- /dev/null
@@ -0,0 +1,8 @@
+#include <msp/strings/format.h>
+#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 (file)
index 0000000..86d26f4
--- /dev/null
@@ -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
index f1a0adb7b633c78a6b16896be775a65ba5f497fd..2f4ee645281c1727aca01cb0b4abced00124a463 100644 (file)
@@ -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