[xharness]: Add xharness support for mono-native.

This commit is contained in:
Martin Baulig 2018-11-14 13:26:30 -05:00
Родитель 91169d6112
Коммит 6ff0ddd74c
14 изменённых файлов: 650 добавлений и 50 удалений

Просмотреть файл

@ -290,6 +290,19 @@ namespace xharness
MacTestProjects.Add (bclTestProject);
}
}
foreach (var flavor in new MonoNativeFlavor[] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) {
foreach (var macFlavor in new MacFlavors[] { MacFlavors.Full, MacFlavors.Modern }) {
var monoNativeInfo = new MacMonoNativeInfo (this, flavor, macFlavor);
var macTestProject = new MacTestProject (monoNativeInfo.ProjectPath, targetFrameworkFlavor: macFlavor, generateVariations: true) {
MonoNativeInfo = monoNativeInfo,
Name = monoNativeInfo.ProjectName,
Platform = "AnyCPU"
};
MacTestProjects.Add (macTestProject);
}
}
}
void AutoConfigureIOS ()
@ -353,6 +366,16 @@ namespace xharness
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link all", "link all.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "link sdk", "link sdk.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
foreach (var flavor in new MonoNativeFlavor[] { MonoNativeFlavor.Compat, MonoNativeFlavor.Unified }) {
var monoNativeInfo = new MonoNativeInfo (this, flavor);
var iosTestProject = new iOSTestProject (monoNativeInfo.ProjectPath, generateVariations: false) {
MonoNativeInfo = monoNativeInfo,
Name = monoNativeInfo.ProjectName
};
IOSTestProjects.Add (iosTestProject);
}
WatchOSContainerTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "templates/WatchContainer"));
WatchOSAppTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "templates/WatchApp"));
WatchOSExtensionTemplate = Path.GetFullPath (Path.Combine (RootDirectory, "templates/WatchExtension"));
@ -430,22 +453,28 @@ namespace xharness
foreach (var bclTestInfo in MacTestProjects.Where (x => x.BCLInfo != null).Select (x => x.BCLInfo))
bclTestInfo.Convert ();
foreach (var monoNativeInfo in MacTestProjects.Where (x => x.MonoNativeInfo != null).Select (x => x.MonoNativeInfo))
monoNativeInfo.Convert ();
foreach (var proj in MacTestProjects.Where ((v) => v.GenerateVariations)) {
var file = Path.ChangeExtension (proj.Path, "csproj");
if (!File.Exists (file))
if (proj.MonoNativeInfo != null)
file = proj.MonoNativeInfo.TemplatePath;
if (!File.Exists (file))
throw new FileNotFoundException (file);
foreach (bool thirtyTwoBit in new bool[] { false, true })
{
if (proj.GenerateModern) {
var modern = new MacUnifiedTarget (true, thirtyTwoBit);
modern.MonoNativeInfo = proj.MonoNativeInfo;
configureTarget (modern, file, proj.IsNUnitProject);
unified_targets.Add (modern);
}
if (proj.GenerateFull) {
var full = new MacUnifiedTarget (false, thirtyTwoBit);
full.MonoNativeInfo = proj.MonoNativeInfo;
configureTarget (full, file, proj.IsNUnitProject);
unified_targets.Add (full);
}
@ -458,9 +487,11 @@ namespace xharness
unified_targets.Add (system);
}
var classic = new MacClassicTarget ();
configureTarget (classic, file, false);
classic_targets.Add (classic);
if (proj.MonoNativeInfo == null) {
var classic = new MacClassicTarget ();
configureTarget (classic, file, false);
classic_targets.Add (classic);
}
}
foreach (var proj in MacTestProjects.Where (v => !v.GenerateVariations)) {
@ -488,9 +519,13 @@ namespace xharness
foreach (var bclTestInfo in IOSTestProjects.Where (x => x.BCLInfo != null).Select (x => x.BCLInfo))
bclTestInfo.Convert ();
foreach (var monoNativeInfo in IOSTestProjects.Where (x => x.MonoNativeInfo != null).Select (x => x.MonoNativeInfo))
monoNativeInfo.Convert ();
foreach (var proj in IOSTestProjects) {
var file = proj.Path;
if (proj.MonoNativeInfo != null)
file = proj.MonoNativeInfo.TemplatePath;
if (!File.Exists (file))
throw new FileNotFoundException (file);

Просмотреть файл

@ -127,6 +127,10 @@ namespace xharness
targets = new AppRunnerTarget [] { AppRunnerTarget.Simulator_iOS32, AppRunnerTarget.Simulator_iOS64 };
platforms = new TestPlatform [] { TestPlatform.iOS_Unified32, TestPlatform.iOS_Unified64 };
break;
case TestPlatform.iOS_TodayExtension64:
targets = new AppRunnerTarget[] { AppRunnerTarget.Simulator_iOS64 };
platforms = new TestPlatform[] { TestPlatform.iOS_TodayExtension64 };
break;
default:
throw new NotImplementedException ();
}
@ -162,23 +166,118 @@ namespace xharness
public string Defines;
public string Undefines;
public bool Ignored;
public MonoNativeFlavor MonoNativeFlavor;
public MonoNativeLinkMode MonoNativeLinkMode;
}
IEnumerable<TestData> GetTestData (RunTestTask test)
{
// This function returns additional test configurations (in addition to the default one) for the specific test
MonoNativeFlavor flavor;
switch (test.TestName) {
case "mono-native-compat":
flavor = MonoNativeFlavor.Compat;
break;
case "mono-native-unified":
flavor = MonoNativeFlavor.Unified;
break;
default:
flavor = MonoNativeFlavor.None;
break;
}
if (flavor != MonoNativeFlavor.None) {
switch (test.ProjectPlatform) {
case "iPhone":
/* we don't add --assembly-build-target=@all=staticobject because that's the default in all our test projects */
yield return new TestData {
Variation = "AssemblyBuildTarget: dylib (debug)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary",
Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: dylib (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary",
Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: SDK framework (debug)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject",
Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject",
Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: SDK framework (release)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject",
Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: dylib (release)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary",
Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: dylib (release, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary",
Debug = false, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "AssemblyBuildTarget: SDK framework (release, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject",
Debug = false, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false,
MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all",
Debug = false, Profiling = false, LinkMode = "Full", MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static",
Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all",
Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ",
MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
break;
case "iPhoneSimulator":
yield return new TestData {
Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false,
MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all",
Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ",
MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static",
Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
yield return new TestData {
Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all",
Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ",
MonoNativeLinkMode = MonoNativeLinkMode.Static, MonoNativeFlavor = flavor
};
break;
}
yield break;
}
switch (test.ProjectPlatform) {
case "iPhone":
/* we don't add --assembly-build-target=@all=staticobject because that's the default in all our test projects */
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = false };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = false };
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = true };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = true };
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (debug, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = true, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = false };
yield return new TestData { Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
switch (test.TestName) {
case "monotouch-test":
@ -195,6 +294,20 @@ namespace xharness
yield return new TestData { Variation = "Debug (interpreter)", MTouchExtraArgs = "--interpreter", Debug = true, Profiling = false, Undefines = "FULL_AOT_RUNTIME" };
yield return new TestData { Variation = "Debug (interpreter -mscorlib)", MTouchExtraArgs = "--interpreter=-mscorlib", Debug = true, Profiling = false, Undefines = "FULL_AOT_RUNTIME" };
break;
#if FIXME
case "mono-native-compat":
case "mono-native-unified":
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (release)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "AssemblyBuildTarget: dylib (release, profiling)", MTouchExtraArgs = "--assembly-build-target=@all=dynamiclibrary", Debug = false, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "AssemblyBuildTarget: SDK framework (release, profiling)", MTouchExtraArgs = "--assembly-build-target=@sdk=framework=Xamarin.Sdk --assembly-build-target=@all=staticobject", Debug = false, Profiling = true, MonoNativeLinkMode = MonoNativeLinkMode.Dynamic };
yield return new TestData { Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ", MonoNativeLinkMode = MonoNativeLinkMode.Static };
break;
#endif
}
break;
case "iPhoneSimulator":
@ -205,6 +318,16 @@ namespace xharness
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL" };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all,-remove-uithread-checks", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL", Ignored = !IncludeAll };
break;
#if FIXME
case "mono-native-compat":
case "mono-native-unified":
yield return new TestData { Variation = "Release", MTouchExtraArgs = "", Debug = false, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Release (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = false, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ", MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Debug (static registrar)", MTouchExtraArgs = "--registrar:static", Debug = true, Profiling = false, MonoNativeLinkMode = MonoNativeLinkMode.Static };
yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL; ", MonoNativeLinkMode = MonoNativeLinkMode.Static };
break;
#endif
}
break;
case "AnyCPU":
@ -254,6 +377,7 @@ namespace xharness
await clone.CreateCopyAsync (task);
var isMac = false;
var canSymlink = false;
switch (task.Platform) {
case TestPlatform.Mac:
case TestPlatform.Mac_Classic:
@ -264,6 +388,13 @@ namespace xharness
case TestPlatform.Mac_UnifiedSystem:
isMac = true;
break;
case TestPlatform.iOS:
case TestPlatform.iOS_TodayExtension64:
case TestPlatform.iOS_Unified:
case TestPlatform.iOS_Unified32:
case TestPlatform.iOS_Unified64:
canSymlink = true;
break;
}
if (!string.IsNullOrEmpty (mtouch_extra_args))
@ -291,6 +422,12 @@ namespace xharness
}
}
clone.Xml.SetNode (isMac ? "Profiling" : "MTouchProfiling", profiling ? "True" : "False", task.ProjectPlatform, configuration);
if (test_data.MonoNativeFlavor != MonoNativeFlavor.None) {
var mono_native_link = test_data.MonoNativeLinkMode;
if (!canSymlink && mono_native_link == MonoNativeLinkMode.Symlink)
mono_native_link = MonoNativeLinkMode.Static;
MonoNativeHelper.AddProjectDefines (clone.Xml, test_data.MonoNativeFlavor, mono_native_link, task.ProjectPlatform, configuration);
}
if (!debug && !isMac)
clone.Xml.SetMtouchUseLlvm (true, task.ProjectPlatform, configuration);
@ -331,6 +468,8 @@ namespace xharness
var ps = new List<Tuple<TestProject, TestPlatform, bool>> ();
if (!project.SkipiOSVariation)
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project, TestPlatform.iOS_Unified, ignored || !IncludeiOS));
if (project.MonoNativeInfo != null)
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project, TestPlatform.iOS_TodayExtension64, ignored || !IncludeiOS));
if (!project.SkiptvOSVariation)
ps.Add (new Tuple<TestProject, TestPlatform, bool> (project.AsTvOSProject (), TestPlatform.tvOS, ignored || !IncludetvOS));
if (!project.SkipwatchOSVariation)
@ -391,7 +530,7 @@ namespace xharness
TestName = project.Name,
};
build64.CloneTestProject (project);
rv.Add (new RunDeviceTask (build64, Devices.Connected64BitIOS) { Ignored = ignored || !IncludeiOS, BuildOnly = project.BuildOnly });
rv.Add (new RunDeviceTask (build64, Devices.Connected64BitIOS.Where (d => d.IsSupported (project))) { Ignored = ignored || !IncludeiOS, BuildOnly = project.BuildOnly });
var build32 = new XBuildTask {
Jenkins = this,
@ -401,7 +540,7 @@ namespace xharness
TestName = project.Name,
};
build32.CloneTestProject (project);
rv.Add (new RunDeviceTask (build32, Devices.Connected32BitIOS) { Ignored = ignored || !IncludeiOS, BuildOnly = project.BuildOnly });
rv.Add (new RunDeviceTask (build32, Devices.Connected32BitIOS.Where (d => d.IsSupported (project))) { Ignored = ignored || !IncludeiOS, BuildOnly = project.BuildOnly });
var todayProject = project.AsTodayExtensionProject ();
var buildToday = new XBuildTask {
@ -412,7 +551,7 @@ namespace xharness
TestName = project.Name,
};
buildToday.CloneTestProject (todayProject);
rv.Add (new RunDeviceTask (buildToday, Devices.Connected64BitIOS) { Ignored = ignored || !IncludeiOSExtensions, BuildOnly = project.BuildOnly || ForceExtensionBuildOnly });
rv.Add (new RunDeviceTask (buildToday, Devices.Connected64BitIOS.Where (d => d.IsSupported (project))) { Ignored = ignored || !IncludeiOSExtensions, BuildOnly = project.BuildOnly || ForceExtensionBuildOnly });
}
if (!project.SkiptvOSVariation) {
@ -425,7 +564,7 @@ namespace xharness
TestName = project.Name,
};
buildTV.CloneTestProject (tvOSProject);
rv.Add (new RunDeviceTask (buildTV, Devices.ConnectedTV) { Ignored = ignored || !IncludetvOS, BuildOnly = project.BuildOnly });
rv.Add (new RunDeviceTask (buildTV, Devices.ConnectedTV.Where (d => d.IsSupported (project))) { Ignored = ignored || !IncludetvOS, BuildOnly = project.BuildOnly });
}
if (!project.SkipwatchOSVariation) {
@ -438,7 +577,7 @@ namespace xharness
TestName = project.Name,
};
buildWatch.CloneTestProject (watchOSProject);
rv.Add (new RunDeviceTask (buildWatch, Devices.ConnectedWatch) { Ignored = ignored || !IncludewatchOS, BuildOnly = project.BuildOnly });
rv.Add (new RunDeviceTask (buildWatch, Devices.ConnectedWatch.Where (d => d.IsSupported (project))) { Ignored = ignored || !IncludewatchOS, BuildOnly = project.BuildOnly });
}
}
@ -697,7 +836,11 @@ namespace xharness
configurations = new string [] { "Debug" };
foreach (var config in configurations) {
BuildProjectTask build;
if (project.GenerateVariations) {
if (project.MonoNativeInfo != null) {
build = new XBuildTask ();
build.Platform = TestPlatform.Mac_Unified;
build.CloneTestProject (project);
} else if (project.GenerateVariations) {
build = new MdtoolTask ();
build.Platform = TestPlatform.Mac_Classic;
build.TestProject = project;
@ -745,9 +888,9 @@ namespace xharness
Tasks.AddRange (execs);
foreach (var e in execs) {
if (project.GenerateVariations) {
if (project.GenerateVariations && project.MonoNativeInfo == null) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified, "-unified", ignored));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-unified-32", ignored32, true));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_Unified32, "-unified" + "-32", ignored32, true));
if (project.GenerateFull) {
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45, "-unifiedXM45", ignored));
Tasks.Add (CloneExecuteTask (e, project, TestPlatform.Mac_UnifiedXM45_32, "-unifiedXM45-32", ignored32, true));
@ -873,6 +1016,7 @@ namespace xharness
Ignored = ignore,
TestName = task.TestName,
IsUnitTest = macExec.IsUnitTest,
Variation = task.Variation
};
}
var nunit = task as NUnitExecuteTask;

Просмотреть файл

@ -6,6 +6,8 @@ namespace xharness
{
public bool ThirtyTwoBit;
public MonoNativeInfo MonoNativeInfo { get; set; }
protected override bool FixProjectReference (string name)
{
switch (name) {

Просмотреть файл

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
namespace xharness
{
@ -29,6 +31,8 @@ namespace xharness
if (IsBCL)
Name = Name + BCLInfo.FlavorSuffix;
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}
public override bool ShouldSkipProjectGeneration
@ -38,15 +42,18 @@ namespace xharness
return SkipProjectGeneration;
}
}
public override string Suffix {
get {
if (SkipProjectGeneration)
return "";
if (MonoNativeInfo != null) {
if (System)
return MonoNativeInfo.FlavorSuffix + "-system";
return MonoNativeInfo.FlavorSuffix + (ThirtyTwoBit ? "-32" : "");
}
if (System)
return "-system";
var suffix = (Mobile ? "" : "XM45") + (ThirtyTwoBit ? "-32" : "");
return "-unified" + (IsBCL ? "" : suffix);
}
@ -139,5 +146,41 @@ namespace xharness
return props;
}
}
protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo == null)
return templateMinimumOSVersion;
switch (MonoNativeInfo.Flavor) {
case MonoNativeFlavor.Compat:
return "10.9";
case MonoNativeFlavor.Unified:
return "10.12";
default:
throw new Exception ($"Unknown MonoNativeFlavor: {MonoNativeInfo.Flavor}");
}
}
protected override void ProcessProject ()
{
base.ProcessProject ();
if (MonoNativeInfo == null)
return;
MonoNativeInfo.AddProjectDefines (inputProject);
inputProject.AddAdditionalDefines ("MONO_NATIVE_MAC");
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info" + Suffix + ".plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info-mac.plist"));
BundleIdentifier = info_plist.GetCFBundleIdentifier ();
var plist_min_version = info_plist.GetPListStringValue ("LSMinimumSystemVersion");
info_plist.SetPListStringValue ("LSMinimumSystemVersion", GetMinimumOSVersion (plist_min_version));
inputProject.FixInfoPListInclude (Suffix);
Harness.Save (info_plist, target_info_plist);
}
}
}

Просмотреть файл

@ -0,0 +1,216 @@
//
// MonoNativeInfo.cs
//
// Author:
// Martin Baulig <mabaul@microsoft.com>
//
// Copyright (c) 2018 Xamarin Inc. (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.IO;
using System.Xml;
namespace xharness
{
public enum MonoNativeFlavor
{
None,
Compat,
Unified
}
public enum MonoNativeLinkMode
{
None,
Static,
Dynamic,
Symlink
}
public static class MonoNativeHelper
{
public static void AddProjectDefines (
XmlDocument project, MonoNativeFlavor flavor, MonoNativeLinkMode link,
string platform, string config)
{
AddProjectDefines (project, flavor, platform, config);
AddProjectDefines (project, link, platform, config);
}
public static void AddProjectDefines (
XmlDocument project, MonoNativeFlavor flavor,
string platform = null, string config = null)
{
switch (flavor) {
case MonoNativeFlavor.Compat:
if (platform != null)
project.AddAdditionalDefines ("MONO_NATIVE_COMPAT", platform, config);
else
project.AddAdditionalDefines ("MONO_NATIVE_COMPAT");
break;
case MonoNativeFlavor.Unified:
if (platform != null)
project.AddAdditionalDefines ("MONO_NATIVE_UNIFIED", platform, config);
else
project.AddAdditionalDefines ("MONO_NATIVE_UNIFIED");
break;
default:
throw new Exception ($"Unknown MonoNativeFlavor: {flavor}");
}
}
public static void AddProjectDefines (
XmlDocument project, MonoNativeLinkMode link,
string platform, string config)
{
switch (link) {
case MonoNativeLinkMode.Static:
project.AddAdditionalDefines ("MONO_NATIVE_STATIC", platform, config);
project.RemoveDefines ("MONO_NATIVE_DYNAMIC; MONO_NATIVE_SYMLINK", platform, config);
break;
case MonoNativeLinkMode.Dynamic:
project.AddAdditionalDefines ("MONO_NATIVE_DYNAMIC", platform, config);
project.RemoveDefines ("MONO_NATIVE_STATIC; MONO_NATIVE_SYMLINK", platform, config);
break;
case MonoNativeLinkMode.Symlink:
project.AddAdditionalDefines ("MONO_NATIVE_SYMLINK", platform, config);
project.RemoveDefines ("MONO_NATIVE_MONO_NATIVE_STATIC; MONO_NATIVE_DYNAMIC", platform, config);
break;
default:
throw new Exception ($"Unknown MonoNativeLinkMode: {link}");
}
}
public static void RemoveSymlinkMode (XmlDocument project)
{
AddProjectDefines (project, MonoNativeLinkMode.Static, "iPhone", "Debug");
AddProjectDefines (project, MonoNativeLinkMode.Static, "iPhoneSimulator", "Debug");
}
public static string GetMinimumOSVersion (DevicePlatform platform, MonoNativeFlavor flavor)
{
switch (flavor) {
case MonoNativeFlavor.Compat:
switch (platform) {
case DevicePlatform.iOS:
return "8.0";
case DevicePlatform.tvOS:
return "9.0";
case DevicePlatform.watchOS:
return "2.0";
default:
throw new Exception ($"Unknown DevicePlatform: {platform}");
}
case MonoNativeFlavor.Unified:
switch (platform) {
case DevicePlatform.iOS:
case DevicePlatform.tvOS:
return "10.0";
case DevicePlatform.watchOS:
return "4.0";
default:
throw new Exception ($"Unknown DevicePlatform: {platform}");
}
default:
throw new Exception ($"Unknown MonoNativeFlavor: {flavor}");
}
}
}
public class MonoNativeInfo
{
public Harness Harness { get; }
public MonoNativeFlavor Flavor { get; }
public MonoNativeInfo (Harness harness, MonoNativeFlavor flavor)
{
Harness = harness;
Flavor = flavor;
}
string NativeFlavorSuffix => Flavor == MonoNativeFlavor.Compat ? "-compat" : "-unified";
public virtual string FlavorSuffix => NativeFlavorSuffix;
public string ProjectName => "mono-native" + NativeFlavorSuffix;
public string ProjectPath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native" + FlavorSuffix + ".csproj");
public string TemplatePath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native" + (Harness.Mac ? "-mac" : string.Empty) + ".csproj.template");
public void Convert ()
{
var inputProject = new XmlDocument ();
var xml = File.ReadAllText (TemplatePath);
inputProject.LoadXmlWithoutNetworkAccess (xml);
inputProject.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + FlavorSuffix);
inputProject.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + FlavorSuffix);
inputProject.SetAssemblyName (inputProject.GetAssemblyName () + FlavorSuffix);
AddProjectDefines (inputProject);
Convert (inputProject);
Console.Error.WriteLine ($"CONVERT: {Harness.Mac} {ProjectPath}");
Harness.Save (inputProject, ProjectPath);
}
protected virtual void Convert (XmlDocument inputProject)
{
}
public void AddProjectDefines (XmlDocument project)
{
MonoNativeHelper.AddProjectDefines (project, Flavor);
}
}
public class MacMonoNativeInfo : MonoNativeInfo
{
public MacFlavors MacFlavor { get; set; }
public override string FlavorSuffix => base.FlavorSuffix + (MacFlavor == MacFlavors.Full ? "-full" : "-modern");
public MacMonoNativeInfo (Harness harness, MonoNativeFlavor flavor, MacFlavors macFlavor)
: base (harness, flavor)
{
if (macFlavor == MacFlavors.All)
throw new ArgumentException ("Each target must be a specific flavor");
MacFlavor = macFlavor;
}
protected override void Convert (XmlDocument inputProject)
{
switch (MacFlavor) {
case MacFlavors.Modern:
inputProject.SetTargetFrameworkIdentifier ("Xamarin.Mac");
inputProject.SetTargetFrameworkVersion ("v2.0");
inputProject.RemoveNode ("UseXamMacFullFramework");
inputProject.AddAdditionalDefines ("MOBILE;XAMMAC");
inputProject.AddReference ("Mono.Security");
break;
case MacFlavors.Full:
inputProject.AddAdditionalDefines ("XAMMAC_4_5");
break;
}
base.Convert (inputProject);
}
}
}

Просмотреть файл

@ -813,6 +813,14 @@ namespace xharness
}
}
public bool IsSupported (iOSTestProject project)
{
if (project.MonoNativeInfo == null)
return true;
var min_version = MonoNativeHelper.GetMinimumOSVersion (DevicePlatform, project.MonoNativeInfo.Flavor);
return Version.Parse (ProductVersion) >= Version.Parse (min_version);
}
public Architecture Architecture {
get {
var model = ProductType;

Просмотреть файл

@ -8,6 +8,12 @@ namespace xharness
public class TVOSTarget : iOSTarget
{
public override string Suffix {
get {
return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-tvos" : "-tvos";
}
}
public override string ExtraLinkerDefsSuffix {
get {
return "-tvos";
}
@ -55,9 +61,18 @@ namespace xharness
}
}
protected override string GetMinimumOSVersion(string templateMinimumOSVersion)
protected override void CalculateName ()
{
return "9.0";
base.CalculateName ();
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}
protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo == null)
return "9.0";
return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.tvOS, MonoNativeInfo.Flavor);
}
protected override int[] UIDeviceFamily {
@ -90,6 +105,12 @@ namespace xharness
{
base.ProcessProject ();
if (MonoNativeInfo != null) {
inputProject.AddAdditionalDefines ("MONO_NATIVE_TV");
MonoNativeHelper.AddProjectDefines (inputProject, MonoNativeInfo.Flavor);
MonoNativeHelper.RemoveSymlinkMode (inputProject);
}
var srcDirectory = Path.Combine (Harness.RootDirectory, "..", "src");
string project_guid;

Просмотреть файл

@ -37,6 +37,7 @@ namespace xharness
public virtual string Suffix { get { throw new NotImplementedException (); } }
public virtual string MakefileWhereSuffix { get { return string.Empty; } }
public virtual string ProjectFileSuffix { get { return Suffix; } }
public virtual string ExtraLinkerDefsSuffix { get { return Suffix; } }
protected virtual string ProjectTypeGuids { get { throw new NotImplementedException (); } }
protected virtual string BindingsProjectTypeGuids { get { throw new NotImplementedException (); } }
protected virtual string TargetFrameworkIdentifier { get { throw new NotImplementedException (); } }
@ -113,7 +114,7 @@ namespace xharness
} else {
inputProject.FixArchitectures (SimulatorArchitectures, DeviceArchitectures);
inputProject.FixInfoPListInclude (Suffix);
inputProject.SetExtraLinkerDefs ("extra-linker-defs" + Suffix + ".xml");
inputProject.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
}
Harness.Save (inputProject, ProjectPath);
@ -164,7 +165,15 @@ namespace xharness
targetDirectory = Path.GetDirectoryName(TemplateProjectPath);
CalculateName ();
ProjectPath = Path.Combine (targetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + ProjectFileSuffix + "." + ProjectFileExtension);
var templateName = Path.GetFileName (TemplateProjectPath);
if (templateName.EndsWith (".template", StringComparison.OrdinalIgnoreCase))
templateName = Path.GetFileNameWithoutExtension (templateName);
templateName = Path.GetFileNameWithoutExtension (templateName);
if (templateName.Equals ("mono-native-mac"))
templateName = "mono-native";
ProjectPath = Path.Combine (targetDirectory, templateName + ProjectFileSuffix + "." + ProjectFileExtension);
if (!ShouldSkipProjectGeneration)
{

Просмотреть файл

@ -150,6 +150,9 @@ namespace xharness
// Optional
public BCLTestInfo BCLInfo { get; set; }
// Optional
public MonoNativeInfo MonoNativeInfo { get; set; }
public iOSTestProject ()
{
}
@ -169,6 +172,9 @@ namespace xharness
// Optional
public MacBCLTestInfo BCLInfo { get; set; }
// Optional
public MacMonoNativeInfo MonoNativeInfo { get; set; }
public bool GenerateModern => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.NonSystem || TargetFrameworkFlavor == MacFlavors.Modern;
public bool GenerateFull => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.NonSystem || TargetFrameworkFlavor == MacFlavors.Full;
public bool GenerateSystem => TargetFrameworkFlavor == MacFlavors.All || TargetFrameworkFlavor == MacFlavors.System;

Просмотреть файл

@ -17,6 +17,12 @@ namespace xharness
public string TodayExtensionProjectPath { get; private set; }
public override string Suffix {
get {
return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-today" : "-today";
}
}
public override string ExtraLinkerDefsSuffix {
get {
return "-today";
}
@ -24,14 +30,23 @@ namespace xharness
public override string ProjectFileSuffix {
get {
if (MonoNativeInfo != null)
return MonoNativeInfo.FlavorSuffix + "-today";
return "-today";
}
}
protected override void CalculateName ()
{
base.CalculateName ();
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}
void CreateTodayContainerProject ()
{
var csproj = new XmlDocument ();
var suffix = "-today";
var suffix = Suffix;
csproj.LoadWithoutNetworkAccess (Path.Combine (Harness.TodayContainerTemplate, "TodayContainer.csproj"));
csproj.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + suffix, false);
csproj.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + suffix);
@ -43,21 +58,25 @@ namespace xharness
TodayContainerGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}";
ProjectGuid = TodayContainerGuid;
csproj.SetProjectGuid (TodayContainerGuid);
if (MonoNativeInfo != null) {
MonoNativeInfo.AddProjectDefines (csproj);
csproj.AddAdditionalDefines ("MONO_NATIVE_TODAY");
}
Harness.Save (csproj, TodayContainerProjectPath);
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-today.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{suffix}.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (Harness.TodayContainerTemplate, "Info.plist"));
info_plist.SetCFBundleIdentifier (BundleIdentifier);
info_plist.SetCFBundleName (Name);
info_plist.SetMinimumOSVersion ("8.0");
info_plist.SetMinimumOSVersion (GetMinimumOSVersion ("8.0"));
Harness.Save (info_plist, target_info_plist);
}
void CreateTodayExtensionProject ()
{
var csproj = inputProject;
var suffix = "-today-extension";
var suffix = Suffix + "-extension";
csproj.SetProjectTypeGuids ("{EE2C853D-36AF-4FDB-B1AD-8E90477E2198};" + LanguageGuid);
csproj.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + suffix);
csproj.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + suffix);
@ -68,19 +87,23 @@ namespace xharness
var ext = IsFSharp ? "fs" : "cs";
csproj.AddCompileInclude ("TodayExtensionMain." + ext, Path.Combine (Harness.TodayExtensionTemplate, "TodayExtensionMain." + ext), true);
csproj.AddInterfaceDefinition (Path.Combine (Harness.TodayExtensionTemplate, "TodayView.storyboard").Replace ('/', '\\'));
csproj.SetExtraLinkerDefs ("extra-linker-defs" + Suffix + ".xml");
csproj.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
csproj.FixProjectReferences ("-today");
if (MonoNativeInfo != null) {
MonoNativeInfo.AddProjectDefines (csproj);
csproj.AddAdditionalDefines ("MONO_NATIVE_TODAY");
}
Harness.Save (csproj, TodayExtensionProjectPath);
TodayExtensionGuid = csproj.GetProjectGuid ();
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-today-extension.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{suffix}.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist"));
BundleIdentifier = info_plist.GetCFBundleIdentifier () + "-today";
info_plist.SetCFBundleIdentifier (BundleIdentifier + ".todayextension");
info_plist.SetMinimumOSVersion ("8.0");
info_plist.SetMinimumOSVersion (GetMinimumOSVersion ("8.0"));
info_plist.AddPListStringValue ("CFBundlePackageType", "XPC!");
info_plist.SetCFBundleDisplayName (Name);
info_plist.AddPListKeyValuePair ("NSExtension", "dict",
@ -98,10 +121,15 @@ namespace xharness
ExtensionName = Name + " Today Extension";
AppName = Name + " Today";
var templateName = Path.GetFileName (TemplateProjectPath);
if (templateName.EndsWith (".template", StringComparison.OrdinalIgnoreCase))
templateName = Path.GetFileNameWithoutExtension (templateName);
templateName = Path.GetFileNameWithoutExtension (templateName);
switch (OutputType) {
case "Exe":
TodayExtensionProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-today-extension." + ProjectFileExtension);
TodayContainerProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-today." + ProjectFileExtension);
TodayExtensionProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "-extension." + ProjectFileExtension);
TodayContainerProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "." + ProjectFileExtension);
CreateTodayExtensionProject ();
CreateTodayContainerProject ();
break;
@ -113,6 +141,13 @@ namespace xharness
}
}
protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo == null)
return templateMinimumOSVersion;
return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.iOS, MonoNativeInfo.Flavor);
}
public override IEnumerable<RelatedProject> GetRelatedProjects ()
{
return new RelatedProject [] {

Просмотреть файл

@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Xml;
namespace xharness
{
@ -6,10 +8,16 @@ namespace xharness
{
public override string Suffix {
get {
return "-ios";
return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix : "-ios";
}
}
public override string ExtraLinkerDefsSuffix {
get {
return string.Empty;
}
}
protected override string ProjectTypeGuids {
get {
return "{FEACFBD2-3405-455C-9665-78FE426C6842};" + LanguageGuid;
@ -55,9 +63,18 @@ namespace xharness
}
}
protected override string GetMinimumOSVersion(string templateMinimumOSVersion)
protected override void CalculateName ()
{
return templateMinimumOSVersion;
base.CalculateName ();
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}
protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo == null)
return templateMinimumOSVersion;
return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.iOS, MonoNativeInfo.Flavor);
}
protected override int[] UIDeviceFamily {
@ -86,6 +103,8 @@ namespace xharness
public override string ProjectFileSuffix {
get {
if (MonoNativeInfo != null)
return MonoNativeInfo.FlavorSuffix;
return string.Empty;
}
}
@ -98,7 +117,22 @@ namespace xharness
protected override void ExecuteInternal ()
{
// Nothing to do here
if (MonoNativeInfo == null)
return;
MonoNativeInfo.AddProjectDefines (inputProject);
inputProject.AddAdditionalDefines ("MONO_NATIVE_IOS");
inputProject.FixInfoPListInclude (Suffix);
inputProject.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
Harness.Save (inputProject, ProjectPath);
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info" + Suffix + ".plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist"));
info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ()));
Harness.Save (info_plist, target_info_plist);
}
}
}

Просмотреть файл

@ -21,7 +21,7 @@ namespace xharness
void CreateWatchOSAppProject ()
{
var csproj = new XmlDocument ();
var suffix = "-watchos-app";
var suffix = Suffix + "-app";
csproj.LoadWithoutNetworkAccess (Path.Combine (Harness.WatchOSAppTemplate, "App.csproj"));
csproj.FindAndReplace ("%WATCHAPP_PATH%", Path.GetFullPath (Harness.WatchOSAppTemplate).Replace ('/', '\\') + "\\");
csproj.FindAndReplace ("%WATCHEXTENSION_CSPROJ%", Path.GetFileName (WatchOSExtensionProjectPath));
@ -30,14 +30,20 @@ namespace xharness
WatchOSAppGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}";
csproj.SetProjectGuid (WatchOSAppGuid);
csproj.FixInfoPListInclude (suffix);
if (MonoNativeInfo != null) {
csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH");
MonoNativeHelper.AddProjectDefines (csproj, MonoNativeInfo.Flavor);
MonoNativeHelper.RemoveSymlinkMode (csproj);
}
Harness.Save (csproj, WatchOSAppProjectPath);
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-watchos-app.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{Suffix}-app.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (Harness.WatchOSAppTemplate, "Info.plist"));
info_plist.SetCFBundleIdentifier (BundleIdentifier + ".watchkitapp");
info_plist.SetPListStringValue ("WKCompanionAppBundleIdentifier", BundleIdentifier);
info_plist.SetPListStringValue ("CFBundleName", Name);
info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ()));
Harness.Save (info_plist, target_info_plist);
}
@ -51,20 +57,27 @@ namespace xharness
csproj.SetProjectReferenceValue (Path.GetFileName (WatchOSAppProjectPath), "Name", Path.GetFileNameWithoutExtension (WatchOSAppProjectPath));
WatchOSGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}";
csproj.SetProjectGuid (WatchOSGuid);
csproj.FixInfoPListInclude (Suffix);
if (MonoNativeInfo != null) {
csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH");
MonoNativeHelper.AddProjectDefines (csproj, MonoNativeInfo.Flavor);
MonoNativeHelper.RemoveSymlinkMode (csproj);
}
Harness.Save (csproj, WatchOSProjectPath);
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-watchos.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{Suffix}.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (Harness.WatchOSContainerTemplate, "Info.plist"));
info_plist.SetCFBundleIdentifier (BundleIdentifier);
info_plist.SetCFBundleName (Name);
info_plist.SetMinimumOSVersion ("9.0");
Harness.Save (info_plist, target_info_plist);
}
void CreateWatchOSExtensionProject ()
{
var csproj = inputProject;
var suffix = "-watchos-extension";
var suffix = Suffix + "-extension";
csproj.SetProjectTypeGuids ("{1E2E965C-F6D2-49ED-B86E-418A60C69EEF};" + LanguageGuid);
csproj.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + suffix);
csproj.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + suffix);
@ -80,10 +93,16 @@ namespace xharness
csproj.RemoveReferences ("OpenTK-1.0");
var ext = IsFSharp ? "fs" : "cs";
csproj.AddCompileInclude ("InterfaceController." + ext, Path.Combine (Harness.WatchOSExtensionTemplate, "InterfaceController." + ext));
csproj.SetExtraLinkerDefs ("extra-linker-defs" + Suffix + ".xml");
csproj.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
csproj.SetMtouchUseBitcode (true, "iPhone", "Release");
csproj.SetMtouchUseLlvm (true, "iPhone", "Release");
if (MonoNativeInfo != null) {
csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH");
MonoNativeHelper.AddProjectDefines (csproj, MonoNativeInfo.Flavor);
MonoNativeHelper.RemoveSymlinkMode (csproj);
}
// Not linking a watch extensions requires passing -Os to the native compiler.
// https://github.com/mono/mono/issues/9867
var configurations = new string [] { "Debug", "Debug32", "Release", "Release32", "Release-bitcode" };
@ -96,13 +115,13 @@ namespace xharness
WatchOSExtensionGuid = csproj.GetProjectGuid ();
XmlDocument info_plist = new XmlDocument ();
var target_info_plist = Path.Combine (TargetDirectory, "Info-watchos-extension.plist");
var target_info_plist = Path.Combine (TargetDirectory, $"Info{Suffix}-extension.plist");
info_plist.LoadWithoutNetworkAccess (Path.Combine (TargetDirectory, "Info.plist"));
BundleIdentifier = info_plist.GetCFBundleIdentifier () + "-watch";
if (BundleIdentifier.Length >= 58)
BundleIdentifier = BundleIdentifier.Substring (0, 57); // If the main app's bundle id is 58 characters (or sometimes more), then the watch extension crashes at launch. radar #29847128.
info_plist.SetCFBundleIdentifier (BundleIdentifier + ".watchkitapp.watchkitextension");
info_plist.SetMinimumOSVersion ("2.0");
info_plist.SetMinimumOSVersion (GetMinimumOSVersion ("2.0"));
info_plist.SetUIDeviceFamily (4);
info_plist.AddPListStringValue ("RemoteInterfacePrincipleClass", "InterfaceController");
info_plist.AddPListKeyValuePair ("NSExtension", "dict", string.Format (
@ -148,7 +167,7 @@ namespace xharness
csproj.SetImport (IsBindingProject ? BindingsImports : Imports);
csproj.AddAdditionalDefines ("XAMCORE_2_0;XAMCORE_3_0");
csproj.FixProjectReferences (Suffix);
csproj.SetExtraLinkerDefs ("extra-linker-defs" + Suffix + ".xml");
csproj.SetExtraLinkerDefs ("extra-linker-defs" + ExtraLinkerDefsSuffix + ".xml");
csproj.FixTestLibrariesReferences (Platform);
Harness.Save (csproj, WatchOSProjectPath);
@ -160,10 +179,15 @@ namespace xharness
ExtensionName = Name + " Extension";
AppName = Name + " App";
var templateName = Path.GetFileName (TemplateProjectPath);
if (templateName.EndsWith (".template", StringComparison.OrdinalIgnoreCase))
templateName = Path.GetFileNameWithoutExtension (templateName);
templateName = Path.GetFileNameWithoutExtension (templateName);
switch (OutputType) {
case "Exe":
WatchOSExtensionProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-watchos-extension.csproj");
WatchOSAppProjectPath = Path.Combine (TargetDirectory, Path.GetFileNameWithoutExtension (TemplateProjectPath) + "-watchos-app.csproj");
WatchOSExtensionProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "-extension.csproj");
WatchOSAppProjectPath = Path.Combine (TargetDirectory, templateName + Suffix + "-app.csproj");
CreateWatchOSExtensionProject ();
CreateWatchOSAppProject ();
CreateWatchOSContainerProject ();
@ -176,7 +200,27 @@ namespace xharness
}
}
protected override void CalculateName ()
{
base.CalculateName ();
if (MonoNativeInfo != null)
Name = Name + MonoNativeInfo.FlavorSuffix;
}
protected override string GetMinimumOSVersion (string templateMinimumOSVersion)
{
if (MonoNativeInfo == null)
return templateMinimumOSVersion;
return MonoNativeHelper.GetMinimumOSVersion (DevicePlatform.watchOS, MonoNativeInfo.Flavor);
}
public override string Suffix {
get {
return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-watchos" : "-watchos";
}
}
public override string ExtraLinkerDefsSuffix {
get {
return "-watchos";
}

Просмотреть файл

@ -6,5 +6,7 @@ namespace xharness
public class iOSTarget : Target
{
public iOSTestProject TestProject;
public MonoNativeInfo MonoNativeInfo => TestProject.MonoNativeInfo;
}
}

Просмотреть файл

@ -107,6 +107,7 @@
</Compile>
<Compile Include="SimpleFileListener.cs" />
<Compile Include="iOSTarget.cs" />
<Compile Include="MonoNativeInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>