forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.ps1
218 lines (212 loc) · 6.13 KB
/
make.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
function FindMSBuild
{
$msBuildVersions = @("4.0")
foreach ($msBuildVersion in $msBuildVersions)
{
$key = "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\{0}" -f $msBuildVersion
$property = Get-ItemProperty $key -ErrorAction SilentlyContinue
if ($property -eq $null -or $property.MSBuildToolsPath -eq $null)
{
continue
}
$path = Join-Path $property.MSBuildToolsPath -ChildPath "MSBuild.exe"
if (Test-Path $path)
{
return $path
}
}
return $null
}
function UtilityNotFound
{
echo "OpenRA.Utility.exe could not be found. Build the project first using the `"all`" command."
}
if ($args.Length -eq 0)
{
echo "Command list:"
echo ""
echo " all Builds the game and its development tools."
echo " dependencies Copies the game's dependencies into the main game folder."
echo " version Sets the version strings for the default mods to the latest"
echo " version for the current Git branch."
echo " clean Removes all built and copied files. Use the 'all' and"
echo " 'dependencies' commands to restore removed files."
echo " test Tests the default mods for errors."
echo " check Checks .cs files for StyleCop violations."
echo " docs Generates the trait and Lua API documentation."
echo ""
$command = (Read-Host "Enter command").Split(' ', 2)
}
else
{
$command = $args
}
if ($command -eq "all")
{
$msBuild = FindMSBuild
$msBuildArguments = "/t:Rebuild /nr:false"
if ($msBuild -eq $null)
{
echo "Unable to locate an appropriate version of MSBuild."
}
else
{
$proc = Start-Process $msBuild $msBuildArguments -NoNewWindow -PassThru -Wait
if ($proc.ExitCode -ne 0)
{
echo "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game."
}
else
{
echo "Build succeeded."
}
}
}
elseif ($command -eq "clean")
{
$msBuild = FindMSBuild
$msBuildArguments = "/t:Clean /nr:false"
if ($msBuild -eq $null)
{
echo "Unable to locate an appropriate version of MSBuild."
}
else
{
$proc = Start-Process $msBuild $msBuildArguments -NoNewWindow -PassThru -Wait
rm *.dll
rm *.dll.config
rm mods/*/*.dll
if (Test-Path thirdparty/download/)
{
rmdir thirdparty/download -Recurse -Force
}
echo "Clean complete."
}
}
elseif ($command -eq "version")
{
if ($command.Length -gt 1)
{
$version = $command[1]
}
elseif (Get-Command 'git' -ErrorAction SilentlyContinue)
{
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
if ($version -eq $null)
{
$version = "git-" + (git rev-parse --short HEAD)
}
}
else
{
echo "Unable to locate Git. The version will remain unchanged."
}
if ($version -ne $null)
{
$mods = @("mods/ra/mod.yaml", "mods/cnc/mod.yaml", "mods/d2k/mod.yaml", "mods/modchooser/mod.yaml")
foreach ($mod in $mods)
{
$replacement = (gc $mod) -Replace "Version:.*", ("Version: {0}" -f $version)
sc $mod $replacement
}
echo ("Version strings set to '{0}'." -f $version)
}
}
elseif ($command -eq "dependencies")
{
cd thirdparty
./fetch-thirdparty-deps.ps1
cp download/*.dll ..
cp download/GeoLite2-Country.mmdb.gz ..
cp download/windows/*.dll ..
cd ..
echo "Dependencies copied."
$dep = "Microsoft Visual C++ 201"
$results = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName | Where-Object {$_.DisplayName -like $("$dep*")}
if (!($results -is [array]) -and !$results.DisplayName)
{
Write-Host "Warning! Freetype6.dll requires Microsoft Visual C++ 2010 x86 Redistributable!" -Foreground "Red"
}
}
elseif ($command -eq "test")
{
if (Test-Path OpenRA.Utility.exe)
{
echo "Testing mods..."
echo "Testing Red Alert mod MiniYAML..."
./OpenRA.Utility.exe ra --check-yaml
echo "Testing Tiberian Dawn mod MiniYAML..."
./OpenRA.Utility.exe cnc --check-yaml
echo "Testing Dune 2000 mod MiniYAML..."
./OpenRA.Utility.exe d2k --check-yaml
echo "Testing Tiberian Sun mod MiniYAML..."
./OpenRA.Utility.exe ts --check-yaml
}
else
{
UtilityNotFound
}
}
elseif ($command -eq "check")
{
if (Test-Path OpenRA.Utility.exe)
{
echo "Checking for code style violations in OpenRA.Renderer.Null..."
./OpenRA.Utility.exe ra --check-code-style OpenRA.Renderer.Null
echo "Checking for code style violations in OpenRA.GameMonitor..."
./OpenRA.Utility.exe ra --check-code-style OpenRA.GameMonitor
echo "Checking for code style violations in OpenRA.Game..."
./OpenRA.Utility.exe ra --check-code-style OpenRA.Game
echo "Checking for code style violations in OpenRA.Mods.Common..."
./OpenRA.Utility.exe ra --check-code-style OpenRA.Mods.Common
echo "Checking for code style violations in OpenRA.Mods.RA..."
./OpenRA.Utility.exe ra --check-code-style OpenRA.Mods.RA
echo "Checking for code style violations in OpenRA.Mods.Cnc..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.Cnc
echo "Checking for code style violations in OpenRA.Mods.D2k..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.D2k
echo "Checking for code style violations in OpenRA.Mods.TS..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.TS
echo "Checking for code style violations in OpenRA.Editor..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Editor
echo "Checking for code style violations in OpenRA.Renderer.Sdl2..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Renderer.Sdl2
echo "Checking for code style violations in OpenRA.Utility..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Utility
echo "Checking for code style violations in OpenRA.Test..."
./OpenRA.Utility.exe cnc --check-code-style OpenRA.Test
}
else
{
UtilityNotFound
}
}
elseif ($command -eq "docs")
{
if (Test-Path OpenRA.Utility.exe)
{
./make.ps1 version
./OpenRA.Utility.exe all --docs | Out-File -Encoding "UTF8" DOCUMENTATION.md
./OpenRA.Utility.exe ra --lua-docs | Out-File -Encoding "UTF8" Lua-API.md
}
else
{
UtilityNotFound
}
}
else
{
echo ("Invalid command '{0}'" -f $command)
}
if ($args.Length -eq 0)
{
echo "Press enter to continue."
while ($true)
{
if ([System.Console]::KeyAvailable)
{
break
}
Start-Sleep -Milliseconds 50
}
}