Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[msbuild] Make it possible to override the path to the 'strip' tool. #21581

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
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