#include "architecture.h"
#include "builder.h"
#include "executable.h"
+#include "importlibrary.h"
#include "objectfile.h"
#include "sharedlibrary.h"
#include "staticlibrary.h"
{
add_pattern<SharedLibrary>("%.dll");
add_pattern<SharedLibrary>("lib%.dll");
- /* XXX Hack: Consider import libraries (*.dll.a) as dynamic libraries,
- even though technically they are linked statically. */
- add_pattern<SharedLibrary>("lib%.dll.a");
+ add_pattern<ImportLibrary>("lib%.dll.a");
add_pattern<StaticLibrary>("lib%.a");
add_pattern<StaticLibrary>("%.lib");
add_pattern<Executable>("%.exe");
#include <msp/strings/format.h>
+#include "architecture.h"
+#include "builder.h"
#include "component.h"
#include "exportdefinitions.h"
#include "importlibrary.h"
{ }
ImportLibrary::ImportLibrary(Builder &b, const Component &c, SharedLibrary &sl, ExportDefinitions &exp):
- FileTarget(b, c.get_package(), c.get_package().get_output_directory()/format("lib%s.dll.a", sl.get_libname())),
+ FileTarget(b, c.get_package(), c.get_package().get_output_directory()/generate_filename(c, sl)),
shared_lib(&sl)
{
component = &c;
const string &version = component->get_package().get_interface_version();
if(!version.empty())
- install_filename = format("lib%s-%s.dll.a", sl.get_libname(), version);
+ {
+ const Architecture &arch = builder.get_current_arch();
+ install_filename = arch.create_filename<ImportLibrary>(format("%s-%s", sl.get_libname(), version));
+ }
+}
+
+string ImportLibrary::generate_filename(const Component &comp, const SharedLibrary &sl)
+{
+ const Architecture &arch = comp.get_package().get_builder().get_current_arch();
+ return arch.create_filename<ImportLibrary>(sl.get_libname());
}
public:
ImportLibrary(Builder &, const Msp::FS::Path &);
ImportLibrary(Builder &, const Component &, SharedLibrary &, ExportDefinitions &);
+private:
+ static std::string generate_filename(const Component &, const SharedLibrary &);
+public:
virtual const char *get_type() const { return "ImportLibrary"; }
SharedLibrary *get_shared_library() const { return shared_lib; }
const Architecture &arch = builder.get_current_arch();
list<string> shared_names;
+ bool use_import_lib = false;
if(mode!=BuildInfo::FORCE_STATIC)
- shared_names = Pattern::apply_list(arch.get_patterns<SharedLibrary>(), lib);
+ {
+ shared_names = Pattern::apply_list(arch.get_patterns<ImportLibrary>(), lib);
+ if(!(use_import_lib = !shared_names.empty()))
+ shared_names = Pattern::apply_list(arch.get_patterns<SharedLibrary>(), lib);
+ }
list<string> static_names;
if(mode!=BuildInfo::FORCE_DYNAMIC)
builder.get_logger().log("vfs", format("Library %s (%s) found in %s", lib, *j, i->str()));
if(cur_names==&shared_names)
{
- /* 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")
+ if(use_import_lib)
return new ImportLibrary(builder, filename);
return new SharedLibrary(builder, filename);
}