-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
90 lines (81 loc) · 2.22 KB
/
Copy pathbuild.ps1
File metadata and controls
90 lines (81 loc) · 2.22 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
# PowerShell build script for Windows
param(
[Parameter(Position=0)]
[string]$Command,
[Parameter(Position=1)]
[string]$Option
)
function Build-Debug {
Write-Host "Building debug version..." -ForegroundColor Green
cmake --preset win-debug
cmake --build ./out/win-debug
}
function Build-Release {
Write-Host "Building release version..." -ForegroundColor Green
cmake --preset win-release
cmake --build ./out/win-release
}
function Run-Debug {
Build-Debug
./out/win-debug/main.exe
}
function Run-Release {
Build-Release
./out/win-release/main.exe
}
function Clean-Build {
param([string]$Type)
switch ($Type) {
"--debug" {
Remove-Item -Path "./out/win-debug" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Cleaned debug build directory."
}
"--release" {
Remove-Item -Path "./out/win-release" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Cleaned release build directory."
}
default {
Remove-Item -Path "./out" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "Cleaned all build directories."
}
}
}
switch ($Command) {
"run" {
switch ($Option) {
$null { Run-Debug }
"--debug" { Run-Debug }
"--release" { Run-Release }
default {
Write-Host "Invalid option. Use --debug or --release."
exit 1
}
}
}
"build" {
switch ($Option) {
$null { Build-Debug }
"--debug" { Build-Debug }
"--release" { Build-Release }
"--all" {
Write-Host "Building both debug and release versions..."
Build-Debug
Build-Release
}
default {
Write-Host "Invalid option. Use --debug or --release or --all."
exit 1
}
}
}
"clean" {
Clean-Build $Option
}
"help" {
Write-Host "Usage: .\build.ps1 [run|build|clean|help] [--debug|--release|--all]"
}
default {
Write-Host "Usage: .\build.ps1 run [--debug|--release]"
exit 1
}
}