|
| 1 | +param( |
| 2 | + [Parameter(Mandatory = $true)] |
| 3 | + [ValidateSet("dev", "alpha", "beta", "release")] |
| 4 | + [string]$BuildType, |
| 5 | + |
| 6 | + [Parameter(Mandatory = $true)] |
| 7 | + [ValidateNotNullOrEmpty()] |
| 8 | + [string]$VcpkgRootDir, |
| 9 | + |
| 10 | + [string]$VersionIdentifier = "0" |
| 11 | +) |
| 12 | + |
| 13 | +if (-not (Test-Path $VcpkgRootDir)) { |
| 14 | + Write-Error "Vcpkg root directory does not exist: $VcpkgRootDir" |
| 15 | + exit 1 |
| 16 | +} |
| 17 | + |
| 18 | +Write-Host "Build type: $BuildType" |
| 19 | +Write-Host "Commit: $Commit" |
| 20 | +Write-Host "Vcpkg root directory: $VcpkgRootDir" |
| 21 | + |
| 22 | +$cmakeListsPath = "CMakeLists.txt" |
| 23 | + |
| 24 | +$cmakeContent = Get-Content $cmakeListsPath -Raw |
| 25 | +$projectMatch = [regex]::Match($cmakeContent, 'project\s*\(\s*(\w+)\s+VERSION\s+([\d.]+)') |
| 26 | + |
| 27 | +if (-not $projectMatch.Success) { |
| 28 | + Write-Error "Could not find project declaration with VERSION in CMakeLists.txt" |
| 29 | + exit 1 |
| 30 | +} |
| 31 | + |
| 32 | +$projectName = $projectMatch.Groups[1].Value |
| 33 | +$version = $projectMatch.Groups[2].Value |
| 34 | + |
| 35 | +Write-Host "Project name: $projectName" |
| 36 | +Write-Host "Project version: $version" |
| 37 | + |
| 38 | +$applicationName = $projectName |
| 39 | +$applicationDisplayName = $projectName |
| 40 | +$semver = $version |
| 41 | + |
| 42 | +switch ($BuildType) { |
| 43 | + "dev" { |
| 44 | + $applicationName += "_dev" |
| 45 | + $applicationDisplayName += " (Dev)" |
| 46 | + $semver += "+$VersionIdentifier" |
| 47 | + } |
| 48 | + "alpha" { |
| 49 | + $applicationName += "_alpha" |
| 50 | + $applicationDisplayName += " (Alpha)" |
| 51 | + $semver += "-alpha.$VersionIdentifier" |
| 52 | + } |
| 53 | + "beta" { |
| 54 | + $semver += "-beta.$VersionIdentifier" |
| 55 | + } |
| 56 | + "release" { |
| 57 | + # No changes needed for release |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +Write-Host "Application name: $applicationName" |
| 62 | +Write-Host "Application display name: $applicationDisplayName" |
| 63 | +Write-Host "Semver: $semver" |
| 64 | + |
| 65 | +$installerFileBase = "${applicationName}_$($semver -replace '[\.\-\+]', '_')_installer" |
| 66 | + |
| 67 | +cmake -B build -G Ninja ` |
| 68 | + -DCMAKE_BUILD_TYPE=RelWithDebInfo ` |
| 69 | + "-DCMAKE_TOOLCHAIN_FILE=$(Join-Path $VcpkgRootDir scripts/buildsystems/vcpkg.cmake)" ` |
| 70 | + -DCK_ENABLE_CONSOLE:BOOL=FALSE ` |
| 71 | + -DAPPLICATION_INSTALL:BOOL=ON ` |
| 72 | + -DAPPLICATION_CONFIGURE_INSTALLER:BOOL=ON ` |
| 73 | + -DINNOSETUP_USE_UNOFFICIAL_LANGUAGE:BOOL=ON ` |
| 74 | + "-DAPPLICATION_INSTALLER_OUTPUT_DIR=$(Resolve-Path .)" ` |
| 75 | + "-DAPPLICATION_INSTALLER_FILE_BASE=$installerFileBase" ` |
| 76 | + "-DAPPLICATION_NAME=$applicationName" ` |
| 77 | + "-DAPPLICATION_DISPLAY_NAME=$applicationDisplayName" ` |
| 78 | + "-DAPPLICATION_SEMVER=$semver" ` |
| 79 | + -DCMAKE_INSTALL_PREFIX=installed |
| 80 | + |
| 81 | +cmake --build build --target all |
| 82 | +cmake --build build --target install |
| 83 | + |
| 84 | +$buildResult = @{ |
| 85 | + ProjectName = $projectName |
| 86 | + Version = $version |
| 87 | + ApplicationName = $applicationName |
| 88 | + ApplicationDisplayName = $applicationDisplayName |
| 89 | + Semver = $semver |
| 90 | + BuildDir = $(Resolve-Path "build") |
| 91 | + InstalledDir = $(Resolve-Path "installed") |
| 92 | + InstallerFileBase = $installerFileBase |
| 93 | +} |
| 94 | + |
| 95 | +Write-Output $buildResult |
0 commit comments