forked from grayver/mi-vigem
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Build.ps1
76 lines (54 loc) · 2.19 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
64
65
66
67
68
69
70
71
72
73
74
75
76
[CmdletBinding()]
param (
[Parameter()][ValidateSet("DEBUG", "RELEASE")][string]$Configuration = "DEBUG",
[Parameter()][ValidateSet("x86", "x64")][string]$Architecture = "x86"
)
$script:CommonFlags = @("/Zi", "/W4", "/EHsc", "/DWIN32", "/D_UNICODE", "/DUNICODE")
$script:DebugFlags = @( "/Od" )
$script:ReleaseFlags = @("/GL", "/O2")
$script:OutputName = "stadia-vigem-"
function Import-Prerequisites {
if (Get-Module -ListAvailable -Name WintellectPowerShell) {
Update-Module -Name WintellectPowerShell
} else {
Install-Module -Name WintellectPowerShell -Scope CurrentUser -Force
}
Import-Module -Name WintellectPowerShell
}
function Invoke-BuildTools {
param (
$Architecture
)
$latestVsInstallationInfo = Get-VSSetupInstance -All | Sort-Object -Property InstallationVersion -Descending | Select-Object -First 1
Invoke-CmdScript "$($latestVsInstallationInfo.InstallationPath)\VC\Auxiliary\Build\vcvarsall.bat" $Architecture
}
function Invoke-Build {
param (
$Architecture
)
$OutputName = "$script:OutputName$Architecture.exe"
$Flags = If ($Configuration -eq "DEBUG") {$script:DebugFlags} else {$script:ReleaseFlags}
$StopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
Write-Host "*** ${OutputName}: Build started ***"
Write-Host
$StopWatch.Start()
& "rc.exe" /foobj/stadia-vigem.res res/res.rc
& "cl.exe" $Flags $CommonFlags /IViGEmClient/include /Foobj/ /Febin/$OutputName ViGEmClient/src/*.cpp obj/stadia-vigem.res src/*.c
$StopWatch.Stop()
Write-Host
Write-Host "*** ${OutputName}: Build finished in $($StopWatch.Elapsed) ***"
}
# Entry
New-Item -Path "bin" -ItemType Directory -Force > $null
New-Item -Path "obj" -ItemType Directory -Force > $null
Import-Prerequisites
Write-Host "-- Build started. Configuration: $Configuration, Architecture: $Architecture --"
if ($Architecture -eq "x86" -Or $Architecture -eq "ALL") {
Invoke-BuildTools -Architecture "x86"
Invoke-Build -Architecture "x86"
}
if ($Architecture -eq "x64" -Or $Architecture -eq "ALL") {
Invoke-BuildTools -Architecture "x64"
Invoke-Build -Architecture "x64"
}
Write-Host "-- Build completed. --"