From 947524d0f125acdeeb77ec8b1dd35709e1e531fa Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Sun, 28 Oct 2018 18:02:44 -0400 Subject: [PATCH] X --- tests/mono-native/.gitignore | 1 - tests/mono-native/NativePlatformConfig.cs | 34 ++++++++++++ tests/mono-native/NativePlatformTest.cs | 41 +++++++++----- tests/mono-native/extra-linker-defs-today.xml | 7 +++ tests/mono-native/extra-linker-defs-tvos.xml | 7 +++ .../mono-native/extra-linker-defs-watchos.xml | 7 +++ tests/mono-native/mono-native.csproj.template | 5 +- tests/xharness/AppRunner.cs | 2 + tests/xharness/Harness.cs | 3 + tests/xharness/Jenkins.cs | 22 ++++++++ tests/xharness/MonoNativeInfo.cs | 55 ++++++++----------- tests/xharness/TVOSTarget.cs | 26 +++++++-- tests/xharness/Target.cs | 3 +- tests/xharness/TodayExtensionTarget.cs | 23 +++++--- tests/xharness/UnifiedTarget.cs | 31 ++++++++--- tests/xharness/WatchOSTarget.cs | 43 +++++++++++++-- tests/xharness/xharness.csproj | 3 +- tools/mtouch/Target.cs | 2 +- tools/mtouch/mtouch.cs | 2 +- 19 files changed, 239 insertions(+), 78 deletions(-) create mode 100644 tests/mono-native/NativePlatformConfig.cs create mode 100644 tests/mono-native/extra-linker-defs-today.xml create mode 100644 tests/mono-native/extra-linker-defs-tvos.xml create mode 100644 tests/mono-native/extra-linker-defs-watchos.xml diff --git a/tests/mono-native/.gitignore b/tests/mono-native/.gitignore index 2c3e91d112ab..a1f447a8043b 100644 --- a/tests/mono-native/.gitignore +++ b/tests/mono-native/.gitignore @@ -1,2 +1 @@ mono-native-compat.csproj -extra-linker-defs-*.xml diff --git a/tests/mono-native/NativePlatformConfig.cs b/tests/mono-native/NativePlatformConfig.cs new file mode 100644 index 000000000000..bf0170f0fa30 --- /dev/null +++ b/tests/mono-native/NativePlatformConfig.cs @@ -0,0 +1,34 @@ +using System; +using NUnit.Framework; +using Mono; + +namespace Mono.Native.Tests +{ + [TestFixture] + public class NativePlatformConfig + { + static bool ShouldUseCompat { + get { +#if MONO_NATIVE_COMPAT + return true; +#elif MONO_NATIVE_UNIFIED + return false; +#else + Assert.Fail ("Missing `MONO_NATIVE_COMPAT` or `MONO_NATIVE_UNIFIED`"); + throw new NotImplementedException (); +#endif + } + } + [Test] + public void PlatformType () + { + var type = MonoNativePlatform.GetPlatformType (); + Assert.That ((int)type, Is.GreaterThan (0), "platform type"); + + Console.Error.WriteLine ($"NATIVE PLATFORM TYPE: {type}"); + + var usingCompat = (type & MonoNativePlatformType.MONO_NATIVE_PLATFORM_TYPE_COMPAT) != 0; + Assert.AreEqual (ShouldUseCompat, usingCompat, "using compatibility layer"); + } + } +} diff --git a/tests/mono-native/NativePlatformTest.cs b/tests/mono-native/NativePlatformTest.cs index a8ebac610644..85ed9803e374 100644 --- a/tests/mono-native/NativePlatformTest.cs +++ b/tests/mono-native/NativePlatformTest.cs @@ -11,40 +11,53 @@ namespace Mono.Native.Tests public class NativePlatformTest { [Test] - public void Test () + public void PlatformType () { var type = MonoNativePlatform.GetPlatformType (); Assert.That ((int)type, Is.GreaterThan (0), "platform type"); - - Console.Error.WriteLine ($"NATIVE PLATFORM TYPE: {type}"); - - // var usingCompat = (type & MonoNativePlatformType.MONO_NATIVE_PLATFORM_TYPE_COMPAT) != 0; - // Assert.AreEqual (MonoNativeConfig.UsingCompat, usingCompat, "using compatibility layer"); } [Test] public void TestInitialize () { MonoNativePlatform.Initialize (); + var initialized = MonoNativePlatform.IsInitialized (); + Assert.IsTrue (initialized, "MonoNativePlatform.IsInitialized()"); } [Test] - public void MartinTest () + public void TestReflectionInitialize () { - MonoNativePlatform.Initialize (); - var asm = typeof (string).Assembly; var type = asm.GetType ("Mono.MonoNativePlatform"); - Console.Error.WriteLine ($"TEST: {type}"); + Assert.IsNotNull (type, "MonoNativePlatform"); var method = type.GetMethod ("Initialize", BindingFlags.Static | BindingFlags.Public); + Assert.IsNotNull (method, "MonoNativePlatform.Initialize"); + + var method2 = type.GetMethod ("IsInitialized", BindingFlags.Static | BindingFlags.Public); + Assert.IsNotNull (method2, "MonoNativePlatform.IsInitialized"); + method.Invoke (null, null); - Console.Error.WriteLine ($"CALLED INITIALIZE!"); - var method2 = type.GetMethod ("Test", BindingFlags.Static | BindingFlags.Public); - method2.Invoke (null, null); + var result = (bool)method2.Invoke (null, null); + Assert.IsTrue (result, "MonoNativePlatform.IsInitialized()"); + } + + [Test] + public void TestInternalCounter () + { + MonoNativePlatform.Initialize (); + + var asm = typeof (string).Assembly; + var type = asm.GetType ("Mono.MonoNativePlatform"); + Assert.IsNotNull (type, "MonoNativePlatform"); + + var method = type.GetMethod ("TestInternalCounter", BindingFlags.Static | BindingFlags.NonPublic); + Assert.IsNotNull (method, "MonoNativePlatform.TestInternalCounter"); + var result = method.Invoke (null, null); - Console.Error.WriteLine ($"CALLED TEST!"); + Assert.That (result, Is.GreaterThan (0), "MonoNativePlatform.TestInternalCounter()"); } } } diff --git a/tests/mono-native/extra-linker-defs-today.xml b/tests/mono-native/extra-linker-defs-today.xml new file mode 100644 index 000000000000..ce5fd6cbf37f --- /dev/null +++ b/tests/mono-native/extra-linker-defs-today.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/mono-native/extra-linker-defs-tvos.xml b/tests/mono-native/extra-linker-defs-tvos.xml new file mode 100644 index 000000000000..ce5fd6cbf37f --- /dev/null +++ b/tests/mono-native/extra-linker-defs-tvos.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/mono-native/extra-linker-defs-watchos.xml b/tests/mono-native/extra-linker-defs-watchos.xml new file mode 100644 index 000000000000..ce5fd6cbf37f --- /dev/null +++ b/tests/mono-native/extra-linker-defs-watchos.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/mono-native/mono-native.csproj.template b/tests/mono-native/mono-native.csproj.template index 919714ce85ac..f8e19650f205 100644 --- a/tests/mono-native/mono-native.csproj.template +++ b/tests/mono-native/mono-native.csproj.template @@ -168,13 +168,16 @@ - + MonoNativePlatform.cs MonoNativePlatformType.cs + + NativePlatformTest.cs + diff --git a/tests/xharness/AppRunner.cs b/tests/xharness/AppRunner.cs index 3cac8aac977d..a4fecd75fb89 100644 --- a/tests/xharness/AppRunner.cs +++ b/tests/xharness/AppRunner.cs @@ -467,6 +467,8 @@ public async Task RunAsync () args.Append (" -setenv=NUNIT_AUTOEXIT=true"); args.Append (" -argument=-app-arg:-enablenetwork"); args.Append (" -setenv=NUNIT_ENABLE_NETWORK=true"); + args.Append (" -setenv=MONO_LOG_LEVEL=debug"); + args.Append (" -setenv=MONO_LOG_MASK=dll,asm"); // detect if we are using a jenkins bot. var useXmlOutput = Harness.InJenkins; if (useXmlOutput) { diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 5cb2ef487836..f9775606048b 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -503,6 +503,9 @@ void ConfigureIOS () 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); diff --git a/tests/xharness/Jenkins.cs b/tests/xharness/Jenkins.cs index 8e80aa0bbf22..e62e2c9a34a1 100644 --- a/tests/xharness/Jenkins.cs +++ b/tests/xharness/Jenkins.cs @@ -126,6 +126,10 @@ IEnumerable CreateRunSimulatorTaskAsync (XBuildTask buildTask) 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 (); } @@ -204,6 +208,22 @@ IEnumerable GetTestData (RunTestTask test) 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; + case "mono-native-compat": + case "mono-native-unified": + 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, 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: 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 }; + 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 (static registrar)", MTouchExtraArgs = "--registrar:static", Debug = true, Profiling = false }; + yield return new TestData { Variation = "Debug (all optimizations)", MTouchExtraArgs = "--registrar:static --optimize:all", Debug = true, Profiling = false, LinkMode = "Full", Defines = "OPTIMIZEALL" }; + break; } break; case "AnyCPU": @@ -330,6 +350,8 @@ IEnumerable CreateRunSimulatorTasks () var ps = new List> (); if (!project.SkipiOSVariation) ps.Add (new Tuple (project, TestPlatform.iOS_Unified, ignored || !IncludeiOS)); + if (project.MonoNativeInfo != null) + ps.Add (new Tuple (project, TestPlatform.iOS_TodayExtension64, ignored || !IncludeiOS)); if (!project.SkiptvOSVariation) ps.Add (new Tuple (project.AsTvOSProject (), TestPlatform.tvOS, ignored || !IncludetvOS)); if (!project.SkipwatchOSVariation) diff --git a/tests/xharness/MonoNativeInfo.cs b/tests/xharness/MonoNativeInfo.cs index 1e63d434fc8c..ac40751db627 100644 --- a/tests/xharness/MonoNativeInfo.cs +++ b/tests/xharness/MonoNativeInfo.cs @@ -50,53 +50,42 @@ public MonoNativeInfo (Harness harness, MonoNativeFlavor flavor) public string ProjectPath => Path.Combine (Harness.RootDirectory, "mono-native", ProjectName + ".csproj"); public string TemplatePath => Path.Combine (Harness.RootDirectory, "mono-native", "mono-native.csproj.template"); - public string GetMinimumOSVersion () + public void Convert () { - if (Harness.Mac) - throw new NotImplementedException (); - switch (Flavor) { - case MonoNativeFlavor.Compat: - return "9.0"; - case MonoNativeFlavor.Unified: - return "10.0"; - default: - throw new Exception (string.Format ("Unknown MonoNativeFlavor: {0}", Flavor)); - } - } + 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); - public string GetMinimumWatchOSVersion () - { switch (Flavor) { case MonoNativeFlavor.Compat: - return "2.0"; + inputProject.AddAdditionalDefines ("MONO_NATIVE_COMPAT"); + break; case MonoNativeFlavor.Unified: - return "4.0"; + inputProject.AddAdditionalDefines ("MONO_NATIVE_UNIFIED"); + break; default: - throw new Exception (string.Format ("Unknown MonoNativeFlavor: {0}", Flavor)); + throw new Exception ($"Unknown MonoNativeFlavor: {Flavor}"); } + + // Harness.Save (inputProject, ProjectPath); } - public void Convert () + public void AddProjectDefines (XmlDocument project) { - var inputProject = new XmlDocument (); - - var xml = File.ReadAllText (TemplatePath); - inputProject.LoadXmlWithoutNetworkAccess (xml); - switch (Flavor) { case MonoNativeFlavor.Compat: -// inputProject.SetTargetFrameworkIdentifier ("Xamarin.Mac"); -// inputProject.SetTargetFrameworkVersion ("v2.0"); -// inputProject.RemoveNode ("UseXamMacFullFramework"); -// inputProject.AddAdditionalDefines ("MOBILE;XAMMAC"); -// inputProject.AddReference ("Mono.Security"); + project.AddAdditionalDefines ("MONO_NATIVE_COMPAT"); break; + case MonoNativeFlavor.Unified: + project.AddAdditionalDefines ("MONO_NATIVE_UNIFIED"); + break; + default: + throw new Exception ($"Unknown MonoNativeFlavor: {Flavor}"); } - inputProject.SetOutputPath ("bin\\$(Platform)\\$(Configuration)" + FlavorSuffix); - inputProject.SetIntermediateOutputPath ("obj\\$(Platform)\\$(Configuration)" + FlavorSuffix); - inputProject.SetAssemblyName (inputProject.GetAssemblyName () + FlavorSuffix); - - Harness.Save (inputProject, ProjectPath); } } } diff --git a/tests/xharness/TVOSTarget.cs b/tests/xharness/TVOSTarget.cs index 2ee25c26bb79..76e819986d9e 100644 --- a/tests/xharness/TVOSTarget.cs +++ b/tests/xharness/TVOSTarget.cs @@ -13,6 +13,12 @@ public override string Suffix { } } + public override string ExtraLinkerDefsSuffix { + get { + return "-tvos"; + } + } + protected override string BindingsProjectTypeGuids { get { return "{4A1ED743-3331-459B-915A-4B17C7B6DBB6}"; @@ -62,11 +68,18 @@ protected override void CalculateName () Name = Name + MonoNativeInfo.FlavorSuffix; } - protected override string GetMinimumOSVersion(string templateMinimumOSVersion) + protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo != null) - return MonoNativeInfo.GetMinimumOSVersion (); - return "9.0"; + if (MonoNativeInfo == null) + return "9.0"; + switch (MonoNativeInfo.Flavor) { + case MonoNativeFlavor.Compat: + return "9.0"; + case MonoNativeFlavor.Unified: + return "10.0"; + default: + throw new Exception ($"Unknown MonoNativeFlavor: {MonoNativeInfo.Flavor}"); + } } protected override int[] UIDeviceFamily { @@ -99,6 +112,11 @@ protected override void ProcessProject () { base.ProcessProject (); + if (MonoNativeInfo != null) { + MonoNativeInfo.AddProjectDefines (inputProject); + inputProject.AddAdditionalDefines ("MONO_NATIVE_TV"); + } + var srcDirectory = Path.Combine (Harness.RootDirectory, "..", "src"); string project_guid; diff --git a/tests/xharness/Target.cs b/tests/xharness/Target.cs index e50b772e1c8d..4846790af470 100644 --- a/tests/xharness/Target.cs +++ b/tests/xharness/Target.cs @@ -37,6 +37,7 @@ public abstract class Target 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 @@ protected void CreateExecutableProject () } 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); diff --git a/tests/xharness/TodayExtensionTarget.cs b/tests/xharness/TodayExtensionTarget.cs index 60415e58cf5a..dc72e36d0111 100644 --- a/tests/xharness/TodayExtensionTarget.cs +++ b/tests/xharness/TodayExtensionTarget.cs @@ -22,6 +22,12 @@ public override string Suffix { } } + public override string ExtraLinkerDefsSuffix { + get { + return "-today"; + } + } + public override string ProjectFileSuffix { get { if (MonoNativeInfo != null) @@ -37,13 +43,6 @@ protected override void CalculateName () Name = Name + MonoNativeInfo.FlavorSuffix; } - protected override string GetMinimumOSVersion (string templateMinimumOSVersion) - { - if (MonoNativeInfo != null) - return MonoNativeInfo.GetMinimumOSVersion (); - return templateMinimumOSVersion; - } - void CreateTodayContainerProject () { var csproj = new XmlDocument (); @@ -59,6 +58,10 @@ void CreateTodayContainerProject () 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 (); @@ -84,8 +87,12 @@ void CreateTodayExtensionProject () 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); diff --git a/tests/xharness/UnifiedTarget.cs b/tests/xharness/UnifiedTarget.cs index 4d2baa4432df..aecbc3a754d1 100644 --- a/tests/xharness/UnifiedTarget.cs +++ b/tests/xharness/UnifiedTarget.cs @@ -11,7 +11,13 @@ public override string Suffix { 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; @@ -64,11 +70,18 @@ protected override void CalculateName () Name = Name + MonoNativeInfo.FlavorSuffix; } - protected override string GetMinimumOSVersion(string templateMinimumOSVersion) + protected override string GetMinimumOSVersion (string templateMinimumOSVersion) { - if (MonoNativeInfo != null) - return MonoNativeInfo.GetMinimumOSVersion (); - return templateMinimumOSVersion; + if (MonoNativeInfo == null) + return templateMinimumOSVersion; + switch (MonoNativeInfo.Flavor) { + case MonoNativeFlavor.Compat: + return "8.0"; + case MonoNativeFlavor.Unified: + return "10.0"; + default: + throw new Exception ($"Unknown MonoNativeFlavor: {MonoNativeInfo.Flavor}"); + } } protected override int[] UIDeviceFamily { @@ -111,8 +124,12 @@ protected override bool SupportsBitcode { protected override void ExecuteInternal () { - if (MonoNativeInfo != null) - base.ExecuteInternal (); + if (MonoNativeInfo == null) + return; + + MonoNativeInfo.AddProjectDefines (inputProject); + inputProject.AddAdditionalDefines ("MONO_NATIVE_IOS"); + base.ExecuteInternal (); } } } diff --git a/tests/xharness/WatchOSTarget.cs b/tests/xharness/WatchOSTarget.cs index 8327cf13b461..8d53e02a690d 100644 --- a/tests/xharness/WatchOSTarget.cs +++ b/tests/xharness/WatchOSTarget.cs @@ -30,6 +30,10 @@ void CreateWatchOSAppProject () WatchOSAppGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}"; csproj.SetProjectGuid (WatchOSAppGuid); csproj.FixInfoPListInclude (suffix); + if (MonoNativeInfo != null) { + MonoNativeInfo.AddProjectDefines (csproj); + csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH"); + } Harness.Save (csproj, WatchOSAppProjectPath); XmlDocument info_plist = new XmlDocument (); @@ -38,8 +42,7 @@ void CreateWatchOSAppProject () info_plist.SetCFBundleIdentifier (BundleIdentifier + ".watchkitapp"); info_plist.SetPListStringValue ("WKCompanionAppBundleIdentifier", BundleIdentifier); info_plist.SetPListStringValue ("CFBundleName", Name); - if (MonoNativeInfo != null) - info_plist.SetMinimumOSVersion (MonoNativeInfo.GetMinimumWatchOSVersion ()); + info_plist.SetMinimumOSVersion (GetMinimumOSVersion (info_plist.GetMinimumOSVersion ())); Harness.Save (info_plist, target_info_plist); } @@ -54,6 +57,10 @@ void CreateWatchOSContainerProject () WatchOSGuid = "{" + Harness.NewStableGuid ().ToString ().ToUpper () + "}"; csproj.SetProjectGuid (WatchOSGuid); csproj.FixInfoPListInclude (Suffix); + if (MonoNativeInfo != null) { + MonoNativeInfo.AddProjectDefines (csproj); + csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH"); + } Harness.Save (csproj, WatchOSProjectPath); XmlDocument info_plist = new XmlDocument (); @@ -61,8 +68,7 @@ void CreateWatchOSContainerProject () info_plist.LoadWithoutNetworkAccess (Path.Combine (Harness.WatchOSContainerTemplate, "Info.plist")); info_plist.SetCFBundleIdentifier (BundleIdentifier); info_plist.SetCFBundleName (Name); - if (MonoNativeInfo != null) - info_plist.SetMinimumOSVersion (MonoNativeInfo.GetMinimumOSVersion ()); + info_plist.SetMinimumOSVersion ("9.0"); Harness.Save (info_plist, target_info_plist); } @@ -85,10 +91,15 @@ void CreateWatchOSExtensionProject () 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) { + MonoNativeInfo.AddProjectDefines (csproj); + csproj.AddAdditionalDefines ("MONO_NATIVE_WATCH"); + } + // 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" }; @@ -158,7 +169,7 @@ void CreateWatchOSLibraryProject () 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); @@ -211,12 +222,32 @@ protected override void CalculateName () Name = Name + MonoNativeInfo.FlavorSuffix; } + protected override string GetMinimumOSVersion (string templateMinimumOSVersion) + { + if (MonoNativeInfo == null) + return templateMinimumOSVersion; + switch (MonoNativeInfo.Flavor) { + case MonoNativeFlavor.Compat: + return "2.0"; + case MonoNativeFlavor.Unified: + return "4.0"; + default: + throw new Exception ($"Unknown MonoNativeFlavor: {MonoNativeInfo.Flavor}"); + } + } + public override string Suffix { get { return MonoNativeInfo != null ? MonoNativeInfo.FlavorSuffix + "-watchos" : "-watchos"; } } + public override string ExtraLinkerDefsSuffix { + get { + return "-watchos"; + } + } + public override string Platform { get { return "watchos"; diff --git a/tests/xharness/xharness.csproj b/tests/xharness/xharness.csproj index fcac7b1e1658..6204abfcb22e 100644 --- a/tests/xharness/xharness.csproj +++ b/tests/xharness/xharness.csproj @@ -32,7 +32,8 @@ Project - --verbose --configure --autoconf --rootdir /Developer/Work/xamarin-macios/tests + --configure --autoconf --rootdir /Developer/Work/xamarin-macios/tests + .. Project diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index 3d84046e2258..d42596783ef8 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -1569,7 +1569,7 @@ static void HandleMonoNative (Application app, CompilerFlags compiler_flags) switch (app.Platform) { case ApplePlatform.iOS: case ApplePlatform.TVOS: - compiler_flags.AddFramework ("GSS"); + // compiler_flags.AddFramework ("GSS"); break; } break; diff --git a/tools/mtouch/mtouch.cs b/tools/mtouch/mtouch.cs index 90f4eae7b34d..f752e68a59e7 100644 --- a/tools/mtouch/mtouch.cs +++ b/tools/mtouch/mtouch.cs @@ -691,7 +691,7 @@ public static string GenerateMain (Application app, IEnumerable assemb if (app.LibMonoNativeLinkMode == AssemblyBuildTarget.StaticObject) mono_native_lib = "__Internal"; else - mono_native_lib = "mono-native"; + mono_native_lib = app.GetLibNativeName () + ".dylib"; sw.WriteLine (); sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Native\", NULL, \"{mono_native_lib}\", NULL);"); sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Security.Cryptography.Native.Apple\", NULL, \"{mono_native_lib}\", NULL);");