[msbuild] Merge the GetMlaunchArguments and GetMlaunchArgumentsTaskBase classes. (#18071)

We no longer need two have overridable logic for remote builds, so the
non-abstract task class and the abstract base class can be merged.

Also enable nullability and fix any issues.
This commit is contained in:
Rolf Bjarne Kvinge 2023-04-18 07:59:15 +02:00 коммит произвёл GitHub
Родитель f89c9110ef
Коммит 0f648fbd77
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 26 добавлений и 34 удалений

Просмотреть файл

@ -1,20 +0,0 @@
using Microsoft.Build.Framework;
using Xamarin.Messaging.Build.Client;
namespace Xamarin.iOS.Tasks {
public class GetMlaunchArguments : GetMlaunchArgumentsTaskBase, ICancelableTask {
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
return base.Execute ();
}
public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}

Просмотреть файл

@ -11,41 +11,44 @@ using Microsoft.Build.Framework;
using Xamarin.Localization.MSBuild;
using Xamarin.MacDev;
using Xamarin.MacDev.Tasks;
using Xamarin.Messaging.Build.Client;
using Xamarin.Utils;
#nullable enable
namespace Xamarin.iOS.Tasks {
public abstract class GetMlaunchArgumentsTaskBase : XamarinTask {
public class GetMlaunchArguments : XamarinTask, ICancelableTask {
[Required]
public bool SdkIsSimulator { get; set; }
[Required]
public string SdkVersion { get; set; }
public string SdkVersion { get; set; } = string.Empty;
[Required]
public string AppBundlePath { get; set; }
public string AppBundlePath { get; set; } = string.Empty;
[Required]
public string AppManifestPath { get; set; }
public string AppManifestPath { get; set; } = string.Empty;
[Required]
public string SdkDevPath { get; set; }
public string SdkDevPath { get; set; } = string.Empty;
public ITaskItem [] AdditionalArguments { get; set; } = Array.Empty<ITaskItem> ();
public string DeviceName { get; set; }
public string DeviceName { get; set; } = string.Empty;
public ITaskItem [] EnvironmentVariables { get; set; } = Array.Empty<ITaskItem> ();
public string LaunchApp { get; set; }
public string InstallApp { get; set; }
public string LaunchApp { get; set; } = string.Empty;
public string InstallApp { get; set; } = string.Empty;
public bool CaptureOutput { get; set; } // Set to true to capture output. If StandardOutput|ErrorPath is not set, write to the current terminal's stdout/stderr (requires WaitForExit)
public string StandardOutputPath { get; set; } // Set to a path to capture output there
public string StandardErrorPath { get; set; } // Set to a path to capture output there
public string StandardOutputPath { get; set; } = string.Empty; // Set to a path to capture output there
public string StandardErrorPath { get; set; } = string.Empty;// Set to a path to capture output there
public bool WaitForExit { get; set; } // Required for capturing stdout/stderr output
[Required]
public string MlaunchPath { get; set; }
public string MlaunchPath { get; set; } = string.Empty;
[Output]
public string MlaunchArguments { get; set; }
public string MlaunchArguments { get; set; } = string.Empty;
public IPhoneDeviceType DeviceType {
get {
@ -61,7 +64,7 @@ namespace Xamarin.iOS.Tasks {
}
}
List<string> GetDeviceTypes ()
List<string>? GetDeviceTypes ()
{
var tmpfile = Path.GetTempFileName ();
try {
@ -199,17 +202,26 @@ namespace Xamarin.iOS.Tasks {
static string GetTerminalName (int fd)
{
if (isatty (fd) != 1)
return null;
return string.Empty;
return Marshal.PtrToStringAuto (ttyname (fd));
}
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
MlaunchArguments = GenerateCommandLineCommands ();
return !Log.HasLoggedErrors;
}
public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
[DllImport ("/usr/lib/libc.dylib")]
extern static IntPtr ttyname (int filedes);