[msbuild] Merge the LinkNativeCode[TaskBase] classes. (#19741)
This commit is contained in:
Родитель
8d56ae186d
Коммит
76c642097f
|
@ -1,34 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Build.Framework;
|
||||
using Xamarin.Messaging.Build.Client;
|
||||
using Xamarin.Utils;
|
||||
|
||||
// Disable until we get around to enable + fix any issues.
|
||||
#nullable disable
|
||||
|
||||
namespace Xamarin.MacDev.Tasks {
|
||||
public class LinkNativeCode : LinkNativeCodeTaskBase, ITaskCallback {
|
||||
string outputPath;
|
||||
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (ShouldExecuteRemotely ()) {
|
||||
outputPath = PathUtils.ConvertToMacPath (Path.GetDirectoryName (OutputFile));
|
||||
|
||||
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
|
||||
}
|
||||
|
||||
return base.Execute ();
|
||||
}
|
||||
|
||||
// We should avoid copying files from the output path because those already exist on the Mac
|
||||
// and the ones on Windows are empty, so we will break the build
|
||||
public bool ShouldCopyToBuildServer (ITaskItem item) => !PathUtils.ConvertToMacPath (item.ItemSpec).StartsWith (outputPath);
|
||||
|
||||
public bool ShouldCreateOutputFile (ITaskItem item) => false;
|
||||
|
||||
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
|
||||
}
|
||||
}
|
|
@ -6,13 +6,15 @@ using System.Linq;
|
|||
using Microsoft.Build.Framework;
|
||||
|
||||
using Xamarin.Localization.MSBuild;
|
||||
using Xamarin.Messaging.Build.Client;
|
||||
using Xamarin.Utils;
|
||||
|
||||
// Disable until we get around to enable + fix any issues.
|
||||
#nullable disable
|
||||
|
||||
namespace Xamarin.MacDev.Tasks {
|
||||
public abstract class LinkNativeCodeTaskBase : XamarinTask {
|
||||
public class LinkNativeCode : XamarinTask, ITaskCallback {
|
||||
string outputPath;
|
||||
|
||||
#region Inputs
|
||||
public ITaskItem [] LinkerFlags { get; set; }
|
||||
|
@ -56,6 +58,12 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (ShouldExecuteRemotely ()) {
|
||||
outputPath = PathUtils.ConvertToMacPath (Path.GetDirectoryName (OutputFile));
|
||||
|
||||
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
|
||||
}
|
||||
|
||||
try {
|
||||
return ExecuteUnsafe ();
|
||||
} catch (Exception e) {
|
||||
|
@ -243,5 +251,13 @@ namespace Xamarin.MacDev.Tasks {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// We should avoid copying files from the output path because those already exist on the Mac
|
||||
// and the ones on Windows are empty, so we will break the build
|
||||
public bool ShouldCopyToBuildServer (ITaskItem item) => !PathUtils.ConvertToMacPath (item.ItemSpec).StartsWith (outputPath);
|
||||
|
||||
public bool ShouldCreateOutputFile (ITaskItem item) => false;
|
||||
|
||||
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ namespace Xamarin.iOS.Tasks {
|
|||
}
|
||||
|
||||
gcc.BuildNativeReferenceFlags (Log, NativeReferences);
|
||||
gcc.Arguments.AddQuoted (LinkNativeCodeTaskBase.GetEmbedEntitlementsInExecutableLinkerFlags (CompiledEntitlements));
|
||||
gcc.Arguments.AddQuoted (LinkNativeCode.GetEmbedEntitlementsInExecutableLinkerFlags (CompiledEntitlements));
|
||||
|
||||
foreach (var framework in gcc.Frameworks)
|
||||
args.AddQuotedLine ($"--framework={Path.GetFullPath (framework)}");
|
||||
|
|
Загрузка…
Ссылка в новой задаче