/
Emulator.cs
67 lines (52 loc) · 1.62 KB
/
Emulator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Xamarin.Android.BuildTools.PrepTasks;
namespace Xamarin.Android.Tools.BootstrapTasks
{
public class Emulator : PathToolTask
{
public string Arguments { get; set; }
[Output]
public string[] Output { get; set; }
protected virtual bool LogTaskMessages {
get { return true; }
}
protected override string ToolBaseName {
get { return "emulator"; }
}
List<string> lines;
List<string> Lines {
get { return lines ?? (lines = new List<string> ()); }
}
public override bool Execute ()
{
if (LogTaskMessages) {
Log.LogMessage (MessageImportance.Low, $"Task {nameof (Emulator)}");
Log.LogMessage (MessageImportance.Low, $" {nameof (Arguments)}: {Arguments}");
}
base.Execute ();
Output = lines?.ToArray ();
if (LogTaskMessages) {
Log.LogMessage (MessageImportance.Low, $" [Output] {nameof (Output)}:");
foreach (var line in (Output ?? Array.Empty<string> ()))
Log.LogMessage (MessageImportance.Low, $" {line}");
}
return !Log.HasLoggedErrors;
}
protected override string GenerateCommandLineCommands ()
{
return Arguments;
}
protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance)
{
base.LogEventsFromTextOutput (singleLine, messageImportance);
Lines.Add (singleLine);
}
}
}