From af61a9764778096928245a1e3dde4b6e6b169160 Mon Sep 17 00:00:00 2001 From: Satori Date: Thu, 27 Aug 2020 00:25:17 +0100 Subject: [PATCH] Add PowerShell build script as alternative to cmd --- xb.ps1 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 xb.ps1 diff --git a/xb.ps1 b/xb.ps1 new file mode 100644 index 0000000000..9e24cf3849 --- /dev/null +++ b/xb.ps1 @@ -0,0 +1,24 @@ +function Write-FatalError($message) { + [Console]::ForegroundColor = 'red' + [Console]::Error.WriteLine($message) + [Console]::ResetColor() + Exit 1 +} + +$pythonPath = Get-Command python | Select-Object -ExpandProperty Definition + +# Check for 'python3' if 'python' isn't found +if ([string]::IsNullOrEmpty($pythonPath)) { + $pythonPath = Get-Command python3 | Select-Object -ExpandProperty Definition +} +# Neither found, error and exit +if ([string]::IsNullOrEmpty($pythonPath)) { + Write-FatalError "ERROR: no Python executable found on PATH.`nMake sure you can run 'python' or 'python3' in a Command Prompt." +} + +python -c "import sys; sys.exit(1 if not sys.version_info[:2] >= (3, 4) else 0)" +if ($LASTEXITCODE -gt 0) { + Write-FatalError "ERROR: Python version mismatch, not at least 3.4.`nFound Python executable was $($pythonPath)" +} + +python "$($PSScriptRoot)/xenia-build" $args \ No newline at end of file