Skip to content

Commit

Permalink
[msbuild] Merge the FilterStaticFrameworks[TaskBase] classes. (xamari…
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Dec 20, 2023
1 parent 729d347 commit 51aaac3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 45 deletions.
44 changes: 0 additions & 44 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;
using Xamarin.Utils;

namespace Xamarin.MacDev.Tasks {
// This task takes an itemgroup of frameworks, and filters out frameworks that aren't dynamic libraries.
public abstract class FilterStaticFrameworksTaskBase : XamarinTask {
public class FilterStaticFrameworks : XamarinTask, ITaskCallback {
public bool OnlyFilterFrameworks { get; set; }

[Output]
public ITaskItem []? FrameworkToPublish { get; set; }

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

if (FrameworkToPublish is not null && FrameworkToPublish.Length > 0) {
var list = FrameworkToPublish.ToList ();
for (var i = list.Count - 1; i >= 0; i--) {
Expand Down Expand Up @@ -57,5 +63,26 @@ public override bool Execute ()

return !Log.HasLoggedErrors;
}

public bool ShouldCopyToBuildServer (ITaskItem item) => true;

public bool ShouldCreateOutputFile (ITaskItem item) => false;

public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
{
if (FrameworkToPublish is not null) {
foreach (var item in FrameworkToPublish) {
var fw = item.ItemSpec;
// Copy all the files from the framework to the mac (copying only the executable won't work if it's just a symlink to elsewhere)
if (File.Exists (fw))
fw = Path.GetDirectoryName (fw);
if (!Directory.Exists (fw))
continue;
foreach (var file in Directory.EnumerateFiles (fw, "*.*", SearchOption.AllDirectories)) {
yield return new TaskItem (file);
}
}
}
}
}
}

0 comments on commit 51aaac3

Please sign in to comment.