[Qbs] Some dependency scanning/tracking-questions

Christian Kandeler christian.kandeler at qt.io
Wed Feb 7 13:09:55 CET 2018


On Wed, 7 Feb 2018 12:34:47 +0100
Ola Røer Thorsen <ola at silentwings.no> wrote:

> - How does Qbs keep track of depedencies, like when including c-headers
> that include other c-headers etc.?

That's part of the up-to-date check for object files. If qbs detects that a change is possible (because either a source file or a dependency collected in an earlier run of the scanner has changed), then the includes are re-scanned, the corresponding files are found via cpp.includePaths and their timestamps are checked.

> - Is the compiler used for the scanning of dependencies, or does Qbs scan
> everyting itself?

qbs does that. Known limitations: ifdefs are not considered (all branched are added to the dependency list), and the rather weird "header name is a macro" construct is not understood:
#define MY_HEADER "header.h"
#include MY_HEADER

> - Is the file timestamps used to check for modified files, or a checksum of
> the contents?

Timestamps.

> - Will/could Qbs be able to scan dependencies in ld linker scripts? We've
> got several of those where there are .ld files with "INCLUDE
> xxxxx.ldscript" inside, and it's important that binaries are linked again
> if any of those are modified. If Qbs can't scan these itself, is it
> possible to somehow list those files so that the linking can be done again
> if any of them are modified?

Approach 1: Use a Scanner item with "linkerscript" as the input tag.
http://doc-snapshots.qt.io/qbs-1.11/qml-qbslanguageitems-scanner.html

Approach 2: If the included scripts are all part of your project, it might be simpler to so somthing like this (untested):

Product {
    Group {
        name: "linker script includes"
        files: ["inc1.ldscript, "inc2.ldscript", "inc3.ldscript"]
	fileTags: ["linkerscript.include"]
    }
    Group {
        name: "main linker script"
        files: ["thelinkerscript.ld"]
        fileTags: ["linkerscript.in"]
    }
    Rule {
        inputs: ["linkerscript.in"]
        auxiliaryInputs: ["linkerscript.include"]
        Artifact { filePath: "thelinkerscript.ld"; fileTags: ["linkerscript"] }
        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.description = "updating " + output.fileName;
            cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); };
            return [cmd];
        }
    }
}

(If the includes are not nested, then probably *all* of the source scripts should be includes and the actual script would really be auto-generated using INCLUDE statements.)


Christian



More information about the Qbs mailing list