// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. using System.Diagnostics; using Flax.Build.Projects; namespace Flax.Build.Platforms { /// /// The build platform for all Unix-like systems. /// /// public abstract class UnixPlatform : Platform { /// public override bool HasPrecompiledHeaderSupport => false; /// public override string ExecutableFileExtension => string.Empty; /// public override string SharedLibraryFileExtension => ".so"; /// public override string StaticLibraryFileExtension => ".a"; /// public override string ProgramDatabaseFileExtension => string.Empty; /// public override ProjectFormat DefaultProjectFormat => ProjectFormat.VisualStudioCode; /// /// Initializes a new instance of the class. /// protected UnixPlatform() { } /// /// Uses which command to find the given file. /// /// The name of the file to find. /// The full path or null if not found anything valid. public static string Which(string name) { Process proc = new Process { StartInfo = { FileName = "/bin/sh", Arguments = string.Format("-c 'which {0}'", name), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true } }; proc.Start(); proc.WaitForExit(); string path = proc.StandardOutput.ReadLine(); Log.Verbose(string.Format("which {0} exit code: {1}, result: {2}", name, proc.ExitCode, path)); if (proc.ExitCode == 0 && string.IsNullOrEmpty(proc.StandardError.ReadToEnd())) { return path; } return null; } } }