diff --git a/tools/common/DerivedLinkContext.cs b/tools/common/DerivedLinkContext.cs new file mode 100644 index 0000000000..09856080b4 --- /dev/null +++ b/tools/common/DerivedLinkContext.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; + +using Mono.Cecil; +using Mono.Linker; + +namespace Xamarin.Tuner +{ + public class DerivedLinkContext : LinkContext + { + Dictionary required_symbols; + List marshal_exception_pinvokes; + + public Dictionary RequiredSymbols { + get { + if (required_symbols == null) + required_symbols = new Dictionary (); + return required_symbols; + } + } + + public List MarshalExceptionPInvokes { + get { + if (marshal_exception_pinvokes == null) + marshal_exception_pinvokes = new List (); + return marshal_exception_pinvokes; + } + } + + public DerivedLinkContext (Pipeline pipeline, AssemblyResolver resolver) + : base (pipeline, resolver) + { + } + } +} diff --git a/tools/linker/MobileMarkStep.cs b/tools/linker/MobileMarkStep.cs index c955a72981..8b247a9d95 100644 --- a/tools/linker/MobileMarkStep.cs +++ b/tools/linker/MobileMarkStep.cs @@ -9,12 +9,6 @@ using Mono.Linker; using Mono.Linker.Steps; using Mono.Tuner; -#if MONOMAC -using DerivedLinkContext = MonoMac.Tuner.MonoMacLinkContext; -#else -using DerivedLinkContext = MonoTouch.Tuner.MonoTouchLinkContext; -#endif - namespace Xamarin.Linker.Steps { // XML definition files have their limits, i.e. they are good to keep stuff around unconditionnally diff --git a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs index 2f4e0b57ea..f85579bcd4 100644 --- a/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs +++ b/tools/linker/MonoTouch.Tuner/ListExportedSymbols.cs @@ -8,12 +8,7 @@ using Mono.Tuner; using Xamarin.Bundler; using Xamarin.Linker; - -#if MONOMAC -using DerivedLinkContext = MonoMac.Tuner.MonoMacLinkContext; -#else -using DerivedLinkContext = MonoTouch.Tuner.MonoTouchLinkContext; -#endif +using Xamarin.Tuner; namespace MonoTouch.Tuner { diff --git a/tools/linker/MonoTouch.Tuner/ProcessExportedFields.cs b/tools/linker/MonoTouch.Tuner/ProcessExportedFields.cs index 4b418e7d4b..189b98e490 100644 --- a/tools/linker/MonoTouch.Tuner/ProcessExportedFields.cs +++ b/tools/linker/MonoTouch.Tuner/ProcessExportedFields.cs @@ -7,12 +7,6 @@ using Mono.Linker.Steps; using Mono.Tuner; using Xamarin.Linker; -#if MONOMAC -using DerivedLinkContext = MonoMac.Tuner.MonoMacLinkContext; -#else -using DerivedLinkContext = MonoTouch.Tuner.MonoTouchLinkContext; -#endif - namespace MonoTouch.Tuner { // diff --git a/tools/mmp/Makefile b/tools/mmp/Makefile index 3ba38e3ff4..0db824609f 100644 --- a/tools/mmp/Makefile +++ b/tools/mmp/Makefile @@ -117,6 +117,7 @@ mmp_sources = \ $(TOP)/tools/common/Target.cs \ $(TOP)/tools/common/Application.cs \ $(TOP)/tools/common/Assembly.cs \ + $(TOP)/tools/common/DerivedLinkContext.cs \ $(TOP)/src/Foundation/ConnectAttribute.cs \ $(TOP)/src/Foundation/ExportAttribute.cs \ $(TOP)/src/ObjCRuntime/ArgumentSemantic.cs \ diff --git a/tools/mmp/Tuning.cs b/tools/mmp/Tuning.cs index 688fe21770..cecc6839db 100644 --- a/tools/mmp/Tuning.cs +++ b/tools/mmp/Tuning.cs @@ -11,6 +11,7 @@ using MonoTouch.Tuner; using Xamarin.Bundler; using Xamarin.Linker; using Xamarin.Linker.Steps; +using Xamarin.Tuner; using Xamarin.Utils; using Mono.Cecil; @@ -54,11 +55,9 @@ namespace MonoMac.Tuner { } } - public class MonoMacLinkContext : LinkContext { + public class MonoMacLinkContext : DerivedLinkContext { Dictionary> pinvokes = new Dictionary> (); - public Dictionary RequiredSymbols = new Dictionary (); - List marshal_exception_pinvokes; public MonoMacLinkContext (Pipeline pipeline, AssemblyResolver resolver) : base (pipeline, resolver) { @@ -67,14 +66,6 @@ namespace MonoMac.Tuner { public IDictionary> PInvokeModules { get { return pinvokes; } } - - public List MarshalExceptionPInvokes { - get { - if (marshal_exception_pinvokes == null) - marshal_exception_pinvokes = new List (); - return marshal_exception_pinvokes; - } - } } class Linker { diff --git a/tools/mmp/mmp.csproj b/tools/mmp/mmp.csproj index 9f18fd4830..6dd3e44c92 100644 --- a/tools/mmp/mmp.csproj +++ b/tools/mmp/mmp.csproj @@ -292,6 +292,9 @@ external\Target.cs + + external\DerivedLinkContext.cs + external\Registrar.core.cs diff --git a/tools/mtouch/Makefile b/tools/mtouch/Makefile index 0909aaf534..3e3e8a1c71 100644 --- a/tools/mtouch/Makefile +++ b/tools/mtouch/Makefile @@ -124,6 +124,7 @@ MTOUCH_SOURCES = \ BitcodeConverter.cs \ $(TOP)/tools/common/Application.cs \ $(TOP)/tools/common/Assembly.cs \ + $(TOP)/tools/common/DerivedLinkContext.cs \ $(TOP)/tools/common/Target.cs \ $(TOP)/tools/common/CompilerFlags.cs \ $(TOP)/src/Foundation/ExportAttribute.cs \ diff --git a/tools/mtouch/Tuning.cs b/tools/mtouch/Tuning.cs index c714fd4506..9d1683a6d0 100644 --- a/tools/mtouch/Tuning.cs +++ b/tools/mtouch/Tuning.cs @@ -12,6 +12,7 @@ using Mono.Tuner; using Xamarin.Bundler; using Xamarin.Linker; using Xamarin.Linker.Steps; +using Xamarin.Tuner; namespace MonoTouch.Tuner { @@ -223,26 +224,7 @@ namespace MonoTouch.Tuner { } } - public class MonoTouchLinkContext : LinkContext { - Dictionary required_symbols; - List marshal_exception_pinvokes; - - public Dictionary RequiredSymbols { - get { - if (required_symbols == null) - required_symbols = new Dictionary (); - return required_symbols; - } - } - - public List MarshalExceptionPInvokes { - get { - if (marshal_exception_pinvokes == null) - marshal_exception_pinvokes = new List (); - return marshal_exception_pinvokes; - } - } - + public class MonoTouchLinkContext : DerivedLinkContext { public MonoTouchLinkContext (Pipeline pipeline, AssemblyResolver resolver) : base (pipeline, resolver) { diff --git a/tools/mtouch/mtouch.csproj b/tools/mtouch/mtouch.csproj index 6b40d72d0f..3f0d0091ff 100644 --- a/tools/mtouch/mtouch.csproj +++ b/tools/mtouch/mtouch.csproj @@ -262,6 +262,9 @@ external\Target.cs + + external\DerivedLinkContext.cs + external\Frameworks.cs