forked from sheakelso/ClockMod
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildQMOD.ps1
87 lines (66 loc) · 2.68 KB
/
buildQMOD.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
Param(
[Parameter(Mandatory=$false, HelpMessage="The name the output qmod file should have")][String] $qmodname="ClockMod",
[Parameter(Mandatory=$false, HelpMessage="Switch to create a clean compilation")]
[Alias("rebuild")]
[Switch] $clean,
[Parameter(Mandatory=$false, HelpMessage="Switch to create a release build")]
[Switch] $release,
[Parameter(Mandatory=$false, HelpMessage="Prints the help instructions")]
[Switch] $help,
[Parameter(Mandatory=$false, HelpMessage="Tells the script to not compile and only package the existing files")]
[Alias("actions", "pack")]
[Switch] $package
)
# Builds a .qmod file for loading with QP or MBF
if ($help -eq $true) {
echo "`"BuildQmod <qmodName>`" - Copiles your mod into a `".so`" or a `".a`" library"
echo "`n-- Parameters --`n"
echo "qmodName `t The file name of your qmod"
echo "`n-- Arguments --`n"
echo "-clean `t`t Performs a clean build on both your library and the qmod"
echo "-help `t`t Prints this"
echo "-package `t Only packages existing files, without recompiling`n"
exit
}
if ($qmodName -eq "")
{
echo "Give a proper qmod name and try again"
exit
}
if (($args.Count -eq 0 -or $dev -eq $true) -And $package -eq $false) {
echo "Packaging QMod $qmodName"
& $PSScriptRoot/build.ps1 -clean:$clean --release:$release
if ($LASTEXITCODE -ne 0) {
echo "Failed to build, exiting..."
exit $LASTEXITCODE
}
# Update BS Version in mod.template.json using bs-cordl version.txt
$modTemplate = Get-Content "./mod.template.json" -Raw | ConvertFrom-Json
$bsversion = Get-Content "./extern/includes/bs-cordl/version.txt"
if (-not [string]::IsNullOrWhitespace($bsversion)) {
Write-Output "Setting Package Version to $bsversion"
$modTemplate.packageVersion = $bsversion
$modTemplate | ConvertTo-Json -Depth 10 | Set-Content "./mod.template.json"
} else {
Write-Error "Missing bs-cordl version.txt"
}
}
$qpmshared = "./qpm.shared.json"
$qpmsharedJson = Get-Content $qpmshared -Raw | ConvertFrom-Json
# if ([string]::IsNullOrEmpty($env:version)) {
# $qmodVersion = $qpmsharedJson.config.info.version
# $qmodName += "_v$qmodVersion"
# echo "qmodName set to $qmodName"
# }
if ($package -eq $true -And $env:version.Contains('-Dev')) {
$qmodName = "$($env:module_id)_$($env:version)"
echo "Actions: Packaging QMod $qmodName"
} elseif ($package -eq $true) {
$qmodName = "$($env:module_id)"
echo "Actions: Packaging QMod $qmodName"
} else {
$qmodName += "_$($qpmsharedJson.config.info.version)"
}
$qmod = $qmodName + ".qmod"
& qpm qmod zip -i ./build/ -i ./extern/libs/ $qmod
echo "Task Completed"