-
Notifications
You must be signed in to change notification settings - Fork 486
/
MLaunchTool.cs
110 lines (93 loc) · 2.56 KB
/
MLaunchTool.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Text;
using Xamarin.Utils;
using Xamarin.Tests;
namespace Xamarin
{
class MLaunchTool : Tool
{
public enum MLaunchAction
{
None,
Sim,
Dev,
}
public const string None = "None";
#pragma warning disable 649
public int Verbosity;
public string SdkRoot;
public string Sdk;
public string AppPath;
#pragma warning restore 649
// These are a bit smarter
public MLaunchAction Action = MLaunchAction.Sim;
public Profile Profile = Profile.iOS;
string GetVerbosity ()
{
if (Verbosity == 0)
return string.Empty;
if (Verbosity > 0)
return new string ('-', Verbosity).Replace ("-", "-v ");
return new string ('-', -Verbosity).Replace ("-", "-q ");
}
public int Execute ()
{
return Execute (Configuration.MlaunchPath, BuildArguments ());
}
string BuildArguments ()
{
var sb = new StringBuilder ();
switch (Action) {
case MLaunchAction.None:
break;
case MLaunchAction.Sim:
if (AppPath == null)
throw new Exception ("No AppPath specified.");
sb.Append (" --launchsim ").Append (StringUtils.Quote (AppPath));
break;
default:
throw new Exception ("MLaunchAction not specified.");
}
if (SdkRoot == None) {
// do nothing
} else if (!string.IsNullOrEmpty (SdkRoot)) {
sb.Append (" --sdkroot ").Append (StringUtils.Quote (SdkRoot));
} else {
sb.Append (" --sdkroot ").Append (StringUtils.Quote (Configuration.xcode_root));
}
sb.Append (" ").Append (GetVerbosity ());
if (Sdk == None) {
// do nothing
} else if (!string.IsNullOrEmpty (Sdk)) {
sb.Append (" --sdk ").Append (Sdk);
} else {
sb.Append (" --sdk ").Append (MTouch.GetSdkVersion (Profile));
}
string platformName = null;
string simType = null;
switch (Profile) {
case Profile.iOS:
platformName = "iOS";
simType = "iPhone-SE";
break;
case Profile.tvOS:
platformName = "tvOS";
simType = "Apple-TV-1080p";
break;
default:
throw new Exception ("Profile not specified.");
}
if (!string.IsNullOrEmpty (platformName) && !string.IsNullOrEmpty (simType)) {
var device = string.Format (":v2:runtime=com.apple.CoreSimulator.SimRuntime.{0}-{1},devicetype=com.apple.CoreSimulator.SimDeviceType.{2}", platformName, Configuration.sdk_version.Replace ('.', '-'), simType);
sb.Append (" --device:").Append (StringUtils.Quote (device));
}
return sb.ToString ();
}
protected override string ToolPath {
get { return Configuration.MlaunchPath; }
}
protected override string MessagePrefix {
get { return "HT"; }
}
}
}