[QBS] Error at using multiple artifacts for module's rule

Denis Shienkov denis.shienkov at gmail.com
Fri May 16 14:01:03 CEST 2014


How, this code is works but only in case when Artifact's condition:

//condition: product.moduleProperty(product, "generateListing")

comments out.

I.e. now, how I can get access to my "generateListing" property for write
condition?

Because this:

condition: product.moduleProperty(product, "generateListing")

condition: ModUtils.moduleProperty(product, "generateListing")

condition: product.generateListing

does not work..

===

Module {

    //additionalProductTypes: [ "keil_obj", "keil_lst" ]

    condition: qbs.hostOS.contains("windows")


    property path toolchainInstallPath: ""

    property path toolchainInstallRoot: toolchainInstallPath +
platform + "/bin/"


    property string compilerName: "c51.exe"

    property string compilerPath: compilerName

    property string linkerName: "bl51.exe"

    property string linkerPath: linkerName


    property string platform: ""

    property string vendor: ""


    property bool generateListing: true

    PropertyOptions {

        name: "generateListing"

        description: "generate listing files"

    }


    property string memoryModel: "small"

    PropertyOptions {

        name: "memoryModel"

        description: "this is an compiler option to specify an memory model"

        allowedValues: ["small", "compact", "large", "d512k", "d16m" ]

    }


    property pathList includePaths

    PropertyOptions {

        name: "includePaths"

        description: "directories to add to the include search path"

    }


    property stringList defines

    PropertyOptions {

        name: "defines"

        description: "variables that are defined when using the compiler"

    }


    validate: {

        if (!toolchainInstallPath)

            throw "keil.toolchainInstallPath is not defined. Set
keil.toolchainInstallPath in your profile.";


        if (!toolchainInstallRoot)

            throw "keil.toolchainInstallRoot is not defined. Set
keil.toolchainInstallRoot in your profile."

    }


    setupBuildEnvironment: {

        var v = new ModUtils.EnvironmentVariable("PATH", ";", true);

        v.prepend(toolchainInstallPath);

        v.prepend(toolchainInstallRoot);

        v.set();

    }


    FileTagger {

        patterns: [ "*.c", "*.cpp" ]

        fileTags: ["keil_source"]

    }


    Rule {

        id: compiler

        multiplex: true

        inputs: [ "keil_source" ]


        Artifact {

            fileTags: [ "keil_obj" ]

            fileName: ".obj/" + product.name + "/" +
FileInfo.baseName(input.filePath) + ".obj"

        }


        Artifact {

            //condition: product.moduleProperty(product, "generateListing")

            fileTags: [ "keil_lst" ]

            fileName: ".lst/" + product.name + "/" +
FileInfo.baseName(input.filePath) + ".lst"

        }


        prepare: {

            var args = [];


            // input source file name

            args.push(FileInfo.toWindowsSeparators(input.filePath));

            // memory model

            args.push("rom(" + ModUtils.moduleProperty(product,
"memoryModel") + ")");


            if (ModUtils.moduleProperty(product, "generateListing")) {

                args.push("print(" +
FileInfo.toWindowsSeparators(outputs.keil_lst[0].fileName) + ")");

            } else {

                args.push("noprint");

            }


            // include paths

            var userIncludePaths = ModUtils.moduleProperty(product,
"includePaths");

            var commonIncludePath = ModUtils.moduleProperty(product,
"toolchainInstallPath") + "/" + ModUtils.moduleProperty(product,
"platform") + "/INC";

            userIncludePaths.push(FileInfo.toWindowsSeparators(project.path));

            userIncludePaths.push(FileInfo.toWindowsSeparators(commonIncludePath));

            userIncludePaths.push(FileInfo.toWindowsSeparators(commonIncludePath
+ "/" + ModUtils.moduleProperty(product, "vendor")));

            if (userIncludePaths && userIncludePaths.length > 0)

                args.push("incdir(" + userIncludePaths.join(";") + ")");


            // user-supplied defines

            var defines = ModUtils.moduleProperty(product, "defines");

            if (defines && defines.length > 0)

                args.push("define(" + defines.join(";") + ")");





            // output object file name

            args.push("object(" +
FileInfo.toWindowsSeparators(outputs.keil_obj[0].filePath) + ")");


            var cmd = new Command(ModUtils.moduleProperty(product,
"compilerPath" ), args);

            cmd.description = "compiling " + FileInfo.fileName(input.filePath);

            cmd.highlight = "compiler";

            cmd.workingDirectory = FileInfo.path(outputs.keil_obj[0].filePath);

            return cmd;

        }

    }


}

BR,
Denis




2014-05-16 15:44 GMT+04:00 Denis Shienkov <denis.shienkov at gmail.com>:

> Hi all..
>
> My new question is continuation of previous issue:
> http://lists.qt-project.org/pipermail/qbs/2014-May/000703.html
>
> Where I trying to adapt an Keil (C51) compiler to Qbs.
>
> Now I want to create multiple artifacts:
>
> - one to generate the object file (*.obj)
> - one to genetate the listings file (*.lst)
>
> from source file *.c.
>
> I take as example the WiX module with their linker Rule, with adaptation
> to my specific, where now my KeilModule has this content:
>
>
> import qbs
>
> import qbs.File
>
> import qbs.FileInfo
>
> import "../utils.js" as ModUtils
>
>
> Module {
>
>     //additionalProductTypes: [ "keil_obj", "keil_lst" ]
>
>     condition: qbs.hostOS.contains("windows")
>
>
>     property path toolchainInstallPath: ""
>
>     property path toolchainInstallRoot: toolchainInstallPath + platform + "/bin/"
>
>
>     property string compilerName: "c51.exe"
>
>     property string compilerPath: compilerName
>
>     property string linkerName: "bl51.exe"
>
>     property string linkerPath: linkerName
>
>
>     property string platform: ""
>
>     property string vendor: ""
>
>
>     property bool generateListing: true
>
>     PropertyOptions {
>
>         name: "generateListing"
>
>         description: "generate listing files"
>
>     }
>
>
>     property string memoryModel: "small"
>
>     PropertyOptions {
>
>         name: "memoryModel"
>
>         description: "this is an compiler option to specify an memory model"
>
>         allowedValues: ["small", "compact", "large", "d512k", "d16m" ]
>
>     }
>
>
>     property pathList includePaths
>
>     PropertyOptions {
>
>         name: "includePaths"
>
>         description: "directories to add to the include search path"
>
>     }
>
>
>     property stringList defines
>
>     PropertyOptions {
>
>         name: "defines"
>
>         description: "variables that are defined when using the compiler"
>
>     }
>
>
>     validate: {
>
>         if (!toolchainInstallPath)
>
>             throw "keil.toolchainInstallPath is not defined. Set keil.toolchainInstallPath in your profile.";
>
>
>         if (!toolchainInstallRoot)
>
>             throw "keil.toolchainInstallRoot is not defined. Set keil.toolchainInstallRoot in your profile."
>
>     }
>
>
>     setupBuildEnvironment: {
>
>         var v = new ModUtils.EnvironmentVariable("PATH", ";", true);
>
>         v.prepend(toolchainInstallPath);
>
>         v.prepend(toolchainInstallRoot);
>
>         v.set();
>
>     }
>
>
>     FileTagger {
>
>         patterns: [ "*.c", "*.cpp" ]
>
>         fileTags: ["keil_source"]
>
>     }
>
>
>     Rule {
>
>         id: compiler
>
>         //multiplex: true
>
>         inputs: [ "keil_source" ]
>
>
>         Artifact {
>
>             fileTags: [ "keil_obj" ]
>
>             fileName: ".obj/" + product.name + "/" + FileInfo.baseName(input.filePath) + ".obj"
>
>         }
>
>
>         Artifact {
>
>             condition: product.moduleProperty("qbs", "generateListing")
>
>             fileTags: [ "keil_lst" ]
>
>             fileName: ".lst/" + product.name + "/" + FileInfo.baseName(input.filePath) + ".lst"
>
>         }
>
>
>         prepare: {
>
>             var args = [];
>
>
>             // input source file name
>
>             args.push(FileInfo.toWindowsSeparators(input.filePath));
>
>             // memory model
>
>             args.push("rom(" + ModUtils.moduleProperty(product, "memoryModel") + ")");
>
>
>             if (ModUtils.moduleProperty(product, "generateListing")) {
>
>                 args.push("print(" + FileInfo.toWindowsSeparators(outputs.keil_lst[0].fileName) + ")");
>
>             } else {
>
>                 args.push("noprint");
>
>             }
>
>
>             // include paths
>
>             var userIncludePaths = ModUtils.moduleProperty(product, "includePaths");
>
>             var commonIncludePath = ModUtils.moduleProperty(product, "toolchainInstallPath") + "/" + ModUtils.moduleProperty(product, "platform") + "/INC";
>
>             userIncludePaths.push(FileInfo.toWindowsSeparators(project.path));
>
>             userIncludePaths.push(FileInfo.toWindowsSeparators(commonIncludePath));
>
>             userIncludePaths.push(FileInfo.toWindowsSeparators(commonIncludePath + "/" + ModUtils.moduleProperty(product, "vendor")));
>
>             if (userIncludePaths && userIncludePaths.length > 0)
>
>                 args.push("incdir(" + userIncludePaths.join(";") + ")");
>
>
>             // user-supplied defines
>
>             var defines = ModUtils.moduleProperty(product, "defines");
>
>             if (defines && defines.length > 0)
>
>                 args.push("define(" + defines.join(";") + ")");
>
>
>
>
>
>             // output object file name
>
>             args.push("object(" + FileInfo.toWindowsSeparators(output.filePath) + ")");
>
>
>             var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath" ), args);
>
>             cmd.description = "compiling " + FileInfo.fileName(input.filePath);
>
>             cmd.highlight = "compiler";
>
>             cmd.workingDirectory = FileInfo.path(output.filePath);
>
>             return cmd;
>
>         }
>
>     }
>
>
> }
>
>
> but at attempt to build the project I got an error:
>
> {quote}
> evaluating prepare script: TypeError: Result of expression
> 'outputs.keil_lst' [undefined] is not an object.
> {quote}
>
> Using the "multiplex" or "additionalProductTypes" property has no effect.
>
> Say please, what I do wrong?
>
> BR,
> Denis
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140516/14434408/attachment.html>


More information about the Qbs mailing list