using System.Collections.Generic; namespace UnityEditor.Il2Cpp { /// /// Toolchain package implementation for building Linux players on a Linux x86_64 host. /// /// /// This package provides the LLVM/Clang toolchain (compiler, linker, etc.). It does not /// include a sysroot; pair it with a matching sysroot package when cross-compiling. /// The payload is distributed via UPM under and installed /// into the sysroot/toolchain cache by the base SysrootPackage. /// public class ToolchainLinuxX86_64 : SysrootPackage { /// /// UPM package name that ships the LLVM/Clang toolchain payload. /// private string _packageName => "com.unity.toolchain.linux-x86_64-linux"; /// /// Human-readable package name as exposed to callers. /// public override string Name => _packageName; /// /// Host operating system this toolchain runs on. /// public override string HostPlatform => "linux"; /// /// Host CPU architecture this toolchain runs on. /// public override string HostArch => "x86_64"; /// /// Target operating system this toolchain is intended to produce binaries for. /// /// /// The exact target triple and sysroot (if any) are provided elsewhere (e.g., by a sysroot package /// and compiler flags). This package focuses on supplying the host-side tool binaries. /// public override string TargetPlatform => "linux"; /// /// Identifier for the specific payload version expected by this package. /// /// /// CI typically substitutes this placeholder at pack/publish time so the package resolves /// a precise, immutable payload directory on disk. /// private string _payloadVersion => "15.0.6_99c1b61e5651af630294cdd18fbd4d55900aad70f94c602c76b35989f0b571cf-1"; /// /// Relative path (under the cache) to the toolchain payload root for this host/target. /// private string _payloadDir; /// /// Relative path (inside the payload) to the linker binary to use with -fuse-ld=. /// private string _linkerFile => "bin/ld.lld"; /// /// Initializes the package and registers its toolchain payload so it can be resolved on disk. /// public ToolchainLinuxX86_64() : base() { _payloadDir = $"llvm-linux-x64/{_payloadVersion}"; RegisterPayload(_packageName, _payloadDir); } /// /// Gets the absolute path to the installed toolchain payload root directory. /// /// Absolute path to the toolchain payload root. public string PathToPayload() { return PayloadInstallDirectory(_payloadDir).ToString(); } /// /// Absolute path to a sysroot for IL2CPP (not applicable for this toolchain-only package). /// /// Always null for this package. public override string GetSysrootPath() { return null; } /// /// Absolute path to the installed toolchain that IL2CPP should use. /// /// Absolute path to the toolchain payload root. public override string GetToolchainPath() { return PathToPayload(); } /// /// Additional compiler flags to pass to IL2CPP/Clang (none required by this package). /// /// /// Targeting flags (e.g., -target) are typically supplied by the corresponding sysroot package. /// /// null (no extra compiler flags). public override string GetIl2CppCompilerFlags() { return null; } /// /// Additional linker flags to ensure IL2CPP uses this package's linker. /// /// /// Forces the linker to the payload’s ld.lld via -fuse-ld= (quoted path), and links /// libstdc++ statically for portability. Adjust if your distribution policy prefers dynamic libstdc++. /// /// A space-separated string of linker flags. public override string GetIl2CppLinkerFlags() { var linkerpath = PayloadInstallDirectory(_payloadDir).Combine(_linkerFile); return $"-fuse-ld={linkerpath.InQuotes()} -static-libstdc++"; } } }