2023-01-27 21:08:47 +01:00
import qbs . File
import qbs . FileInfo
import qbs . Environment
import qbs . Utilities
import qbs . ModUtils
/ * *
This module uses _macdeployqt_ program to collect Qt runtime for MacOS deployment .
* /
Module {
additionalProductTypes: [ "macdeployqt" ]
property bool artifacts: true
property string macdeployqtArtifact: artifacts ? "maceployqt.txt" : undefined
2023-09-21 16:44:59 +02:00
property string macdeployqtProgramBinPath : undefined
2023-01-27 21:08:47 +01:00
property string macdeployqtProgram: "macdeployqt"
property bool noPlugins: false
property int verbose: undefined
property bool noStrip: true
property bool useDebugLibs: false
property bool alwaysOverwrite: false
2023-09-21 16:45:30 +02:00
property bool appstoreCompliant: false
2023-01-27 21:08:47 +01:00
2023-09-21 16:45:30 +02:00
property stringList libpath: undefined
2023-01-27 21:08:47 +01:00
2023-09-26 14:46:40 +02:00
property string pluginspath: undefined
2023-01-27 21:08:47 +01:00
property stringList targetApps: undefined
2023-09-12 16:50:15 +02:00
property bool signForNotarization: false
2023-08-18 13:01:03 +02:00
property string signingIdentity: "-" // ad-hoc
2023-01-27 21:08:47 +01:00
Rule {
// alwaysRun: true
multiplex: true
condition: product . qbs . targetOS . contains ( "macos" ) && product . bundle . isBundle && ( product . buildconfig . enableMultiBundle || ( ! product . buildconfig . enableMultiBundle && product . primaryApp ) )
inputs: [ "bundle.content" ]
prepare: {
var macdeployqtProgram = product . macdeployqt . macdeployqtProgram ;
// Checking if directory exists as a dirty workaround to check if `--no-install` options has been set from command line.
if ( ! File . exists ( product . qbs . installRoot ) ) {
var cmd = new JavaScriptCommand ( ) ;
cmd . macdeployqtProgram = macdeployqtProgram ;
cmd . description = "can not invoke '" + macdeployqtProgram + "' when '--no-install` options has been set from command line" ;
cmd . sourceCode = function ( ) {
console . warn ( "Can not invoke '" + macdeployqtProgram + "' when '--no-install` options has been set from command line (tip: remove your build directory entirely after unchecking '--no-install' option)" ) ;
}
} else {
const installRoot = product . qbs . installRoot + product . qbs . installPrefix + "/" + product . buildconfig . installAppPath ;
var cmdArgs = [ installRoot + "/" + product . targetName + ".app" ] ;
if ( product . macdeployqt . noPlugins )
2023-08-18 12:51:36 +02:00
cmdArgs . push ( "-no-plugins" ) ;
2023-01-27 21:08:47 +01:00
if ( product . macdeployqt . verbose !== undefined )
2023-09-21 16:45:30 +02:00
cmdArgs . push ( "-verbose=" + product . macdeployqt . verbose ) ;
2023-01-27 21:08:47 +01:00
if ( product . macdeployqt . noStrip )
cmdArgs . push ( "-no-strip" ) ;
if ( product . macdeployqt . useDebugLibs )
cmdArgs . push ( "-use-debug-libs" ) ;
if ( product . macdeployqt . alwaysOverwrite )
cmdArgs . push ( "-always-overwrite" ) ;
if ( product . macdeployqt . appstoreCompliant )
cmdArgs . push ( "-appstore-compliant" ) ;
if ( product . macdeployqt . libpath !== undefined )
2023-09-21 16:45:30 +02:00
product . macdeployqt . libpath . forEach ( function ( libpath ) {
cmdArgs . push ( "-libpath=" + libpath ) ;
} ) ;
2023-01-27 21:08:47 +01:00
2023-09-26 14:46:40 +02:00
if ( product . macdeployqt . pluginspath !== undefined )
cmdArgs . push ( "-pluginspath=" + product . macdeployqt . pluginspath ) ;
2023-09-12 16:50:15 +02:00
if ( product . buildconfig . enableCodeSigning ) {
if ( product . macdeployqt . signForNotarization )
cmdArgs . push ( "-sign-for-notarization=" + product . macdeployqt . signingIdentity ) ;
else
cmdArgs . push ( "-codesign=" + product . macdeployqt . signingIdentity ) ;
}
2023-08-18 13:01:03 +02:00
2023-09-21 16:37:49 +02:00
if ( product . macdeployqt . targetApps !== undefined )
2023-01-27 21:08:47 +01:00
{
product . macdeployqt . targetApps . forEach ( function ( targetApp ) {
2023-09-21 16:37:49 +02:00
cmdArgs . push ( "-executable=" + FileInfo . joinPaths ( installRoot , product . targetName + ".app" , "Contents" , "MacOS" , targetApp ) ) ;
2023-01-27 21:08:47 +01:00
} ) ;
}
2023-09-21 16:44:59 +02:00
var macdeployqtProgramBinPath = product . Qt . core . binPath ;
if ( product . macdeployqt . macdeployqtProgramBinPath !== undefined )
macdeployqtProgramBinPath = product . macdeployqt . macdeployqtProgramBinPath ;
var cmd = new Command ( macdeployqtProgramBinPath + "/" + macdeployqtProgram , cmdArgs ) ;
2023-01-27 21:08:47 +01:00
cmd . jobPool = "macdeployqt" ;
cmd . description = "invoking '" + macdeployqtProgram ;
cmd . stdoutFilePath = product . buildDirectory + "/" + product . macdeployqt . macdeployqtArtifact ;
}
cmd . workingDirectory = product . qbs . installRoot ;
cmd . highlight = "filegen" ;
return [ cmd ]
}
Artifact {
filePath: product . buildDirectory + "/" + product . macdeployqt . macdeployqtArtifact
fileTags: [ "macdeployqt" ]
}
}
JobLimit {
jobPool: "macdeployqt"
jobCount: 1
}
}