forked from NVIDIAGameWorks/dxvk-remix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_common.ps1
102 lines (84 loc) · 3.25 KB
/
build_common.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
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
95
96
97
98
99
100
101
102
<#
Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
#>
#
# Find vswhere (installed with recent Visual Studio versions).
#
If ($vsWhere = Get-Command "vswhere.exe" -ErrorAction SilentlyContinue) {
$vsWhere = $vsWhere.Path
} ElseIf (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe") {
$vsWhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
}
Else {
Write-Error "vswhere not found. Aborting." -ErrorAction Stop
}
Write-Host "vswhere found at: $vsWhere" -ForegroundColor Yellow
#
# Get path to Visual Studio installation using vswhere.
#
$vsPath = &$vsWhere -latest -version "[16.0,18.0)" -products * `
-requires Microsoft.Component.MSBuild `
-property installationPath
If ([string]::IsNullOrEmpty("$vsPath")) {
Write-Error "Failed to find Visual Studio 2019 installation. Aborting." -ErrorAction Stop
}
Write-Host "Using Visual Studio installation at: ${vsPath}" -ForegroundColor Yellow
#
# Make sure the Visual Studio Command Prompt variables are set.
#
# Load VC vars
Push-Location "${vsPath}\VC\Auxiliary\Build"
cmd /c ".\vcvars64.bat x64&set" |
ForEach-Object {
If ($_ -match "=") {
$v = $_.split("="); Set-Item -Force -Path "ENV:\$($v[0])" -Value "$($v[1])"
}
}
Pop-Location
Write-Host "Visual Studio Command Prompt variables set." -ForegroundColor Yellow
function PerformBuild {
param(
[Parameter(Mandatory)]
[string]$Backend,
[Parameter(Mandatory)]
[string]$BuildFlavour,
[Parameter(Mandatory)]
[string]$BuildSubDir,
[Parameter(Mandatory)]
[string]$EnableTracy,
[string]$BuildTarget
)
$CurrentDir = Get-Location
$OutputDir = [IO.Path]::Combine($CurrentDir, "_output")
$BuildDir = [IO.Path]::Combine($CurrentDir, $BuildSubDir)
Push-Location $CurrentDir
$mesonArgs = "setup --buildtype `"$BuildFlavour`" --backend `"$Backend`" -Denable_tracy=`"$EnableTracy`" `"$BuildSubDir`""
Start-Process "meson" -NoNewWindow -ArgumentList $mesonArgs -wait
Pop-Location
if ( $LASTEXITCODE -ne 0 ) {
Write-Output "Failed to run meson setup"
exit $LASTEXITCODE
}
Push-Location $BuildDir
& meson compile $BuildTarget
Pop-Location
if ( $LASTEXITCODE -ne 0 ) {
Write-Output "Failed to run build step"
exit $LASTEXITCODE
}
}