[build] Make sure -mmacosx-version-min is passed to the mono build. Fixes #5553.
Also add a test. Fixes https://github.com/xamarin/xamarin-macios/issues/5553.
This commit is contained in:
Родитель
6b0f9fbf07
Коммит
bcbc838fd3
|
@ -244,7 +244,7 @@ $(2)_CPPFLAGS = \
|
|||
-mmacosx-version-min=$(MIN_OSX_SDK_VERSION)
|
||||
$(2)_CFLAGS = -O2 -arch $(1)
|
||||
$(2)_CXXFLAGS = -O2 -arch $(1)
|
||||
$(2)_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
$(2)_LDFLAGS = $(COMMON_LDFLAGS) -mmacosx-version-min=$(MIN_OSX_SDK_VERSION)
|
||||
$(2)_CONFIGURE_FLAGS = \
|
||||
--prefix=$$(BUILD_DESTDIR)/$(2) \
|
||||
--host=$(1)-apple-darwin10 \
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
**/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Xamarin;
|
||||
|
||||
namespace Xamarin.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
|
@ -32,6 +36,73 @@ namespace Xamarin.Tests
|
|||
Assert.DoesNotThrow (() => Version.Parse (version), "version");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase (Profile.macOSSystem, MachO.LoadCommands.MinMacOSX)]
|
||||
[TestCase (Profile.macOSFull, MachO.LoadCommands.MinMacOSX)]
|
||||
[TestCase (Profile.macOSMobile, MachO.LoadCommands.MinMacOSX)]
|
||||
[TestCase (Profile.iOS, MachO.LoadCommands.MiniPhoneOS, false)]
|
||||
[TestCase (Profile.iOS, MachO.LoadCommands.MiniPhoneOS, true)]
|
||||
[TestCase (Profile.watchOS, MachO.LoadCommands.MinwatchOS, false)]
|
||||
[TestCase (Profile.watchOS, MachO.LoadCommands.MinwatchOS, true)]
|
||||
[TestCase (Profile.tvOS, MachO.LoadCommands.MintvOS, false)]
|
||||
[TestCase (Profile.tvOS, MachO.LoadCommands.MintvOS, true)]
|
||||
public void MinOSVersion (Profile profile, MachO.LoadCommands load_command, bool device = false)
|
||||
{
|
||||
var dylibs = Directory.GetFiles (Configuration.GetSdkPath (profile, device), "*.dylib", SearchOption.AllDirectories)
|
||||
.Where ((v) => !v.Contains ("dylib.dSYM/Contents/Resources/DWARF")); // Don't include *.dylib from inside .dSYMs.
|
||||
|
||||
var failed = new List<string> ();
|
||||
foreach (var dylib in dylibs) {
|
||||
var fatfile = MachO.Read (dylib);
|
||||
foreach (var slice in fatfile) {
|
||||
var any_load_command = false;
|
||||
foreach (var lc in slice.load_commands) {
|
||||
var mincmd = lc as MinCommand;
|
||||
if (mincmd == null)
|
||||
continue;
|
||||
// Console.WriteLine ($" {mincmd.Command} version: {mincmd.version}=0x{mincmd.version.ToString ("x")}={mincmd.Version} sdk: {mincmd.sdk}=0x{mincmd.sdk.ToString ("x")}={mincmd.Sdk}");
|
||||
|
||||
Assert.AreEqual (load_command, mincmd.Command, "Unexpected min load command");
|
||||
|
||||
Version version;
|
||||
Version alternate_version = null;
|
||||
switch (load_command) {
|
||||
case MachO.LoadCommands.MinMacOSX:
|
||||
version = SdkVersions.MinOSXVersion;
|
||||
break;
|
||||
case MachO.LoadCommands.MiniPhoneOS:
|
||||
version = SdkVersions.MiniOSVersion;
|
||||
if (device) {
|
||||
if (version.Major < 7)
|
||||
version = new Version (7, 0, 0); // dylibs are supported starting with iOS 7.
|
||||
alternate_version = new Version (8, 0, 0); // some iOS dylibs also have min OS 8.0 (if they're used as frameworks as well).
|
||||
}
|
||||
break;
|
||||
case MachO.LoadCommands.MintvOS:
|
||||
version = SdkVersions.MinTVOSVersion;
|
||||
break;
|
||||
case MachO.LoadCommands.MinwatchOS:
|
||||
version = SdkVersions.MinWatchOSVersion;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException (load_command.ToString ());
|
||||
}
|
||||
|
||||
version = new Version (version.Major, version.Minor, version.Build < 0 ? 0 : version.Build);
|
||||
if (alternate_version == null)
|
||||
alternate_version = version;
|
||||
|
||||
if (version != mincmd.Version && alternate_version != mincmd.Version)
|
||||
failed.Add ($"Unexpected minOS version (expected {version}, alternatively {alternate_version}, found {mincmd.Version}) in {dylib}.");
|
||||
any_load_command = true;
|
||||
}
|
||||
if (!any_load_command)
|
||||
failed.Add ($"No minOS version found in {dylib}.");
|
||||
}
|
||||
}
|
||||
CollectionAssert.IsEmpty (failed, "Failures");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@
|
|||
<Link>ErrorHelper.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="RuntimeException.cs" />
|
||||
<Compile Include="..\..\tools\mtouch\SdkVersions.cs">
|
||||
<Link>SdkVersions.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче