-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.ps1
67 lines (61 loc) · 2.5 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
Param (
[Parameter(Mandatory=$false, HelpMessage="The version the mod should be compiled with")][Alias("ver")][string]$Version,
[Parameter(Mandatory=$false, HelpMessage="Switch to create a clean compilation")][Alias("rebuild")][Switch]$clean,
[Parameter(Mandatory=$false, HelpMessage="To create a release build")][Alias("publish")][Switch]$release,
[Parameter(Mandatory=$false, HelpMessage="To create a github actions build, assumes specific Environment variables are set")][Alias("github-build")][Switch]$actions,
[Parameter(Mandatory=$false, HelpMessage="To create a debug build (Does not strip other libs)")][Alias("debug-build")][Switch]$debugbuild
)
$QPMpackage = "./qpm.json"
$qpmjson = Get-Content $QPMpackage -Raw | ConvertFrom-Json
$ModID = $qpmjson.info.id
if ($actions) {
$VERSION = $env:version
}
elseif (-not $Version) {
$VERSION = $qpmjson.info.version
} else {
$VERSION = $Version
}
if ($release -ne $true -and -not $VERSION.Contains('-Dev') -and -not $actions) {
$VERSION += "-Dev"
}
if ([string]::IsNullOrEmpty($env:version) -and $VERSION) {
& qpm package edit --version $VERSION
}
if ((Test-Path "./extern/includes/beatsaber-hook/shared/inline-hook/And64InlineHook.cpp", "./extern/includes/beatsaber-hook/shared/inline-hook/inlineHook.c", "./extern/includes/beatsaber-hook/shared/inline-hook/relocate.c") -contains $false) {
Write-Host "Critical: Missing inline-hook"
if (!(Test-Path "./extern/includes/beatsaber-hook/shared/inline-hook/And64InlineHook.cpp")) {
Write-Host "./extern/includes/beatsaber-hook/shared/inline-hook/And64InlineHook.cpp"
}
if (!(Test-Path "./extern/includes/beatsaber-hook/shared/inline-hook/inlineHook.c")) {
Write-Host "./extern/includes/beatsaber-hook/shared/inline-hook/inlineHook.c"
}
if (!(Test-Path "./extern/includes/beatsaber-hook/inline-hook/shared/relocate.c")) {
Write-Host "./extern/includes/beatsaber-hook/shared/inline-hook/relocate.c"
}
Write-Host "Task Failed, see output above"
exit 1;
}
echo "Building mod $ModID version $VERSION"
if ($clean.IsPresent)
{
if (Test-Path -Path "build")
{
remove-item build -R
}
}
if (($clean.IsPresent) -or (-not (Test-Path -Path "build")))
{
$out = new-item -Path build -ItemType Directory
}
cd build
if ($debugbuild -eq $true) {
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DDEBUG=true ../
} else {
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../
}
& cmake --build .
$ExitCode = $LastExitCode
cd ..
exit $ExitCode
echo Done