-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.ps1
141 lines (137 loc) · 3.68 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
param($command, $mode)
function Display-Info
{
Write-Output "`n>Zenith Engine CLI build tool syntax:"
Write-Output " build.ps1"
Write-Output " <COMMAND: (default - build project)"
Write-Output " help - display tool syntax (MODE not required)"
Write-Output " init - initialize submodules (MODE not required)"
Write-Output " clean/clear - clear the build system (MODE not required)"
Write-Output " clean-ext/clear-ext - clear builded external libraries (MODE not required)"
Write-Output " clean-all/clear-all - clear builded external libraries and the build system (MODE not required)"
Write-Output " up - update submodules (MODE not required)"
Write-Output " gen - generate build system"
Write-Output " run - run tech demo (you can specify additional arguments after MODE parameter that will be passed to the application)>"
Write-Output " <MODE: D|Debug; Dev|Development; P|Profile; R|Release; CI (static analysis setup)>"
Write-Output " <ARGS: additional parameters for run command>`n"
}
Switch ($command)
{
{($_ -eq "clean") -or ($_ -eq "clear")}
{
Get-ChildItem Bin -Recurse | Remove-Item -Recurse
Get-ChildItem Build -Recurse | Remove-Item -Recurse
exit 0
}
{($_ -eq "clean-ext") -or ($_ -eq "clear-ext")}
{
Get-ChildItem External/Bin -Recurse | Remove-Item -Recurse
exit 0
}
{($_ -eq "clean-all") -or ($_ -eq "clear-all")}
{
Get-ChildItem Bin -Recurse | Remove-Item -Recurse
Get-ChildItem Build -Recurse | Remove-Item -Recurse
Get-ChildItem External/Bin -Recurse | Remove-Item -Recurse
exit 0
}
"init"
{
git submodule update --init
exit 0
}
"up"
{
git submodule update --remote --merge
Get-ChildItem External/Bin -Recurse | Remove-Item -Recurse
exit 0
}
"help"
{
Display-Info
exit 0
}
default
{
if (!$mode)
{
$mode=$command
}
}
}
$build_type
$build_preset
Switch ($mode)
{
{($_ -eq "r") -or ($_ -eq "release") -or ($_ -eq "ci")}
{
$build_type="Release"
$build_preset="Release-Win"
break
}
{($_ -eq "p") -or ($_ -eq "profile")}
{
$build_type="Profile"
$build_preset="Profile-Win"
break
}
{($_ -eq "dev") -or ($_ -eq "development")}
{
$build_type="Development"
$build_preset="Development-Win"
break
}
{($_ -eq "d") -or ($_ -eq "debug")}
{
$build_type="Debug"
$build_preset="Debug-Win"
break
}
default
{
Write-Output "`nNot specified correct build mode!"
Display-Info
exit -1
}
}
$obj_dir="Build/$build_type"
$bin_dir="Bin/$build_type"
Switch ($command)
{
"gen"
{
$args=""
if ($mode -eq "ci")
{
$args="-DZE_CI_JOB=ON"
}
cmake $args -S ./ --preset=$build_preset
break
}
"run"
{
if (Test-Path -Path "$bin_dir/ZenithDemo.exe" -PathType Leaf)
{
cd "$bin_dir"
Start-Process -NoNewWindow "./ZenithDemo.exe" -ArgumentList $args
cd ../..
}
else
{
Write-Output "`nApplication must be built first!`n"
}
break
}
default
{
if (Test-Path -Path "$obj_dir" -PathType Container)
{
cmake --build "$obj_dir" --config $build_type
}
else
{
Write-Output "`nBuild system must be generated first!`n"
}
break
}
}