summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-12 21:35:36 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-01-25 08:32:20 -0300
commitb5e32ea4f620a0f7e3e2ee6bba741b0f08686312 (patch)
tree51be92c646b7418259faf9f8620cfa9bd4889414 /main.cpp
parentb3daa9b6f33fe0925d0983b7dc84add876abc36a (diff)
downloadgeneratorrunner-b5e32ea4f620a0f7e3e2ee6bba741b0f08686312.tar.gz
generatorrunner-b5e32ea4f620a0f7e3e2ee6bba741b0f08686312.tar.xz
generatorrunner-b5e32ea4f620a0f7e3e2ee6bba741b0f08686312.zip
GeneratorRunner looks for loadable generator modules in many places.
Besides loading generator modules given as full file paths, and placed in the place where GeneratorRunner was installed, the modules are also looked for in paths added via QT_PLUGIN_PATH.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/main.cpp b/main.cpp
index 88e4eab..9397ba8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -127,15 +127,30 @@ int main(int argc, char *argv[])
if (!generatorSet.isEmpty()) {
QFileInfo generatorFile(generatorSet);
- if (generatorFile.baseName() == generatorSet)
- generatorFile.setFile(QDir(GENERATORRUNNER_PLUGIN_DIR), generatorSet + "_generator");
+ if (!generatorFile.exists()) {
+ QString generatorSetName(generatorSet + "_generator" + MODULE_EXTENSION);
+
+ // More library paths may be added via the QT_PLUGIN_PATH environment variable.
+ QCoreApplication::addLibraryPath(GENERATORRUNNER_PLUGIN_DIR);
+ foreach (const QString& path, QCoreApplication::libraryPaths()) {
+ generatorFile.setFile(QDir(path), generatorSetName);
+ if (generatorFile.exists())
+ break;
+ }
+ }
+
+ if (!generatorFile.exists()) {
+ std::cerr << argv[0] << ": Error loading generator-set plugin: ";
+ std::cerr << qPrintable(generatorFile.baseName()) << " module not found." << std::endl;
+ return EXIT_FAILURE;
+ }
QLibrary plugin(generatorFile.filePath());
getGeneratorsFunc getGenerators = (getGeneratorsFunc)plugin.resolve("getGenerators");
- if (getGenerators)
+ if (getGenerators) {
getGenerators(&generators);
- else {
- std::cerr << argv[0] << ": Error loading generatorset plugin: " << qPrintable(plugin.errorString()) << std::endl;
+ } else {
+ std::cerr << argv[0] << ": Error loading generator-set plugin: " << qPrintable(plugin.errorString()) << std::endl;
return EXIT_FAILURE;
}
} else if (!args.contains("help")) {