77 [ValidateNotNullOrEmpty ()]
88 [string ]$VcpkgRootDir ,
99
10- [string ]$VersionIdentifier = " 0"
10+ [Parameter (Mandatory = $true )]
11+ [ValidateNotNullOrEmpty ()]
12+ [string ]$BuildDir ,
13+
14+ [Parameter (Mandatory = $true )]
15+ [ValidateNotNullOrEmpty ()]
16+ [string ]$InstallDir ,
17+
18+ [string ]$VersionIdentifier = " 0" ,
19+
20+ [switch ]$CCache = $false
1121)
1222
1323if (-not (Test-Path $VcpkgRootDir )) {
1424 throw " Vcpkg root directory does not exist: $VcpkgRootDir "
1525}
1626
27+ New-Item $BuildDir - ItemType Directory - Force
28+ New-Item $InstallDir - ItemType Directory - Force
29+
1730Write-Host " Build type: $BuildType "
18- Write-Host " Commit: $Commit "
1931Write-Host " Vcpkg root directory: $VcpkgRootDir "
32+ Write-Host " Build directory: $ ( Resolve-Path $BuildDir ) "
33+ Write-Host " Install directory: $ ( Resolve-Path $InstallDir ) "
34+ Write-Host " Version identifier: $VersionIdentifier "
35+ Write-Host " Use CCache: $CCache "
2036
2137$cmakeListsPath = " CMakeLists.txt"
2238
@@ -62,9 +78,12 @@ Write-Host "Semver: $semver"
6278
6379$installerFileBase = " ${applicationName} _$ ( $semver -replace ' [\.\-\+]' , ' _' ) _installer"
6480
65- cmake - B build - G Ninja `
81+ cmake - S . - B $ ( Resolve-Path $BuildDir ) - G Ninja `
6682 - DCMAKE_BUILD_TYPE= RelWithDebInfo `
6783 " -DCMAKE_TOOLCHAIN_FILE=$ ( Join-Path $VcpkgRootDir scripts/ buildsystems/ vcpkg.cmake) " `
84+ " -DCMAKE_C_COMPILER_LAUNCHER=$ ( $CCache ? ' ccache' : ' ' ) " `
85+ " -DCMAKE_CXX_COMPILER_LAUNCHER=$ ( $CCache ? ' ccache' : ' ' ) " `
86+ - DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT= Embedded `
6887 - DCK_ENABLE_CONSOLE:BOOL= FALSE `
6988 - DAPPLICATION_INSTALL:BOOL= ON `
7089 - DAPPLICATION_CONFIGURE_INSTALLER:BOOL= ON `
@@ -74,19 +93,35 @@ cmake -B build -G Ninja `
7493 " -DAPPLICATION_NAME=$applicationName " `
7594 " -DAPPLICATION_DISPLAY_NAME=$applicationDisplayName " `
7695 " -DAPPLICATION_SEMVER=$semver " `
77- - DCMAKE_INSTALL_PREFIX= installed | Write-Host
96+ " -DCMAKE_INSTALL_PREFIX=$ ( Resolve-Path $InstallDir ) " | Write-Host
97+ if ($LASTEXITCODE -ne 0 ) {
98+ throw " Configure failed"
99+ }
100+
101+ if ($CCache ) {
102+ ccache -- zero- stats | Write-Host
103+ }
104+
105+ cmake -- build $ (Resolve-Path $BuildDir ) -- target all | Write-Host
106+ if ($LASTEXITCODE -ne 0 ) {
107+ throw " Build failed"
108+ }
109+
110+ if ($CCache ) {
111+ ccache -- show-stats | Write-Host
112+ }
78113
79- cmake -- build build -- target all | Write-Host
80- cmake -- build build -- target install | Write-Host
114+ cmake -- build $ (Resolve-Path $BuildDir ) -- target install | Write-Host
115+ if ($LASTEXITCODE -ne 0 ) {
116+ throw " Install failed"
117+ }
81118
82119$buildResult = @ {
83120 ProjectName = $projectName
84121 Version = $version
85122 ApplicationName = $applicationName
86123 ApplicationDisplayName = $applicationDisplayName
87124 Semver = $semver
88- BuildDir = $ (Resolve-Path " build" )
89- InstalledDir = $ (Resolve-Path " installed" )
90125 InstallerFileBase = $installerFileBase
91126}
92127
0 commit comments