aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/dmg/DMGModule.qbs
blob: c5d097a0bfeca1549ee5c8f32a4887a90c80667d (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qbs.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

import qbs.DarwinTools
import qbs.File
import qbs.FileInfo
import qbs.ModUtils
import qbs.Process
import qbs.TextFile
import "dmg.js" as Dmg

Module {
    Depends { name: "xcode"; required: false }

    condition: qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin")

    property string volumeName: product.targetName
    PropertyOptions {
        name: "volumeName"
        description: "the name of the disk image (displayed in Finder when mounted)"
    }

    property bool badgeVolumeIcon: false
    PropertyOptions {
        name: "badgeVolumeIcon"
        description: "whether to render the user-supplied icon on top of the " +
                     "default volume icon instead of using it directly"
    }

    property string format: "UDBZ"
    PropertyOptions {
        name: "format"
        description: "the format to create the disk image in"
    }

    property int compressionLevel: qbs.buildVariant === "release" ? 9 : undefined
    PropertyOptions {
        name: "compressionLevel"
        description: "sets the zlib or bzip2 compression level for UDZO and UDBZ disk images"
    }

    property string textutilPath: "/usr/bin/textutil"
    property string hdiutilPath: "/usr/bin/hdiutil"
    property string dmgSuffix: ".dmg"

    property string sourceBase

    readonly property string pythonPath: File.canonicalFilePath(FileInfo.joinPaths(path,
                                                                "..", "..",
                                                                "python"))

    property string backgroundColor
    property int iconSize: 128
    property int windowX: 100
    property int windowY: 100
    property int windowWidth: 640
    property int windowHeight: 480
    property var iconPositions

    property int iconX: windowWidth / 2
    property int iconY: windowHeight / 2

    property string defaultLicenseLocale
    property string licenseLocale
    property string licenseLanguageName
    property string licenseAgreeButtonText
    property string licenseDisagreeButtonText
    property string licensePrintButtonText
    property string licenseSaveButtonText
    property string licenseInstructionText

    FileTagger {
        patterns: [
            "*.txt", "*.rtf", "*.html", "*.doc", "*.docx", "*.odt", "*.xml", "*.webarchive",
            "LICENSE"
        ]
        fileTags: ["dmg.license.input"]
    }

    FileTagger {
        patterns: ["*.icns"]
        fileTags: ["icns"]
    }

    FileTagger {
        patterns: ["*.tif", "*.tiff"]
        fileTags: ["tiff"]
    }

    Rule {
        inputs: ["dmg.license.input"]

        outputFileTags: ["dmg.license"]
        outputArtifacts: ([{
            filePath: FileInfo.joinPaths(product.destinationDirectory, "licenses",
                                         FileInfo.relativePath(product.sourceDirectory,
                                                               input.filePath) + ".rtf"),
            fileTags: ["dmg.license"],
            dmg: {
                licenseLocale: input.dmg.licenseLocale,
                licenseLanguageName: input.dmg.licenseLanguageName,
                licenseAgreeButtonText: input.dmg.licenseAgreeButtonText,
                licenseDisagreeButtonText: input.dmg.licenseDisagreeButtonText,
                licensePrintButtonText: input.dmg.licensePrintButtonText,
                licenseSaveButtonText: input.dmg.licenseSaveButtonText,
                licenseInstructionText: input.dmg.licenseInstructionText
            }
        }])

        prepare: Dmg.prepareLicense.apply(Dmg, arguments)
    }

    Rule {
        multiplex: true
        inputs: ["dmg.input", "dmg.license", "icns", "tiff"]

        Artifact {
            fileTags: ["dmg.dmg"]
            filePath: FileInfo.joinPaths(product.destinationDirectory,
                                         product.targetName + product.dmg.dmgSuffix)
        }

        prepare: Dmg.prepareDmg.apply(Dmg, arguments)
    }
}