[QBS] Again is not started an Rule from the Module

Denis Shienkov denis.shienkov at gmail.com
Fri May 16 10:35:48 CEST 2014


Hi guys..

I want to create the separate module for support of Keil compiler to
assembly of my Embedded project. I inherit the module from the Module, but
not from the CppModule because my module has to be in directory
"/qbs/modules" of my project (besides, I can not able to inherit from the
CppModule because in this case need to specify a full patch to the
CppModule.qbs file, because the CppModule impossible to import, it is
private.. yes?).

For a start I would like to implement only a call of the compiler (c51.exe)
for compilation of one source file (blinky.c) to the object file
(blinky.obj).

I'm use the QtCreator v 3.1 with integrated Qbs (by default).

My project has the following contents:


== keil_qbs/keil_qbs.qbs ==

import qbs 1.0


Project {

    qbsSearchPaths: "qbs"

    references: [ "blinky/blinky.qbs" ]

}



== keil_qbs/blinky/blinky.qbs ==

import qbs.base 1.0


Product {

    name: "test"

    type: "obj"

    Depends { name: "keil" }


    keil.toolchainInstallPath: "c:/Keil/"

    keil.platform: "C51"

    keil.vendor: "Philips"


    files: [ "blinky.c" ]

}



== keil_qbs/qbs/modules/keil/KeilModule.qbs ==

import qbs 1.0

import qbs.File

import qbs.FileInfo

import "../utils.js" as ModUtils


Module {

    additionalProductTypes: [ "obj" ]

    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: ""


    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();

    }


    Rule {

        id: compiler

        inputs: [ "c" ]


        Artifact {

            fileName: ".obj/" + product.name + "/" +
input.baseDir.replace(':', '') + "/" +
FileInfo.baseName(input.filePath) + ".obj"

            fileTags: [ "obj" ]

        }


        prepare: {

            var args = [];


            // input source file name

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


            // include paths

            var commonIncludePath = ModUtils.moduleProperty(product,
"toolchainInstallPath")

                    + "/" + ModUtils.moduleProperty(product,
"platform") + "/INC/";

            var vendorIncludePath = commonIncludePath +
ModUtils.moduleProperty(product, "vendor");

            var includePaths = [];

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

            includePaths.push(FileInfo.toWindowsSeparators(vendorIncludePath));

            args.push("INCDIR(" + includePaths.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 with this implementation, nothing happens, no Rule running..

So, what I should to change to solve my problem? I do not understand..

BR,
Denis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20140516/1f2c2964/attachment.html>


More information about the Qbs mailing list