From d7ab8476970fbbd11b659c1db4a69036f9c38e5f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 24 Aug 2020 17:50:42 +0200 Subject: [PATCH] [dotnet] Implement support for our different link modes. (#9460) * [mmp] Rename LinkMode.All to LinkMode.Full. So that we can continue to use Enum.Parse to parse 'Full' as the link mode. * [dotnet] Implement support for our different link modes. Tell the managed linker what to do with each input assembly depending the selected link mode (link all, link sdk, don't link). --- dotnet/targets/Xamarin.Shared.Sdk.targets | 22 +++++++++++++++++++++- tools/common/Application.cs | 2 +- tools/common/LinkMode.cs | 2 +- tools/mmp/driver.cs | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 097ab04454a0..b79b2ce0fc38 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -116,7 +116,10 @@ <_AdditionalTaskAssemblyDirectory>$(_XamarinSdkRootDirectory)tools/dotnet-linker/ <_AdditionalTaskAssembly>$(_AdditionalTaskAssemblyDirectory)dotnet-linker.dll - + + + + <_CustomLinkerOptionsFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)custom-linker-options.txt')) @@ -146,6 +149,11 @@ <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) -p copy "System.Runtime" + + copy + link + + <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --verbose @@ -161,7 +169,19 @@ --> <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) -b + + + + link + + + + + <_TrimmerCustomSteps Include="$(_AdditionalTaskAssembly)"> LoadReferencesStep diff --git a/tools/common/Application.cs b/tools/common/Application.cs index 7bccce19232e..b1c228827d38 100644 --- a/tools/common/Application.cs +++ b/tools/common/Application.cs @@ -74,7 +74,7 @@ public partial class Application public ApplePlatform Platform { get { return Driver.TargetFramework.Platform; } } // Linker config - public LinkMode LinkMode = LinkMode.All; + public LinkMode LinkMode = LinkMode.Full; public List LinkSkipped = new List (); public List Definitions = new List (); public I18nAssemblies I18n; diff --git a/tools/common/LinkMode.cs b/tools/common/LinkMode.cs index 4d293115c603..cff6a2ac4ad3 100644 --- a/tools/common/LinkMode.cs +++ b/tools/common/LinkMode.cs @@ -8,7 +8,7 @@ namespace Xamarin.Bundler { public enum LinkMode { None, SDKOnly, - All, + Full, Platform, } } diff --git a/tools/mmp/driver.cs b/tools/mmp/driver.cs index 23f4ebbfadc9..213f5a590dfd 100644 --- a/tools/mmp/driver.cs +++ b/tools/mmp/driver.cs @@ -599,7 +599,7 @@ static void Pack (IList unprocessed) if (generate_plist) GeneratePList (); - if (App.LinkMode != LinkMode.All && App.RuntimeOptions != null) + if (App.LinkMode != LinkMode.Full && App.RuntimeOptions != null) App.RuntimeOptions.Write (resources_dir); if (App.AOTOptions != null && App.AOTOptions.IsAOT) {