// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. using System; using System.IO; namespace Flax.Build.Platforms { /// /// The Linux build platform implementation. /// /// /// public class LinuxPlatform : UnixPlatform { /// public override TargetPlatform Target => TargetPlatform.Linux; /// public override bool HasRequiredSDKsInstalled { get; } /// public override bool HasSharedLibrarySupport => true; /// /// The toolchain folder root. /// public readonly string ToolchainRoot; /// /// True if use platform native system compiler instead of external package. /// public readonly bool UseSystemCompiler; /// /// Initializes a new instance of the class. /// public LinuxPlatform() { // Check if use system compiler if (Environment.OSVersion.Platform == PlatformID.Unix && Which("clang++-7") != null) { // Build toolchain root path ToolchainRoot = string.Empty; Log.Verbose("Using native Linux toolchain (system compiler)"); HasRequiredSDKsInstalled = true; UseSystemCompiler = true; } else { // Check if Linux toolchain is installed string toolchainName = "v13_clang-7.0.1-centos7"; string toolchainsRoot = Environment.GetEnvironmentVariable("LINUX_TOOLCHAINS_ROOT"); if (string.IsNullOrEmpty(toolchainsRoot) || !Directory.Exists(Path.Combine(toolchainsRoot, toolchainName))) { if (string.IsNullOrEmpty(toolchainsRoot)) { Log.Warning("Missing Linux Toolchain. Cannot build for Linux platform."); } return; } // Build toolchain root path ToolchainRoot = Path.Combine(toolchainsRoot, toolchainName).Replace('\\', '/'); Log.Verbose(string.Format("Found Linux Toolchain at {0}", ToolchainRoot)); HasRequiredSDKsInstalled = true; UseSystemCompiler = false; } } /// protected override Toolchain CreateToolchain(TargetArchitecture architecture) { return new LinuxToolchain(this, architecture); } /// public override bool CanBuildPlatform(TargetPlatform platform) { switch (platform) { case TargetPlatform.Linux: return true; case TargetPlatform.Android: return AndroidSdk.Instance.IsValid && AndroidNdk.Instance.IsValid; default: return false; } } } }