mirror of https://github.com/nymea/nymea.git
Merge PR #584: Allow to override default paths using new env variable
commit
d59a6edd27
|
|
@ -12,11 +12,11 @@
|
|||
|
||||
To make nymead load the plugin from the plugins build directory, run nymead with an environment variable exported
|
||||
\code
|
||||
$ NYMEA_PLUGINS_PATH=/path/to/plugin/ nymead -n
|
||||
$ NYMEA_PLUGINS_EXTRA_PATH=/path/to/plugin/ nymead -n
|
||||
\endcode
|
||||
|
||||
In order to easier debug things, it is advised to enable debug output for the device manager and your plugin. E.g.
|
||||
\code
|
||||
$ NYMEA_PLUGINS_PATH=/path/to/plugin nymead -n -d DeviceManager -d YourPlugin
|
||||
$ NYMEA_PLUGINS_EXTRA_PATH=/path/to/plugin nymead -n -d DeviceManager -d YourPlugin
|
||||
\endcode
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -75,18 +75,30 @@ void ExperienceManager::loadPlugins()
|
|||
|
||||
QStringList ExperienceManager::pluginSearchDirs() const
|
||||
{
|
||||
const char *envDefaultPath = "NYMEA_EXPERIENCE_PLUGINS_PATH";
|
||||
const char *envExtraPath = "NYMEA_EXPERIENCE_PLUGINS_EXTRA_PATH";
|
||||
|
||||
QStringList searchDirs;
|
||||
QByteArray envPath = qgetenv("NYMEA_EXPERIENCE_PLUGINS_PATH");
|
||||
if (!envPath.isEmpty()) {
|
||||
searchDirs << QString(envPath).split(':');
|
||||
QByteArray envExtraPathData = qgetenv(envExtraPath);
|
||||
if (!envExtraPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envExtraPathData).split(':');
|
||||
}
|
||||
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "experiences");
|
||||
if (qEnvironmentVariableIsSet(envDefaultPath)) {
|
||||
QByteArray envDefaultPathData = qgetenv(envDefaultPath);
|
||||
if (!envDefaultPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envDefaultPathData).split(':');
|
||||
}
|
||||
} else {
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "experiences");
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/experiences").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../experiences/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../experiences/").absolutePath();
|
||||
}
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/experiences";
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../experiences/";
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../../../experiences/";
|
||||
|
||||
searchDirs.removeDuplicates();
|
||||
return searchDirs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,18 +39,29 @@ QHash<QString, ApiKey> ApiKeysProvidersLoader::allApiKeys() const
|
|||
|
||||
QStringList ApiKeysProvidersLoader::pluginSearchDirs() const
|
||||
{
|
||||
const char *envDefaultPath = "NYMEA_APIKEYS_PLUGINS_PATH";
|
||||
const char *envExtraPath = "NYMEA_APIKEYS_PLUGINS_EXTRA_PATH";
|
||||
|
||||
QStringList searchDirs;
|
||||
QByteArray envPath = qgetenv("NYMEA_APIKEYS_PLUGINS_PATH");
|
||||
if (!envPath.isEmpty()) {
|
||||
searchDirs << QString(envPath).split(':');
|
||||
QByteArray envExtraPathData = qgetenv(envExtraPath);
|
||||
if (!envExtraPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envExtraPathData).split(':');
|
||||
}
|
||||
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "apikeysproviders");
|
||||
if (qEnvironmentVariableIsSet(envDefaultPath)) {
|
||||
QByteArray envDefaultPathData = qgetenv(envDefaultPath);
|
||||
if (!envDefaultPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envDefaultPathData).split(':');
|
||||
}
|
||||
} else {
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "apikeysproviders");
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/apikeysproviders").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../apikeysproviders/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../apikeysproviders/").absolutePath();
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/apikeysproviders/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../apikeysproviders/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../apikeysproviders/").absolutePath();
|
||||
|
||||
searchDirs.removeDuplicates();
|
||||
return searchDirs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,21 +131,32 @@ ThingManagerImplementation::~ThingManagerImplementation()
|
|||
|
||||
QStringList ThingManagerImplementation::pluginSearchDirs()
|
||||
{
|
||||
const char *envDefaultPath = "NYMEA_PLUGINS_PATH";
|
||||
const char *envExtraPath = "NYMEA_PLUGINS_EXTRA_PATH";
|
||||
|
||||
QStringList searchDirs;
|
||||
QByteArray envPath = qgetenv("NYMEA_PLUGINS_PATH");
|
||||
if (!envPath.isEmpty()) {
|
||||
searchDirs << QString(envPath).split(':');
|
||||
QByteArray envExtraPathData = qgetenv(envExtraPath);
|
||||
if (!envExtraPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envExtraPathData).split(':');
|
||||
}
|
||||
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea");
|
||||
if (qEnvironmentVariableIsSet(envDefaultPath)) {
|
||||
QByteArray envDefaultPathData = qgetenv(envDefaultPath);
|
||||
if (!envDefaultPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envDefaultPathData).split(':');
|
||||
}
|
||||
} else {
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea");
|
||||
}
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("plugins", "nymea/plugins");
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../plugins/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../plugins/").absolutePath();
|
||||
}
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("plugins", "nymea/plugins");
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../plugins/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../plugins/").absolutePath();
|
||||
|
||||
searchDirs.removeDuplicates();
|
||||
return searchDirs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,21 +101,33 @@ PlatformZeroConfController *Platform::zeroConfController() const
|
|||
|
||||
QStringList Platform::pluginSearchDirs() const
|
||||
{
|
||||
const char *envDefaultPath = "NYMEA_PLATFORM_PLUGINS_PATH";
|
||||
const char *envExtraPath = "NYMEA_PLATFORM_PLUGINS_EXTRA_PATH";
|
||||
|
||||
QStringList searchDirs;
|
||||
QByteArray envPath = qgetenv("NYMEA_PLATFORM_PLUGINS_PATH");
|
||||
if (!envPath.isEmpty()) {
|
||||
searchDirs << QString(envPath).split(':');
|
||||
QByteArray envExtraPathData = qgetenv(envExtraPath);
|
||||
if (!envExtraPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envExtraPathData).split(':');
|
||||
}
|
||||
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "platform");
|
||||
if (qEnvironmentVariableIsSet(envDefaultPath)) {
|
||||
QByteArray envDefaultPathData = qgetenv(envDefaultPath);
|
||||
if (!envDefaultPathData.isEmpty()) {
|
||||
searchDirs << QString::fromUtf8(envDefaultPathData).split(':');
|
||||
}
|
||||
} else {
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "platform");
|
||||
}
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("plugins", "nymea/platform");
|
||||
}
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/platform/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../platform/").absolutePath();
|
||||
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../platform/").absolutePath();
|
||||
}
|
||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||
searchDirs << libraryPath.replace("plugins", "nymea/platform");
|
||||
}
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/platform/";
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../platform/";
|
||||
searchDirs << QCoreApplication::applicationDirPath() + "/../../../platform/";
|
||||
|
||||
searchDirs.removeDuplicates();
|
||||
return searchDirs;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue