forked from OpenRA/OpenRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.ps1
118 lines (115 loc) · 3.02 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
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
}
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 ""
$command = Read-Host "Enter command"
}
else
{
$command = $args
}
if ($command -eq "all")
{
$msBuild = FindMSBuild
if ($msBuild -eq $null)
{
echo "Unable to locate an appropriate version of MSBuild."
}
else
{
$proc = Start-Process $msBuild /t:Rebuild -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
if ($msBuild -eq $null)
{
echo "Unable to locate an appropriate version of MSBuild."
}
else
{
$proc = Start-Process $msBuild /t:Clean -NoNewWindow -PassThru -Wait
rm *.dll # delete third party dependencies
rm *.config
rm mods/*/*.dll
echo "Clean complete."
}
}
elseif ($command -eq "version")
{
$version = git name-rev --name-only --tags --no-undefined HEAD 2>$null
if ($version -eq $null)
{
$version = "git-" + (git rev-parse --short HEAD)
}
$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")
{
cp thirdparty/*.dll .
cp thirdparty/windows/*.dll .
echo "Dependencies copied."
}
elseif ($command -eq "test")
{
echo "Testing mods..."
echo "OpenRA.Lint: checking Red Alert mod MiniYAML..."
./OpenRA.Lint.exe --verbose ra
echo "OpenRA.Lint: checking Tiberian Dawn mod MiniYAML..."
./OpenRA.Lint.exe --verbose cnc
echo "OpenRA.Lint: checking Dune 2000 mod MiniYAML..."
./OpenRA.Lint.exe --verbose d2k
echo "OpenRA.Lint: checking Tiberian Sun mod MiniYAML..."
./OpenRA.Lint.exe --verbose ts
}
else
{
echo ("Invalid command '{0}'" -f $command)
}
if ($args.Length -eq 0)
{
echo "Press enter to continue."
[System.Console]::ReadKey($true) >$null
}