[QBS] Qt Plugin with QBS
at-2500
sokolabla at gmail.com
Mon Mar 16 13:12:14 CET 2015
Hi,
I am trying to set up a project using the Qt Plugin System. The project consists of multiple binaries, one dynamic library that defines the Q_INTERFACE (LIB) and multiple plugins (PLUGIN) implementing this interface. To have common unit tests for all plugins, I have a gtest-based binary that loads and tests the plugins via their interface. This binary should only get linked to LIB, not to PLUGINS, which is why I removed the „dynamiclibrary“ tag, and added a new tag, „plugin“ for PLUGINS. Now, of course, my plugin will not be build because there is no rule cpp,hpp - plugin. Is there an easy way to call the prepare script of the cpp rules that would be active for a dynamic library? Something like prepare: cpp.compiler.prepare? Or is there a better way to achieve what I want?
I am probably not the only person trying to create a plugin, maybe it would make sense to add such a plugin type to QBS.cpp or qt_plugin to QBS.Qt? Or is there already something like this?
plugin1.qbs:
Product {
name: „PLUGIN1“
type: „plugin“
Depends {name: „cpp“}
Depends { name: „LIB“ }
Rule {
id: mycompiler
inputs: ["cpp"]
auxiliaryInputs: ["hpp"]
Artifact {
fileTags: [„plugin"]
filePath: product.name + ".so"
}
prepare: compiler.prepare
}
}
test.qbs
CppApplication {
type: ["application", "copied_plugins"]
name: "PluginTester"
Depends { name: "cpp" }
cpp.systemIncludePaths: [ "/usr/src/gtest/" ]
Depends { name: „LIB" }
Depends { name: „PLUGIN1" }
files: [ "main.cpp" ]
Rule {
id: plugin_copy
// take outputs of projects this product depends on, if they are of type plugin
// as input to this rule
usings: [„plugin"]
Artifact {
fileTags: [ "copied_plugins" ]
filePath: input.fileName
}
prepare: {
var args = []
args.push("--symbolic-link")
args.push(input.filePath)
args.push(output.filePath)
var cmd = new Command("cp", args)
cmd.description = "creating symlink for " + input.fileName + " to PluginTester"
return cmd;
}
}
}
More information about the Qbs
mailing list