Skip to content
Merged
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
50 changes: 29 additions & 21 deletions src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class Aot : Task

public ITaskItem[] AdditionalNativeLibraryReferences { get; set; }

public string ExtraAotOptions { get; set; }

[Output]
public string[] NativeLibrariesReferences { get; set; }

Expand Down Expand Up @@ -318,19 +320,28 @@ bool DoExecute () {
string seqpointsFile = Path.Combine(outdir, string.Format ("{0}.msym",
Path.GetFileName (assembly.ItemSpec)));

string aotOptions = string.Format (
"{0}--aot={9}{8}{1}outfile={2},asmwriter,mtriple={3},tool-prefix={4},ld-flags={5},llvm-path={6},temp-path={7}",
EnableLLVM ? "--llvm " : string.Empty,
AotMode != AotMode.Normal ? string.Format("{0},", AotMode.ToString().ToLowerInvariant()) : string.Empty,
QuoteFileName (outputFile),
mtriple,
QuoteFileName (toolPrefix),
ldFlags,
QuoteFileName (SdkBinDirectory),
QuoteFileName (outdir),
sequencePointsMode == SequencePointsMode.Offline ? string.Format("msym-dir={0},", QuoteFileName(outdir)) : string.Empty,
AotAdditionalArguments != string.Empty ? string.Format ("{0},", AotAdditionalArguments) : string.Empty
);
List<string> aotOptions = new List<string> ();

if (!string.IsNullOrEmpty (AotAdditionalArguments))
aotOptions.Add (AotAdditionalArguments);
if (sequencePointsMode == SequencePointsMode.Offline)
aotOptions.Add ("msym-dir=" + QuoteFileName (outdir));
if (AotMode != AotMode.Normal)
aotOptions.Add (AotMode.ToString ().ToLowerInvariant ());

aotOptions.Add ("outfile=" + QuoteFileName (outputFile));
aotOptions.Add ("asmwriter");
aotOptions.Add ("mtriple=" + mtriple);
aotOptions.Add ("tool-prefix=" + QuoteFileName (toolPrefix));
aotOptions.Add ("ld-flags=" + ldFlags);
aotOptions.Add ("llvm-path=" + QuoteFileName (SdkBinDirectory));
aotOptions.Add ("temp-path=" + QuoteFileName (outdir));

string aotOptionsStr = (EnableLLVM ? "--llvm " : "") + "--aot=" + string.Join (",", aotOptions);

if (!string.IsNullOrEmpty (ExtraAotOptions)) {
aotOptionsStr += (aotOptions.Count > 0 ? "," : "") + ExtraAotOptions;
}

// Due to a Monodroid MSBuild bug we can end up with paths to assemblies that are not in the intermediate
// assembly directory (typically obj/assemblies). This can lead to problems with the Mono loader not being
Expand All @@ -348,7 +359,7 @@ bool DoExecute () {
var assembliesPath = Path.GetFullPath (Path.GetDirectoryName (resolvedPath));
var assemblyPath = QuoteFileName (Path.GetFullPath (resolvedPath));

if (!RunAotCompiler (assembliesPath, aotCompiler, aotOptions, assemblyPath)) {
if (!RunAotCompiler (assembliesPath, aotCompiler, aotOptionsStr, assemblyPath)) {
Log.LogCodedError ("XA3001", "Could not AOT the assembly: {0}", assembly.ItemSpec);
return false;
}
Expand All @@ -366,15 +377,9 @@ bool DoExecute () {

bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOptions, string assembly)
{
var arguments = aotOptions + " " + assembly;

Log.LogMessage (MessageImportance.High, "[AOT] " + assembly);
Log.LogMessage (MessageImportance.Low, "Mono arguments: " + arguments);
Log.LogMessage (MessageImportance.Low, "MONO_PATH=" + assembliesPath);

var psi = new ProcessStartInfo () {
FileName = aotCompiler,
Arguments = arguments,
Arguments = aotOptions + " \"" + assembly + "\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
Expand All @@ -388,6 +393,9 @@ bool RunAotCompiler (string assembliesPath, string aotCompiler, string aotOption
// so we provide this out-of-band to the cross-compilers - this can be extended to communicate a few others bits as well
psi.EnvironmentVariables ["MONO_PATH"] = assembliesPath;

Log.LogDebugMessage ("[AOT] MONO_PATH=\"{0}\" MONO_ENV_OPTIONS=\"{1}\" {2} {3}",
psi.EnvironmentVariables ["MONO_PATH"], psi.EnvironmentVariables ["MONO_ENV_OPTIONS"], psi.FileName, psi.Arguments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be High? It means we will always how this regardless of the verbosity set. We should be using Log.LogDebugMessage instead? This would mean it only shows up in diagnostic builds.


var proc = new Process ();
proc.OutputDataReceived += OnAotOutputData;
proc.ErrorDataReceived += OnAotErrorData;
Expand Down