Skip to content

BesLyric-for-X/BesLyric-for-X_Windows_deploy-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BesLyric-for-X Deployment and Packaging Scripts (Windows)

Introduction

The script(s) in this repository are used to deploy and package BesLyric-for-X on Windows.

Environment

Windows 10 x86

Dependent tools

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

How to use

Get

PS > git clone --recurse-submodules https://github.com/BesLyric-for-X/BesLyric-for-X_Windows_deploy-package.git
PS > #         \--------__--------/
PS > #              Important!

Prepare

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>'

Execute with parameters

Deployment script

windeployqt
$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

Packaging scripts

Inno Setup
$issParams = @{
    ISCC_PATH               = ${isccPath}
    ISS_COMPRESSION         = ${issCompression}
    TARGET                  = ${target}
    DEPLOY_DIR_PATH         = ${deployDirPath}

    ISS_INSTALLER_FILE_PATH = ${issInstallerFilePath}
}

& '.\package\call_iscc.ps1' @issParams
Enigma Virtual Box
$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

Common code snippets

Hash Table & Splatting

I'm using hash tables and splatting to reduce the line length of the code.

Hash table:

Splatting:

$hashTable = @{
    foo = 'bar'
}

Invoke-Cmdlet @hashTable

Show all incoming parameters

Source: about_Automatic_Variables - PowerShell | Microsoft Docs § $PSBoundParameters

$PSBoundParameters | Format-List

Execute programs with call operator (&) and check the exit code $LASTEXITCODE

Call operator:

Execution status $? and exit code $LASTEXITCODE :

& '.\foo' 'bar'

if ($LASTEXITCODE -ne 0) {
    throw '...'
}

Get temperary file with specific extension

Source: Temporary file with given extension. | IT Pro PowerShell experience

${tempFile} = `
    [System.IO.Path]::GetTempFileName() | `
    Rename-Item -NewName { $_ -replace @('\.tmp$', '.ext') } -PassThru

Get the absolute path to a file that may not exist

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

Credits

Projects:

Documentation: