Store the minimum mono version for Xamarin.Mac in one place only (Make.config) and bump it to 5.14. Fixes #4120. (#4695)

* Store the minimum mono version for Xamarin.Mac in one place only (Make.config) and bump it to 5.14. Fixes #4120.

I've verified that we fail at launch of running on 5.12, while 5.14 works fine
(to launch at least), so the minimum system mono version is _at least_ 5.14.

Fixes https://github.com/xamarin/xamarin-macios/issues/4120.

* [mmp] Load mono's version file instead of using pkg-config to get mono's version.

pkg-config will only get three parts of the version, while the version file
has all four parts.

This is important, since we're now verifying the four parts of the version
file, and without loading those four from the system, we'll fail builds like
this:

    error MM0001: This version of Xamarin.Mac requires Mono 5.14.0.136 (the current Mono version is 5.14.0).

because the three part version's fourth number is assumed to be 0.

* Only verify mono runtime version when running with system/dynamic mono.

There should be no need to verify the mono runtime version when embedding mono:

* If it's a mono we're shipping, something very bad happened in our
  build/package for it to be an invalid mono.
* If it's a system mono that's being embedded, then we verify in mmp at build
  time.

In the first scenario (a mono we're shipping), the problem is that the mono
we've built does not report back the full version number (with four parts) [1],
which means we'll fail any check whose requirements are identical for the
first three parts, and non-zero for the last.

[1] The fourth part of the version number is created/calculated when packaging
mono, and we're not packaging it.
This commit is contained in:
Rolf Bjarne Kvinge 2018-08-29 14:28:56 +02:00 коммит произвёл GitHub
Родитель 2ee29f38ce
Коммит 33c1db4b68
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 35 добавлений и 19 удалений

Просмотреть файл

@ -66,6 +66,10 @@ MIN_MONO_VERSION=5.14.0.136
MAX_MONO_VERSION=5.14.99
MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-04/111/07c8f25fe536dbb7e244f965aa3f9a871f41e953/MonoFramework-MDK-5.14.0.136.macos10.xamarin.universal.pkg
# Minimum Mono version for Xamarin.Mac apps using the system mono
MIN_XM_MONO_VERSION=5.14.0.136
MIN_XM_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2018-04/111/07c8f25fe536dbb7e244f965aa3f9a871f41e953/MonoFramework-MDK-5.14.0.136.macos10.xamarin.universal.pkg
# Minimum Visual Studio version
MIN_VISUAL_STUDIO_URL=https://download.visualstudio.microsoft.com/download/pr/11550896/783d2219a348f93b6988fb415951788a/VisualStudioForMac-Preview-7.4.0.985.dmg
MIN_VISUAL_STUDIO_VERSION=7.4.0.985

Просмотреть файл

@ -27,7 +27,7 @@ SHARED_HEADERS += shared.h product.h delegates.h runtime-internal.h $(SHARED_INC
SHARED_FILES = $(SHARED_SOURCES) $(SHARED_HEADERS) $(SHARED_I386_SOURCES) $(SHARED_X86_64_SOURCES)
EXTRA_DEPENDENCIES = $(SHARED_HEADERS)
EXTRA_DEPENDENCIES = $(SHARED_HEADERS) $(TOP)/Make.config
xamarin/mono-runtime.h: mono-runtime.h.t4 exports.t4
$(Q_GEN) $(TT) $< -o $@
@ -396,8 +396,8 @@ MAC_CLANG = DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT) $(MAC_CC)
MAC_SHIPPED_HEADERS = xamarin/launch.h
MAC_OBJC_CFLAGS=-ObjC++ -std=c++0x -fno-exceptions
MAC_CFLAGS = -mmacosx-version-min=$(MIN_OSX_SDK_VERSION) -Wall -DMONOMAC -g
MAC_OBJC_CFLAGS=-ObjC++ -std=c++0x -fno-exceptions -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\"
MAC_CFLAGS = -mmacosx-version-min=$(MIN_OSX_SDK_VERSION) -Wall -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\"
MAC_LDFLAGS = -mmacosx-version-min=$(MIN_OSX_SDK_VERSION) -framework AppKit
MAC_STATIC_CFLAGS = $(MAC_CFLAGS) -I$(TOP)/builds/$(BUILD_DESTDIR)/install/mac32/include/mono-2.0
@ -446,22 +446,22 @@ DYNAMIC_DYLIB$(2)_OBJECTS = $$(foreach src,$$(MAC_SOURCES),.libs/mac/$$(basena
STATIC_LAUNCHER$(2)_OBJECTS = $$(foreach src,$$(MAC_SOURCES),.libs/mac/$$(basename $$(src))$(3).static.$(1).o)
SYSTEM_LAUNCHER$(2)_OBJECTS = $$(foreach src,$$(MAC_SOURCES),.libs/mac/$$(basename $$(src))$(3).system.$(1).o)
.libs/mac/%$(3).dylib.$(1).o: %.m $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).dylib.$(1).o: %.m $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,OBJC, [mac]) $(MAC_CLANG) -arch $(1) $(4) -c $$(MAC_OBJC_CFLAGS) $$(MAC_CFLAGS) -DDYNAMIC_MONO_RUNTIME -DDYLIB -o $$@ $$<
.libs/mac/%$(3).dylib.$(1).o: %.s $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).dylib.$(1).o: %.s $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,ASM, [mac]) $(MAC_CLANG) -arch $(1) $(4) -c $$(MAC_CFLAGS) -DDYNAMIC_MONO_RUNTIME -DDYLIB -o $$@ $$<
.libs/mac/%$(3).static.$(1).o: %.s $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).static.$(1).o: %.s $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,ASM, [mac]) $(MAC_CLANG) -arch $(1) $(4) -c $$(MAC_STATIC_CFLAGS) -o $$@ $$<
.libs/mac/%$(3).static.$(1).o: %.m $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).static.$(1).o: %.m $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,OBJC, [mac]) $(MAC_CLANG) -arch $(1) $(4) $$(MAC_OBJC_CFLAGS) -c $$(MAC_STATIC_CFLAGS) -o $$@ $$<
.libs/mac/%$(3).system.$(1).o: %.m $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).system.$(1).o: %.m $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,OBJC, [mac]) $(MAC_CLANG) -arch $(1) $(4) $$(MAC_OBJC_CFLAGS) -c $$(MAC_CFLAGS) -DDYNAMIC_MONO_RUNTIME -o $$@ $$<
.libs/mac/%$(3).system.$(1).o: %.s $$(SHARED_HEADERS) | .libs/mac
.libs/mac/%$(3).system.$(1).o: %.s $$(SHARED_HEADERS) $$(EXTRA_DEPENDENCIES) | .libs/mac
$$(call Q_2,ASM, [mac]) $(MAC_CLANG) -arch $(1) $(4) -c $(MAC_CFLAGS) -DDYNAMIC_MONO_RUNTIME -o $$@ $$<
.libs/mac/libxammac$(3).$(1).dylib: $$(DYNAMIC_DYLIB$(2)_OBJECTS)

Просмотреть файл

@ -247,6 +247,7 @@ exit_with_message (const char *reason, const char *argv0, bool request_mono)
exit (1);
}
#ifdef DYNAMIC_MONO_RUNTIME
static int
check_mono_version (const char *version, const char *req_version)
{
@ -280,7 +281,6 @@ check_mono_version (const char *version, const char *req_version)
return TRUE;
}
#ifdef DYNAMIC_MONO_RUNTIME
static int
push_env (const char *variable, NSString *str_value)
{
@ -427,8 +427,9 @@ app_initialize (xamarin_initialize_data *data)
setrlimit (RLIMIT_NOFILE, &limit);
}
// 5) Verify the minimum Mono version. The minimum mono version is specified in: [...]
NSDictionary *plist = [[NSBundle mainBundle] infoDictionary];
#ifdef DYNAMIC_MONO_RUNTIME
// 5) Verify the minimum Mono version. The minimum mono version is specified in: [...]
NSString *minVersion = NULL;
if (plist != NULL) {
minVersion = (NSString *) [plist objectForKey:@"MonoMinimumVersion"];
@ -440,11 +441,10 @@ app_initialize (xamarin_initialize_data *data)
if (!minVersion) {
// This must be kept in sync with mmp's minimum mono version (in driver.cs)
minVersion = @"4.2.0";
minVersion = @MIN_XM_MONO_VERSION;
}
char *mono_version;
#ifdef DYNAMIC_MONO_RUNTIME
const char *err = xamarin_initialize_dynamic_runtime (mono_runtime_prefix);
if (err) {
mono_version = xamarin_get_mono_runtime_build_info ();
@ -454,11 +454,11 @@ app_initialize (xamarin_initialize_data *data)
exit_with_message (err, data->basename, true);
}
}
#endif
mono_version = mono_get_runtime_build_info ();
if (!check_mono_version (mono_version, [minVersion UTF8String]))
exit_with_message ([[NSString stringWithFormat:@"This application requires the Mono framework version %@ or newer.", minVersion] UTF8String], data->basename, true);
#endif
// 6) Find the executable. The name is: [...]
if (data->launch_mode == XamarinLaunchModeApp) {

Просмотреть файл

@ -3,6 +3,7 @@ SdkVersions.cs: ../common/SdkVersions.cs.in Makefile $(TOP)/Make.config
-e 's/@IOS_SDK_VERSION@/$(IOS_SDK_VERSION)/g' -e 's/@WATCHOS_SDK_VERSION@/$(WATCH_SDK_VERSION)/' -e 's/@TVOS_SDK_VERSION@/$(TVOS_SDK_VERSION)/' -e 's/@OSX_SDK_VERSION@/$(OSX_SDK_VERSION)/' \
-e 's/@MIN_IOS_SDK_VERSION@/$(MIN_IOS_SDK_VERSION)/g' -e 's/@MIN_WATCHOS_SDK_VERSION@/$(MIN_WATCHOS_SDK_VERSION)/' -e 's/@MIN_TVOS_SDK_VERSION@/$(MIN_TVOS_SDK_VERSION)/' -e 's/@MIN_OSX_SDK_VERSION@/$(MIN_OSX_SDK_VERSION)/' \
-e 's/@XCODE_VERSION@/$(XCODE_VERSION)/g' \
-e 's/@MIN_XM_MONO_VERSION@/$(MIN_XM_MONO_VERSION)/g' \
$< > $@

Просмотреть файл

@ -58,5 +58,13 @@ namespace Xamarin {
}
}
#endif
}
#if MMP
static class MonoVersions {
public static string MinimumMono = "@MIN_XM_MONO_VERSION@";
public static Version MinimumMonoVersion { get { return new Version (MinimumMono); }}
}
#endif
}

Просмотреть файл

@ -119,8 +119,6 @@ namespace Xamarin.Bundler {
static bool is_extension;
static bool frameworks_copied_to_bundle_dir; // Have we copied any frameworks to Foo.app/Contents/Frameworks?
// This must be kept in sync with the system launcher's minimum mono version (in launcher/launcher-system.m)
static Version MinimumMonoVersion = new Version (4, 2, 0);
const string pkg_config = "/Library/Frameworks/Mono.framework/Commands/pkg-config";
static void ShowHelp (OptionSet os) {
@ -1193,15 +1191,20 @@ namespace Xamarin.Bundler {
RunCommand (pkg_config, "--cflags mono-2", env, cflagsb);
RunCommand (pkg_config, "--variable=libdir mono-2", env, libdirb);
RunCommand (pkg_config, "--modversion mono-2", env, mono_version);
var versionFile = "/Library/Frameworks/Mono.framework/Versions/Current/VERSION";
if (File.Exists (versionFile)) {
mono_version.Append (File.ReadAllText (versionFile));
} else {
RunCommand (pkg_config, "--modversion mono-2", env, mono_version);
}
} catch (Win32Exception e) {
throw new MonoMacException (5301, true, e, "pkg-config could not be found. Please install the Mono.framework from http://mono-project.com/Downloads");
}
Version mono_ver;
if (Version.TryParse (mono_version.ToString ().TrimEnd (), out mono_ver) && mono_ver < MinimumMonoVersion)
if (Version.TryParse (mono_version.ToString ().TrimEnd (), out mono_ver) && mono_ver < MonoVersions.MinimumMonoVersion)
throw new MonoMacException (1, true, "This version of Xamarin.Mac requires Mono {0} (the current Mono version is {1}). Please update the Mono.framework from http://mono-project.com/Downloads",
MinimumMonoVersion, mono_version.ToString ().TrimEnd ());
MonoVersions.MinimumMonoVersion, mono_version.ToString ().TrimEnd ());
cflags = cflagsb.ToString ().Replace (Environment.NewLine, String.Empty);
libdir = libdirb.ToString ().Replace (Environment.NewLine, String.Empty);