diff options
Diffstat (limited to 'doc/howtos.qdoc')
-rw-r--r-- | doc/howtos.qdoc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/howtos.qdoc b/doc/howtos.qdoc index cc982023d..dd1b45130 100644 --- a/doc/howtos.qdoc +++ b/doc/howtos.qdoc @@ -38,6 +38,7 @@ \li \l{How do I build a Qt-based project?} \li \l{How do I make my app build against my library?} \li \l{How do I use precompiled headers?} + \li \l{How do I make sure my generated sources are getting compiled?} \li \l{How do I run my autotests?} \li \l{How do I create a module for a third-party library?} \li \l{How do I create application bundles and frameworks on iOS, macOS, tvOS, and watchOS?} @@ -130,6 +131,42 @@ } \endcode + \section1 How do I make sure my generated sources are getting compiled? + + The rules in a \QBS project do not care whether its inputs are actual source files + listed on the right-hand side of a \l{Product::files}{files} property or artifacts + that were generated by another rule. For instance, the C++ compiler rule considers + all input files of type "cpp", no matter how they got into the product. The following + example project demonstrates this. One of its source files exists in the repository, + the other one is generated at build time. Both are getting compiled the same way. + \note Do not try to add the generated files to a \c files property. Declaring them + as rule outputs is all that is needed to make \QBS know about them. + \code + import qbs.TextFile + CppApplication { + files: ["impl.cpp", "impl.h"] + cpp.includePaths: sourceDirectory + Rule { + multiplex: true + Artifact { filePath: "main.cpp"; fileTags: "cpp" } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.writeLine("#include <impl.h>"); + f.writeLine("int main()"); + f.writeLine("{"); + f.writeLine(" return functionFromImpl();"); + f.writeLine("}"); + f.close(); + }; + return cmd; + } + } + } + \endcode + \section1 How do I run my autotests? There are two simple things you need to do in your project. Firstly, you |