diff options
author | Martin Baulig <mabaul@microsoft.com> | 2018-10-15 18:38:45 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-10-15 18:38:45 +0300 |
commit | 51548b4d379a5a98db4cf81ea46e83567bd38cd9 (patch) | |
tree | 369900fab5e1834de1b6eb6f3214145a3692c78f /m4 | |
parent | 2ebb5efed57f6c7e1ce172a70611d2786e32751b (diff) |
Initial Mono.Native Support. (#10596)
`Mono.Native` is the new name for both `System.Native` and `System.Security.Cryptography.Apple`.
It is built as a stand-alone shared library and not bundled with the runtime because we
may need to build two different versions of it.
Starting with macOS 10.12+ and iOS 10+, Apple introduced a new Unified API for some of the
crypto primitives that we're using as part of System.Security.Cryptography.Apple.
On Desktop, we can check at runtime whether the OS version is recent enough and switch
implementation accordingly. We build a single `libmono_native` shared library.
However, on Mobile we cannot have any undefined symbols as this would break Bitcode.
During the mobile build, we are called with `CC` containing an explicit minium version flag,
which is either `-mmacosx-version-min=`, `-mios-simulator-version-min=` or `-miphoneos-version-min=`
depending on platform.
We build two versions of the shared library:
- `libmono_native_compat` is built with whichever minimum version is passed to us via `CC`.
- `libmono_native_unifed` is built with the minimum version set to macOS 10.12+ / iOS 10+.
For testing purposes, there is a function called `mono_native_get_platform_type ()`
(see mono/native/mono-native-platform.c), which returns a `MonoNativePlatformType` enum value.
There is also `Mono.MonoNativePlatform.GetPlatformType ()` (see mcs/class/corlib/Mono/MonoNativePlatform.cs).
This can be called by automated tests both to ensure that the library has been correctly installed and also
to verify that it's the correct version of it.
* `configure.ac`: add new configure checks for Mono.Native.
* `mono/native/`: new directory - this replaces the `System.Native` code that was previously in `mono/metadata`.
* `mcs/class/corlib/Mono`: New internal `MonoNativePlatformType` and `MonoNativePlatform` classes.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/apple-target.m4 | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/m4/apple-target.m4 b/m4/apple-target.m4 new file mode 100644 index 00000000000..3e5844e1fae --- /dev/null +++ b/m4/apple-target.m4 @@ -0,0 +1,40 @@ +# Usage: +# AC_MONO_APPLE_TARGET(target-name, action-if-found, action-if-not-found) +# +# Checks whether `target-name` is defined in "TargetConditionals.h" +# +AC_DEFUN([AC_MONO_APPLE_TARGET], [ + AC_MONO_APPLE_AVAILABLE([$1], [for $1], [$1 == 1], $2, $3) +]) + + +# Usage: +# AC_MONO_APPLE_AVAILABLE(name, message, conditional, action-if-found, action-if-not-found) +# +# Checks for `conditional` using "TargetConditionals.h" and "AvailabilityMacros.h" +# +AC_DEFUN([AC_MONO_APPLE_AVAILABLE], [ + # cache the compilation check + AC_CACHE_CHECK([$2], [ac_cv_apple_available_[]$1], [ + AC_TRY_COMPILE([ + #include "TargetConditionals.h" + #include "AvailabilityMacros.h" + ],[ + #if !($3) + #error failed + #endif + ], [ + ac_cv_apple_available_[]$1=yes + ], [ + ac_cv_apple_available_[]$1=no + ]) + ]) + # keep the actions out of the cache check because they need to be always executed. + if test x$ac_cv_apple_available_[]$1 = xyes; then + $1=yes + [$4] + else + $1=no + [$5] + fi +]) |