Skip to content

Instantly share code, notes, and snippets.

@steve7411
Forked from megamorf/Install-LinuxToolChain
Last active December 2, 2017 19:27
Show Gist options
  • Save steve7411/8fbf71e8919fb588bfa6a8ce180d623a to your computer and use it in GitHub Desktop.
Save steve7411/8fbf71e8919fb588bfa6a8ce180d623a to your computer and use it in GitHub Desktop.
Powershell function to help setting up the Linux toolchain for UE4
function Install-LinuxToolChain {
<#
.SYNOPSIS
Downloads and installs the UE4 linux toolchain components.
.DESCRIPTION
Downloads the clang compiler to $ToolChainDestination and creates a
system-wide environment variable pointing to it.
Afterwards you have to regenerate the UE4 engine project files and
rebuild the engine.
.NOTES
https://wiki.unrealengine.com/Compiling_For_Linux
https://wiki.unrealengine.com/Dedicated_Server_Guide_(Windows_%26_Linux)
#>
[CmdletBinding()]
param(
[string]$ToolChainDestination = "C:\UE-Toolchain\",
[string]$ToolChainURL = "http://cdn.unrealengine.com/qfe/v8_clang-3.9.0-centos7.zip"
)
if(!(Test-Path $ToolChainDestination))
{
Write-Verbose "Toolchain destination directory doesn't exist. Creating now..."
try {
[void](mkdir $ToolChainDestination)
}
catch {
Write-Error "Failed to create target folder (Error: " $_.Exception.Message ")"
exit
}
}
$DestinationFileName = $ToolChainURL.Split('/')[-1]
$DestinationFilePath = Join-Path $ToolChainDestination $DestinationFileName
Write-Verbose ("Start download: [{0}]->[{1}]" -f $ToolChainURL,$DestinationFilePath)
Invoke-WebRequest $ToolChainURL -OutFile $DestinationFilePath
Write-Verbose ("Unpacking {0}" -f $DestinationFilePath)
try {
$shell = New-Object -ComObject Shell.Application
$shell.Namespace($ToolChainDestination).copyhere(($shell.NameSpace($DestinationFilePath)).items())
}
catch {
Write-Warning -Message "Unexpected Error. (Error: " $_.Exception.Message ")"
}
$ExtractedDirectory = $DestinationFilePath.Substring(0, $DestinationFilePath.Length - 4)
$ToolChain = Join-Path $ExtractedDirectory 'x86_64-unknown-linux-gnu'
Write-Verbose ("Create environment variable: [{0}]->[{1}] for compatibility" -f 'LINUX_ROOT', $ToolChain)
[Environment]::SetEnvironmentVariable('LINUX_ROOT', $ToolChain, 'Machine')
Write-Verbose ("Create environment variable: [{0}]->[{1}]" -f 'LINUX_MULTIARCH_ROOT',$ExtractedDirectory)
[Environment]::SetEnvironmentVariable('LINUX_MULTIARCH_ROOT', $ExtractedDirectory, 'Machine')
Get-Childitem $ToolChainDestination -filter *.zip | Remove-item -force
}
Install-LinuxToolChain -Verbose
@TheGreatCabbage
Copy link

Works nicely, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment