Skip to content

Commit

Permalink
[msbuild] Make it possible to override the path to the 'strip' tool. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Nov 5, 2024
1 parent eafa2d1 commit 70b61c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/build-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ The default behavior is to use `xcrun metallib`.
The full path to the Metal compiler.

The default behavior is to use `xcrun metal`.

## StripPath

The full path to the `strip` command-line tool.

The default behavior is to use `xcrun strip`.
16 changes: 13 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class SymbolStrip : XamarinParallelTask, ITaskCallback {
[Required]
public ITaskItem [] Executable { get; set; } = Array.Empty<ITaskItem> ();

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

// This can also be specified as metadata on the Executable item (as 'SymbolFile')
public string SymbolFile { get; set; } = string.Empty;

Expand All @@ -31,11 +33,19 @@ bool GetIsFramework (ITaskItem item)
return string.Equals (value, "Framework", StringComparison.OrdinalIgnoreCase);
}

static string GetExecutable (List<string> arguments, string toolName, string toolPathOverride)
{
if (string.IsNullOrEmpty (toolPathOverride)) {
arguments.Insert (0, toolName);
return "xcrun";
}
return toolPathOverride;
}

void ExecuteStrip (ITaskItem item)
{
var args = new List<string> ();

args.Add ("strip");
var executable = GetExecutable (args, "strip", StripPath);

var symbolFile = GetNonEmptyStringOrFallback (item, "SymbolFile", SymbolFile);
if (!string.IsNullOrEmpty (symbolFile)) {
Expand All @@ -52,7 +62,7 @@ void ExecuteStrip (ITaskItem item)

args.Add (Path.GetFullPath (item.ItemSpec));

ExecuteAsync ("xcrun", args).Wait ();
ExecuteAsync (executable, args).Wait ();
}

public override bool Execute ()
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Executable="$(_AppContainerDir)%(_NativeStripItems.Identity)"
Kind="%(_NativeStripItems.Kind)"
MaxDegreeOfParallelism="$(SymbolStripMaxDegreeOfParallelism)"
StripPath="$(StripPath)"
SymbolFile="%(_NativeStripItems.SymbolFile)"
/>

Expand Down

5 comments on commit 70b61c1

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.