Tooling support for mono-native.
This commit is contained in:
Родитель
7e7ad1678f
Коммит
91169d6112
|
@ -2508,9 +2508,6 @@ xamarin_create_product_exception (int code, const char *message)
|
|||
void
|
||||
xamarin_insert_dllmap ()
|
||||
{
|
||||
mono_dllmap_insert (NULL, "System.Native", NULL, "mono-native", NULL);
|
||||
mono_dllmap_insert (NULL, "System.Security.Cryptography.Native.Apple", NULL, "mono-native", NULL);
|
||||
|
||||
#if defined (OBJC_ZEROCOST_EXCEPTIONS) && (defined (__i386__) || defined (__x86_64__))
|
||||
if (xamarin_marshal_objectivec_exception_mode == MarshalObjectiveCExceptionModeDisable)
|
||||
return;
|
||||
|
|
|
@ -378,6 +378,9 @@ namespace Xamarin.Bundler {
|
|||
switch (file) {
|
||||
// special case
|
||||
case "__Internal":
|
||||
case "System.Native":
|
||||
case "System.Security.Cryptography.Native.Apple":
|
||||
case "System.Net.Security.Native":
|
||||
// well known libs
|
||||
case "libc":
|
||||
case "libSystem":
|
||||
|
|
|
@ -71,6 +71,14 @@ namespace Xamarin.Tuner
|
|||
}
|
||||
}
|
||||
|
||||
public bool RequireMonoNative {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool RequireGss {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DerivedLinkContext (Pipeline pipeline, AssemblyResolver resolver)
|
||||
: base (pipeline, resolver)
|
||||
{
|
||||
|
|
|
@ -112,8 +112,21 @@ namespace MonoTouch.Tuner
|
|||
}
|
||||
}
|
||||
|
||||
if (pinfo.Module.Name == "__Internal")
|
||||
switch (pinfo.Module.Name) {
|
||||
case "__Internal":
|
||||
DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method);
|
||||
break;
|
||||
case "System.Native":
|
||||
case "System.Security.Cryptography.Native.Apple":
|
||||
DerivedLinkContext.RequireMonoNative = true;
|
||||
DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method);
|
||||
break;
|
||||
case "System.Net.Security.Native":
|
||||
DerivedLinkContext.RequireGss = true;
|
||||
DerivedLinkContext.RequireMonoNative = true;
|
||||
DerivedLinkContext.RequiredSymbols.AddFunction (pinfo.EntryPoint).AddMember (method);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MarkStep.IsPropertyMethod (method)) {
|
||||
|
|
|
@ -64,8 +64,7 @@ namespace Xamarin.Bundler {
|
|||
public enum MonoNativeMode {
|
||||
None,
|
||||
Compat,
|
||||
Unified,
|
||||
Combined
|
||||
Unified
|
||||
}
|
||||
|
||||
public partial class Application
|
||||
|
@ -1421,8 +1420,12 @@ namespace Xamarin.Bundler {
|
|||
{
|
||||
switch (Platform) {
|
||||
case ApplePlatform.iOS:
|
||||
case ApplePlatform.TVOS:
|
||||
MonoNativeMode = DeploymentTarget.Major >= 10 ? MonoNativeMode.Unified : MonoNativeMode.Compat;
|
||||
break;
|
||||
case ApplePlatform.WatchOS:
|
||||
MonoNativeMode = DeploymentTarget.Major >= 3 ? MonoNativeMode.Unified : MonoNativeMode.Compat;
|
||||
break;
|
||||
default:
|
||||
MonoNativeMode = MonoNativeMode.None;
|
||||
break;
|
||||
|
@ -1608,9 +1611,12 @@ namespace Xamarin.Bundler {
|
|||
info.Sources.Add (GetLibMono (AssemblyBuildTarget.Framework));
|
||||
}
|
||||
|
||||
var require_mono_native = false;
|
||||
|
||||
// Collect files to bundle from every target
|
||||
if (Targets.Count == 1) {
|
||||
bundle_files = Targets [0].BundleFiles;
|
||||
require_mono_native = Targets[0].LinkContext?.RequireMonoNative ?? true;
|
||||
} else {
|
||||
foreach (var target in Targets) {
|
||||
foreach (var kvp in target.BundleFiles) {
|
||||
|
@ -1619,10 +1625,11 @@ namespace Xamarin.Bundler {
|
|||
bundle_files [kvp.Key] = info = new BundleFileInfo () { DylibToFramework = kvp.Value.DylibToFramework };
|
||||
info.Sources.UnionWith (kvp.Value.Sources);
|
||||
}
|
||||
require_mono_native |= target.LinkContext?.RequireMonoNative ?? true;
|
||||
}
|
||||
}
|
||||
|
||||
if (MonoNativeMode != MonoNativeMode.None && LibMonoNativeLinkMode == AssemblyBuildTarget.DynamicLibrary) {
|
||||
if (require_mono_native && MonoNativeMode != MonoNativeMode.None && (LibMonoNativeLinkMode == AssemblyBuildTarget.DynamicLibrary)) {
|
||||
BundleFileInfo info;
|
||||
var lib_native_name = GetLibNativeName () + ".dylib";
|
||||
bundle_files[lib_native_name] = info = new BundleFileInfo ();
|
||||
|
@ -1884,8 +1891,6 @@ namespace Xamarin.Bundler {
|
|||
return "libmono-native-unified";
|
||||
case MonoNativeMode.Compat:
|
||||
return "libmono-native-compat";
|
||||
case MonoNativeMode.Combined:
|
||||
return "libmono-native";
|
||||
default:
|
||||
throw ErrorHelper.CreateError (100, "Invalid mono native type: '{0}'. Please file a bug report with a test case (http://bugzilla.xamarin.com).", MonoNativeMode);
|
||||
}
|
||||
|
|
|
@ -1550,12 +1550,15 @@ namespace Xamarin.Bundler
|
|||
build_tasks.Add (link_task);
|
||||
}
|
||||
|
||||
static void HandleMonoNative (Application app, CompilerFlags compiler_flags)
|
||||
void HandleMonoNative (Application app, CompilerFlags compiler_flags)
|
||||
{
|
||||
if (app.MonoNativeMode == MonoNativeMode.None)
|
||||
return;
|
||||
if (LinkContext != null && !LinkContext.RequireMonoNative)
|
||||
return;
|
||||
var libnative = app.GetLibNativeName ();
|
||||
var libdir = Driver.GetMonoTouchLibDirectory (app);
|
||||
Driver.Log (3, "Adding mono-native library {0} for {1}.", libnative, app);
|
||||
switch (app.LibMonoNativeLinkMode) {
|
||||
case AssemblyBuildTarget.DynamicLibrary:
|
||||
libnative = Path.Combine (libdir, libnative + ".dylib");
|
||||
|
@ -1564,6 +1567,14 @@ namespace Xamarin.Bundler
|
|||
case AssemblyBuildTarget.StaticObject:
|
||||
libnative = Path.Combine (libdir, libnative + ".a");
|
||||
compiler_flags.AddLinkWith (libnative);
|
||||
switch (app.Platform) {
|
||||
case ApplePlatform.iOS:
|
||||
if (LinkContext?.RequireGss ?? false) {
|
||||
Driver.Log (3, "Adding GSS framework reference.");
|
||||
compiler_flags.AddFramework ("GSS");
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw ErrorHelper.CreateError (100, "Invalid assembly build target: '{0}'. Please file a bug report with a test case (http://bugzilla.xamarin.com).", app.LibMonoLinkMode);
|
||||
|
@ -1626,6 +1637,23 @@ namespace Xamarin.Bundler
|
|||
|
||||
Symlinked = true;
|
||||
|
||||
if (App.MonoNativeMode != MonoNativeMode.None) {
|
||||
var lib_native_target = Path.Combine (TargetDirectory, "libmono-native.dylib");
|
||||
Application.TryDelete (lib_native_target);
|
||||
|
||||
try {
|
||||
var lib_native_name = App.GetLibNativeName () + ".dylib";
|
||||
var lib_native_path = Path.Combine (Driver.GetMonoTouchLibDirectory (App), lib_native_name);
|
||||
File.Copy (lib_native_path, lib_native_target);
|
||||
File.SetLastWriteTime (lib_native_path, DateTime.Now);
|
||||
Driver.Log (3, "Adding mono-native library {0} for {1}.", lib_native_name, App.MonoNativeMode);
|
||||
} catch (MonoTouchException) {
|
||||
throw;
|
||||
} catch (Exception ex) {
|
||||
throw new MonoTouchException (1015, true, ex, "Failed to create the Mono.Native library '{0}': {1}", lib_native_target, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (Driver.Verbosity > 0)
|
||||
Console.WriteLine ("Application ({0}) was built using fast-path for simulator.", string.Join (", ", Abis.ToArray ()));
|
||||
}
|
||||
|
|
|
@ -686,6 +686,19 @@ namespace Xamarin.Bundler
|
|||
}
|
||||
}
|
||||
|
||||
if (app.MonoNativeMode != MonoNativeMode.None) {
|
||||
string mono_native_lib;
|
||||
if (app.LibMonoNativeLinkMode == AssemblyBuildTarget.StaticObject)
|
||||
mono_native_lib = "__Internal";
|
||||
else
|
||||
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);");
|
||||
sw.WriteLine ($"\tmono_dllmap_insert (NULL, \"System.Net.Security.Native\", NULL, \"{mono_native_lib}\", NULL);");
|
||||
sw.WriteLine ();
|
||||
}
|
||||
|
||||
if (app.EnableDebug)
|
||||
sw.WriteLine ("\txamarin_gc_pump = {0};", app.DebugTrack.Value ? "TRUE" : "FALSE");
|
||||
sw.WriteLine ("\txamarin_init_mono_debug = {0};", app.PackageManagedDebugSymbols ? "TRUE" : "FALSE");
|
||||
|
|
|
@ -31,6 +31,10 @@ void xamarin_setup_impl ()
|
|||
#else
|
||||
xamarin_marshal_objectivec_exception_mode = MarshalObjectiveCExceptionModeDisabled;
|
||||
#endif
|
||||
|
||||
mono_dllmap_insert (NULL, "System.Native", NULL, "mono-native", NULL);
|
||||
mono_dllmap_insert (NULL, "System.Security.Cryptography.Native.Apple", NULL, "mono-native", NULL);
|
||||
mono_dllmap_insert (NULL, "System.Net.Security.Native", NULL, "mono-native", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Загрузка…
Ссылка в новой задаче