This answer is based on a letter from Qbs author JΓΆrg Bornemann, who allowed me to bring it here.
The usings rule property allows you to add artifacts from product dependencies on input data. In this case, we are interested in application artifacts.
After that, the list of applications can be obtained as input.application .
Application { name: "my_app" Group { files: 'main.cpp.in' fileTags: ['cpp_in'] } Depends { name: "cpp" } // we need this dependency to make sure that my_tool exists before building my_app Depends { name: "my_tool" } Rule { inputs: ["cpp_in"] usings: ["application"] // dependent "application" products appear in inputs Artifact { fileName: input.completeBaseName fileTags: "cpp" } prepare: { // inputs["application"] is a list of "application" products var mytool = inputs["application"][0].fileName; var cmd = new Command(mytool, [inputs["cpp_in"][0].fileName, output.fileName]); cmd.description = "Generate\t" + input.baseName; cmd.highlight = "codegen"; return cmd; } } }
source share