aboutsummaryrefslogtreecommitdiffstats
path: root/src/packages/archive/archive.qbs
blob: 4686063683a6a0c78c5b721369b6bc41e3517c59 (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
76
77
78
79
80
81
82
83
84
85
86
import qbs
import qbs.FileInfo
import qbs.ModUtils
import qbs.Process
import qbs.TextFile

QbsProduct {
    Depends { name: "qbs_processlauncher" }
    Depends { name: "qbscore" }
    Depends { name: "bundledqt"; required: false }
    Depends { name: "qbs documentation"; condition: project.withDocumentation }
    Depends { name: "qbs resources" }
    Depends {
        name: "qbs man page"
        condition: qbs.targetOS.contains("unix") && project.withDocumentation
    }
    Depends { productTypes: ["qbsapplication", "qbsplugin"] }

    Depends { name: "archiver" }

    property bool includeTopLevelDir: false

    builtByDefault: false
    name: "qbs archive"
    type: ["archiver.archive"]
    targetName: "qbs-" + qbs.targetOS[0] + "-" + qbs.architecture + "-" + qbsversion.version
    destinationDirectory: project.buildDirectory

    archiver.type: qbs.targetOS.contains("windows") ? "zip" : "tar"
    Properties {
        condition: includeTopLevelDir
        archiver.workingDirectory: qbs.installRoot + "/.."
    }
    archiver.workingDirectory: qbs.installRoot

    Group {
        name: "Licenses"
        prefix: "../../../"
        files: [
            "LGPL_EXCEPTION.txt",
            "LICENSE.LGPLv3",
            "LICENSE.LGPLv21",
            "LICENSE.GPL3-EXCEPT",
        ]
        qbs.install: true
        qbs.installDir: "share/doc/qbs"
    }

    Rule {
        multiplex: true
        inputs: ["installable"]
        inputsFromDependencies: ["installable"]

        Artifact {
            filePath: "list.txt"
            fileTags: ["archiver.input-list"]
        }

        prepare: {
            var cmd = new JavaScriptCommand();
            cmd.silent = true;
            cmd.excludedPathPrefixes = product.excludedPathPrefixes;
            cmd.inputFilePaths = inputs.installable.map(function(a) {
                return ModUtils.artifactInstalledFilePath(a);
            });
            cmd.outputFilePath = output.filePath;
            cmd.baseDirectory = product.moduleProperty("archiver", "workingDirectory");
            cmd.sourceCode = function() {
                inputFilePaths.sort();
                var tf;
                try {
                    tf = new TextFile(outputFilePath, TextFile.ReadWrite);
                    for (var i = 0; i < inputFilePaths.length; ++i) {
                        var relativePath = FileInfo.relativePath(baseDirectory, inputFilePaths[i]);
                        tf.writeLine(relativePath);
                    }
                } finally {
                    if (tf)
                        tf.close();
                }
            };

            return [cmd];
        }
    }
}