Skip to content
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
9 changes: 5 additions & 4 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,12 @@ In this message, the term "binding" means a piece of generated code that makes i
"r10d" is the version of the NDK.</comment>
</data>
<data name="XA3006" xml:space="preserve">
<value>Could not compile native assembly file: {0}</value>
<comment>In this message, the term "assembly" means the low-level language that an assembler like `as` takes as input. (This is different from most of the other messages, where the term "assembly" means the file type that the C# compiler produces.)</comment>
<value>Could not compile native assembly file: {0}{1}</value>
<comment>In this message, the term "assembly" means the low-level language that an assembler like `as` takes as input. (This is different from most of the other messages, where the term "assembly" means the file type that the C# compiler produces). The '{1}' placeholder is replaced with full output of the failed command, starting and ending with a newline.</comment>
</data>
<data name="XA3007" xml:space="preserve">
<value>Could not link native shared library: {0}</value>
<value>Could not link native shared library: {0}{1}</value>
<comment>The '{1}' placeholder is replaced with full output of the failed command, starting and ending with a newline.</comment>
</data>
<data name="XA4209" xml:space="preserve">
<value>Failed to generate Java type for class: {0} due to {1}</value>
Expand Down Expand Up @@ -886,4 +887,4 @@ In this message, the term "handheld app" means "app for handheld devices."
{1} - A Filename.
</comment>
</data>
</root>
</root>
17 changes: 12 additions & 5 deletions src/Xamarin.Android.Build.Tasks/Tasks/CompileNativeAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,24 @@ void RunAssembler (Config config)

string assemblerName = Path.GetFileName (config.AssemblerPath);
LogDebugMessage ($"[LLVM llc] {psi.FileName} {psi.Arguments}");

var stdoutLines = new List<string> ();
var stderrLines = new List<string> ();

using (var proc = new Process ()) {
proc.OutputDataReceived += (s, e) => {
if (e.Data != null)
if (e.Data != null) {
OnOutputData (assemblerName, s, e);
else
stdoutLines.Add (e.Data);
} else
stdout_completed.Set ();
};

proc.ErrorDataReceived += (s, e) => {
if (e.Data != null)
if (e.Data != null) {
OnErrorData (assemblerName, s, e);
else
stderrLines.Add (e.Data);
} else
stderr_completed.Set ();
};

Expand All @@ -87,7 +93,8 @@ void RunAssembler (Config config)
stdout_completed.WaitOne (TimeSpan.FromSeconds (30));

if (proc.ExitCode != 0) {
LogCodedError ("XA3006", Properties.Resources.XA3006, Path.GetFileName (config.InputSource));
var sb = MonoAndroidHelper.MergeStdoutAndStderrMessages (stdoutLines, stderrLines);
LogCodedError ("XA3006", Properties.Resources.XA3006, Path.GetFileName (config.InputSource), sb.ToString ());
Cancel ();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;

using Microsoft.Build.Framework;
Expand Down Expand Up @@ -67,18 +68,24 @@ void RunLinker (Config config)

string linkerName = Path.GetFileName (config.LinkerPath);
LogDebugMessage ($"[Native Linker] {psi.FileName} {psi.Arguments}");

var stdoutLines = new List<string> ();
var stderrLines = new List<string> ();

using (var proc = new Process ()) {
proc.OutputDataReceived += (s, e) => {
if (e.Data != null)
if (e.Data != null) {
OnOutputData (linkerName, s, e);
else
stdoutLines.Add (e.Data);
} else
stdout_completed.Set ();
};

proc.ErrorDataReceived += (s, e) => {
if (e.Data != null)
if (e.Data != null) {
OnErrorData (linkerName, s, e);
else
stderrLines.Add (e.Data);
} else
stderr_completed.Set ();
};

Expand All @@ -96,7 +103,8 @@ void RunLinker (Config config)
stdout_completed.WaitOne (TimeSpan.FromSeconds (30));

if (proc.ExitCode != 0) {
LogCodedError ("XA3007", Properties.Resources.XA3007, Path.GetFileName (config.OutputSharedLibrary));
var sb = MonoAndroidHelper.MergeStdoutAndStderrMessages (stdoutLines, stderrLines);
LogCodedError ("XA3007", Properties.Resources.XA3007, Path.GetFileName (config.OutputSharedLibrary), sb.ToString ());
Cancel ();
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ public partial class MonoAndroidHelper
public static AndroidVersions SupportedVersions;
public static AndroidSdkInfo AndroidSdk;

public static StringBuilder MergeStdoutAndStderrMessages (List<string> stdout, List<string> stderr)
{
var sb = new StringBuilder ();

sb.AppendLine ();
AppendLines ("stdout", stdout, sb);
sb.AppendLine ();
AppendLines ("stderr", stderr, sb);
sb.AppendLine ();

return sb;

void AppendLines (string prefix, List<string> lines, StringBuilder sb)
{
if (lines == null || lines.Count == 0) {
return;
}

foreach (string line in lines) {
sb.AppendLine ($"{prefix} | {line}");
}
}
}

public static int RunProcess (string name, string args, DataReceivedEventHandler onOutput, DataReceivedEventHandler onError, Dictionary<string, string> environmentVariables = null)
{
var psi = new ProcessStartInfo (name, args) {
Expand Down