Nuke.Unreal
Build Unreal apps in Style.
Loading...
Searching...
No Matches
WindowsHostsLinux.cs
1using System;
2using System.Threading.Tasks;
3using Nuke.Cola.Tooling;
4using Nuke.Common;
5using Nuke.Common.IO;
6using Nuke.Common.Tooling;
7using Serilog;
8
10
12{
13 private IPlatformSdk SelfPlatformSdk => this;
16
17 private static string? GetEpicToolchainName(string unrealVersion) => unrealVersion switch
18 {
19 "5.0" => "v20_clang-13.0.1-centos7",
20 "5.1" => "v20_clang-13.0.1-centos7",
21 "5.2" => "v21_clang-15.0.1-centos7",
22 "5.3" => "v22_clang-16.0.6-centos7",
23 "5.4" => "v22_clang-16.0.6-centos7",
24 "5.5" => "v23_clang-18.1.0-rockylinux8",
25 "5.6" => "v25_clang-18.1.0-rockylinux8",
26 "5.7" => "v26_clang-20.1.8-rockylinux8",
27 _ => null
28 };
29
30 public static string? GetEpicToolchainName(IUnrealBuild build)
31 => GetEpicToolchainName(Unreal.Version(build).VersionMinor);
32
33 public async Task Setup(IUnrealBuild build)
34 {
35 var epicToolchainName = GetEpicToolchainName(build);
36 var sdkPath = GetSdkPath(build);
37
38 Log.Information("Setting up Linux toolchain {0} at {1}", epicToolchainName, sdkPath);
39 if (!SelfPlatformSdk.Exists(build))
40 {
41 var url = $"https://cdn.unrealengine.com/CrossToolchain_Linux/{epicToolchainName}.exe";
42 var installerPath = NukeBuild.TemporaryDirectory / "LinuxSdkTemp" / (epicToolchainName + ".exe");
43
44 Log.Debug(" Downloading from {0} to {1}", url, installerPath);
45 await HttpTasks.HttpDownloadFileAsync(url, installerPath);
46
47 Log.Debug(" Because this installer require admin rights we will rather extract its contents with 7zip");
48 SevenZip.Exe($"x -bso1 -bse1 -bsp1 -o{sdkPath} {installerPath}");
49 }
50 Environment.SetEnvironmentVariable("LINUX_MULTIARCH_ROOT", sdkPath, EnvironmentVariableTarget.Process);
51 }
52
53 public bool IsValid(IUnrealBuild build) => GetEpicToolchainName(build) != null;
54
55 public AbsolutePath GetSdkPath(IUnrealBuild build)
56 => SelfPlatformSdk.GetSdkVersionsPath(build) / GetEpicToolchainName(build);
57
58 public AbsolutePath GetToolchainPath(IUnrealBuild build)
59 => GetSdkPath(build) / "x86_64-unknown-linux-gnu";
60
62 => new(
63 $"""
64 --sdk="{GetToolchainPath(build)}"
65 """,
66 ToolSetup: _ => _.WithPathVar(GetToolchainPath(build) / "bin")
67 );
68}
string VersionMinor
Only the Major.Minor version components, with extra information trimmed.
bool IsValid(IUnrealBuild build)
Would this SDK be ever valid for the given Unreal project. This check is done before Setup is called....
UnrealPlatform Host
The platform used for development, hosting this SDK to cross-compile target platform.
AbsolutePath GetToolchainPath(IUnrealBuild build)
Get the path to a C++ toolchain folder which may be used to compile external C++ code with to maintai...
PlatformSdkXMakeData GetXMakeData(IUnrealBuild build)
If applicable and XMake can work with the toolchains provided by this SDK, return information for it ...
AbsolutePath GetSdkPath(IUnrealBuild build)
The root of the currently used platform SDK in the file system, if there's one.
UnrealPlatform Target
The platform targeted by given SDK.
High level representation of common platforms supported by Unreal Engine (NDA ones excluded) and extr...
static readonly UnrealPlatform Win64
Any platform name containing 'Windows' is also mapped to this platform.
A collection of utilities around basic functions regarding the environment of the Engine we're workin...
Definition Unreal.cs:24
static EngineVersion Version(IUnrealBuild build)
Get high-level version of currently used Engine.
Base interface for build components which require an UnrealBuild main class.
Base interface for implementing the automatic SDK management for a host-target platform pair.
bool Exists(IUnrealBuild build)
Whether a valid platform SDK exists locally for given project, and is ready to use without further do...
AbsolutePath GetSdkVersionsPath(IUnrealBuild build)
A shared user folder for this SDK version, owned by Nuke.Unreal. This may be a parent folder to store...
record class PlatformSdkXMakeData(string Arguments, string? Platform=null, Func< ToolEx, ToolEx >? ToolSetup=null)
A record for providing build information for XMake/XRepo when that may be requested.