2016-05-26 16:06:52 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
2018-11-14 21:26:30 +03:00
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
2019-01-10 02:47:22 +03:00
|
|
|
using Xamarin;
|
|
|
|
|
2016-05-26 16:06:52 +03:00
|
|
|
namespace xharness
|
|
|
|
{
|
2019-06-19 19:08:48 +03:00
|
|
|
public class MacTarget : Target
|
2016-05-26 16:06:52 +03:00
|
|
|
{
|
2019-06-19 19:46:41 +03:00
|
|
|
public MacFlavors Flavor { get; private set; }
|
|
|
|
public bool Modern => Flavor == MacFlavors.Modern;
|
|
|
|
public bool System => Flavor == MacFlavors.System;
|
|
|
|
public bool Full => Flavor == MacFlavors.Full;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
2019-06-19 19:46:41 +03:00
|
|
|
public MacTarget (MacFlavors flavor)
|
2016-05-26 16:06:52 +03:00
|
|
|
{
|
2019-06-19 19:46:41 +03:00
|
|
|
Flavor = flavor;
|
2017-10-28 00:44:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void CalculateName ()
|
|
|
|
{
|
|
|
|
base.CalculateName ();
|
|
|
|
|
2018-11-14 21:26:30 +03:00
|
|
|
if (MonoNativeInfo != null)
|
|
|
|
Name = Name + MonoNativeInfo.FlavorSuffix;
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string Suffix {
|
|
|
|
get {
|
2019-06-19 19:46:41 +03:00
|
|
|
switch (Flavor) {
|
|
|
|
case MacFlavors.Modern:
|
|
|
|
return string.Empty;
|
|
|
|
case MacFlavors.Full:
|
|
|
|
return "-full";
|
|
|
|
case MacFlavors.System:
|
2018-10-15 17:51:46 +03:00
|
|
|
return "-system";
|
2019-06-19 19:46:41 +03:00
|
|
|
default:
|
|
|
|
throw new NotImplementedException ($"Suffix for {Flavor}");
|
|
|
|
}
|
2017-10-20 18:14:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string MakefileWhereSuffix {
|
|
|
|
get {
|
2019-06-19 19:46:41 +03:00
|
|
|
switch (Flavor) {
|
|
|
|
case MacFlavors.Modern:
|
2019-06-24 17:08:13 +03:00
|
|
|
return "modern";
|
2019-06-19 19:46:41 +03:00
|
|
|
case MacFlavors.Full:
|
|
|
|
return "full";
|
|
|
|
case MacFlavors.System:
|
2018-10-15 17:51:46 +03:00
|
|
|
return "system";
|
2019-06-19 19:46:41 +03:00
|
|
|
default:
|
|
|
|
throw new NotImplementedException ($"Suffix for {Flavor}");
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string ProjectTypeGuids {
|
|
|
|
get {
|
|
|
|
return "{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};" + LanguageGuid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string BindingsProjectTypeGuids {
|
|
|
|
get {
|
|
|
|
return "{810C163F-4746-4721-8B8E-88A3673A62EA}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string TargetFrameworkIdentifier {
|
|
|
|
get {
|
|
|
|
return "Xamarin.Mac";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string Imports {
|
|
|
|
get {
|
|
|
|
return IsFSharp ? "Mac\\Xamarin.Mac.FSharp.targets" : "Mac\\Xamarin.Mac.CSharp.targets";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string BindingsImports {
|
|
|
|
get {
|
|
|
|
return "Mac\\Xamarin.Mac.ObjcBinding.CSharp";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string AdditionalDefines {
|
|
|
|
get {
|
2019-06-19 19:46:41 +03:00
|
|
|
var rv = "XAMCORE_2_0";
|
|
|
|
|
|
|
|
if (Full)
|
|
|
|
rv += ";XAMMAC_4_5";
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string RemoveDefines {
|
|
|
|
get {
|
|
|
|
var rv = string.Empty;
|
|
|
|
|
|
|
|
if (!Modern)
|
|
|
|
rv += ";XAMMAC;MOBILE";
|
|
|
|
|
|
|
|
return rv;
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string Platform {
|
|
|
|
get {
|
|
|
|
return "mac";
|
|
|
|
}
|
|
|
|
}
|
2019-06-19 19:05:36 +03:00
|
|
|
|
|
|
|
public MonoNativeInfo MonoNativeInfo { get; set; }
|
|
|
|
|
2019-06-24 09:35:50 +03:00
|
|
|
protected override bool FixProjectReference (string name, out string fixed_name)
|
2019-06-19 19:05:36 +03:00
|
|
|
{
|
2019-06-24 09:35:50 +03:00
|
|
|
fixed_name = null;
|
2019-06-19 19:05:36 +03:00
|
|
|
switch (name) {
|
|
|
|
case "GuiUnit_NET_4_5":
|
2019-06-19 19:43:24 +03:00
|
|
|
if (Flavor == MacFlavors.Full || Flavor == MacFlavors.System)
|
|
|
|
return false;
|
2019-06-24 09:35:50 +03:00
|
|
|
fixed_name = "GuiUnit_xammac_mobile";
|
2019-06-19 19:43:24 +03:00
|
|
|
return true;
|
|
|
|
case "GuiUnit_xammac_mobile":
|
|
|
|
if (Flavor == MacFlavors.Modern)
|
|
|
|
return false;
|
2019-06-24 09:35:50 +03:00
|
|
|
fixed_name = "GuiUnit_NET_4_5";
|
2019-06-19 19:43:24 +03:00
|
|
|
return true;
|
2019-06-19 19:05:36 +03:00
|
|
|
default:
|
2019-06-24 09:35:50 +03:00
|
|
|
return base.FixProjectReference (name, out fixed_name);
|
2019-06-19 19:05:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string SimplifiedName {
|
|
|
|
get {
|
|
|
|
return Name.EndsWith ("-mac", StringComparison.Ordinal) ? Name.Substring (0, Name.Length - 4) : Name;
|
|
|
|
}
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
|
2019-06-17 09:03:58 +03:00
|
|
|
public override string DefaultAssemblyReference { get { return "Xamarin.Mac"; } }
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
|
|
public override IEnumerable<string> ReferenceToRemove { get { yield return "System.Drawing"; } }
|
|
|
|
|
2019-06-19 19:23:06 +03:00
|
|
|
public override bool ShouldSetTargetFrameworkIdentifier { get { return Modern; } }
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
|
|
public override Dictionary<string, string> NewPropertiesToAdd
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2016-11-30 18:38:32 +03:00
|
|
|
var props = new Dictionary<string, string> ();
|
|
|
|
|
|
|
|
|
2018-10-15 17:51:46 +03:00
|
|
|
if (System) {
|
|
|
|
props.Add ("TargetFrameworkVersion", "v4.7.1");
|
|
|
|
props.Add ("MonoBundlingExtraArgs", "--embed-mono=no");
|
2019-06-19 19:23:06 +03:00
|
|
|
} else if (Modern)
|
2016-11-30 18:38:32 +03:00
|
|
|
{
|
|
|
|
props.Add ("TargetFrameworkVersion", "v2.0");
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
else
|
2016-11-30 18:38:32 +03:00
|
|
|
{
|
|
|
|
props.Add ("TargetFrameworkVersion", "v4.5");
|
|
|
|
props.Add ("UseXamMacFullFramework", "true");
|
|
|
|
}
|
|
|
|
|
2019-06-17 09:03:58 +03:00
|
|
|
props.Add ("XamMacArch", "x86_64");
|
2016-11-30 18:38:32 +03:00
|
|
|
return props;
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-14 21:26:30 +03:00
|
|
|
|
2019-06-17 09:03:58 +03:00
|
|
|
public override HashSet<string> PropertiesToRemove {
|
|
|
|
get {
|
|
|
|
if (!ShouldSetTargetFrameworkIdentifier)
|
|
|
|
return new HashSet<string> { "TargetFrameworkIdentifier" };
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2019-06-20 09:27:45 +03:00
|
|
|
|
|
|
|
protected override void PostProcessExecutableProject ()
|
|
|
|
{
|
|
|
|
base.PostProcessExecutableProject ();
|
|
|
|
|
|
|
|
ProjectGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}";
|
|
|
|
inputProject.SetProjectGuid (ProjectGuid);
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|