Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/build')
-rw-r--r--main/build/MacOSX/Makefile.am10
-rw-r--r--main/build/MacOSX/monostub.mm108
2 files changed, 70 insertions, 48 deletions
diff --git a/main/build/MacOSX/Makefile.am b/main/build/MacOSX/Makefile.am
index fb0277af8f..1836b55a7f 100644
--- a/main/build/MacOSX/Makefile.am
+++ b/main/build/MacOSX/Makefile.am
@@ -8,8 +8,8 @@ EXTRAS=$(top_srcdir)/../extras
ARTIFACTS=$(top_srcdir)/../../artifacts
MD_CONFIGURE=$(top_srcdir)/../scripts/configure.sh
EXTERNAL=../../external
-MONOSTUB_DEFINES=-DXM_REGISTRAR
-MONOSTUB_STATIC_LINK=$(EXTERNAL)/Xamarin.Mac.registrar.full.a
+MONOSTUB_DEFINES=-DXM_REGISTRAR -DXM_SYSTEM -DDYNAMIC_MONO_RUNTIME
+MONOSTUB_STATIC_LINK=$(EXTERNAL)/Xamarin.Mac.registrar.full.a $(EXTERNAL)/libxammac-system.a
EXTERN_C_XM_REGISTRAR_DEFINE=$(shell ./check-xm-extern.sh)
#SDK_PATH=$(shell xcrun --sdk macosx10.8 --show-sdk-path)
@@ -35,13 +35,15 @@ System_Native.o: System_Native.cpp
g++ -std=c++14 -c -Wall -mmacosx-version-min=10.10 -o $@ $^
monostub.o: monostub.mm $(MONOSTUB_EXTRA_SOURCES)
- g++ $(EXTERN_C_XM_REGISTRAR_DEFINE) $(MONOSTUB_DEFINES) -c -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub.mm
+ g++ -g $(EXTERN_C_XM_REGISTRAR_DEFINE) $(MONOSTUB_DEFINES) -c -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub.mm -I/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/include/xamarin
monostub: monostub.o System_Native.o $(MONOSTUB_STATIC_LINK)
- clang++ -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ $^ -framework AppKit -framework Quartz -undefined dynamic_lookup
+ clang++ -g -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ -Wl,-all_load $^ -framework AppKit -framework Quartz -undefined dynamic_lookup
# gcc -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub.m -framework AppKit -isysroot $(SDK_PATH)
cp monostub ../bin/MonoDevelop
cp monostub ../bin/mdtool
+ mkdir -p ../bin/Contents
+ ln -sfh .. "../bin/Contents/MonoBundle"
monostub-test: monostub-test.m $(MONOSTUB_EXTRA_SOURCES)
gcc -g -Wall -mmacosx-version-min=10.10 -m$(MONOSTUB_ARCH) -o $@ monostub-test.m -framework AppKit
diff --git a/main/build/MacOSX/monostub.mm b/main/build/MacOSX/monostub.mm
index db58b5f57a..bc24d663d1 100644
--- a/main/build/MacOSX/monostub.mm
+++ b/main/build/MacOSX/monostub.mm
@@ -12,15 +12,21 @@
#include <ctype.h>
#include <time.h>
-#include "monostub-utils.h"
-
-#import <Foundation/Foundation.h>
-
+#if XM_SYSTEM
+#include <main.h>
+#include <launch.h>
+#include <runtime.h>
+#else
typedef int (* mono_main) (int argc, char **argv);
typedef void (* mono_free) (void *ptr);
typedef char * (* mono_get_runtime_build_info) (void);
+#endif
typedef void (* gobject_tracker_init) (void *libmono);
+#include "monostub-utils.h"
+
+#import <Foundation/Foundation.h>
+
#if XM_REGISTRAR
extern
#if EXTERN_C
@@ -37,7 +43,7 @@ extern
void xamarin_create_classes ();
#endif
-void *libmono, *libxammac;
+void *libmono;
static void
exit_with_message (const char *reason, char *argv0)
@@ -269,6 +275,56 @@ try_load_gobject_tracker (void *libmono, char *entry_executable)
}
}
+static void
+run_md_bundle_if_needed(NSString *appDir, int argc, char **argv)
+{
+ // if we are running inside an app bundle and --start-app-bundle has been passed
+ // run the actual bundle and exit.
+ if (![appDir isEqualToString:@"."] && argc > 1 && !strcmp(argv[1], "--start-app-bundle")) {
+ NSArray *arguments = [NSArray array];
+ if (argc > 2) {
+ NSString *strings[argc-2];
+ for (int i = 0; i < argc-2; i++)
+ strings [i] = [[NSString alloc] initWithUTF8String:argv[i+2]];
+ arguments = [NSArray arrayWithObjects:strings count:argc-2];
+ }
+ run_md_bundle (appDir, arguments);
+ }
+}
+
+static void
+init_registrar()
+{
+#if XM_REGISTRAR
+ xamarin_create_classes_Xamarin_Mac ();
+#elif STATIC_REGISTRAR
+ xamarin_create_classes ();
+#endif
+}
+
+#ifdef XM_SYSTEM
+extern "C"
+void xamarin_app_initialize(xamarin_initialize_data *data)
+{
+ setenv ("MONO_GC_PARAMS", "major=marksweep-conc,nursery-size=8m", 0);
+
+ run_md_bundle_if_needed(data->app_dir, data->argc, data->argv);
+
+ data->requires_relaunch = update_environment ([[data->app_dir stringByAppendingPathComponent:@"Contents"] UTF8String], true);
+
+ if (data->requires_relaunch)
+ return;
+
+ correct_locale();
+}
+
+extern "C" int
+xammac_setup ()
+{
+ init_registrar();
+ return 0;
+}
+#else
int main (int argc, char **argv)
{
//clock_t start = clock();
@@ -286,18 +342,7 @@ int main (int argc, char **argv)
NSString *appDir = [[NSBundle mainBundle] bundlePath];
- // if we are running inside an app bundle and --start-app-bundle has been passed
- // run the actual bundle and exit.
- if (![appDir isEqualToString:@"."] && argc > 1 && !strcmp(argv[1],"--start-app-bundle")) {
- NSArray *arguments = [NSArray array];
- if (argc > 2) {
- NSString *strings[argc-2];
- for (int i = 0; i < argc-2; i++)
- strings [i] = [[NSString alloc] initWithUTF8String:argv[i+2]];
- arguments = [NSArray arrayWithObjects:strings count:argc-2];
- }
- run_md_bundle (appDir, arguments);
- }
+ run_md_bundle_if_needed(appDir, argc, argv);
// can be overridden with plist string MonoMinVersion
NSString *req_mono_version = @"5.2.0.171";
@@ -368,33 +413,7 @@ int main (int argc, char **argv)
exit_with_message ((char *)[msg UTF8String], argv[0]);
}
-#if XM_REGISTRAR
- libxammac = dlopen ("@loader_path/libxammac.dylib", RTLD_LAZY);
- if (!libxammac) {
- libxammac = dlopen ("@loader_path/../Resources/lib/monodevelop/bin/libxammac.dylib", RTLD_LAZY);
- if (!libxammac) {
- fprintf (stderr, "Failed to load libxammac.dylib: %s\n", dlerror ());
- NSString *msg = @"This application requires Xamarin.Mac native library side-by-side.";
- exit_with_message ((char *)[msg UTF8String], argv[0]);
- }
- }
-
- xamarin_create_classes_Xamarin_Mac ();
-#endif
-
-#if STATIC_REGISTRAR
- libxammac = dlopen ("@loader_path/libxammac.dylib", RTLD_LAZY);
- if (!libxammac) {
- libxammac = dlopen ("@loader_path/../Resources/lib/monodevelop/bin/libxammac.dylib", RTLD_LAZY);
- if (!libxammac) {
- fprintf (stderr, "Failed to load libxammac.dylib: %s\n", dlerror ());
- NSString *msg = @"This application requires Xamarin.Mac native library side-by-side.";
- exit_with_message ((char *)[msg UTF8String], argv[0]);
- }
- }
-
- xamarin_create_classes ();
-#endif
+ init_registrar();
try_load_gobject_tracker (libmono, argv [0]);
@@ -449,3 +468,4 @@ int main (int argc, char **argv)
return _mono_main (argc + extra_argc + injected, new_argv);
}
+#endif