-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[msbuild] Improve the DSymUtil task. (#14344)
* Enable nullability and fix code accordingly. * Augment it to be able to take multiple files to run dsymutil on at the same time. * Execute using xcrun (ref: #3931) * Pass the full path to the executable file to dsymutil, to make command lines easier to copy-paste.
- Loading branch information
1 parent
84b1a87
commit 56829a2
Showing
3 changed files
with
37 additions
and
54 deletions.
There are no files selected for viewing
70 changes: 31 additions & 39 deletions
70
msbuild/Xamarin.MacDev.Tasks.Core/Tasks/DSymUtilTaskBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
#nullable enable | ||
|
||
namespace Xamarin.MacDev.Tasks | ||
{ | ||
public abstract class DSymUtilTaskBase : XamarinToolTask | ||
public abstract class DSymUtilTaskBase : XamarinTask | ||
{ | ||
#region Inputs | ||
|
||
[Required] | ||
public string DSymDir { get; set; } | ||
// This can also be specified as metadata on the Executable item (as 'DSymDir') | ||
public string DSymDir { get; set; } = string.Empty; | ||
|
||
[Output] | ||
[Required] | ||
public ITaskItem Executable { get; set; } | ||
public ITaskItem [] Executable { get; set; } = Array.Empty<ITaskItem> (); | ||
|
||
#endregion | ||
|
||
#region Outputs | ||
|
||
// This property is required for XVS to work properly, even though it's not used for anything in the targets. | ||
[Output] | ||
public ITaskItem[] DsymContentFiles { get; set; } | ||
public ITaskItem[] DsymContentFiles { get; set; } = Array.Empty<ITaskItem> (); | ||
|
||
#endregion | ||
|
||
protected override string ToolName { | ||
get { return "dsymutil"; } | ||
} | ||
|
||
public override bool Execute () | ||
{ | ||
var result = base.Execute (); | ||
var contentFiles = new List<ITaskItem> (); | ||
|
||
var contentsDir = Path.Combine (DSymDir, "Contents"); | ||
if (Directory.Exists(contentsDir)) | ||
DsymContentFiles = Directory.EnumerateFiles (contentsDir).Select (x => new TaskItem (x)).ToArray (); | ||
// We're not executing multiple dsymutil processes in parallel, because | ||
// we're asking dsymutil to do parallel processing (we're passing '-num-threads 4' to dsymutil) | ||
foreach (var item in Executable) { | ||
ExecuteDSymUtil (item, contentFiles); | ||
} | ||
|
||
return result; | ||
} | ||
DsymContentFiles = contentFiles.ToArray (); | ||
|
||
protected override string GenerateFullPathToTool () | ||
{ | ||
if (!string.IsNullOrEmpty (ToolPath)) | ||
return Path.Combine (ToolPath, ToolExe); | ||
|
||
var path = Path.Combine (AppleSdkSettings.DeveloperRoot, "Toolchains", "XcodeDefault.xctoolchain", "usr", "bin", ToolExe); | ||
|
||
return File.Exists (path) ? path : ToolExe; | ||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
protected override string GenerateCommandLineCommands () | ||
void ExecuteDSymUtil (ITaskItem item, List<ITaskItem> contentFiles) | ||
{ | ||
var args = new CommandLineBuilder (); | ||
var dSymDir = GetNonEmptyStringOrFallback (item, "DSymDir", DSymDir, required: true); | ||
|
||
args.AppendSwitch ("-num-threads"); | ||
args.AppendSwitch ("4"); | ||
args.AppendSwitch ("-z"); | ||
args.AppendSwitch ("-o"); | ||
args.AppendFileNameIfNotNull (DSymDir); | ||
args.AppendFileNameIfNotNull (Executable.ItemSpec); | ||
var args = new List<string> (); | ||
|
||
return args.ToString (); | ||
} | ||
args.Add ("dsymutil"); | ||
args.Add ("-num-threads"); | ||
args.Add ("4"); | ||
args.Add ("-z"); | ||
args.Add ("-o"); | ||
args.Add (dSymDir); | ||
|
||
protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance) | ||
{ | ||
if (singleLine.StartsWith ("warning:", StringComparison.Ordinal) && !singleLine.Contains ("unable to open object file: No such file or directory")) | ||
Log.LogWarning (singleLine); | ||
else | ||
Log.LogMessage (messageImportance, singleLine); | ||
args.Add (Path.GetFullPath (item.ItemSpec)); | ||
ExecuteAsync ("xcrun", args).Wait (); | ||
|
||
var contentsDir = Path.Combine (dSymDir, "Contents"); | ||
if (Directory.Exists (contentsDir)) | ||
contentFiles.AddRange (Directory.EnumerateFiles (contentsDir).Select (x => new TaskItem (x)).ToArray ()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56829a2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌
Tests failed on VSTS: simulator tests iOS.
Test results
10 tests failed, 224 tests passed.
Failed tests
No test log file was produced)
No test log file was produced)
No test log file was produced)
Pipeline on Agent XAMMINI-053.Monterey'
[msbuild] Improve the DSymUtil task. (#14344)