Skip to content

Commit

Permalink
Use Write-Host instead of echo
Browse files Browse the repository at this point in the history
  • Loading branch information
teinarss committed May 12, 2019
1 parent 1c13520 commit e605a94
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions make.ps1
Expand Up @@ -15,11 +15,11 @@ function All-Command
dotnet build /p:Configuration=Release /nologo
if ($lastexitcode -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."
Write-Host "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." -ForegroundColor Red
}
else
{
echo "Build succeeded."
Write-Host "Build succeeded." -ForegroundColor Green
}
}

Expand All @@ -43,7 +43,7 @@ function Clean-Command
{
rmdir thirdparty/download -Recurse -Force
}
echo "Clean complete."
Write-Host "Clean complete." -ForegroundColor Green
}

function Version-Command
Expand All @@ -65,12 +65,12 @@ function Version-Command
}
else
{
echo "Not a git repository. The version will remain unchanged."
Write-Host "Not a git repository. The version will remain unchanged." -ForegroundColor Red
}
}
else
{
echo "Unable to locate Git. The version will remain unchanged."
Write-Host "Unable to locate Git. The version will remain unchanged." -ForegroundColor Red
}

if ($version -ne $null)
Expand All @@ -90,7 +90,7 @@ function Version-Command
$replacement = (gc $mod) -Replace ".*: User", ("{0}/{1}: User" -f $prefix, $version)
sc $mod $replacement
}
echo ("Version strings set to '{0}'." -f $version)
Write-Host ("Version strings set to '{0}'." -f $version)
}
}

Expand All @@ -102,7 +102,7 @@ function Dependencies-Command
cp download/GeoLite2-Country.mmdb.gz ..
cp download/windows/*.dll ..
cd ..
echo "Dependencies copied."
Write-Host "Dependencies copied." -ForegroundColor Blue

if (CheckForDotnet -eq 1)
{
Expand All @@ -112,7 +112,7 @@ function Dependencies-Command
dotnet restore /nologo
if ($lastexitcode -ne 0)
{
echo "Project restoration failed."
Write-Host "Project restoration failed." -ForegroundColor Red
}
}

Expand All @@ -123,29 +123,29 @@ function Test-Command
return
}

echo "Testing mods..."
echo "Testing Tiberian Sun mod MiniYAML..."
Write-Host "Testing mods..." -ForegroundColor Blue
Write-Host "Testing Tiberian Sun mod MiniYAML..." -ForegroundColor Blue
./OpenRA.Utility.exe ts --check-yaml
echo "Testing Dune 2000 mod MiniYAML..."
Write-Host "Testing Dune 2000 mod MiniYAML..." -ForegroundColor Blue
./OpenRA.Utility.exe d2k --check-yaml
echo "Testing Tiberian Dawn mod MiniYAML..."
Write-Host "Testing Tiberian Dawn mod MiniYAML..." -ForegroundColor Blue
./OpenRA.Utility.exe cnc --check-yaml
echo "Testing Red Alert mod MiniYAML..."
Write-Host "Testing Red Alert mod MiniYAML..." -ForegroundColor Blue
./OpenRA.Utility.exe ra --check-yaml
}

function Check-Command
{
echo "Compiling in debug configuration..."
Write-Host "Compiling in debug configuration..." -ForegroundColor Blue
dotnet build /p:Configuration=Debug /nologo
if ($lastexitcode -ne 0)
{
echo "Build failed."
Write-Host "Build failed." -ForegroundColor Red
}

if (CheckForUtility -eq 0)
{
echo "Checking for explicit interface violations..."
Write-Host "Checking for explicit interface violations..." -ForegroundColor Blue
./OpenRA.Utility.exe all --check-explicit-interfaces
}
}
Expand All @@ -154,7 +154,7 @@ function Check-Scripts-Command
{
if ((Get-Command "luac.exe" -ErrorAction SilentlyContinue) -ne $null)
{
echo "Testing Lua scripts..."
Write-Host "Testing Lua scripts..." -ForegroundColor Blue
foreach ($script in ls "mods/*/maps/*/*.lua")
{
luac -p $script
Expand All @@ -163,11 +163,11 @@ function Check-Scripts-Command
{
luac -p $script
}
echo "Check completed!"
Write-Host "Check completed!" -ForegroundColor Green
}
else
{
echo "luac.exe could not be found. Please install Lua."
Write-Host "luac.exe could not be found. Please install Lua." -ForegroundColor Red
}
}

Expand All @@ -192,15 +192,15 @@ function CheckForUtility
return 0
}

echo "OpenRA.Utility.exe could not be found. Build the project first using the `"all`" command."
Write-Host "OpenRA.Utility.exe could not be found. Build the project first using the `"all`" command." -ForegroundColor Red
return 1
}

function CheckForDotnet
{
if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null)
{
echo "The 'dotnet' tool is required to compile OpenRA. Please install the .NET Core SDK or Visual studio and try again."
Write-Host "The 'dotnet' tool is required to compile OpenRA. Please install the .NET Core SDK or Visual Studio and try again. https://dotnet.microsoft.com/download" -ForegroundColor Red
return 1
}

Expand All @@ -209,7 +209,7 @@ function CheckForDotnet

function WaitForInput
{
echo "Press enter to continue."
Write-Host "Press enter to continue."
while ($true)
{
if ([System.Console]::KeyAvailable)
Expand All @@ -225,26 +225,26 @@ function WaitForInput
###############################################################
if ($PSVersionTable.PSVersion.Major -clt 3)
{
echo "The makefile requires PowerShell version 3 or higher."
echo "Please download and install the latest Windows Management Framework version from Microsoft."
Write-Host "The makefile requires PowerShell version 3 or higher." -ForegroundColor Red
Write-Host "Please download and install the latest Windows Management Framework version from Microsoft." -ForegroundColor Red
WaitForInput
}

if ($args.Length -eq 0)
{
echo "Command list:"
echo ""
echo " all, a Builds the game and its development tools."
echo " dependencies, d Copies the game's dependencies into the main game folder."
echo " version, v Sets the version strings for the default mods to the"
echo " latest version for the current Git branch."
echo " clean, c Removes all built and copied files. Use the 'all' and"
echo " 'dependencies' commands to restore removed files."
echo " test, t Tests the default mods for errors."
echo " check, ck Checks .cs files for StyleCop violations."
echo " check-scripts, cs Checks .lua files for syntax errors."
echo " docs Generates the trait and Lua API documentation."
echo ""
Write-Host "Command list:"
Write-Host ""
Write-Host " all, a Builds the game and its development tools."
Write-Host " dependencies, d Copies the game's dependencies into the main game folder."
Write-Host " version, v Sets the version strings for the default mods to the"
Write-Host " latest version for the current Git branch."
Write-Host " clean, c Removes all built and copied files. Use the 'all' and"
Write-Host " 'dependencies' commands to restore removed files."
Write-Host " test, t Tests the default mods for errors."
Write-Host " check, ck Checks .cs files for StyleCop violations."
Write-Host " check-scripts, cs Checks .lua files for syntax errors."
Write-Host " docs Generates the trait and Lua API documentation."
Write-Host ""
$command = (Read-Host "Enter command").Split(' ', 2)
}
else
Expand All @@ -268,7 +268,7 @@ switch ($execute)
{"check", "ck" -contains $_} { Check-Command }
{"check-scripts", "cs" -contains $_} { Check-Scripts-Command }
"docs" { Docs-Command }
Default { echo ("Invalid command '{0}'" -f $command) }
Default { Write-Host ("Invalid command '{0}'" -f $command) }
}

#In case the script was called without any parameters we keep the window open
Expand Down

0 comments on commit e605a94

Please sign in to comment.