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
|
import qbs 1.0
import qbs.FileInfo
import qbs.ModUtils
import qbs.Process
import qbs.PropertyList
import "../cpp/bundle-tools.js" as BundleTools
import "../cpp/darwin-tools.js" as DarwinTools
Module {
condition: qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin")
property string outputFormat: "human-readable-text"
property bool flatten: true // false to preserve editability of the resulting nib file
property bool autoUpgrade: false
property bool warnings: true
property bool errors: true
property bool notices: true
property stringList flags
FileTagger {
patterns: ["*.nib", "*.xib"]
fileTags: ["nib"]
}
Rule {
inputs: ["nib"]
explicitlyDependsOn: ["infoplist"]
Artifact {
fileName: {
var path = product.destinationDirectory;
var xibFilePath = input.baseDir + '/' + input.fileName;
var key = DarwinTools.localizationKey(xibFilePath);
if (key) {
path += '/' + BundleTools.localizedResourcesFolderPath(product, key);
var subPath = DarwinTools.relativeResourcePath(xibFilePath);
if (subPath && subPath !== '.')
path += '/' + subPath;
} else {
path += '/' + BundleTools.unlocalizedResourcesFolderPath(product);
path += '/' + input.baseDir;
}
return path + '/' + input.completeBaseName + ".nib";
}
fileTags: ["compiled_nib"]
}
prepare: {
var args = [];
var flags = ModUtils.moduleProperty(product, "flags");
if (flags)
args = args.concat(flags);
var outputFormat = ModUtils.moduleProperty(product, "outputFormat");
if (!["binary1", "xml1", "human-readable-text"].contains(outputFormat))
throw("Invalid ibtool output format: " + outputFormat + ". " +
"Must be in [binary1, xml1, human-readable-text].");
args.push("--output-format");
args.push(outputFormat);
args.push("--flatten");
args.push(ModUtils.moduleProperty(product, "flatten") ? 'YES' : 'NO');
if (ModUtils.moduleProperty(product, "autoUpgrade"))
args.push("--upgrade");
if (ModUtils.moduleProperty(product, "warnings"))
args.push("--warnings");
if (ModUtils.moduleProperty(product, "errors"))
args.push("--errors");
if (ModUtils.moduleProperty(product, "notices"))
args.push("--notices");
var process;
var version;
try {
process = new Process();
if (process.exec("ibtool", ["--version"], true) !== 0)
print(process.readStdErr());
var plist = new PropertyList();
plist.readFromString(process.readStdOut());
plist = JSON.parse(plist.toJSONString());
if (plist)
plist = plist["com.apple.ibtool.version"];
if (plist)
version = plist["short-bundle-version"];
} finally {
process.close();
}
// --minimum-deployment-target was introduced in Xcode 5.0
if (version && parseInt(version.split('.')[0], 10) >= 5) {
if (product.moduleProperty("cpp", "minimumOsxVersion")) {
args.push("--minimum-deployment-target");
args.push(product.moduleProperty("cpp", "minimumOsxVersion"));
}
if (product.moduleProperty("cpp", "minimumIosVersion")) {
args.push("--minimum-deployment-target");
args.push(product.moduleProperty("cpp", "minimumIosVersion"));
}
}
if (product.moduleProperty("qbs", "sysroot")) {
args.push("--sdk");
args.push(product.moduleProperty("qbs", "sysroot"));
}
args.push("--compile");
args.push(output.filePath);
args.push(input.filePath);
var cmd = new Command("ibtool", args);
cmd.description = 'ibtool ' + FileInfo.fileName(input.filePath);
// Also display the language name of the XIB being compiled if it has one
var localizationKey = DarwinTools.localizationKey(input.filePath);
if (localizationKey)
cmd.description += ' (' + localizationKey + ')';
cmd.highlight = 'compiler';
return cmd;
}
}
}
|