summaryrefslogtreecommitdiff
path: root/doc/man/man.qbs
blob: 32f8e624eec81a9ec3f2b24f04c1441b6c587695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import qbs
import qbs.File
import qbs.FileInfo
import qbs.ModUtils
import qbs.Probes
import qbs.Utilities

Product {
    name: "qbs man page"
    type: ["manpage"]

    Depends { productTypes: ["qbsapplication"]; condition: updateManPage }
    Depends { name: "qbsbuildconfig" }

    property bool updateManPage: false
    property string help2ManFilePath: help2ManProbe.filePath

    Group {
        name: "man page"
        files: ["qbs.1"]
        qbs.install: qbsbuildconfig.installManPage
        qbs.installDir: "share/man/man1"
    }

    Group {
        name: "additional sections"
        files: ["see-also.h2m"]
        fileTags: ["man.section"]
    }

    Rule {
        condition: updateManPage
        multiplex: true
        // TODO: Remove in 1.14.
        explicitlyDependsOn: ["application"]
        property stringList explicitlyDependsOnFromDependencies: ["application"]
        inputs: ["man.section"]
        Artifact {
            filePath: "qbs.1"
            fileTags: ["manpage"]
        }
        prepare: {
            var help2ManExe = product.help2ManFilePath;
            if (!help2ManExe)
                throw "Cannot update man page: help2man not available";
            if (Utilities.versionCompare(product.qbs.version, "1.9") < 0)
                throw "Cannot update man page: qbs >= 1.9 required";
            var qbsApp;
            for (var i = 0; i < explicitlyDependsOn.application.length; ++i) {
                var artifact = explicitlyDependsOn.application[i];
                if (artifact.product.name === "qbs_app")
                    qbsApp = ModUtils.artifactInstalledFilePath(artifact);
            }
            var args = [qbsApp, "-o", output.filePath,
                        "--no-info", "--name=the Qbs build tool"];
            var sections = inputs ? inputs["man.section"] : [];
            for (var i = 0; i < sections.length; ++i)
                args.push("--include=" + sections[i].filePath);
            var help2ManCmd = new Command(help2ManExe, args);
            help2ManCmd.description = "creating man page";
            var copyCmd = new JavaScriptCommand();
            copyCmd.silent = true;
            copyCmd.sourceCode = function() {
                File.copy(output.filePath,
                          FileInfo.joinPaths(product.sourceDirectory, output.fileName));
            }
            return [help2ManCmd, copyCmd];
        }
    }

    Probes.BinaryProbe {
        id: help2ManProbe
        names: ["help2man"]
    }
}