Modify support build script, add compiled DLL

This commit is contained in:
Anthony Lavado 2024-05-11 14:09:56 -04:00
parent d98f6ea0b6
commit 92dbfae510
2 changed files with 6 additions and 122 deletions

View File

@ -9,14 +9,9 @@ $ErrorActionPreference = "Stop"
# Disabling this, improves vastly performance:
$ProgressPreference = 'SilentlyContinue'
# change directory to the directory above (if needed)
Set-Location -Path "$PSScriptRoot\..\"
# Global constants
$RootPath = "$PWD"
$BuildPath = "$RootPath\build"
$DeployPath = "$RootPath\deploy"
$WindowsPath ="$RootPath\windows"
# Execute native command with errorlevel handling
Function Invoke-Native-Command {
@ -33,48 +28,6 @@ Function Invoke-Native-Command {
}
}
# Cleanup existing build folders
Function Clean-Build-Environment
{
if (Test-Path -Path $BuildPath) { Remove-Item -Path $BuildPath -Recurse -Force }
if (Test-Path -Path $DeployPath) { Remove-Item -Path $DeployPath -Recurse -Force }
New-Item -Path $BuildPath -ItemType Directory
New-Item -Path $DeployPath -ItemType Directory
}
# For sourceforge links we need to get the correct mirror (especially NISIS) Thanks: https://www.powershellmagazine.com/2013/01/29/pstip-retrieve-a-redirected-url/
Function Get-RedirectedUrl {
param(
[Parameter(Mandatory=$true)]
[string] $url
)
$numAttempts = 10
$sleepTime = 10
$maxSleepTime = 80
for ($attempt = 1; $attempt -le $numAttempts; $attempt++) {
try {
$request = [System.Net.WebRequest]::Create($url)
$request.AllowAutoRedirect=$true
$response=$request.GetResponse()
$response.ResponseUri.AbsoluteUri
$response.Close()
return
} catch {
if ($attempt -lt $numAttempts) {
Write-Warning "Caught error: $_"
Write-Warning "Get-RedirectedUrl: Fetch attempt #${attempt}/${numAttempts} for $url failed, trying again in ${sleepTime}s"
Start-Sleep -Seconds $sleepTime
$sleepTime = [Math]::Min($sleepTime * 2, $maxSleepTime)
continue
}
Write-Error "Get-RedirectedUrl: All ${numAttempts} fetch attempts for $url failed, failing whole call"
throw
}
}
}
function Initialize-Module-Here ($m) { # see https://stackoverflow.com/a/51692402
# If module is imported say that and do nothing
@ -104,41 +57,8 @@ function Initialize-Module-Here ($m) { # see https://stackoverflow.com/a/5169240
}
}
# Download and uncompress dependency in ZIP format
Function Install-Dependency
{
param(
[Parameter(Mandatory=$true)]
[string] $Uri,
[Parameter(Mandatory=$true)]
[string] $Name,
[Parameter(Mandatory=$true)]
[string] $Destination
)
if (Test-Path -Path "$WindowsPath\$Destination")
{
echo "Using ${WindowsPath}\${Destination} from previous run (e.g. actions/cache)"
return
}
$TempFileName = [System.IO.Path]::GetTempFileName() + ".zip"
$TempDir = [System.IO.Path]::GetTempPath()
if ($Uri -Match "downloads.sourceforge.net")
{
$Uri = Get-RedirectedUrl -URL $Uri
}
Invoke-WebRequest -Uri $Uri -OutFile $TempFileName
echo $TempFileName
Expand-Archive -Path $TempFileName -DestinationPath $TempDir -Force
echo $WindowsPath\$Destination
Move-Item -Path "$TempDir\$Name" -Destination "$WindowsPath\$Destination" -Force
Remove-Item -Path $TempFileName -Force
}
# Install VSSetup (Visual Studio detection), ASIO SDK and NSIS Installer
# Install VSSetup (Visual Studio detection)
Function Install-Dependencies
{
if (-not (Get-PackageProvider -Name nuget).Name -eq "nuget") {
@ -201,44 +121,10 @@ Function Initialize-Build-Environment
}
# Build Windows installer
Function Build-Installer
{
param(
[string] $BuildOption
)
foreach ($_ in Get-Content -Path "$RootPath\$AppName.pro")
{
if ($_ -Match "^VERSION *= *(.*)$")
{
$AppVersion = $Matches[1]
break
}
}
if ($BuildOption -ne "")
{
Invoke-Native-Command -Command "$RootPath\libs\NSIS\NSIS-source\makensis" `
-Arguments ("/v4", "/DAPP_NAME=$AppName", "/DAPP_VERSION=$AppVersion", `
"/DROOT_PATH=$RootPath", "/DWINDOWS_PATH=$WindowsPath", "/DDEPLOY_PATH=$DeployPath", `
"/DBUILD_OPTION=$BuildOption", `
"$WindowsPath\installer.nsi")
}
else
{
Invoke-Native-Command -Command "$RootPath\libs\NSIS\NSIS-source\makensis" `
-Arguments ("/v4", "/DAPP_NAME=$AppName", "/DAPP_VERSION=$AppVersion", `
"/DROOT_PATH=$RootPath", "/DWINDOWS_PATH=$WindowsPath", "/DDEPLOY_PATH=$DeployPath", `
"$WindowsPath\installer.nsi")
}
}
# Build and copy NS-Process dll
Function Build-NSProcess
{
if (!(Test-Path -path "$RootPath\libs\NSIS\nsProcess.dll")) {
if (!(Test-Path -path "$RootPath\..\..\nsis\plugins\nsProcess.dll")) {
echo "Building nsProcess..."
@ -246,17 +132,15 @@ Function Build-NSProcess
Initialize-Build-Environment -BuildArch "x86"
Invoke-Native-Command -Command "msbuild" `
-Arguments ("$RootPath\libs\NSIS\nsProcess\nsProcess.sln", '/p:Configuration="Release UNICODE"', `
-Arguments ("$RootPath\nsProcess.sln", '/p:Configuration="Release UNICODE"', `
"/p:Platform=Win32")
Move-Item -Path "$RootPath\libs\NSIS\nsProcess\Release\nsProcess.dll" -Destination "$RootPath\libs\NSIS\nsProcess.dll" -Force
Remove-Item -Path "$RootPath\libs\NSIS\nsProcess\Release\" -Force -Recurse
Move-Item -Path "$RootPath\Release\nsProcess.dll" -Destination "$RootPath\..\..\nsis\plugins\nsProcess.dll" -Force
Remove-Item -Path "$RootPath\Release\" -Force -Recurse
$OriginalEnv | % { Set-Item "Env:$($_.Name)" $_.Value }
}
}
Clean-Build-Environment
Install-Dependencies
Build-NSProcess

Binary file not shown.