summaryrefslogtreecommitdiffstats
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
parentb3daa9b6f33fe0925d0983b7dc84add876abc36a (diff)
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.
-rw-r--r--generatorrunnerconfig.h.in3
-rw-r--r--main.cpp25
2 files changed, 23 insertions, 5 deletions
diff --git a/generatorrunnerconfig.h.in b/generatorrunnerconfig.h.in
index 93b6bb01..d291fcc5 100644
--- a/generatorrunnerconfig.h.in
+++ b/generatorrunnerconfig.h.in
@@ -7,4 +7,7 @@
// generatorrunner plugin dir
#define GENERATORRUNNER_PLUGIN_DIR "@generator_plugin_DIR@"
+// module extension
+#define MODULE_EXTENSION "@CMAKE_SHARED_LIBRARY_SUFFIX@"
+
#endif
diff --git a/main.cpp b/main.cpp
index 88e4eabd..9397ba87 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")) {