valentina/qbs/modules/multibundle/multibundle.qbs

131 lines
5.5 KiB
QML
Raw Normal View History

2023-01-27 18:07:24 +01:00
import qbs.File
Module {
additionalProductTypes: ["multibundle"]
property stringList targetApps: undefined
Rule {
// alwaysRun: true
multiplex: true
condition: product.qbs.targetOS.contains("macos") && product.buildconfig.enableMultiBundle && product.type.contains("dynamiclibrary")
inputs: product.bundle.isBundle ? ["bundle.content"] : ["dynamiclibrary"]
outputFileTags: ["multibundle"]
outputArtifacts: {
var artifactNames = [];
const fileName = product.bundle.isBundle ? product.bundle.bundleName : inputs["dynamiclibrary"][0].fileName;
const installRoot = product.qbs.installRoot + product.qbs.installPrefix + "/" + product.buildconfig.installAppPath;
product.multibundle.targetApps.forEach(function(targetApp) {
artifactNames.push(installRoot + "/" + targetApp + ".app/Contents/Frameworks/" + fileName);
if (product.installDebugInformation)
artifactNames.push(installRoot + "/" + targetApp + ".app/Contents/Frameworks/" + fileName +
product.cpp.debugInfoBundleSuffix);
});
var artifacts = artifactNames.map(function(art){
var a = {
filePath: art,
fileTags: ["multibundle"]
}
return a;
});
return artifacts;
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "Copying dynamic library into bundles";
cmd.highlight = "filegen";
const fileName = product.bundle.isBundle ? product.bundle.bundleName : inputs["dynamiclibrary"][0].fileName;
const installRoot = product.qbs.installRoot + product.qbs.installPrefix + "/" + product.buildconfig.installAppPath;
var data = [];
product.multibundle.targetApps.forEach(function(targetApp) {
data.push({
"source" : product.buildDirectory + "/" + fileName,
"destination": installRoot + "/" + targetApp + ".app/Contents/Frameworks/" + fileName
});
if (product.installDebugInformation)
data.push({
"source" : product.buildDirectory + "/" + fileName + product.cpp.debugInfoBundleSuffix,
"destination": installRoot + "/" + targetApp + ".app/Contents/Frameworks/" + fileName +
product.cpp.debugInfoBundleSuffix
});
});
cmd.data = data;
cmd.sourceCode = function() {
data.forEach(function(copyData) {
File.copy(copyData.source, copyData.destination);
});
};
return [cmd];
}
}
Rule {
// alwaysRun: true
condition: product.qbs.targetOS.contains("macos") && !product.buildconfig.enableMultiBundle && product.type.contains("application")
inputs: ["bundle.application-executable"]
2023-01-27 18:07:24 +01:00
outputFileTags: ["multibundle"]
outputArtifacts: {
var artifactNames = [];
const installRoot = product.qbs.installRoot + product.qbs.installPrefix + "/" + product.buildconfig.installAppPath;
product.multibundle.targetApps.forEach(function(targetApp) {
artifactNames.push(installRoot + "/" + targetApp + ".app/Contents/MacOS/" + input.fileName);
if (product.installDebugInformation)
2024-03-26 19:33:21 +01:00
artifactNames.push(installRoot + "/" + targetApp + ".app/Contents/MacOS/" + input.fileName + ".app" +
2023-01-27 18:07:24 +01:00
product.cpp.debugInfoBundleSuffix);
});
var artifacts = artifactNames.map(function(art){
var a = {
filePath: art,
fileTags: ["multibundle"]
}
return a;
});
return artifacts;
}
prepare: {
var cmd = new JavaScriptCommand();
cmd.description = "Copying auxiliary binary into bundle";
cmd.highlight = "filegen";
2023-02-20 11:59:24 +01:00
const fileName = product.bundle.isBundle ? product.bundle.bundleName : inputs["application"][0].fileName;
2023-01-27 18:07:24 +01:00
const installRoot = product.qbs.installRoot + product.qbs.installPrefix + "/" + product.buildconfig.installAppPath;
var data = [];
product.multibundle.targetApps.forEach(function(targetApp) {
data.push({
"source" : input.filePath,
"destination": installRoot + "/" + targetApp + ".app/Contents/MacOS/" + input.fileName
});
if (product.installDebugInformation)
data.push({
2024-03-26 19:33:21 +01:00
"source" : product.buildDirectory + "/" + input.fileName + ".app" + product.cpp.debugInfoBundleSuffix,
2023-01-27 18:07:24 +01:00
"destination": installRoot + "/" + targetApp + ".app/Contents/MacOS/" + fileName +
product.cpp.debugInfoBundleSuffix
});
});
cmd.data = data;
cmd.sourceCode = function() {
data.forEach(function(copyData) {
console.info("Dynamic source: " + copyData.source);
console.info("Dynamic destination: " + copyData.destination);
File.copy(copyData.source, copyData.destination);
});
};
return [cmd];
}
}
}