[QBS] Some questions about modules creating

Алексей Шашев ashashev at gmail.com
Sat May 7 16:14:18 CEST 2016

Hi, there. I need help with modules creating.

1) I'm trying to make the rule independent of configure, I mean "debug" or
"release". For example I have archives containing *.h and *.cpp files. I

    property string outputPath: product.sourceDirectory + "/generated"
    FileTagger {
        patterns: "*.7z"
        fileTags: ["unpack7z"]

    Rule {
        id: extractor7z
        inputs: ["unpack7z"]

        Artifact {
            filePath: product.moduleProperty("extractor7z","outputPath")  +
                      "/" + input.baseDir
            fileTags: "unpacked"

        condition: {
            return true;

        prepare: {
            var cmdFunc = function() {
                if ( !File.exists(output.filePath) ||
                    File.lastModified(output.filePath) <
                    var args = [];
                    args.push("-o" + output.filePath);
                    var cmd = new Command("7z", args);

                    return cmd;
                    var cmd = new JavaScriptCommand();
                    cmd.sourceCode = function() {
                        print("Do nothing...");
                    return cmd;

            var cmd = cmdFunc();
            cmd.description = "extracting " + input.fileName;
            cmd.highlight = "extractor 7z";

            return cmd;


It works but I'm not sure that it's good idea. Does right way to do it

And if I update archive I get warning "WARNING: Cannot remove
What does it mean?

May be archive is not good example, but in reality I want to get external
dependencies from another source control systems and network shares.
Product will have special files with path to external dependencies.

2) What does "id" property of Rule Item mean?

3) I can't understand how module "cpp" works. Only CppModule.qbs contains
Module Item, other qbs files contain UnixGCC Item, CppModule Item. I guess
Module Item from CppModule.qbs describes general properties of module "cpp"
and the condition property of Item defines which Item will work. But I had
tried to do it and I got error "Module mymodule could not be loaded".
Could you explain how it works?

Thank a lot for your support.

*Yours faithfully,*
*Alexey Shashev*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20160507/dbe01414/attachment.html>

More information about the Qbs mailing list