diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index c6dbefd0a00d..56c08f132d4e 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -139,7 +139,7 @@ <_AdditionalTaskAssemblyDirectory>$(_XamarinSdkRootDirectory)tools/dotnet-linker/ <_AdditionalTaskAssembly>$(_AdditionalTaskAssemblyDirectory)dotnet-linker.dll - + @@ -164,6 +164,7 @@ LinkMode=$(_LinkMode) MarshalManagedExceptionMode=$(_MarshalManagedExceptionMode) MarshalObjectiveCExceptionMode=$(_MarshalObjectiveCExceptionMode) + Optimize=$(_BundlerOptimize) PartialStaticRegistrarLibrary=$(_LibPartialStaticRegistrar) Platform=$(_PlatformName) PlatformAssembly=$(_PlatformAssemblyName).dll diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index 7efeda850cfe..34ac0afc6dc8 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -12,7 +12,10 @@ namespace Xamarin.Tests { [TestFixture] public class DotNetProjectTest { - Dictionary verbosity = new Dictionary { { "_BundlerVerbosity", "1" } }; + Dictionary verbosity = new Dictionary { + { "MtouchExtraArgs", "-v" }, + { "MonoBundlingExtraArgs", "-v" }, + }; string GetProjectPath (string project, string subdir = null) { diff --git a/tests/xharness/Harness.cs b/tests/xharness/Harness.cs index 8a00ed0602d2..84df31ff5e02 100644 --- a/tests/xharness/Harness.cs +++ b/tests/xharness/Harness.cs @@ -390,7 +390,7 @@ void AutoConfigureIOS () IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "interdependent-binding-projects", "interdependent-binding-projects.csproj"))) { Name = "interdependent-binding-projects" }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "interdependent-binding-projects", "dotnet", "iOS", "interdependent-binding-projects.csproj"))) { Name = "interdependent-binding-projects", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios.csproj"))) { Name = "introspection" }); - IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios-dotnet.csproj"))) { Name = "introspection", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = false, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, }); + IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios-dotnet.csproj"))) { Name = "introspection", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "monotouch-test", "dotnet", "iOS", "monotouch-test.csproj"))) { Name = "monotouch-test", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" } }); IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true }); diff --git a/tools/dotnet-linker/LinkerConfiguration.cs b/tools/dotnet-linker/LinkerConfiguration.cs index e682d5860656..1e59a0cc38e0 100644 --- a/tools/dotnet-linker/LinkerConfiguration.cs +++ b/tools/dotnet-linker/LinkerConfiguration.cs @@ -45,6 +45,8 @@ public class LinkerConfiguration { // The list of assemblies is populated in CollectAssembliesStep. public List Assemblies = new List (); + + string user_optimize_flags; public static LinkerConfiguration GetInstance (LinkContext context) { @@ -134,6 +136,9 @@ public static LinkerConfiguration GetInstance (LinkContext context) Application.MarshalObjectiveCExceptions = mode; } break; + case "Optimize": + user_optimize_flags = value; + break; case "PartialStaticRegistrarLibrary": PartialStaticRegistrarLibrary = value; break; @@ -191,10 +196,16 @@ public static LinkerConfiguration GetInstance (LinkContext context) ErrorHelper.Platform = Platform; + // Optimizations.Parse can only be called after setting ErrorHelper.Platform + if (!string.IsNullOrEmpty (user_optimize_flags)) { + var messages = new List (); + Application.Optimizations.Parse (Application.Platform, user_optimize_flags, messages); + ErrorHelper.Show (messages); + } + Application.CreateCache (significantLines.ToArray ()); Application.Cache.Location = CacheDirectory; Application.DeploymentTarget = DeploymentTarget; - Application.EnableCoopGC ??= Platform == ApplePlatform.WatchOS; Application.SdkVersion = SdkVersion; switch (Platform) { @@ -211,8 +222,7 @@ public static LinkerConfiguration GetInstance (LinkContext context) if (Driver.TargetFramework.Platform != Platform) throw ErrorHelper.CreateError (99, "Inconsistent platforms. TargetFramework={0}, Platform={1}", Driver.TargetFramework.Platform, Platform); - Application.SetManagedExceptionMode (); - Application.SetObjectiveCExceptionMode (); + Application.InitializeCommon (); } public void Write () @@ -232,6 +242,7 @@ public void Write () Console.WriteLine ($" LinkMode: {LinkMode}"); Console.WriteLine ($" MarshalManagedExceptions: {Application.MarshalManagedExceptions} (IsDefault: {Application.IsDefaultMarshalManagedExceptionMode})"); Console.WriteLine ($" MarshalObjectiveCExceptions: {Application.MarshalObjectiveCExceptions}"); + Console.WriteLine ($" Optimize: {user_optimize_flags} => {Application.Optimizations}"); Console.WriteLine ($" PartialStaticRegistrarLibrary: {PartialStaticRegistrarLibrary}"); Console.WriteLine ($" Platform: {Platform}"); Console.WriteLine ($" PlatformAssembly: {PlatformAssembly}.dll");