-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_windows.ps1
More file actions
103 lines (74 loc) · 3.46 KB
/
Copy pathbuild_windows.ps1
File metadata and controls
103 lines (74 loc) · 3.46 KB
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
103
$arch = "x64"
$vs_arch = "x86.x64"
$cmake_arch = "x64"
if ($Args[0] -eq "arm64")
{
$arch = $Args[0]
$vs_arch = "ARM64"
$cmake_arch = "ARM64"
}
$sdlPath = Convert-Path -LiteralPath "./SDL"
$faudioPath = Convert-Path -LiteralPath "./FAudio"
$outputFolder = "./binaries/win-$arch"
Remove-Item $outputFolder -Recurse -ErrorAction SilentlyContinue
if (!(Test-Path -Path $outputFolder)) {New-Item $outputFolder -Type Directory >$null}
$logFolder = "./logs/win-$arch"
Remove-Item $logFolder -Recurse -ErrorAction SilentlyContinue
if (!(Test-Path -Path $logFolder)) {New-Item $logFolder -Type Directory >$null}
$buildFolder = "build"
$sdlBuild = "$sdlPath/$buildFolder"
$faudioBuild = "$faudioPath/$buildFolder"
Write-Host "Look for MSBuild with C++ support" -ForegroundColor DarkCyan
Set-Alias vswhere -Value "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = vswhere -latest -requires Microsoft.VisualStudio.Component.VC.Tools.$vs_arch -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
if (!$msbuild -Or !(Test-Path -Path $msbuild))
{
Write-Host "`tNot installed. Build aborted. Please install Visual Studio with the C++ component." -ForegroundColor DarkRed
Read-Host -Prompt "Press Enter to exit"
Break
}
else
{
Write-Host "`tFound at: $msbuild"
Set-Alias msbuild -Value "$msbuild"
}
Write-Host "Look for CMake support" -ForegroundColor DarkCyan
if (!(Get-Command "cmake" -errorAction SilentlyContinue))
{
$cmake = vswhere -latest -find **\cmake.exe | select-object -first 1
if (!$cmake -Or !(Test-Path -Path $cmake))
{
Write-Host "`tCMake is not installed or not on PATH. Please add it to PATH or install it from the Visual Studio components." -ForegroundColor DarkRed
Read-Host -Prompt "Press Enter to exit"
Break
}
else
{
Write-Host "`tFound at (from Visual Studio): $cmake"
Set-Alias cmake -Value "$cmake"
}
}
else
{
$cmake = (Get-Command "cmake" -errorAction SilentlyContinue).Path
Write-Host "`tFound at (from PATH): $cmake"
}
Write-Host "Generate SDL" -ForegroundColor DarkCyan
Remove-Item $sdlBuild -Recurse -ErrorAction SilentlyContinue
if (!(Test-Path -Path $sdlBuild)) {New-Item $sdlBuild -Type Directory >$null}
cmake -S $sdlPath -B $sdlBuild -G "Visual Studio 17 2022" -A $cmake_arch -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded | Out-File -FilePath "$logFolder/SDL.gen.log" -Append
Write-Host "`tDone"
Write-Host "Build SDL" -ForegroundColor DarkCyan
msbuild $sdlBuild/SDL3.sln /p:Configuration="Release" /p:Platform="$cmake_arch" | Out-File -FilePath "$logFolder/SDL.bin.log" -Append
Write-Host "`tDone"
Write-Host "Generate FAudio" -ForegroundColor DarkCyan
Remove-Item $faudioBuild -Recurse -ErrorAction SilentlyContinue
if (!(Test-Path -Path $faudioBuild)) {New-Item $faudioBuild -Type Directory >$null}
cmake -S $faudioPath -B $faudioBuild -G "Visual Studio 17 2022" -A $cmake_arch -DSDL3_DIR="$sdlBuild" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded | Out-File -FilePath "$logFolder/FAudio.gen.log" -Append
Write-Host "`tDone"
Write-Host "Build FAudio" -ForegroundColor DarkCyan
msbuild $faudioBuild/FAudio.sln /t:FAudio-shared /p:Configuration="Release" /p:Platform="$cmake_arch" | Out-File -FilePath "$logFolder/FAudio.bin.log" -Append
if (!(Test-Path -Path "$outputFolder")) {New-Item "$outputFolder" -Type Directory >$null}
Copy-Item -Path "$faudioBuild/Release/FAudio.dll" -Destination "$outputFolder/FAudio.dll"
Write-Host "`tDone"
Read-Host -Prompt "All done - Press Enter to exit"