-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.ps1
63 lines (52 loc) · 2.23 KB
/
build.ps1
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
function Invoke-Environment {
param
(
[Parameter(Mandatory=$true)]
[string] $Command
)
$Command = "`"" + $Command + "`""
cmd /c "$Command > nul 2>&1 && set" | . { process {
if ($_ -match '^([^=]+)=(.*)') {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}}
}
$origEnv = Get-ChildItem Env:*;
$vsInstallationPath = & 'vswhere.exe' -property installationPath
if (-not $vsInstallationPath) {
Write-Host "No Visual Studio installation found."
exit 1
}
Remove-Item -Path "$PSScriptRoot\build" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$PSScriptRoot\dist" -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path "$PSScriptRoot\build" -ItemType Directory
New-Item -Path "$PSScriptRoot\build\win64" -ItemType Directory
New-Item -Path "$PSScriptRoot\build\win32" -ItemType Directory
New-Item -Path "$PSScriptRoot\dist" -ItemType Directory
Invoke-Environment "$vsInstallationPath\VC\Auxiliary\Build\vcvars32.bat"
cmake -S "$PSScriptRoot" -B "$PSScriptRoot\build\win32" -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\build\win32" -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles"
cmake --build "$PSScriptRoot\build\win32"
cmake --install "$PSScriptRoot\build\win32"
$origEnv | ForEach-Object { [System.Environment]::SetEnvironmentVariable($_.Name, $_.Value) }
Invoke-Environment "$vsInstallationPath\VC\Auxiliary\Build\vcvars64.bat"
cmake -S "$PSScriptRoot" -B "$PSScriptRoot\build\win64" -DCMAKE_INSTALL_PREFIX="$PSScriptRoot\build\win64" -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles"
cmake --build "$PSScriptRoot\build\win64"
cmake --install "$PSScriptRoot\build\win64"
$origEnv | ForEach-Object { [System.Environment]::SetEnvironmentVariable($_.Name, $_.Value) }
function package {
param (
[string]$platform
)
$files = @(
"$PSScriptRoot\README.md",
"$PSScriptRoot\LICENSE",
"$PSScriptRoot\CHANGELOG.md",
"$PSScriptRoot\VERSION",
"$PSScriptRoot\build\$platform\lib",
"$PSScriptRoot\build\$platform\include"
)
$version = (Get-Content "$PSScriptRoot\VERSION" | Out-String).Trim()
Compress-Archive -Path $files -DestinationPath "$PSScriptRoot\dist\libwnp-${version}_$platform.zip" -CompressionLevel Optimal
}
package -platform "win32"
package -platform "win64"