Hi Sebastian,
You need to give the output artifact of your Rule the cpp file tag in order it
to be recognized as a C++ source file. The outputFileTags property only
indicates the potential set of file tags that artifacts in the outputArtifacts
script may contain (for more complex Rules where the list of artifacts may
vary, the distinction is necessary); you still have to explicitly state which
file tags each Artifact has. You can also use output.filePath in your prepare
script instead of repeating the value of your Artifact's filePath literally.
For example:
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",
fileTags: ["cpp"]}]
outputFileTags: ["cpp"]
// Instead of outputArtifacts and outputFileTags, you could also use the
following, since there is only one output Artifact:
/*Artifact {
filePath: FileInfo.baseName(input.filePath) + ".txt"
fileTags: ["cpp"]
}*/
prepare: {
var awk = "awk"
var awkScript = project.path + "/../utils/sql/db2c++.awk";
var args = ["-f ", awkScript, "-v", "prifile=" + output.filePath,
input.filePath];
var cmd = new Command(awk, args);
cmd.workingDirectory = product.buildDirectory;
cmd.description = "generating C++ source";
return cmd;
}
}
Export { Depends { name: "core" } }
}
On May 18, 2016, at 12:33 AM, Sebastian Stadelmann
<[email protected]<mailto:[email protected]>> wrote:
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" } }
}
_______________________________________________
QBS mailing list
[email protected]<mailto:[email protected]>
http://lists.qt-project.org/mailman/listinfo/qbs
--
Jake Petroules -
[email protected]<mailto:[email protected]>
Consulting Services Engineer - The Qt Company
Qbs build system evangelist - qbs.io<http://qbs.io>
_______________________________________________
QBS mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/qbs