summaryrefslogtreecommitdiffhomepage
path: root/opentrack
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-06 07:37:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-06 12:07:48 +0200
commit069ebb6212aa096adb1ded0823ac4194db9b0d03 (patch)
treea31c1026a6a0349e7867713ca85e83e8ff79b1be /opentrack
parent56e9f634d5dd4122278a8f1c5f8e9fe39ed3652e (diff)
gui, api, csv: support hier(7) on Unix
This affects platforms such as FreeBSD, Cygwin or Linux.
Diffstat (limited to 'opentrack')
-rw-r--r--opentrack/CMakeLists.txt1
-rw-r--r--opentrack/library-path.cpp4
-rw-r--r--opentrack/library-path.hpp2
-rw-r--r--opentrack/plugin-support.hpp39
4 files changed, 27 insertions, 19 deletions
diff --git a/opentrack/CMakeLists.txt b/opentrack/CMakeLists.txt
index 6dc6a96d..13b054ca 100644
--- a/opentrack/CMakeLists.txt
+++ b/opentrack/CMakeLists.txt
@@ -1,2 +1,3 @@
opentrack_boilerplate(opentrack-api NO-COMPAT)
target_link_libraries(opentrack-api opentrack-compat)
+target_include_directories(opentrack-api PUBLIC ${CMAKE_BINARY_DIR})
diff --git a/opentrack/library-path.cpp b/opentrack/library-path.cpp
new file mode 100644
index 00000000..683dc346
--- /dev/null
+++ b/opentrack/library-path.cpp
@@ -0,0 +1,4 @@
+#include "library-path.hpp"
+#include "opentrack-library-path.h"
+
+const char* opentrack_library_path = OPENTRACK_LIBRARY_PATH;
diff --git a/opentrack/library-path.hpp b/opentrack/library-path.hpp
new file mode 100644
index 00000000..49a3adb4
--- /dev/null
+++ b/opentrack/library-path.hpp
@@ -0,0 +1,2 @@
+#include "export.hpp"
+extern "C" OPENTRACK_API_EXPORT const char* opentrack_library_path;
diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp
index b228b8d4..dbb985dc 100644
--- a/opentrack/plugin-support.hpp
+++ b/opentrack/plugin-support.hpp
@@ -9,6 +9,7 @@
#include "plugin-api.hpp"
#include "opentrack-compat/options.hpp"
+#include "library-path.hpp"
#include <QWidget>
#include <QDebug>
@@ -29,22 +30,21 @@
#include <QStringList>
#if defined(__APPLE__)
-# define OPENTRACK_SONAME "dylib"
+# define OPENTRACK_SOLIB_EXT "dylib"
#elif defined(_WIN32)
-# define OPENTRACK_SONAME "dll"
+# define OPENTRACK_SOLIB_EXT "dll"
#else
-# define OPENTRACK_SONAME "so"
+# define OPENTRACK_SOLIB_EXT "so"
#endif
#include <iostream>
#ifdef _MSC_VER
-# define OPENTRACK_LIB_PREFIX ""
+# define OPENTRACK_SOLIB_PREFIX ""
#else
-# define OPENTRACK_LIB_PREFIX "lib"
+# define OPENTRACK_SOLIB_PREFIX "lib"
#endif
-
extern "C" typedef void* (*OPENTRACK_CTOR_FUNPTR)(void);
extern "C" typedef Metadata* (*OPENTRACK_METADATA_FUNPTR)(void);
@@ -108,29 +108,30 @@ struct dylib final {
static QList<mem<dylib>> enum_libraries()
{
- const char* filters_n[] = { "opentrack-filter-*.",
- "opentrack-tracker-*.",
- "opentrack-proto-*."
+ const char* filters_n[] = { OPENTRACK_SOLIB_PREFIX "opentrack-filter-*." OPENTRACK_SOLIB_EXT,
+ OPENTRACK_SOLIB_PREFIX "opentrack-tracker-*." OPENTRACK_SOLIB_EXT,
+ OPENTRACK_SOLIB_PREFIX "opentrack-proto-*." OPENTRACK_SOLIB_EXT,
};
const Type filters_t[] = { Filter, Tracker, Protocol };
- QDir settingsDir( QCoreApplication::applicationDirPath() );
+ static const QString libexec_path(QStringLiteral("./") + opentrack_library_path);
+
+ QDir settingsDir(libexec_path);
QList<mem<dylib>> ret;
for (int i = 0; i < 3; i++)
{
- QString filter = filters_n[i];
- auto t = filters_t[i];
- QStringList filenames = settingsDir.entryList(QStringList { OPENTRACK_LIB_PREFIX + filter + OPENTRACK_SONAME },
- QDir::Files,
- QDir::Name);
- for (int i = 0; i < filenames.size(); i++) {
+ QString glob = filters_n[i];
+ Type t = filters_t[i];
+ QStringList filenames = settingsDir.entryList(QStringList { glob }, QDir::Files, QDir::Name);
+
+ for (const QString& filename : filenames)
+ {
QIcon icon;
QString longName;
- QString str = filenames.at(i);
- auto lib = std::make_shared<dylib>(str, t);
- qDebug() << "Loading" << str;
+ auto lib = std::make_shared<dylib>(libexec_path + QStringLiteral("/") + filename, t);
+ qDebug() << "Loading" << filename;
std::cout.flush();
if (!get_metadata(lib, longName, icon))
continue;