-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ps1
More file actions
94 lines (78 loc) · 3.32 KB
/
deploy.ps1
File metadata and controls
94 lines (78 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
param (
[string]$mingwFolder
)
# Define paths
$buildDir = "build"
$installDir = "install"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$innoSetupPath = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
$issScriptPath = Join-Path -Path $scriptDir -ChildPath "installer_script_updated.iss"
$UpdateISSScript = Join-Path -Path $scriptDir -ChildPath "update_iss_script.ps1"
$MoveRequiredLibsScript = Join-Path -Path $scriptDir -ChildPath "move_required_libs_for_windows.ps1"
$outputDir = "Output"
# Check for required executables
$missingComponents = @()
if (-Not (Test-Path $innoSetupPath)) {
$missingComponents += "Inno Setup (ISCC.exe)"
}
$makePath = Join-Path $mingwFolder "mingw32-make.exe"
$cmakePath = Join-Path $mingwFolder "cmake.exe"
if (-Not (Test-Path $cmakePath)) {
$missingComponents += "CMake(cmake.exe)"
}
if (-Not (Test-Path $makePath)) {
$missingComponents += "MinGW Make (mingw32-make.exe)"
}
# Warn if any component is missing
if ($missingComponents.Count -gt 0) {
Write-Host "ERROR: The following required components are missing:" -ForegroundColor Red
$missingComponents | ForEach-Object { Write-Host "- $_" -ForegroundColor Yellow }
exit 1
}
# Create build directory and navigate to it
if (-Not (Test-Path $buildDir)) {
New-Item -Path $buildDir -ItemType Directory
}
Set-Location -Path $buildDir
# Run CMake to configure the project
& $cmakePath -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER="$mingwFolder\clang++.exe" -DCMAKE_C_COMPILER="$mingwFolder\clang.exe" -DCMAKE_INSTALL_PREFIX=install ..
# Build and install the project using parallel jobs
$cpuCount = $env:NUMBER_OF_PROCESSORS
Write-Host "Building project with $cpuCount parallel jobs..."
& $makePath -j $cpuCount install
# Navigate to the install directory
$navDir = Join-Path -Path $scriptDir -ChildPath $buildDir
$navDir = Join-Path -Path $navDir -ChildPath $installDir
Set-Location -Path $navDir
# Move required libs under mingw to project install path
Write-Host "Running move_required_libs_for_windows.PS1 script..."
& $MoveRequiredLibsScript $mingwFolder
# Verify that the update script ran successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to move required libs. Exiting..."
exit $LASTEXITCODE
}
# Remove unnecessary files
Remove-Item -Path .\include\ -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path .\lib\ -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path .\XFakeContrib.desktop -Force -ErrorAction SilentlyContinue
# Remove old iss script
$oldISS = Join-Path -Path $scriptDir -ChildPath "installer_script_updated.iss"
Remove-Item $oldISS -Force -ErrorAction SilentlyContinue
# Run the PowerShell script to update the ISS script
Write-Host "Running update ISS script..."
& $UpdateISSScript
# Verify that the update script ran successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to update the ISS script. Exiting."
exit $LASTEXITCODE
}
# Compile the Inno Setup script
Write-Host "Compiling Inno Setup script..."
& $innoSetupPath /O"$outputDir" $issScriptPath
# Verify that the compilation succeeded
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to compile the Inno Setup script."
exit $LASTEXITCODE
}
Write-Host "Script execution completed successfully."