The script(s) in this repository are used to deploy and package BesLyric-for-X on Windows.
Windows 10 x86
These tools are required to complete the work:
- PowerShell 5 / 7
- windeployqt
- Inno Setup 6.0.5 (u)
- Enigma Virtual Box v9.60 Build 20210209
PS > git clone --recurse-submodules https://github.com/BesLyric-for-X/BesLyric-for-X_Windows_deploy-package.git
PS > # \--------__--------/
PS > # Important!
First of all, we should not let go of any mistake:
$ErrorActionPreference = 'Stop' # set -e for cmdlet
Set-StrictMode -Version 3.0 # set -u
Then, I think creating some variables may be helpful. For example:
# From qmake
${target} = '<"TARGET" in qmake project. "BesLyric-for-X" by default>'
${installRoot} = '<"INSTALL_ROOT" of "make install">'
# Common
${deployDirPath} = '<path to the directory contains deployed files>'
# For windeployqt
${windeployqtPath} = '<path to windeployqt.exe>'
${mingwBinDirPath} = '<path to the directory contains g++.exe>'
${libDirPath} = '<path to "%B4X_DEP_PATH%\lib", contains all 3rd party dll files>'
# For Inno Setup
${isccPath} = "<path to Inno Setup's ISCC.exe>"
${issCompression} = '<https://jrsoftware.org/ishelp/topic_setup_compression.htm>'
${issInstallerFilePath} = '<path to generated Inno Setup installer>'
# For Enigma Virtual Box
${enigmavbconsolePath} = "<path to Enigma Virtual Box's enigmavbconsole.exe>"
${doesEvbCompressFiles} = "does Enigma Virtual Box compress files: $true or $false"
${evbBoxFilePath} = '<path to generated Enigma Virtual Box boxed exe>'
$windeployqtParams = @{
WINDEPLOYQT_PATH = ${windeployqtPath}
MINGW_BIN_DIR_PATH = ${mingwBinDirPath}
LIB_DIR_PATH = ${libDirPath}
TARGET = ${target}
INSTALL_ROOT = ${installRoot}
DEPLOY_DIR_PATH = ${deployDirPath}
}
& '.\deploy\call_windeployqt.ps1' @windeployqtParams
$issParams = @{
ISCC_PATH = ${isccPath}
ISS_COMPRESSION = ${issCompression}
TARGET = ${target}
DEPLOY_DIR_PATH = ${deployDirPath}
ISS_INSTALLER_FILE_PATH = ${issInstallerFilePath}
}
& '.\package\call_iscc.ps1' @issParams
$evbParams = @{
ENIGMAVBCONSOLE_PATH = ${enigmavbconsolePath}
DOES_EVB_COMPRESS_FILES = ${doesEvbCompressFiles}
TARGET = ${target}
DEPLOY_DIR_PATH = ${deployDirPath}
EVB_BOX_FILE_PATH = ${evbBoxFilePath}
}
& '.\package\call_evbconsole.ps1' @evbParams
I'm using hash tables and splatting to reduce the line length of the code.
Hash table:
- about_Hash_Tables - PowerShell | Microsoft Docs
- Everything you wanted to know about hashtables - PowerShell | Microsoft Docs
Splatting:
- about_Splatting - PowerShell | Microsoft Docs
- Use Splatting to Simplify Your PowerShell Scripts | Scripting Blog
$hashTable = @{
foo = 'bar'
}
Invoke-Cmdlet @hashTable
Source: about_Automatic_Variables - PowerShell | Microsoft Docs § $PSBoundParameters
$PSBoundParameters | Format-List
Call operator:
- about_Operators - PowerShell | Microsoft Docs § Call operator
&
- Call operator - Run - PowerShell - SS64.com
- Powershell executable isn't outputting to STDOUT - Stack Overflow
Execution status $?
and exit code $LASTEXITCODE
:
- about_Automatic_Variables - PowerShell | Microsoft Docs§ $?
- about_Automatic_Variables - PowerShell | Microsoft Docs§ $LastExitCode
- windows - Difference between $? and $LastExitCode in PowerShell - Stack Overflow
- windows - $LastExitCode=0, but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError - Stack Overflow
& '.\foo' 'bar'
if ($LASTEXITCODE -ne 0) {
throw '...'
}
Source: Temporary file with given extension. | IT Pro PowerShell experience
${tempFile} = `
[System.IO.Path]::GetTempFileName() | `
Rename-Item -NewName { $_ -replace @('\.tmp$', '.ext') } -PassThru
Source: answer 16964490 § How to normalize a path in PowerShell? - Stack Overflow
${absolutePath} = `
[System.IO.Path]::Combine('baseDirPath', 'relativeOrAbsolutePath')
Doc: Combine(String, String) § Path.Combine Method (System.IO) | Microsoft Docs
Projects:
- Inno Setup - jrsoftware
- idleberg.innosetup - Inno Setup - Visual Studio Marketplace
- alefragnani.pascal - Pascal - Visual Studio Marketplace
- kira-96/Inno-Setup-Chinese-Simplified-Translation
- Enigma Virtual Box
Documentation: