Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ The full path to the `altool` tool.

The default behavior is to use `xcrun altool`.

## ACToolPath

The full path to the `actool` tool.

The default behavior is to use `xcrun actool`.

## AppBundleResourcePrefix

The directory where resources are stored (this prefix will be removed when copying resources to the app bundle).
Expand Down Expand Up @@ -517,6 +523,12 @@ Default: true

Where the generated source from the generator are saved.

## IBToolPath

The full path to the `ibtool` tool.

The default behavior is to use `xcrun ibtool`.

## IncludeAllAppIcons

Set the `IncludeAllAppIcons` property to true to automatically include all app
Expand Down Expand Up @@ -1261,6 +1273,12 @@ It's also possible to use a platform-specific property:
* [macOSMinimumVersion](#macosminimumversion)
* [MacCatalystMinimumVersion](#maccatalystminimumversion)

## TextureAtlasPath

The full path to the `TextureAtlas` tool.

The default behavior is to use `xcrun TextureAtlas`.

## TrimMode

Specifies the trimming granularity.
Expand Down
12 changes: 1 addition & 11 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ACTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Xamarin.Utils;

namespace Xamarin.MacDev.Tasks {
public class ACTool : XcodeCompilerToolTask, ICancelableTask {
public class ACTool : XcodeCompilerToolTask {
string? outputSpecs;
string? partialAppManifestPath;

Expand Down Expand Up @@ -58,10 +58,6 @@ public class ACTool : XcodeCompilerToolTask, ICancelableTask {
HashSet<string> brandAssetsInAssets = new (); // tvOS
HashSet<string> imageStacksInAssets = new (); // tvOS

protected override string DefaultBinDir {
get { return DeveloperRootBinDir; }
}

protected override string ToolName {
get { return "actool"; }
}
Expand Down Expand Up @@ -544,12 +540,6 @@ public override bool Execute ()

return !Log.HasLoggedErrors;
}

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

class AssetInfo {
Expand Down
12 changes: 1 addition & 11 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/IBTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Xamarin.Utils;

namespace Xamarin.MacDev.Tasks {
public class IBTool : XcodeCompilerToolTask, ICancelableTask {
public class IBTool : XcodeCompilerToolTask {
static readonly string [] WatchAppExtensions = { "-glance.plist", "-notification.plist" };

#region Inputs
Expand All @@ -30,10 +30,6 @@ public class IBTool : XcodeCompilerToolTask, ICancelableTask {

#endregion

protected override string DefaultBinDir {
get { return DeveloperRootBinDir; }
}

protected override string ToolName {
get { return "ibtool"; }
}
Expand Down Expand Up @@ -459,11 +455,5 @@ public override bool Execute ()

return !Log.HasLoggedErrors;
}

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}
14 changes: 2 additions & 12 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/TextureAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#nullable enable

namespace Xamarin.MacDev.Tasks {
public class TextureAtlas : XcodeToolTaskBase, ICancelableTask {
public class TextureAtlas : XcodeToolTaskBase {
readonly Dictionary<string, (ITaskItem Item, List<ITaskItem> Items)> atlases = new ();

#region Inputs
Expand All @@ -20,15 +20,11 @@ public class TextureAtlas : XcodeToolTaskBase, ICancelableTask {

#endregion

protected override string DefaultBinDir {
get { return DeveloperRootBinDir; }
}

protected override string ToolName {
get { return "TextureAtlas"; }
}

protected override void AppendCommandLineArguments (IDictionary<string, string?> environment, List<string> args, ITaskItem input, ITaskItem output)
protected override void AppendCommandLineArguments (List<string> args, ITaskItem input, ITaskItem output)
{
args.Add (input.GetMetadata ("FullPath"));
args.Add (Path.GetDirectoryName (output.GetMetadata ("FullPath"))!);
Expand Down Expand Up @@ -117,11 +113,5 @@ public override bool Execute ()

return base.Execute ();
}

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}
54 changes: 25 additions & 29 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeCompilerToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
using Xamarin.Localization.MSBuild;

using Xamarin.MacDev;
using Xamarin.Messaging.Build.Client;
using Xamarin.Utils;

#nullable enable

namespace Xamarin.MacDev.Tasks {
public abstract class XcodeCompilerToolTask : XamarinTask, IHasProjectDir, IHasResourcePrefix {
public abstract class XcodeCompilerToolTask : XamarinTask, IHasProjectDir, IHasResourcePrefix, ICancelableTask {
CancellationTokenSource cancellationTokenSource = new ();

protected bool Link { get; set; }
string? toolExe;

#region Inputs

Expand All @@ -44,11 +46,6 @@ public abstract class XcodeCompilerToolTask : XamarinTask, IHasProjectDir, IHasR
[Required]
public string SdkVersion { get; set; } = string.Empty;

public string ToolExe {
get { return toolExe ?? ToolName; }
set { toolExe = value; }
}

public string ToolPath { get; set; } = string.Empty;

#endregion
Expand Down Expand Up @@ -87,14 +84,6 @@ public IPhoneDeviceType ParsedUIDeviceFamily {
}
}

protected abstract string DefaultBinDir {
get;
}

protected string DeveloperRootBinDir {
get { return Path.Combine (GetSdkDevPath (), "usr", "bin"); }
}

protected abstract string ToolName { get; }

protected virtual bool UseCompilationDirectory {
Expand Down Expand Up @@ -170,18 +159,6 @@ protected int Compile (ITaskItem [] items, string output, ITaskItem manifest)
var environment = new Dictionary<string, string?> ();
var args = new List<string> ();

// workaround for ibtool[d] bug / asserts if Intel version is loaded
string tool;
if (IsTranslated ()) {
// we force the Intel (translated) msbuild process to launch ibtool as "Apple"
tool = "arch";
args.Add ("-arch");
args.Add ("arm64e");
args.Add ("/usr/bin/xcrun");
} else {
tool = "/usr/bin/xcrun";
}
args.Add (ToolName);
args.Add ("--errors");
args.Add ("--warnings");
args.Add ("--notices");
Expand All @@ -202,11 +179,21 @@ protected int Compile (ITaskItem [] items, string output, ITaskItem manifest)
foreach (var item in items)
args.Add (item.GetMetadata ("FullPath"));

// don't bother executing the tool if we've already looged errors.
var executable = GetExecutable (args, ToolName, ToolPath);
// workaround for ibtool[d] bug / asserts if Intel version is loaded
if (IsTranslated ()) {
// we force the Intel (translated) msbuild process to launch ibtool as "Apple"
args.Insert (0, "-arch");
args.Insert (1, "arm64e");
args.Insert (2, executable);
executable = "arch";
}

// don't bother executing the tool if we've already logged errors.
if (Log.HasLoggedErrors)
return 1;

var rv = ExecuteAsync (tool, args, environment: environment).Result;
var rv = ExecuteAsync (executable, args, environment: environment, cancellationToken: cancellationTokenSource.Token).Result;
var exitCode = rv.ExitCode;
var messages = rv.Output.StandardOutput;
File.WriteAllText (manifest.ItemSpec, messages);
Expand Down Expand Up @@ -310,5 +297,14 @@ protected void LogWarningsAndErrors (PDictionary plist, ITaskItem file)
}
}
}

public void Cancel ()
{
if (ShouldExecuteRemotely ()) {
BuildConnection.CancelAsync (BuildEngine4).Wait ();
} else {
cancellationTokenSource?.Cancel ();
}
}
}
}
54 changes: 17 additions & 37 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/XcodeTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
using System.Diagnostics;
using System.ComponentModel;
using System.Collections.Generic;
using System.Threading;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Xamarin.Localization.MSBuild;

using Xamarin.MacDev;
using Xamarin.Messaging.Build.Client;

#nullable enable

namespace Xamarin.MacDev.Tasks {
public abstract class XcodeToolTaskBase : XamarinTask, IHasProjectDir, IHasResourcePrefix {
string? toolExe;
public abstract class XcodeToolTaskBase : XamarinTask, IHasProjectDir, IHasResourcePrefix, ICancelableTask {
CancellationTokenSource cancellationTokenSource = new ();

#region Inputs

Expand All @@ -27,11 +29,6 @@ public abstract class XcodeToolTaskBase : XamarinTask, IHasProjectDir, IHasResou
[Required]
public string ResourcePrefix { get; set; } = string.Empty;

public string ToolExe {
get { return toolExe ?? ToolName; }
set { toolExe = value; }
}

public string ToolPath { get; set; } = string.Empty;

#endregion
Expand All @@ -43,27 +40,11 @@ public string ToolExe {

#endregion

protected abstract string DefaultBinDir {
get;
}

protected string DeveloperRootBinDir {
get { return Path.Combine (GetSdkDevPath (), "usr", "bin"); }
}

protected string DevicePlatformBinDir {
get { return Path.Combine (GetSdkDevPath (), "Platforms", "iPhoneOS.platform", "Developer", "usr", "bin"); }
}

protected string SimulatorPlatformBinDir {
get { return Path.Combine (GetSdkDevPath (), "Platforms", "iPhoneSimulator.platform", "Developer", "usr", "bin"); }
}

protected abstract string ToolName { get; }

protected abstract IEnumerable<ITaskItem> EnumerateInputs ();

protected abstract void AppendCommandLineArguments (IDictionary<string, string?> environment, List<string> args, ITaskItem input, ITaskItem output);
protected abstract void AppendCommandLineArguments (List<string> args, ITaskItem input, ITaskItem output);

protected virtual string GetBundleRelativeOutputPath (ITaskItem input)
{
Expand All @@ -83,24 +64,14 @@ protected virtual bool NeedsBuilding (ITaskItem input, ITaskItem output)
return !File.Exists (dest) || File.GetLastWriteTimeUtc (src) > File.GetLastWriteTimeUtc (dest);
}

string GetFullPathToTool ()
{
if (!string.IsNullOrEmpty (ToolPath))
return Path.Combine (ToolPath, ToolExe);

var path = Path.Combine (DefaultBinDir, ToolExe);

return File.Exists (path) ? path : ToolExe;
}

int ExecuteTool (ITaskItem input, ITaskItem output)
{
var environment = new Dictionary<string, string?> ();
var args = new List<string> ();

AppendCommandLineArguments (environment, args, input, output);
AppendCommandLineArguments (args, input, output);

var rv = ExecuteAsync (GetFullPathToTool (), args, environment: environment).Result;
var executable = GetExecutable (args, ToolName, ToolPath);
var rv = ExecuteAsync (executable, args, cancellationToken: cancellationTokenSource.Token).Result;
return rv.ExitCode;
}

Expand Down Expand Up @@ -142,5 +113,14 @@ public override bool Execute ()

return !Log.HasLoggedErrors;
}

public void Cancel ()
{
if (ShouldExecuteRemotely ()) {
BuildConnection.CancelAsync (BuildEngine4).Wait ();
} else {
cancellationTokenSource?.Cancel ();
}
}
}
}
3 changes: 0 additions & 3 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<IBTool
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(IBToolExe)"
ToolPath="$(IBToolPath)"
BundleIdentifier="$(_BundleIdentifier)"
CLKComplicationGroup="$(_CLKComplicationGroup)"
Expand Down Expand Up @@ -1020,7 +1019,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<ACTool
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '@(ImageAsset)' != ''"
ToolExe="$(ACToolExe)"
ToolPath="$(ACToolPath)"
AccentColor="$(AccentColor)"
AlternateAppIcons="@(AlternateAppIcon)"
Expand Down Expand Up @@ -1446,7 +1444,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<TextureAtlas
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(TextureAtlasExe)"
ToolPath="$(TextureAtlasPath)"
AtlasTextures="@(AtlasTexture)"
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
Expand Down
Loading