qtqbs

How to get outputs of one Rule item as inputs of another one?


I want to create automatic crossplatform installation builder for my project. For this reason I made this file myprojectpackage.qbs:

Product {
   type: "mypackage"

   Depends { name: "myproject" } // <- this one has type "application"
   Depends { name: "applicationpackage" }
}

applicationpackage.qbs uses some submodules and looks like:

Module {
   name: "applicationpackage"
   Depends { name: "qtlibsbinariespackage" }
   Depends { name: "3rdpartybinariespackage" }
   Depends { name: "resourcepackage" }
}

All these modules try to find something and copy to package directory. After they finish, I have a folder with a portable version of application. Every module of this group have typical structure:

Module {
    name: "somepackage"

    Rule {
        condition: qbs.targetOS.contains("windows")
        multiplex: true
        alwaysRun: true
        inputsFromDependencies: ["application"]

        Artifact {
            filePath: "Copied_files.txt"
            fileTags: "mypackage"
        }

        prepare: {
            var cmdQt = new JavaScriptCommand()
            // prepare paths
            cmdQt.sourceCode = function() {
                // copy some files and write to Copied_files.txt
            }
            return [cmdQt]
        }
    }
}

After portable folder package complete, I want to make a zip archieve. So, I need another Module, which will run after package modules. I think, that only way to do like this is taking .txt files, that were created by modules in applicationpackage, as inputs for another Rule.

I have tried a lot of things (FileTaggers, outputFileTags etc.), but noone worked properly. So is there any way to do make modules work in pipeline as I want to do?


Solution

  • Do I understand correctly that you want to "merge" the contents of the txt files tagged "mypackage" into the archive, i.e. everything listed in all the files is supposed to end up there? If so, then you simply need a "top-level" rule that does the aggregation. Your existing rules would tag their outputs as e.g. "mypackage.part" and then a multiplex rule would take these as inputs and create a "mypackage" artifact. Note that there is the archiver module (https://doc.qt.io/qbs/archiver-module.html) that can do the final step of creating the package for you from the aggregated txt file.