Skip to content

Commit 7da8ecd

Browse files
committed
[java-intero] Selectively keep DylibMono for Xamarin.Android
Context: dotnet/android#3504 Context: dotnet/android#3223 When bumping xamarin-android/master to 2abfc1e, the build broke because of commit 285a32b: In file included from /Users/vsts/agent/2.155.1/work/1/s/external/Java.Interop/src/java-interop/java-interop-mono.cc:2: ../../../../../external/Java.Interop/src/java-interop/java-interop-mono.h:10:11: fatal error: 'mono/metadata/assembly.h' file not found #include <mono/metadata/assembly.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. We need to continue supporting the DylibMono backend for integration purposes (dotnet/android#3504) *while also* allowing for the *removal* of DylibMono (dotnet/android#3223). Attempt to support these divergent needs by replacing this: #if defined (ANDROID) || defined (XAMARIN_ANDROID_DYLIB_MONO) with this: #if defined (XAMARIN_ANDROID_DYLIB_MONO) removing the check for the `ANDROID` define. This will allow xamrin/xamarin-android#3223 to *remove* the `XAMARIN_ANDROID_DYLIB_MONO` definition in order to introduce it's desired behavior, removing DylibMono use. This partially reverts commit 285a32b.
1 parent ffbb2dc commit 7da8ecd

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/java-interop/java-interop-gc-bridge-mono.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ java_interop_gc_bridge_new (JavaVM *jvm)
268268
if (jvm == NULL)
269269
return NULL;
270270

271+
#if defined (XAMARIN_ANDROID_DYLIB_MONO)
272+
if (!monodroid_dylib_mono_init (monodroid_get_dylib (), NULL)) {
273+
log_fatal (LOG_DEFAULT, "mono runtime initialization error: %s", dlerror ());
274+
exit (FATAL_EXIT_CANNOT_FIND_MONO);
275+
}
276+
#endif /* defined (XAMARIN_ANDROID_DYLIB_MONO) */
277+
271278
lookup_optional_mono_thread_functions ();
272279

273280
JavaInteropGCBridge bridge = {0};

src/java-interop/java-interop-mono.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33

44
#include "java-interop.h"
55

6+
#if defined (XAMARIN_ANDROID_DYLIB_MONO)
7+
8+
#include "dylib-mono.h"
9+
#include "monodroid-glue.h"
10+
11+
#define mono_class_from_mono_type (monodroid_get_dylib ()->class_from_mono_type)
12+
#define mono_class_from_name (monodroid_get_dylib ()->class_from_name)
13+
#define mono_class_get_field_from_name (monodroid_get_dylib ()->class_get_field_from_name)
14+
#define mono_class_get_name (monodroid_get_dylib ()->class_get_name)
15+
#define mono_class_get_namespace (monodroid_get_dylib ()->class_get_namespace)
16+
#define mono_class_is_subclass_of (monodroid_get_dylib ()->class_is_subclass_of)
17+
#define mono_class_vtable (monodroid_get_dylib ()->class_vtable)
18+
#define mono_domain_get (monodroid_get_dylib ()->domain_get)
19+
#define mono_field_get_value (monodroid_get_dylib ()->field_get_value)
20+
#define mono_field_set_value (monodroid_get_dylib ()->field_set_value)
21+
#define mono_field_static_set_value (monodroid_get_dylib ()->field_static_set_value)
22+
#define mono_object_get_class (monodroid_get_dylib ()->object_get_class)
23+
#define mono_thread_attach (monodroid_get_dylib ()->thread_attach)
24+
#define mono_thread_current (monodroid_get_dylib ()->thread_current)
25+
#define mono_gc_register_bridge_callbacks (monodroid_get_dylib ()->gc_register_bridge_callbacks)
26+
#define mono_gc_wait_for_bridge_processing (monodroid_get_dylib ()->gc_wait_for_bridge_processing)
27+
28+
#else /* !defined (XAMARIN_ANDROID_DYLIB_MONO) */
29+
630
#undef MONO_API_EXPORT
731
#undef MONO_API_IMPORT
832
#undef MONO_API
@@ -15,6 +39,8 @@
1539
#include <mono/utils/mono-counters.h>
1640
#include <mono/utils/mono-dl-fallback.h>
1741

42+
#endif /* !defined (XAMARIN_ANDROID_DYLIB_MONO) */
43+
1844
JAVA_INTEROP_BEGIN_DECLS
1945

2046
JAVA_INTEROP_END_DECLS

0 commit comments

Comments
 (0)