From 05616184607593ff52a344df8201ec1e62dc91ca Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 12 Feb 2018 14:42:19 +0100 Subject: [PATCH] [mtouch/mmp] Simplify and unify the code to select/create the static registrar. (#3461) There's only one static registrar now, so there's no need for code to select which one, just create the one and only. Also unify this code between mtouch and mmp. --- tools/common/Application.cs | 2 ++ tools/common/Target.cs | 1 + tools/mmp/Application.cs | 5 +++++ tools/mmp/driver.cs | 18 ++++++++++-------- tools/mtouch/Application.cs | 5 +---- tools/mtouch/Target.cs | 11 ----------- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/tools/common/Application.cs b/tools/common/Application.cs index e7fb62b1d6..7e5183aea7 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -397,6 +397,8 @@ namespace Xamarin.Bundler { public void InitializeCommon () { + SelectRegistrar (); + if (RequiresXcodeHeaders && SdkVersion < SdkVersions.GetVersion (Platform)) { throw ErrorHelper.CreateError (91, "This version of {0} requires the {1} {2} SDK (shipped with Xcode {3}). Either upgrade Xcode to get the required header files or {4} (to try to avoid the new APIs).", ProductName, PlatformName, SdkVersions.GetVersion (Platform), SdkVersions.Xcode, Error91LinkerSuggestion); } diff --git a/tools/common/Target.cs b/tools/common/Target.cs index f0d6d9d88b..24f1aa0828 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -59,6 +59,7 @@ namespace Xamarin.Bundler { public Target (Application app) { this.App = app; + this.StaticRegistrar = new StaticRegistrar (this); } public void ExtractNativeLinkInfo (List exceptions) diff --git a/tools/mmp/Application.cs b/tools/mmp/Application.cs index 4736c47d3c..9fa543e8d6 100644 --- a/tools/mmp/Application.cs +++ b/tools/mmp/Application.cs @@ -17,5 +17,10 @@ namespace Xamarin.Bundler { if (DeploymentTarget == null) DeploymentTarget = new Version (10, 7); } + + void SelectRegistrar () + { + Driver.SelectRegistrar (); + } } } diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index 58f344e647..cf1c488368 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -690,14 +690,9 @@ namespace Xamarin.Bundler { } } - static void Pack (IList unprocessed) + public static void SelectRegistrar () { - string fx_dir = null; - string root_assembly = null; - var native_libs = new Dictionary> (); - - if (Registrar == RegistrarMode.Default) - { + if (Registrar == RegistrarMode.Default) { if (!App.EnableDebug) Registrar = RegistrarMode.Static; else if (IsUnified && App.LinkMode == LinkMode.None && embed_mono && App.IsDefaultMarshalManagedExceptionMode && File.Exists (PartialStaticLibrary)) @@ -706,7 +701,14 @@ namespace Xamarin.Bundler { Registrar = RegistrarMode.Dynamic; Log (1, $"Defaulting registrar to '{Registrar}'"); } - + } + + static void Pack (IList unprocessed) + { + string fx_dir = null; + string root_assembly = null; + var native_libs = new Dictionary> (); + if (no_executable) { if (unprocessed.Count != 0) { var exceptions = new List (); diff --git a/tools/mtouch/Application.cs b/tools/mtouch/Application.cs index e3c51928c2..ffa03ce24b 100644 --- a/tools/mtouch/Application.cs +++ b/tools/mtouch/Application.cs @@ -823,9 +823,9 @@ namespace Xamarin.Bundler { void BuildInitialize () { + SelectRegistrar (); Initialize (); ValidateAbi (); - SelectRegistrar (); ExtractNativeLinkInfo (); SelectNativeCompiler (); } @@ -1363,9 +1363,6 @@ namespace Xamarin.Bundler { Registrar = RegistrarMode.Dynamic; } } - - foreach (var target in Targets) - target.SelectStaticRegistrar (); } // Select all abi from the list matching the specified mask. diff --git a/tools/mtouch/Target.cs b/tools/mtouch/Target.cs index a155746581..a53fbe31b2 100644 --- a/tools/mtouch/Target.cs +++ b/tools/mtouch/Target.cs @@ -872,17 +872,6 @@ namespace Xamarin.Bundler } } - public void SelectStaticRegistrar () - { - switch (App.Registrar) { - case RegistrarMode.Static: - case RegistrarMode.Dynamic: - case RegistrarMode.Default: - StaticRegistrar = new StaticRegistrar (this); - break; - } - } - void AOTCompile () { if (App.IsSimulatorBuild)