forked from ezEngine/ezEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunCMake.ps1
93 lines (71 loc) · 2.41 KB
/
RunCMake.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
param
(
[Parameter(Mandatory = $True)] [ValidateSet('Win64vs2022', 'Uwp64vs2022')][string] $Target,
[switch]$NoUnityBuild,
[switch]$NoSubmoduleUpdate,
[string]$SolutionName
)
Set-Location $PSScriptRoot
if ($NoSubmoduleUpdate -eq $False) {
$CURRENT_COMMIT = git log -n 1 --format=%H
Write-Host "Current commit: $CURRENT_COMMIT"
$UPDATE_SUBMODULES = $True
$LAST_UPDATE_FILE = "$PSScriptRoot\Data\Content\AssetCache\LastSubmoduleUpdate.txt"
if (Test-Path $LAST_UPDATE_FILE -PathType Leaf -ErrorAction SilentlyContinue) {
$LAST_COMMIT = Get-Content -Path $LAST_UPDATE_FILE
if ($CURRENT_COMMIT -eq $LAST_COMMIT) {
Write-Host "Submodules already up-to-date."
$UPDATE_SUBMODULES = $False
}
else {
Write-Host "Submodules were last updated at commit: $LAST_COMMIT"
}
}
if ($UPDATE_SUBMODULES) {
Write-Host "Updating submodules"
git submodule init
git submodule update
Out-File ( New-Item -Path $LAST_UPDATE_FILE -Force) -InputObject $CURRENT_COMMIT
}
}
$CMAKE_ARGS = @("-S", "$PSScriptRoot")
if ($NoUnityBuild) {
$CMAKE_ARGS += "-DEZ_ENABLE_FOLDER_UNITY_FILES:BOOL=OFF"
}
else {
$CMAKE_ARGS += "-DEZ_ENABLE_FOLDER_UNITY_FILES:BOOL=ON"
}
if ($SolutionName -ne "") {
$CMAKE_ARGS += "-DEZ_SOLUTION_NAME:STRING='${SolutionName}'"
}
$CMAKE_ARGS += "-G"
Write-Host ""
if ($Target -eq "Win64vs2022") {
Write-Host "=== Generating Solution for Visual Studio 2022 x64 ==="
$CMAKE_ARGS += "Visual Studio 17 2022"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2022x64"
}
elseif ($Target -eq "Uwp64vs2022") {
Write-Host "=== Generating Solution for Visual Studio 2022 x64 UWP ==="
$CMAKE_ARGS += "Visual Studio 17 2022"
$CMAKE_ARGS += "-A"
$CMAKE_ARGS += "x64"
$CMAKE_ARGS += "-B"
$CMAKE_ARGS += "$PSScriptRoot\Workspace\vs2022x64uwp"
$CMAKE_ARGS += "-DCMAKE_TOOLCHAIN_FILE=$PSScriptRoot\Code\BuildSystem\CMake\toolchain-winstore.cmake"
$CMAKE_ARGS += "-DEZ_ENABLE_QT_SUPPORT:BOOL=OFF"
$CMAKE_ARGS += "-DEZ_BUILD_FILTER='UwpProjects'"
}
else {
throw "Unknown target '$Target'."
}
Write-Host ""
Write-Host "Running cmake.exe $CMAKE_ARGS"
Write-Host ""
&Data\Tools\Precompiled\cmake\bin\cmake.exe $CMAKE_ARGS
if (!$?) {
throw "CMake failed with exit code '$LASTEXITCODE'."
}