[QBS] share functionnality between projects
olivier musse
olivier.musse at sfr.fr
Wed May 14 14:31:17 CEST 2014
Hi,
What is the best way to share source files and functionality among
different projects.
1) imaging I have some source files I want to share among multiple
projects. What is the best way to include these files using QBS?
With Qmake we use to do something like that
common_source.pri :
HEADERS+=$${PWD}/commonsource.h
SOURCES+=$${PWD}/commonsource.cpp
INCLUDEPATH+=$${PWD}
and in the main projet
mainproject.pri:
.....
include(Common/common_source.pri)
.....
So that in one line in all projects we share the same source code
In QBS I succeed to do that but using static library
common_source.qbs
Product {
type: "staticlibrary"
name:"common_source"
files:["commonsource.h","commonsource.cpp"]
Depends { name: "Qt" ; submodules: ["core"] }
Depends { name: "cpp" }
Export{
cpp.includePaths: "."
}
}
mainproject.qbs:
Project{
references:[Common/common_source.qbs]
Application {
......
Depends { name : "common_source"}
....
}
My questions :
- does what I have done is a good solution ?
- is there any other solution by just including source file (like with
qmake) and not creating a static library?
2) How to share functionality between projects.
As an example, imagine I want to automatically generate a file
according to project properties
Project {
propertystringversion:"1.3.5"
......
Transformer {
Artifact {
fileName: "output_file.txt"
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "Generating file '" + output.fileName + "'";
cmd.sourceCode = function() {
var content = "product version "+project.version;
var file = new TextFile(output.fileName, TextFile.WriteOnly);
file.write(content);
file.close();
}
return cmd;
}
}
.....
}
I would like the transformer to be share among many projects so that I
only need to include in the project file a qbs file only containing this
transformer.
What is the best solution to do that ?
Many thanks in advance for help.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140514/67e4e531/attachment.html>
More information about the Qbs
mailing list