forked from Vindicta-Team/External-Faction-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildArmaMod.ps1
88 lines (61 loc) · 2.76 KB
/
buildArmaMod.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
Push-Location
$armaToolsFolder = "C:\Program Files (x86)\Steam\steamapps\common\Arma 3 Tools"
$pboFileName = Get-Content -Path "PBO_FILE_NAME.txt" -TotalCount 1
"Read PBO file name: $pboFileName`n"
# Ensure that PBO file name has been specified
if ($pboFileName -eq "VinFactionExample") {
"ERROR: You must modify PBO_FILE_NAME.txt and provide a unique PBO name."
"`nPlease read the instructions at Github:`nhttps://github.com/Vindicta-Team/External-Faction-Example/blob/master/README.md#2-modify-these-files"
pause
exit 1
}
$modBuildPath = "_build\@$pboFileName"
"Ensure directories, clear temp folder..`n"
New-Item "_build" -ItemType Directory -Force > $null
forEach ($folder in (Get-Childitem -directory -name "_build")) {
Remove-Item "_build\$folder" -Recurse -Force
}
New-Item "_build\temp" -ItemType Directory -Force > $null
New-Item $modBuildPath -ItemType Directory -Force > $null
New-Item "$modBuildPath\addons" -ItemType Directory -Force > $null
New-Item "$modBuildPath\keys" -ItemType Directory -Force > $null
"Copy extra files..`n"
Copy-Item "mod.cpp" $modBuildPath > $null
"Copy addons..`n"
Copy-Item "addon" "$modBuildPath\addons" -Recurse > $null
"Generate PBO_FILE_NAME.hpp`n"
Remove-Item "$modBuildPath\addons\addon\PBO_FILE_NAME.hpp"
"// Auto generated file`n#define PBO_FILE_NAME $pboFileName" >> "$modBuildPath\addons\addon\PBO_FILE_NAME.hpp"
"Generate loadout init file.."
$initLoadoutsSQF = "#include `"common.hpp`"`n// This file is autogenerated`n"
$loadoutFiles = Get-Childitem "$modBuildPath\addons\addon\loadouts"
foreach ($file in $loadoutfiles) {
#$ext = $file.Extension
$loadoutName = $file.baseName
$fileName = $file.Name
" Found loadout: $loadoutName $fileName"
$initLoadoutsSQF += "[`"$loadoutName`", `PATH_TO_FILE(loadouts\$fileName)] call t_fnc_addLoadout;`n"
}
$initLoadoutsSQF | Out-File -FilePath "$modBuildPath\addons\addon\initLoadouts.sqf" -NoNewline -Encoding UTF8
"`n"
"Rename folder..`n"
Rename-Item "$modBuildPath\addons\addon" "$pboFileName"
"Build pbos...`n"
& "$armaToolsFolder\AddonBuilder\AddonBuilder.exe" "$PSScriptRoot\$modBuildPath\addons\$pboFileName" "$PSScriptRoot\$modBuildPath\addons" -packonly -prefix="$pboFileName" -temp="$PSScriptRoot\_build\temp"
"Delete unpacked addon folder..`n"
Remove-Item "$modBuildPath\addons\$pboFileName" -Recurse -Force
"`nCreate key..."
Push-Location
Set-Location "_build"
& "$armaToolsFolder\DSSignFile\DSCreateKey" "$pboFileName"
Copy-Item "$pboFileName.bikey" "@$pboFileName\keys" -Force
"`nSign PBO files..."
Set-Location "@$pboFileName\addons"
$pboFiles = Get-ChildItem -Name "*.pbo"
forEach ($file in $pboFiles) {
"Signing file $file ..."
& "$armaToolsFolder\DSSignFile\DSSignFile" "..\..\$pboFileName.biprivatekey" $file
}
Pop-Location
"`n`nDone!"
pause