qbs

Qbs: Can Module install files?


I want to have a module which will export all needed dependencies like include path, library path and will install needed runtime libraries.

Module {
    Depends { name: "cpp" }
    property path libLocation: ""
    cpp.dynamicLibraries: [
        "mylib"
    ]
    cpp.staticLibraries: [
        "mylib"
    ]
    cpp.includePaths: [
        libLocation + "include/",
    ]
    cpp.libraryPaths: [
        libLocation + "lib/",
    ]
    Group {
        name: "runtime libraries"
        qbs.install: true
        prefix: 'lib_location/'
        files: ["*.dll"]
    }
}

Everything works, but files are not installed. Is it possible to do that?

Update 1:

Files are correctly installed:

Working solution:

Module {
    ...
    Group {
        name: "runtime libraries"
        prefix: "D:/Projects/MyProject/Dependencies/SDL2pp/mingw/bin/" // works!
        //prefix: project.dependenciesPath + "SDL2pp/mingw/bin/" // also works!

        files: "*.dll"
        qbs.install: true
    }
}

But when I'm trying to use Module's property it says: "Reference Error: Can't find variable: ..."

Module {
    ...
    property bool installDlls: true
    property string libPath:  ""
    Group {
        name: "runtime libraries"
        prefix: libPath // Can't find variable
        files: "*.dll"
        qbs.install: installDlls // Can't find variable
    }
}

Also, It is not work if FileInfo module is used for building a path. Outside the Group path was corectly resolved.

import qbs
import qbs.FileInfo

Module {
    ...
    Group {
        name: "runtime libraries"
        prefix: FileInfo.joinPaths(project.dependenciesPaths, './SDL2pp/mingw/bin/') // silently not works
        files: "*.dll"
        qbs.install: true
    }
}

Conclusion
I've found 2 solutuins of it:

I don't know why Module's properties can't be used inside a Group. Are there some limitations or it's a bug?


Solution

  • Late but found this post trying to do the same, maybe it helps other people. Found out that using a Module's property inside a Group can be done by giving the Module an id and referencing the property using the id like this

    Module { id: mymodule ... property bool installDlls: true property string libPath: "" Group { name: "runtime libraries" prefix: mymodule.libPath files: "*.dll" qbs.install: mymodule.installDlls } }

    I'm using Qbs 1.12.1