Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Platform/Linux/LinuxCommon.cs
Joe Kirchoff 78ca8a8fe1 UnrealBuildTool Remove need for ar+ranlib since Linux min clang version supports lld
#rb Brandon.Schaefer
#rnx
#preflight 6297cd32144bede4dd4192bf

[CL 20458509 by Joe Kirchoff in ue5-main branch]
2022-06-01 16:41:24 -04:00

53 lines
1.3 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Win32;
using EpicGames.Core;
using Microsoft.Extensions.Logging;
namespace UnrealBuildTool
{
class LinuxCommon
{
public static string? Which(string name, ILogger Logger)
{
Process proc = new Process();
proc.StartInfo.FileName = "/bin/sh";
proc.StartInfo.Arguments = string.Format("-c 'which {0}'", name);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();
proc.WaitForExit();
string? path = proc.StandardOutput.ReadLine();
Logger.LogDebug("which {Name} result: ({ExitCode}) {Path}", name, proc.ExitCode, path);
if (proc.ExitCode == 0 && string.IsNullOrEmpty(proc.StandardError.ReadToEnd()))
{
return path;
}
return null;
}
public static string? WhichClang(ILogger Logger)
{
string? InternalSDKPath = UEBuildPlatform.GetSDK(UnrealTargetPlatform.Linux)?.GetInternalSDKPath();
if (!string.IsNullOrEmpty(InternalSDKPath))
{
return Path.Combine(InternalSDKPath, "bin", "clang++");
}
return Which("clang++", Logger);
}
}
}