[QBS] QBS Rule Item: Code generation with multiple output files with variable names
Sebastian Stadelmann
s.stadelmann at aucos.de
Wed May 18 09:33:41 CEST 2016
Hi,
in our project we need to generates several „*.cpp“ and „*.h“ files from one input file ("*.db“).
In the input file we define a database table structure for multiple tables and generate one cpp class
for each table definition.
The name of the generated cpp files is not known before we start the code generator because the name
was defined in the input file.
Ex.: input: customer.db
output: parts.h, parts.cpp, orders.h, orders.cpp …
We also generate a text file with a list of all generated files. This text file has a defined name.
Is there a way to compile all generated files in the current product after running the code generator by appending the files from the
generated text file to the product files? Or do you have any other suggestions?
Any help would be appreciated.
Thanks
Sebastian
import qbs
import qbs.FileInfo
AucosDynamicLibrary {
name: "subcore"
Depends { name: "core" }
files: [
"*.db",
"*.cpp",
"*.h"
]
FileTagger {
patterns: ["*.db"]
fileTags: ["db"]
}
Rule {
inputs: ["db"]
outputArtifacts: [{filePath: FileInfo.baseName(input.filePath)+".txt"}]
outputFileTags: ["cpp"]
prepare: {
var awk = "awk"
var awkScript = project.path + "/../utils/sql/db2c++.awk";
var args = ["-f ", awkScript, "-v", "prifile="+FileInfo.baseName(input.filePath)+".txt", input.filePath];
var cmd = new Command(awk, args);
cmd.workingDirectory = product.buildDirectory;
cmd.description = "generating C++ source";
return cmd;
}
}
Export { Depends { name: "core" } }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20160518/624953e3/attachment.sig>
More information about the Qbs
mailing list