aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules/ib/IBModule.qbs
diff options
context:
space:
mode:
Diffstat (limited to 'share/qbs/modules/ib/IBModule.qbs')
-rw-r--r--share/qbs/modules/ib/IBModule.qbs74
1 files changed, 74 insertions, 0 deletions
diff --git a/share/qbs/modules/ib/IBModule.qbs b/share/qbs/modules/ib/IBModule.qbs
index bee1dd9e4..ebcf8fc2e 100644
--- a/share/qbs/modules/ib/IBModule.qbs
+++ b/share/qbs/modules/ib/IBModule.qbs
@@ -6,6 +6,8 @@ import qbs.ModUtils
import 'ib.js' as Ib
Module {
+ Depends { name: "cpp" } // to put toolchainInstallPath in the PATH for actool
+
condition: qbs.hostOS.contains("darwin") && qbs.targetOS.contains("darwin")
property bool warnings: true
@@ -23,9 +25,17 @@ Module {
property string ibtoolPath: ibtoolName
property bool flatten: true
+ // Asset catalog specific
+ property string actoolName: "actool"
+ property string actoolPath: actoolName
+ property string appIconName
+ property string launchImageName
+ property bool compressPngs: true
+
// private properties
property string outputFormat: "human-readable-text"
property string appleIconSuffix: ".icns"
+ property string compiledAssetCatalogSuffix: ".car"
property string compiledNibSuffix: ".nib"
property string ibtoolVersion: { return Ib.ibtoolVersion(ibtoolPath); }
@@ -57,6 +67,11 @@ Module {
fileTags: ["nib"]
}
+ FileTagger {
+ patterns: ["*.xcassets"] // bundle
+ fileTags: ["assetcatalog"]
+ }
+
Rule {
inputs: ["iconset"]
@@ -126,4 +141,63 @@ Module {
return cmd;
}
}
+
+ Rule {
+ inputs: ["assetcatalog"]
+
+ // We only return one artifact, as this is a little complicated...
+ // actool takes an output *directory*, and in this directory it will
+ // potentially output "Assets.car" and/or one or more additional files.
+ // We can discover which files were written in an easily parseable manner
+ // through use of --output-format xml1, but we have a chicken and egg problem
+ // in that we only gain that information *after* running the compilation, so
+ // if we want to know in advance which artifacts are generated we have to run
+ // the compilation twice which probably isn't worth it.
+ outputArtifacts: {
+ var outputDirectory = BundleTools.isBundleProduct(product)
+ ? BundleTools.unlocalizedResourcesFolderPath(product)
+ : product.destinationDirectory;
+ return [{
+ filePath: FileInfo.joinPaths(outputDirectory, "Assets" + ModUtils.moduleProperty(product, "compiledAssetCatalogSuffix")),
+ fileTags: ["compiled_assetcatalog"]
+ },
+ {
+ filePath: FileInfo.joinPaths(product.destinationDirectory, "assetcatalog_generated_info.plist"),
+ fileTags: ["partial_infoplist"]
+ }];
+ }
+
+ outputFileTags: ["compiled_assetcatalog", "partial_infoplist"]
+
+ // Just a note, the man page for actool is somewhat outdated (probably forgotten to be updated late in the development cycle).
+ // It mentions the file extension .assetcatalog (which isn't used by Xcode), the --write option does not exist, and the example
+ // invocation near the bottom of the man page doesn't work at all.
+ // There's also the undocumented --export-dependency-info <output.txt> which is used by Xcode and generated a \0x00\0x02-delimited
+ // file (yes, really) that contains the output file names, identical to the output of actool itself (what's the point?).
+ prepare: {
+ var args = Ib.prepareIbtoold(product, input, outputs);
+
+ var flags = ModUtils.moduleProperty(input, "flags");
+ if (flags)
+ args = args.concat(flags);
+
+ var outputPath = FileInfo.path(outputs.compiled_assetcatalog[0].filePath);
+
+ args.push("--compile");
+ args.push(outputPath);
+ args.push(input.filePath);
+
+ var cmd = new Command(ModUtils.moduleProperty(input, "actoolPath"), args);
+ cmd.description = ModUtils.moduleProperty(input, "actoolName") + ' ' + input.fileName;
+ cmd.highlight = "compiler";
+ cmd.stdoutFilterFunction = function(stdout) {
+ stdout = stdout.replace("/* com.apple.actool.compilation-results */\n", "");
+ return stdout.split("\n").filter(function(line) {
+ return line.length > 0 /*&& line.indexOf(outputPath) !== 0*/;
+ }).join("\n");
+ }
+
+ return cmd;
+ }
+ }
}