Skip to content

Commit

Permalink
[msbuild] Move shared/duplicated code into base XamarinBuildTask clas…
Browse files Browse the repository at this point in the history
…s from the FindILLink/FindAotCompiler tasks. (#19360)
  • Loading branch information
rolfbjarne committed Nov 2, 2023
1 parent b4da429 commit b4f95a6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 61 deletions.
38 changes: 0 additions & 38 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FindAotCompiler.cs

This file was deleted.

4 changes: 2 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FindAotCompilerTaskBase.cs
Expand Up @@ -5,14 +5,14 @@
using Xamarin.Localization.MSBuild;

namespace Xamarin.MacDev.Tasks {
public abstract class FindAotCompilerTaskBase : XamarinBuildTask {
public class FindAotCompiler : XamarinBuildTask {
[Required]
public ITaskItem [] MonoAotCrossCompiler { get; set; }

[Output]
public string AotCompiler { get; set; }

public override bool Execute ()
protected override bool ExecuteLocally ()
{
// If we can't find the AOT compiler path in MonoAotCrossCompiler, evaluate a project file that does know how to find it.
// This happens when executing remotely from Windows, because the MonoAotCrossCompiler item group will be empty in that case.
Expand Down
22 changes: 2 additions & 20 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FindILLink.cs
@@ -1,21 +1,15 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;

namespace Xamarin.MacDev.Tasks {
public class FindILLink : XamarinBuildTask, ITaskCallback, ICancelableTask {
public class FindILLink : XamarinBuildTask {
[Output]
public string ILLinkPath { get; set; }

public override bool Execute ()
protected override bool ExecuteLocally ()
{
if (this.ShouldExecuteRemotely (SessionId))
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;

var targetName = "ComputeILLinkTaskPath";
var target = $@"<Target Name=""{targetName}"">
<WriteLinesToFile File=""$(OutputFilePath)"" Lines=""$(ILLinkTasksAssembly)"" />
Expand All @@ -35,18 +29,6 @@ public override bool Execute ()

return !Log.HasLoggedErrors;
}

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();

public bool ShouldCopyToBuildServer (ITaskItem item) => false;

public bool ShouldCreateOutputFile (ITaskItem item) => false;

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}

24 changes: 23 additions & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinBuildTask.cs
Expand Up @@ -5,10 +5,11 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Tasks;
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;
using Threading = System.Threading.Tasks;

namespace Xamarin.MacDev.Tasks {
public abstract class XamarinBuildTask : XamarinTask {
public abstract class XamarinBuildTask : XamarinTask, ITaskCallback, ICancelableTask {
public bool KeepTemporaryOutput { get; set; }

[Required]
Expand Down Expand Up @@ -110,6 +111,27 @@ async Threading.Task<string> ExecuteBuildAsync (string dotnetPath, string projec
return File.ReadAllText (outputFile).Trim ();
return string.Empty;
}

public override sealed bool Execute ()
{
if (this.ShouldExecuteRemotely (SessionId))
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
return ExecuteLocally ();
}

protected abstract bool ExecuteLocally ();

public virtual IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();

public virtual bool ShouldCopyToBuildServer (ITaskItem item) => false;

public virtual bool ShouldCreateOutputFile (ITaskItem item) => false;

public virtual void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}

5 comments on commit b4f95a6

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Windows Integration Tests passed 💻

All Windows Integration Tests passed.

Pipeline on Agent
Hash: b4f95a67ec8c8db3f662fc51344daae64714e637 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻

All tests on macOS M1 - Mac Ventura (13.0) passed.

Pipeline on Agent
Hash: [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: b4f95a67ec8c8db3f662fc51344daae64714e637 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 [CI Build] Test results 🚀

Test results

✅ All tests passed on VSTS: simulator tests.

🎉 All 235 tests passed 🎉

Tests counts

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ introspection: All 8 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 6 tests passed. Html Report (VSDrops) Download
✅ monotouch: All 41 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download
✅ xtro: All 2 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: b4f95a67ec8c8db3f662fc51344daae64714e637 [CI build]

Please sign in to comment.