From ab582f10545535d17011cf29f391886e57b9fc9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 11:58:53 -0400 Subject: [PATCH 01/10] Bump to xamarin/Java.Interop/main@3436a30 (#8799) Changes: https://github.com/xamarin/java.interop/compare/a7e09b7be4dc9dbc1c1a65b5f2c1e8fcf028b209...3436a306bd23eb4755f769ad88d955323138321f * xamarin/java.interop@3436a306: [ci] Build dotnet release branches and PRs against dotnet release branches. (xamarin/java.interop#1204) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index a7e09b7be4d..3436a306bd2 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit a7e09b7be4dc9dbc1c1a65b5f2c1e8fcf028b209 +Subproject commit 3436a306bd23eb4755f769ad88d955323138321f From 4d1fca774756cb24ef2db5402a549ed3ebc2216c Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:56:34 -0500 Subject: [PATCH 02/10] Bump to dotnet/installer/main@e911f5c82c 9.0.100-preview.3.24161.2 (#8802) Changes: https://github.com/dotnet/installer/compare/893b762b6e...e911f5c82c Changes: https://github.com/dotnet/runtime/compare/5e603d595e...3eb8c7f108 Changes: https://github.com/dotnet/emsdk/compare/0f3e462442...a5f4de78fc Changes: https://github.com/dotnet/cecil/compare/0d0bc8e0f4...ba53c75483 Updates: * Microsoft.Dotnet.Sdk.Internal: from 9.0.100-preview.3.24153.2 to 9.0.100-preview.3.24161.2 * Microsoft.NETCore.App.Ref: from 9.0.0-preview.3.24129.2 to 9.0.0-preview.3.24160.3 * Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport: from 9.0.0-preview.3.24126.1 to 9.0.0-preview.3.24156.3 * Microsoft.NET.ILLink.Tasks: from 9.0.0-preview.3.24129.2 to 9.0.0-preview.3.24160.3 * Microsoft.DotNet.Cecil: from 0.11.4-alpha.24120.1 to 0.11.4-alpha.24158.1 --- eng/Version.Details.xml | 20 ++++++++++---------- eng/Versions.props | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index ca7fbcde99d..e7cec78de4d 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,24 +1,24 @@ - + https://github.com/dotnet/installer - 893b762b6e36d558df7ae6fccdfd8034f83a1c2e + e911f5c82cc02aea96e227596e16c830d54cf03a - + https://github.com/dotnet/runtime - 5e603d595e63ddc5cdce9777a40608279abdcc37 + 3eb8c7f1086b79b28a27b57a935f97be3b7fcccb - + https://github.com/dotnet/runtime - 5e603d595e63ddc5cdce9777a40608279abdcc37 + 3eb8c7f1086b79b28a27b57a935f97be3b7fcccb - + https://github.com/dotnet/emsdk - 0f3e462442af5fe65271e3185d5b645ad40a6041 + a5f4de78fca42544771977f8e8e04c4aa83e1d02 - + https://github.com/dotnet/cecil - 0d0bc8e0f47fdae9834e1eac678f364c50946133 + ba53c75483aa4980a332fa48e61076f80adfec40 diff --git a/eng/Versions.props b/eng/Versions.props index 346f1e1fc29..f16fd164c98 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,15 +1,15 @@ - 9.0.100-preview.3.24153.2 - 9.0.0-preview.3.24129.2 - 9.0.0-preview.3.24129.2 + 9.0.100-preview.3.24161.2 + 9.0.0-preview.3.24160.3 + 9.0.0-preview.3.24160.3 7.0.0-beta.22103.1 7.0.0-beta.22103.1 - 9.0.0-preview.3.24126.1 + 9.0.0-preview.3.24156.3 $(MicrosoftNETWorkloadEmscriptenCurrentManifest90100TransportVersion) 7.0.100-rc.1.22410.7 - 0.11.4-alpha.24120.1 + 0.11.4-alpha.24158.1 $(MicrosoftNETCoreAppRefPackageVersion) From 3ed7de3d27a71198ca5ce332428b3568a0c050ce Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Tue, 12 Mar 2024 19:58:08 -0400 Subject: [PATCH 03/10] Bump to xamarin/monodroid/main@77124dc1 (#8804) Changes: https://github.com/xamarin/monodroid/compare/e13723e701307f9f6966d4b309c3eba10a741694...77124dc16985a92077e62b0cfeaeb007c4d4fd2a * xamarin/monodroid@77124dc16: Bump to xamarin/xamarin-android/main@4d1fca7 (xamarin/monodroid#1447) * xamarin/monodroid@9caae8213: Bump to xamarin/androidtools/main@7818dc5 (xamarin/monodroid#1446) * xamarin/monodroid@84a7fcd54: Bump to xamarin/android-sdk-installer/main@438cf89 (xamarin/monodroid#1448) * xamarin/monodroid@cdb452cf0: [tools/fastdev] Use chmod to set files as readonly (xamarin/monodroid#1425) * xamarin/monodroid@b99fa9086: Bump to xamarin/xamarin-android@5cd9a267e2 (xamarin/monodroid#1444) --- .external | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.external b/.external index 8f7749a446e..97fd41cb9e1 100644 --- a/.external +++ b/.external @@ -1 +1 @@ -xamarin/monodroid:main@e13723e701307f9f6966d4b309c3eba10a741694 +xamarin/monodroid:main@77124dc16985a92077e62b0cfeaeb007c4d4fd2a From dd6e7071b23e9de754ef6e726140f79198fdcfd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 20:17:57 -0400 Subject: [PATCH 04/10] Bump external/Java.Interop from `3436a30` to `5bca8ad` (#8803) Change: https://github.com/xamarin/java.interop/compare/3436a306bd23eb4755f769ad88d955323138321f...5bca8ad6e5cf28d1c1a0bac37d2e0aa311795aa8 * xamarin/java.interop@5bca8ad6: [build] Automatically add NullableAttributes.cs for netstandard2.0 (xamarin/java.interop#1188) * xamarin/java.interop@45437e22: [Java.Interop] suppress IL3050 with `#pragma` (xamarin/java.interop#1201) * xamarin/java.interop@1c9c8c9c: [Java.Interop.Tools.Maven] Initial commit. (xamarin/java.interop#1179) With xamarin/java.interop@5bca8ad6, all instances of nullable attributes types defined in `NullableAttributes.cs` are now `internal`. However, `Xamarin.Android.Build.Tasks` was consuming the `public` types from its reference to `Java.Interop.Tools.JavaCallableWrappers`, so this change resulted in a build break: MavenExtensions.cs(26,32): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level MamJsonParser.cs(92,43): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level MamJsonParser.cs(92,81): error CS0122: 'NotNullWhenAttribute' is inaccessible due to its protection level We can apply almost the same logic from xamarin/java.interop@5bca8ad6 to `xamarin-android`; the difference is that neither of the `netstandard2.0` projects in xamarin-android that need the attributes have `$(Nullable)='enabled'` and thus our `Condition` fails. (`Xamarin.Android.Build.Tasks.csproj` and `Xamarin.Android.Tools.JavadocImporter.csproj` include `.cs` files from `external/Java.Interop` that have been NRT annotated and thus need the nullable attribute types.) We add `$(Nullable)='annotations'` to the `@(Compile)` which allows one to use NRT syntax but does not emit any NRT warnings since these assemblies have not been converted. We then modify the `NullableAttributes.cs` inclusion logic to additionally key off the `$(Nullable)=annotations` value. Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jonathan Pobst --- Directory.Build.targets | 9 +++++++++ external/Java.Interop | 2 +- .../Xamarin.Android.Build.Tasks.csproj | 1 + .../Xamarin.Android.Tools.JavadocImporter.csproj | 4 +--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 8e03cb5cdf5..c9365209289 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -7,4 +7,13 @@ + + + + + + + $(DefineConstants);INTERNAL_NULLABLE_ATTRIBUTES + + diff --git a/external/Java.Interop b/external/Java.Interop index 3436a306bd2..5bca8ad6e5c 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 3436a306bd23eb4755f769ad88d955323138321f +Subproject commit 5bca8ad6e5cf28d1c1a0bac37d2e0aa311795aa8 diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj index d2304de5a5d..3bef384882d 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj @@ -19,6 +19,7 @@ 8632 false ..\..\product.snk + annotations $(NoWarn);CA1310;CA1305 diff --git a/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj b/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj index 8529f06fb6b..1cf29a3ea74 100644 --- a/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj +++ b/src/Xamarin.Android.Tools.JavadocImporter/Xamarin.Android.Tools.JavadocImporter.csproj @@ -6,6 +6,7 @@ false true $(NoWarn);CA1305 + annotations @@ -27,9 +28,6 @@ Crc64.Table.cs - - NullableAttributes.cs - From c20d51fcf8e910b8fb46c5351c26e55ed1fab90c Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 12 Mar 2024 14:19:03 -1000 Subject: [PATCH 05/10] [Mono.Android] Fix missing enum issues that cause BG8800 warnings. (#8707) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/xamarin/xamarin-android/issues/8703 xamarin/xamarin-android#8730 reported that we did not bind [`HardwareBuffer.create(int width, int height, int format, int layers, long usage)`][0]. Indeed, in the build logs for `src/Mono.Android`, there is a BG8800 warning about it! obj/Debug/net9.0/android-34/mcw/api-34.xml(32327,10): warning BG8800: Unknown parameter type 'Android.Hardware.HardwareBufferUsage' for member 'Android.Hardware.HardwareBuffer.Create (int, int, Android.Hardware.HardwareBufferFormat, int, Android.Hardware.HardwareBufferUsage)' The BG8800 was generated because we attempted to map `long usage` to an `enum`, but no enum was created as the values are of type `long`, not `int`. Manually create a `long`-based `HardwareBufferUsage` enum: [Flags] /* partial */ enum HardwareBufferUsage : long { None = 0, UsageComposerOverlay = 0x800, // … } However, `generator` does not support `long` enums, and generates marshalling code using an `int`. Thus, we need to manually bind `HardwareBuffer.create()` and [`HardwareBuffer.getUsage()`][1] so we can replace the `int` machinery with `long`. While we're at it, audit all of the `BG8800` warnings that are caused by improper enumification and fix them: warning BG8800: Unknown parameter type 'Android.Hardware.HardwareBufferUsage' for member 'Android.Hardware.HardwareBuffer.Create (int, int, Android.Hardware.HardwareBufferFormat, int, Android.Hardware.Hardw... warning BG8800: Unknown parameter type 'Android.Hardware.HardwareBufferUsage' for member 'Android.Hardware.HardwareBuffer.IsSupported (int, int, Android.Hardware.HardwareBufferFormat, int, Android.Hardware.... warning BG8800: Unknown parameter type 'Android.App.Bind' for member 'Android.Content.Context'. warning BG8800: Unknown parameter type 'Android.App.Bind' for member 'Android.Content.Context.BindIsolatedService (Android.Content.Intent, Android.App.Bind, java.lang.String, java.util.concurrent.Executor, ... warning BG8800: Unknown parameter type 'Android.Graphics.ImageDecoderAllocatorType' for member 'Android.Graphics.ImageDecoder.SetAllocator (Android.Graphics.ImageDecoderAllocatorType)'. warning BG8800: Unknown parameter type 'Android.Net.WpsFailureReason' for member 'Android.Net.Wifi.WifiManager.WpsCallback.OnFailed (Android.Net.WpsFailureReason)'. warning BG8800: Unknown parameter type 'Android.OS.DeviceTemperatureSource' for member 'Android.OS.HardwarePropertiesManager.GetDeviceTemperatures (Android.OS.DeviceTemperatureType, Android.OS.DeviceTempera... warning BG8800: Unknown parameter type 'Android.Telephony.Mbms.DownloadStatus' for member 'Android.Telephony.Mbms.DownloadStatusListener.OnStatusUpdated (Android.Telephony.Mbms.DownloadRequest, Android.Tel... warning BG8800: Unknown parameter type 'Android.Telephony.StreamingMethod' for member 'Android.Telephony.Mbms.StreamingServiceCallback.OnStreamMethodUpdated (Android.Telephony.StreamingMethod)'. warning BG8800: Unknown parameter type 'Android.Telephony.StreamingState' for member 'Android.Telephony.Mbms.StreamingServiceCallback.OnStreamStateUpdated (Android.Telephony.StreamingState, Android.Telepho... warning BG8800: Unknown parameter type 'Android.Icu.Text.CollatorReorderCodes' for member 'Android.Icu.Text.Collator.GetEquivalentReorderCodes (Android.Icu.Text.CollatorReorderCodes)'. warning BG8800: Unknown parameter type 'params Android.Icu.Text.CollatorReorderCodes[]' for member 'Android.Icu.Text.Collator.SetReorderCodes (params Android.Icu.Text.CollatorReorderCodes[])'. This results in new API being surfaced that was previously not being bound, requiring updates to `src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt`. One of these new APIs is [`WpsCallback.OnFailed(WpsFailureReason)`][2], which is a *new* `abstract` method on an existing non-`abstract` type. Although this is a breaking change, this type previously could not have been inherited from as the Java-side `abstract` method would not have been implemented; consider this C# code: // This C# code compiles, no warnings or errors: class MyCallback : Android.Net.Wifi.WifiManager.WpsCallback { public override void OnStarted(string? pin) {} public override void OnSucceeded() {} } However, the `.csproj` containing `MyCallback` will fail to build: obj/Debug/net8.0-android/android/src/crc64475861335642e0f6/MyCallback.java(4,8): javac error JAVAC0000: error: MyCallback is not abstract and does not override abstract method onFailed(int) in WpsCallback Thus, add it as an "acceptable breakage". [0]: https://developer.android.com/reference/android/hardware/HardwareBuffer?hl=en#create(int,%20int,%20int,%20int,%20long) [1]: https://developer.android.com/reference/android/hardware/HardwareBuffer?hl=en#getUsage() [2]: https://developer.android.com/reference/android/net/wifi/WifiManager.WpsCallback?hl=en#onFailed(int) --- .../Android.Hardware/HardwareBuffer.cs | 44 +++++++++++++ .../Android.Hardware/HardwareBufferUsage.cs | 64 +++++++++++++++++++ .../StreamingService.cs | 24 +++++++ .../Android.Telephony/MbmsDownloadSession.cs | 41 ++++++++++++ src/Mono.Android/Mono.Android.csproj | 4 ++ .../PublicAPI/API-34/PublicAPI.Unshipped.txt | 43 ++++++++++++- src/Mono.Android/map.csv | 16 ++--- src/Mono.Android/metadata | 6 +- src/Mono.Android/methodmap.csv | 18 ++---- ...acceptable-breakages-vReference-net9.0.txt | 1 + 10 files changed, 239 insertions(+), 22 deletions(-) create mode 100644 src/Mono.Android/Android.Hardware/HardwareBuffer.cs create mode 100644 src/Mono.Android/Android.Hardware/HardwareBufferUsage.cs create mode 100644 src/Mono.Android/Android.Telephony.Mbms/StreamingService.cs create mode 100644 src/Mono.Android/Android.Telephony/MbmsDownloadSession.cs diff --git a/src/Mono.Android/Android.Hardware/HardwareBuffer.cs b/src/Mono.Android/Android.Hardware/HardwareBuffer.cs new file mode 100644 index 00000000000..ec3f2351cd2 --- /dev/null +++ b/src/Mono.Android/Android.Hardware/HardwareBuffer.cs @@ -0,0 +1,44 @@ +using Android.Runtime; +using Java.Interop; + +namespace Android.Hardware; + +public partial class HardwareBuffer +{ + // These are manually bound because we do not have a way to bind the `long` enum values. + // generator treats them as int, like: + // __args [4] = new JniArgumentValue ((int) usage); + + // Metadata.xml XPath method reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/method[@name='create' and count(parameter)=5 and parameter[1][@type='int'] and parameter[2][@type='int'] and parameter[3][@type='int'] and parameter[4][@type='int'] and parameter[5][@type='long']]" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + [Register ("create", "(IIIIJ)Landroid/hardware/HardwareBuffer;", "", ApiSince = 26)] + public static unsafe Android.Hardware.HardwareBuffer Create (int width, int height, [global::Android.Runtime.GeneratedEnum] Android.Hardware.HardwareBufferFormat format, int layers, Android.Hardware.HardwareBufferUsage usage) + { + const string __id = "create.(IIIIJ)Landroid/hardware/HardwareBuffer;"; + try { + JniArgumentValue* __args = stackalloc JniArgumentValue [5]; + __args [0] = new JniArgumentValue (width); + __args [1] = new JniArgumentValue (height); + __args [2] = new JniArgumentValue ((int) format); + __args [3] = new JniArgumentValue (layers); + __args [4] = new JniArgumentValue ((long) usage); + var __rm = _members.StaticMethods.InvokeObjectMethod (__id, __args); + return global::Java.Lang.Object.GetObject (__rm.Handle, JniHandleOwnership.TransferLocalRef)!; + } finally { + } + } + + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + public unsafe Android.Hardware.HardwareBufferUsage Usage { + // Metadata.xml XPath method reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/method[@name='getUsage' and count(parameter)=0]" + [Register ("getUsage", "()J", "", ApiSince = 26)] + get { + const string __id = "getUsage.()J"; + try { + var __rm = _members.InstanceMethods.InvokeAbstractInt64Method (__id, this, null); + return (Android.Hardware.HardwareBufferUsage) __rm!; + } finally { + } + } + } +} diff --git a/src/Mono.Android/Android.Hardware/HardwareBufferUsage.cs b/src/Mono.Android/Android.Hardware/HardwareBufferUsage.cs new file mode 100644 index 00000000000..49c24e4b78d --- /dev/null +++ b/src/Mono.Android/Android.Hardware/HardwareBufferUsage.cs @@ -0,0 +1,64 @@ +namespace Android.Hardware; + +[System.Flags] +[global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] +public enum HardwareBufferUsage : long +{ + None = 0, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_COMPOSER_OVERLAY']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android33.0")] + UsageComposerOverlay = 2048, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_READ_OFTEN']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageCpuReadOften = 3, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_READ_RARELY']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageCpuReadRarely = 2, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_WRITE_OFTEN']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageCpuWriteOften = 48, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_CPU_WRITE_RARELY']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageCpuWriteRarely = 32, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_FRONT_BUFFER']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android33.0")] + UsageFrontBuffer = 4294967296, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_COLOR_OUTPUT']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageGpuColorOutput = 512, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_CUBE_MAP']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + UsageGpuCubeMap = 33554432, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_DATA_BUFFER']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageGpuDataBuffer = 16777216, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_MIPMAP_COMPLETE']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + UsageGpuMipmapComplete = 67108864, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_GPU_SAMPLED_IMAGE']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageGpuSampledImage = 256, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_PROTECTED_CONTENT']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageProtectedContent = 16384, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_SENSOR_DIRECT_DATA']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageSensorDirectData = 8388608, + + // Metadata.xml XPath field reference: path="/api/package[@name='android.hardware']/class[@name='HardwareBuffer']/field[@name='USAGE_VIDEO_ENCODE']" + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android26.0")] + UsageVideoEncode = 65536 +} diff --git a/src/Mono.Android/Android.Telephony.Mbms/StreamingService.cs b/src/Mono.Android/Android.Telephony.Mbms/StreamingService.cs new file mode 100644 index 00000000000..8b67f05551a --- /dev/null +++ b/src/Mono.Android/Android.Telephony.Mbms/StreamingService.cs @@ -0,0 +1,24 @@ +using Android.Runtime; + +namespace Android.Telephony.Mbms; + +public partial class StreamingService +{ + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony.mbms']/class[@name='StreamingService']/field[@name='STATE_STALLED']" + [Register ("STATE_STALLED", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in a future version. Use Android.Telephony.StreamingState enum directly instead of this field.", error: true)] + public const int StateStalled = 3; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony.mbms']/class[@name='StreamingService']/field[@name='STATE_STARTED']" + [Register ("STATE_STARTED", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in a future version. Use Android.Telephony.StreamingState enum directly instead of this field.", error: true)] + public const int StateStarted = 2; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony.mbms']/class[@name='StreamingService']/field[@name='STATE_STOPPED']" + [Register ("STATE_STOPPED", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in a future version. Use Android.Telephony.StreamingState enum directly instead of this field.", error: true)] + public const int StateStopped = 1; +} diff --git a/src/Mono.Android/Android.Telephony/MbmsDownloadSession.cs b/src/Mono.Android/Android.Telephony/MbmsDownloadSession.cs new file mode 100644 index 00000000000..7962278b6a8 --- /dev/null +++ b/src/Mono.Android/Android.Telephony/MbmsDownloadSession.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Android.Runtime; + +namespace Android.Telephony; + +public partial class MbmsDownloadSession +{ + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony']/class[@name='MbmsDownloadSession']/field[@name='STATUS_ACTIVELY_DOWNLOADING']" + [Register ("STATUS_ACTIVELY_DOWNLOADING", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in the future version. Use Android.Telephony.Mbms.DownloadStatus enum directly instead of this field.", error: true)] + public const int StatusActivelyDownloading = 1; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony']/class[@name='MbmsDownloadSession']/field[@name='STATUS_PENDING_DOWNLOAD']" + [Register ("STATUS_PENDING_DOWNLOAD", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in the future version. Use Android.Telephony.Mbms.DownloadStatus enum directly instead of this field.", error: true)] + public const int StatusPendingDownload = 2; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony']/class[@name='MbmsDownloadSession']/field[@name='STATUS_PENDING_DOWNLOAD_WINDOW']" + [Register ("STATUS_PENDING_DOWNLOAD_WINDOW", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in the future version. Use Android.Telephony.Mbms.DownloadStatus enum directly instead of this field.", error: true)] + public const int StatusPendingDownloadWindow = 4; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony']/class[@name='MbmsDownloadSession']/field[@name='STATUS_PENDING_REPAIR']" + [Register ("STATUS_PENDING_REPAIR", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in the future version. Use Android.Telephony.Mbms.DownloadStatus enum directly instead of this field.", error: true)] + public const int StatusPendingRepair = 3; + + // Metadata.xml XPath field reference: path="/api/package[@name='android.telephony']/class[@name='MbmsDownloadSession']/field[@name='STATUS_UNKNOWN']" + [Register ("STATUS_UNKNOWN", ApiSince = 28)] + [global::System.Runtime.Versioning.SupportedOSPlatformAttribute ("android28.0")] + [global::System.Obsolete (@"This constant will be removed in the future version. Use Android.Telephony.Mbms.DownloadStatus enum directly instead of this field.", error: true)] + public const int StatusUnknown = 0; +} diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index 006ebd5eb41..1c833d2cd75 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -80,12 +80,16 @@ + + + + diff --git a/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt b/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt index 91b0e1a43b9..9233397fc10 100644 --- a/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt +++ b/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt @@ -1 +1,42 @@ -#nullable enable \ No newline at end of file +#nullable enable +abstract Android.Net.Wifi.WifiManager.WpsCallback.OnFailed(Android.Net.Wifi.WpsFailureReason reason) -> void +Android.Graphics.ImageDecoder.Allocator.get -> Android.Graphics.ImageDecoderAllocator +Android.Graphics.ImageDecoder.Allocator.set -> void +Android.Hardware.HardwareBuffer.Usage.get -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.None = 0 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageComposerOverlay = 2048 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageCpuReadOften = 3 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageCpuReadRarely = 2 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageCpuWriteOften = 48 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageCpuWriteRarely = 32 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageFrontBuffer = 4294967296 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageGpuColorOutput = 512 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageGpuCubeMap = 33554432 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageGpuDataBuffer = 16777216 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageGpuMipmapComplete = 67108864 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageGpuSampledImage = 256 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageProtectedContent = 16384 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageSensorDirectData = 8388608 -> Android.Hardware.HardwareBufferUsage +Android.Hardware.HardwareBufferUsage.UsageVideoEncode = 65536 -> Android.Hardware.HardwareBufferUsage +Android.Telephony.Mbms.DownloadStatus +Android.Telephony.Mbms.DownloadStatus.ActivelyDownloading = 1 -> Android.Telephony.Mbms.DownloadStatus +Android.Telephony.Mbms.DownloadStatus.PendingDownload = 2 -> Android.Telephony.Mbms.DownloadStatus +Android.Telephony.Mbms.DownloadStatus.PendingDownloadWindow = 4 -> Android.Telephony.Mbms.DownloadStatus +Android.Telephony.Mbms.DownloadStatus.PendingRepair = 3 -> Android.Telephony.Mbms.DownloadStatus +Android.Telephony.Mbms.DownloadStatus.Unknown = 0 -> Android.Telephony.Mbms.DownloadStatus +Android.Telephony.StreamingState +Android.Telephony.StreamingState.Stalled = 3 -> Android.Telephony.StreamingState +Android.Telephony.StreamingState.Started = 2 -> Android.Telephony.StreamingState +Android.Telephony.StreamingState.Stopped = 1 -> Android.Telephony.StreamingState +static Android.Hardware.HardwareBuffer.Create(int width, int height, Android.Hardware.HardwareBufferFormat format, int layers, Android.Hardware.HardwareBufferUsage usage) -> Android.Hardware.HardwareBuffer! +static Android.Hardware.HardwareBuffer.IsSupported(int width, int height, Android.Hardware.HardwareBufferFormat format, int layers, long usage) -> bool +static Android.Icu.Text.Collator.GetEquivalentReorderCodes(int reorderCode) -> int[]? +virtual Android.Content.Context.BindIsolatedService(Android.Content.Intent! service, Android.Content.Context.BindServiceFlags! flags, string! instanceName, Java.Util.Concurrent.IExecutor! executor, Android.Content.IServiceConnection! conn) -> bool +virtual Android.Content.Context.BindIsolatedService(Android.Content.Intent! service, int flags, string! instanceName, Java.Util.Concurrent.IExecutor! executor, Android.Content.IServiceConnection! conn) -> bool +virtual Android.Icu.Text.Collator.GetReorderCodes() -> int[]? +virtual Android.Icu.Text.Collator.SetReorderCodes(params int[]? order) -> void +virtual Android.OS.HardwarePropertiesManager.GetDeviceTemperatures(Android.OS.DeviceTemperatureType type, Android.OS.TemperatureSource source) -> float[]! +virtual Android.Telephony.Mbms.DownloadStatusListener.OnStatusUpdated(Android.Telephony.Mbms.DownloadRequest? request, Android.Telephony.Mbms.FileInfo? fileInfo, Android.Telephony.Mbms.DownloadStatus status) -> void +virtual Android.Telephony.Mbms.StreamingServiceCallback.OnStreamMethodUpdated(Android.Telephony.Mbms.StreamingMethod methodType) -> void +virtual Android.Telephony.Mbms.StreamingServiceCallback.OnStreamStateUpdated(Android.Telephony.StreamingState state, Android.Telephony.Mbms.StreamingStateChangedReason reason) -> void \ No newline at end of file diff --git a/src/Mono.Android/map.csv b/src/Mono.Android/map.csv index 3f264f7af74..b544c0ef35f 100644 --- a/src/Mono.Android/map.csv +++ b/src/Mono.Android/map.csv @@ -13581,9 +13581,9 @@ E,28,android/telephony/mbms/StreamingService.REASON_LEFT_MBMS_BROADCAST_AREA,6,A E,28,android/telephony/mbms/StreamingService.REASON_NONE,0,Android.Telephony.Mbms.StreamingStateChangedReason,None,remove, E,28,android/telephony/mbms/StreamingService.REASON_NOT_CONNECTED_TO_HOMECARRIER_LTE,5,Android.Telephony.Mbms.StreamingStateChangedReason,NotConnectedToHomecarrierLte,remove, E,28,android/telephony/mbms/StreamingService.REASON_OUT_OF_MEMORY,4,Android.Telephony.Mbms.StreamingStateChangedReason,OutOfMemory,remove, -I,28,android/telephony/mbms/StreamingService.STATE_STALLED,3,,,, -I,28,android/telephony/mbms/StreamingService.STATE_STARTED,2,,,, -I,28,android/telephony/mbms/StreamingService.STATE_STOPPED,1,,,, +E,28,android/telephony/mbms/StreamingService.STATE_STALLED,3,Android.Telephony.StreamingState,Stalled,keep, +E,28,android/telephony/mbms/StreamingService.STATE_STARTED,2,Android.Telephony.StreamingState,Started,keep, +E,28,android/telephony/mbms/StreamingService.STATE_STOPPED,1,Android.Telephony.StreamingState,Stopped,keep, E,28,android/telephony/mbms/StreamingService.UNICAST_METHOD,2,Android.Telephony.Mbms.StreamingMethod,Unicast,remove, I,28,android/telephony/mbms/StreamingServiceCallback.SIGNAL_STRENGTH_UNAVAILABLE,-1,,,, I,28,android/telephony/MbmsDownloadSession.RESULT_CANCELLED,2,,,, @@ -13594,11 +13594,11 @@ I,28,android/telephony/MbmsDownloadSession.RESULT_IO_ERROR,4,,,, I,28,android/telephony/MbmsDownloadSession.RESULT_OUT_OF_STORAGE,7,,,, I,28,android/telephony/MbmsDownloadSession.RESULT_SERVICE_ID_NOT_DEFINED,5,,,, I,28,android/telephony/MbmsDownloadSession.RESULT_SUCCESSFUL,1,,,, -I,28,android/telephony/MbmsDownloadSession.STATUS_ACTIVELY_DOWNLOADING,1,,,, -I,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_DOWNLOAD,2,,,, -I,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_DOWNLOAD_WINDOW,4,,,, -I,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_REPAIR,3,,,, -I,28,android/telephony/MbmsDownloadSession.STATUS_UNKNOWN,0,,,, +E,28,android/telephony/MbmsDownloadSession.STATUS_ACTIVELY_DOWNLOADING,1,Android.Telephony.Mbms.DownloadStatus,ActivelyDownloading,keep, +E,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_DOWNLOAD,2,Android.Telephony.Mbms.DownloadStatus,PendingDownload,keep, +E,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_DOWNLOAD_WINDOW,4,Android.Telephony.Mbms.DownloadStatus,PendingDownloadWindow,keep, +E,28,android/telephony/MbmsDownloadSession.STATUS_PENDING_REPAIR,3,Android.Telephony.Mbms.DownloadStatus,PendingRepair,keep, +E,28,android/telephony/MbmsDownloadSession.STATUS_UNKNOWN,0,Android.Telephony.Mbms.DownloadStatus,Unknown,keep, I,0,android/telephony/NeighboringCellInfo.UNKNOWN_CID,-1,,,, I,0,android/telephony/NeighboringCellInfo.UNKNOWN_RSSI,99,,,, E,30,android/telephony/NetworkRegistrationInfo.DOMAIN_CS,1,Android.Telephony.NetworkRegistrationInfoDomain,Cs,remove, diff --git a/src/Mono.Android/metadata b/src/Mono.Android/metadata index 2bbf00bbd67..d47276795f3 100644 --- a/src/Mono.Android/metadata +++ b/src/Mono.Android/metadata @@ -1880,7 +1880,11 @@ This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. - + + + + + + + + + true + true + true + + true + + + $(WarningsAsErrors); + IL2000;IL2001;IL2002;IL2003;IL2004; + IL2005;IL2006;IL2007;IL2008;IL2009; + IL2010;IL2011;IL2012;IL2013;IL2014; + IL2015;IL2016;IL2017;IL2018;IL2019; + IL2020;IL2021;IL2022;IL2023;IL2024; + IL2025;IL2026;IL2027;IL2028;IL2029; + IL2030;IL2031;IL2032;IL2033;IL2034; + IL2035;IL2036;IL2037;IL2038;IL2039; + IL2040;IL2041;IL2042;IL2043;IL2044; + IL2045;IL2046;IL2047;IL2048;IL2049; + IL2050;IL2051;IL2052;IL2053;IL2054; + IL2055;IL2056;IL2057;IL2058;IL2059; + IL2060;IL2061;IL2062;IL2063;IL2064; + IL2065;IL2066;IL2067;IL2068;IL2069; + IL2070;IL2071;IL2072;IL2073;IL2074; + IL2075;IL2076;IL2077;IL2078;IL2079; + IL2080;IL2081;IL2082;IL2083;IL2084; + IL2085;IL2086;IL2087;IL2088;IL2089; + IL2090;IL2091;IL2092;IL2093;IL2094; + IL2095;IL2096;IL2097;IL2098;IL2099; + IL2100;IL2101;IL2102;IL2103;IL2104; + IL2105;IL2106;IL2107;IL2108;IL2109; + IL2110;IL2111;IL2112;IL2113;IL2114; + IL2115;IL2116;IL2117;IL2118;IL2119; + IL2120;IL2121;IL2122;IL2123;IL2124; + IL2125;IL2126;IL2127;IL2128;IL2129; + + + true + + + $(WarningsAsErrors); + IL3050;IL3051;IL3052;IL3053;IL3054;IL3055;IL3056; + + + diff --git a/src/Mono.Android/Android.OS/AsyncTask.cs b/src/Mono.Android/Android.OS/AsyncTask.cs index ad5db1b113b..e66a162a145 100644 --- a/src/Mono.Android/Android.OS/AsyncTask.cs +++ b/src/Mono.Android/Android.OS/AsyncTask.cs @@ -9,7 +9,16 @@ namespace Android.OS { [global::System.Runtime.Versioning.ObsoletedOSPlatform ("android30.0")] [Register ("android/os/AsyncTask", DoNotGenerateAcw=true)] - public abstract class AsyncTask : AsyncTask { + public abstract class AsyncTask< + [DynamicallyAccessedMembers (Constructors)] + TParams, + [DynamicallyAccessedMembers (Constructors)] + TProgress, + [DynamicallyAccessedMembers (Constructors)] + TResult + > : AsyncTask { + + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; static IntPtr java_class_handle; internal static IntPtr class_ref { diff --git a/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs b/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs index edfe42ec449..329ee6aa67a 100644 --- a/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs +++ b/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs @@ -24,6 +24,7 @@ public static class AndroidEnvironment { static IX509TrustManager? sslTrustManager; static KeyStore? certStore; static object lock_ = new object (); + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] static Type? httpMessageHandlerType; static void SetupTrustManager () @@ -335,11 +336,18 @@ static IWebProxy GetDefaultProxy () [DynamicDependency (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof (Xamarin.Android.Net.AndroidMessageHandler))] static object GetHttpMessageHandler () { + // FIXME: https://github.com/xamarin/xamarin-android/issues/8797 + // Note that this is a problem for custom $(AndroidHttpClientHandlerType) or $XA_HTTP_CLIENT_HANDLER_TYPE + [UnconditionalSuppressMessage ("Trimming", "IL2057", Justification = "DynamicDependency should preserve AndroidMessageHandler.")] + [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] + static Type TypeGetType (string typeName) => + Type.GetType (typeName, throwOnError: false); + if (httpMessageHandlerType is null) { var handlerTypeName = Environment.GetEnvironmentVariable ("XA_HTTP_CLIENT_HANDLER_TYPE")?.Trim (); Type? handlerType = null; if (!String.IsNullOrEmpty (handlerTypeName)) - handlerType = Type.GetType (handlerTypeName, throwOnError: false); + handlerType = TypeGetType (handlerTypeName); // We don't do any type checking or casting here to avoid dependency on System.Net.Http in Mono.Android.dll if (handlerType is null || !IsAcceptableHttpMessageHandlerType (handlerType)) { @@ -369,13 +377,19 @@ static bool IsAcceptableHttpMessageHandlerType (Type handlerType) return true; } - static bool Extends (Type handlerType, string baseTypeName) { + static bool Extends ( + Type handlerType, + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] + string baseTypeName) + { var baseType = Type.GetType (baseTypeName, throwOnError: false); return baseType?.IsAssignableFrom (handlerType) ?? false; } - static Type GetFallbackHttpMessageHandlerType (string typeName = "Xamarin.Android.Net.AndroidMessageHandler, Mono.Android") + [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] + static Type GetFallbackHttpMessageHandlerType () { + const string typeName = "Xamarin.Android.Net.AndroidMessageHandler, Mono.Android"; var handlerType = Type.GetType (typeName, throwOnError: false) ?? throw new InvalidOperationException ($"The {typeName} was not found. The type was probably linked away."); diff --git a/src/Mono.Android/Android.Runtime/JNIEnv.cs b/src/Mono.Android/Android.Runtime/JNIEnv.cs index 80f214a1454..d5b39708168 100644 --- a/src/Mono.Android/Android.Runtime/JNIEnv.cs +++ b/src/Mono.Android/Android.Runtime/JNIEnv.cs @@ -16,11 +16,27 @@ namespace Android.Runtime { public static partial class JNIEnv { + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + [ThreadStatic] static byte[]? mvid_bytes; public static IntPtr Handle => JniEnvironment.EnvironmentPointer; + static Array ArrayCreateInstance (Type elementType, int length) => + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // IL3050 disabled in source: if someone uses NativeAOT, they will get the warning. + #pragma warning disable IL3050 + Array.CreateInstance (elementType, length); + #pragma warning restore IL3050 + + static Type MakeArrayType (Type type) => + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // IL3050 disabled in source: if someone uses NativeAOT, they will get the warning. + #pragma warning disable IL3050 + type.MakeArrayType (); + #pragma warning restore IL3050 + internal static IntPtr IdentityHash (IntPtr v) { return JNIEnvInit.LocalRefsAreIndirect ? RuntimeNativeMethods._monodroid_get_identity_hash_code (Handle, v) : v; @@ -807,7 +823,7 @@ public static void CopyArray (IntPtr src, Array dest, Type? elementType = null) throw new ArgumentNullException ("dest"); if (elementType != null && elementType.IsValueType) - AssertCompatibleArrayTypes (src, elementType.MakeArrayType ()); + AssertCompatibleArrayTypes (src, MakeArrayType (elementType)); if (elementType != null && elementType.IsArray) { for (int i = 0; i < dest.Length; ++i) { @@ -950,7 +966,7 @@ public static void CopyArray (Array source, Type elementType, IntPtr dest) throw new ArgumentNullException ("elementType"); if (elementType.IsValueType) - AssertCompatibleArrayTypes (elementType.MakeArrayType (), dest); + AssertCompatibleArrayTypes (MakeArrayType (elementType), dest); Action converter = GetConverter (CopyManagedToNativeArray, elementType, dest); @@ -1057,12 +1073,12 @@ public static void CopyArray (T[] src, IntPtr dest) } } }, { typeof (IJavaObject), (type, source, len) => { - var r = Array.CreateInstance (type!, len); + var r = ArrayCreateInstance (type!, len); CopyArray (source, r, type); return r; } }, { typeof (Array), (type, source, len) => { - var r = Array.CreateInstance (type!, len); + var r = ArrayCreateInstance (type!, len); CopyArray (source, r, type); return r; } }, @@ -1075,7 +1091,7 @@ public static void CopyArray (T[] src, IntPtr dest) return null; if (element_type != null && element_type.IsValueType) - AssertCompatibleArrayTypes (array_ptr, element_type.MakeArrayType ()); + AssertCompatibleArrayTypes (array_ptr, MakeArrayType (element_type)); int cnt = _GetArrayLength (array_ptr); @@ -1130,7 +1146,10 @@ static int _GetArrayLength (IntPtr array_ptr) return ret; } - public static T[]? GetArray (Java.Lang.Object[] array) + public static T[]? GetArray< + [DynamicallyAccessedMembers (Constructors)] + T + > (Java.Lang.Object[] array) { if (array == null) return null; @@ -1244,7 +1263,10 @@ static IntPtr GetArrayElementClass(T[] values) return FindClass (elementType); } - public static void CopyObjectArray(IntPtr source, T[] destination) + public static void CopyObjectArray< + [DynamicallyAccessedMembers (Constructors)] + T + >(IntPtr source, T[] destination) { if (source == IntPtr.Zero) return; diff --git a/src/Mono.Android/Android.Runtime/JavaCollection.cs b/src/Mono.Android/Android.Runtime/JavaCollection.cs index 70660bc24a3..8e23660f33b 100644 --- a/src/Mono.Android/Android.Runtime/JavaCollection.cs +++ b/src/Mono.Android/Android.Runtime/JavaCollection.cs @@ -14,6 +14,8 @@ namespace Android.Runtime { // java.util.Collection allows null values public class JavaCollection : Java.Lang.Object, System.Collections.ICollection { + internal const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + internal static IntPtr collection_class = JNIEnv.FindClass ("java/util/Collection"); internal static IntPtr id_add; @@ -148,6 +150,11 @@ internal Java.Lang.Object[] ToArray () // public void CopyTo (Array array, int array_index) { + [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "JavaCollection constructors are preserved by the MarkJavaObjects trimmer step.")] + [return: DynamicallyAccessedMembers (Constructors)] + static Type GetElementType (Array array) => + array.GetType ().GetElementType (); + if (array == null) throw new ArgumentNullException ("array"); if (array_index < 0) @@ -164,7 +171,7 @@ public void CopyTo (Array array, int array_index) JavaConvert.FromJniHandle ( JNIEnv.GetObjectArrayElement (lrefArray, i), JniHandleOwnership.TransferLocalRef, - array.GetType ().GetElementType ()), + GetElementType (array)), array_index + i); JNIEnv.DeleteLocalRef (lrefArray); } @@ -203,7 +210,10 @@ public static IntPtr ToLocalJniHandle (ICollection? items) } [Register ("java/util/Collection", DoNotGenerateAcw=true)] - public sealed class JavaCollection : JavaCollection, ICollection { + public sealed class JavaCollection< + [DynamicallyAccessedMembers (Constructors)] + T + > : JavaCollection, ICollection { public JavaCollection (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) diff --git a/src/Mono.Android/Android.Runtime/JavaDictionary.cs b/src/Mono.Android/Android.Runtime/JavaDictionary.cs index 80656dfc58c..311dbf36ebe 100644 --- a/src/Mono.Android/Android.Runtime/JavaDictionary.cs +++ b/src/Mono.Android/Android.Runtime/JavaDictionary.cs @@ -12,6 +12,8 @@ namespace Android.Runtime { // java.util.HashMap allows null keys and values public class JavaDictionary : Java.Lang.Object, System.Collections.IDictionary { + internal const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + class DictionaryEnumerator : IDictionaryEnumerator { IEnumerator simple_enumerator; @@ -396,7 +398,12 @@ public static IntPtr ToLocalJniHandle (IDictionary? dictionary) // it may throw. // [Register ("java/util/HashMap", DoNotGenerateAcw=true)] - public class JavaDictionary : JavaDictionary, IDictionary { + public class JavaDictionary< + [DynamicallyAccessedMembers (Constructors)] + K, + [DynamicallyAccessedMembers (Constructors)] + V + > : JavaDictionary, IDictionary { [Register (".ctor", "()V", "")] public JavaDictionary () diff --git a/src/Mono.Android/Android.Runtime/JavaList.cs b/src/Mono.Android/Android.Runtime/JavaList.cs index 980b01f386e..e1877533577 100644 --- a/src/Mono.Android/Android.Runtime/JavaList.cs +++ b/src/Mono.Android/Android.Runtime/JavaList.cs @@ -10,6 +10,7 @@ namespace Android.Runtime { // java.util.ArrayList allows null values public partial class JavaList : Java.Lang.Object, System.Collections.IList { + internal const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; internal static readonly JniPeerMembers list_members = new XAPeerMembers ("java/util/List", typeof (JavaList), isInterface: true); // @@ -23,7 +24,10 @@ public partial class JavaList : Java.Lang.Object, System.Collections.IList { // // https://developer.android.com/reference/java/util/List.html?hl=en#get(int) // - internal unsafe object? InternalGet (int location, Type? targetType = null) + internal unsafe object? InternalGet ( + int location, + [DynamicallyAccessedMembers (Constructors)] + Type? targetType = null) { const string id = "get.(I)Ljava/lang/Object;"; JniObjectReference obj; @@ -266,6 +270,11 @@ public unsafe bool Contains (object? item) public void CopyTo (Array array, int array_index) { + [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "JavaList constructors are preserved by the MarkJavaObjects trimmer step.")] + [return: DynamicallyAccessedMembers (Constructors)] + static Type GetElementType (Array array) => + array.GetType ().GetElementType (); + if (array == null) throw new ArgumentNullException ("array"); if (array_index < 0) @@ -273,7 +282,7 @@ public void CopyTo (Array array, int array_index) if (array.Length < array_index + Count) throw new ArgumentException ("array"); - var targetType = array.GetType ().GetElementType (); + var targetType = GetElementType (array); int c = Count; for (int i = 0; i < c; i++) array.SetValue (InternalGet (i, targetType), array_index + i); @@ -673,7 +682,10 @@ public virtual Java.Lang.Object [] ToArray () } [Register ("java/util/ArrayList", DoNotGenerateAcw=true)] - public class JavaList : JavaList, IList { + public class JavaList< + [DynamicallyAccessedMembers (Constructors)] + T + > : JavaList, IList { // // Exception audit: diff --git a/src/Mono.Android/Android.Runtime/JavaSet.cs b/src/Mono.Android/Android.Runtime/JavaSet.cs index c141e1058a4..b84b040289a 100644 --- a/src/Mono.Android/Android.Runtime/JavaSet.cs +++ b/src/Mono.Android/Android.Runtime/JavaSet.cs @@ -268,7 +268,10 @@ public static IntPtr ToLocalJniHandle (ICollection? items) [Register ("java/util/HashSet", DoNotGenerateAcw=true)] // java.util.HashSet allows null - public class JavaSet : JavaSet, ICollection { + public class JavaSet< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + T + > : JavaSet, ICollection { // // Exception audit: diff --git a/src/Mono.Android/Android.Util/SparseArray.cs b/src/Mono.Android/Android.Util/SparseArray.cs index 0fcd05f31f6..2a895fb7307 100644 --- a/src/Mono.Android/Android.Util/SparseArray.cs +++ b/src/Mono.Android/Android.Util/SparseArray.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using Android.Runtime; @@ -7,7 +8,10 @@ namespace Android.Util { [Register ("android/util/SparseArray", DoNotGenerateAcw=true)] - public partial class SparseArray : SparseArray + public partial class SparseArray< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + E + > : SparseArray { public SparseArray () { diff --git a/src/Mono.Android/Android.Widget/AdapterView.cs b/src/Mono.Android/Android.Widget/AdapterView.cs index 5ad2293d8e3..7689b0c39e3 100644 --- a/src/Mono.Android/Android.Widget/AdapterView.cs +++ b/src/Mono.Android/Android.Widget/AdapterView.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using Android.Views; using JLO = Java.Lang.Object; @@ -49,7 +50,10 @@ public event EventHandler ItemSelectionCleared { } [Register ("android/widget/AdapterView", DoNotGenerateAcw=true)] - public abstract class AdapterView : AdapterView where T : IAdapter { + public abstract class AdapterView< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + T + > : AdapterView where T : IAdapter { public AdapterView (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) diff --git a/src/Mono.Android/Android.Widget/ArrayAdapter.cs b/src/Mono.Android/Android.Widget/ArrayAdapter.cs index cf35e67fc07..e54ce8d7c94 100644 --- a/src/Mono.Android/Android.Widget/ArrayAdapter.cs +++ b/src/Mono.Android/Android.Widget/ArrayAdapter.cs @@ -8,7 +8,10 @@ namespace Android.Widget { [Register ("android/widget/ArrayAdapter", DoNotGenerateAcw=true)] - public partial class ArrayAdapter : ArrayAdapter { + public partial class ArrayAdapter< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] + T + > : ArrayAdapter { public ArrayAdapter (IntPtr handle, JniHandleOwnership transfer) : base (handle, transfer) diff --git a/src/Mono.Android/Java.Interop/JavaConvert.cs b/src/Mono.Android/Java.Interop/JavaConvert.cs index c98bc8cd2f2..e7602ba4432 100644 --- a/src/Mono.Android/Java.Interop/JavaConvert.cs +++ b/src/Mono.Android/Java.Interop/JavaConvert.cs @@ -10,6 +10,7 @@ namespace Java.Interop { static class JavaConvert { + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; static Dictionary> JniHandleConverters = new Dictionary>() { { typeof (bool), (handle, transfer) => { @@ -56,6 +57,21 @@ static class JavaConvert { static Func? GetJniHandleConverter (Type? target) { + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // Might cause an issue in the future for NativeAOT + [UnconditionalSuppressMessage ("Trimming", "IL2055", Justification = "We don't think the IDictionary, IList, or ICollection code paths occur if JavaDictionary<,>, JavaList<>, and JavaCollection<> do not exist.")] + [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + static Type MakeGenericType ( + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] + Type type, + params Type [] typeArguments + ) => + // FIXME: https://github.com/xamarin/xamarin-android/issues/8724 + // IL3050 disabled in source: if someone uses NativeAOT, they will get the warning. + #pragma warning disable IL3050 + type.MakeGenericType (typeArguments); + #pragma warning restore IL3050 + if (target == null) return null; @@ -64,19 +80,19 @@ static class JavaConvert { if (target.IsArray) return (h, t) => JNIEnv.GetArray (h, t, target.GetElementType ()); if (target.IsGenericType && target.GetGenericTypeDefinition() == typeof (IDictionary<,>)) { - Type t = typeof (JavaDictionary<,>).MakeGenericType (target.GetGenericArguments ()); + Type t = MakeGenericType (typeof (JavaDictionary<,>), target.GetGenericArguments ()); return GetJniHandleConverterForType (t); } if (typeof (IDictionary).IsAssignableFrom (target)) return (h, t) => JavaDictionary.FromJniHandle (h, t); if (target.IsGenericType && target.GetGenericTypeDefinition() == typeof (IList<>)) { - Type t = typeof (JavaList<>).MakeGenericType (target.GetGenericArguments ()); + Type t = MakeGenericType (typeof (JavaList<>), target.GetGenericArguments ()); return GetJniHandleConverterForType (t); } if (typeof (IList).IsAssignableFrom (target)) return (h, t) => JavaList.FromJniHandle (h, t); if (target.IsGenericType && target.GetGenericTypeDefinition() == typeof (ICollection<>)) { - Type t = typeof (JavaCollection<>).MakeGenericType (target.GetGenericArguments ()); + Type t = MakeGenericType (typeof (JavaCollection<>), target.GetGenericArguments ()); return GetJniHandleConverterForType (t); } if (typeof (ICollection).IsAssignableFrom (target)) @@ -92,13 +108,19 @@ static Func GetJniHandleConverterForType ([D typeof (Func), m); } - public static T? FromJniHandle(IntPtr handle, JniHandleOwnership transfer) + public static T? FromJniHandle< + [DynamicallyAccessedMembers (Constructors)] + T + >(IntPtr handle, JniHandleOwnership transfer) { bool set; return FromJniHandle(handle, transfer, out set); } - public static T? FromJniHandle(IntPtr handle, JniHandleOwnership transfer, out bool set) + public static T? FromJniHandle< + [DynamicallyAccessedMembers (Constructors)] + T + >(IntPtr handle, JniHandleOwnership transfer, out bool set) { if (handle == IntPtr.Zero) { set = false; @@ -133,7 +155,11 @@ static Func GetJniHandleConverterForType ([D return (T?) Convert.ChangeType (v, typeof (T), CultureInfo.InvariantCulture); } - public static object? FromJniHandle (IntPtr handle, JniHandleOwnership transfer, Type? targetType = null) + public static object? FromJniHandle ( + IntPtr handle, + JniHandleOwnership transfer, + [DynamicallyAccessedMembers (Constructors)] + Type? targetType = null) { if (handle == IntPtr.Zero) { return null; @@ -206,13 +232,19 @@ static Func GetJniHandleConverterForType ([D return null; } - public static T? FromJavaObject(IJavaObject? value) + public static T? FromJavaObject< + [DynamicallyAccessedMembers (Constructors)] + T + >(IJavaObject? value) { bool set; return FromJavaObject(value, out set); } - public static T? FromJavaObject(IJavaObject? value, out bool set) + public static T? FromJavaObject< + [DynamicallyAccessedMembers (Constructors)] + T + >(IJavaObject? value, out bool set) { if (value == null) { set = false; @@ -245,7 +277,10 @@ static Func GetJniHandleConverterForType ([D return (T) Convert.ChangeType (value, typeof (T), CultureInfo.InvariantCulture); } - public static object? FromJavaObject (IJavaObject value, Type? targetType = null) + public static object? FromJavaObject ( + IJavaObject value, + [DynamicallyAccessedMembers (Constructors)] + Type? targetType = null) { if (value == null) return null; diff --git a/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs b/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs index 5b083487c5b..345c664c61d 100644 --- a/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs +++ b/src/Mono.Android/Java.Interop/JavaObjectExtensions.cs @@ -17,7 +17,10 @@ public static JavaCollection ToInteroperableCollection (this ICollection instanc } [Obsolete ("Use Android.Runtime.JavaCollection.ToLocalJniHandle()")] - public static JavaCollection ToInteroperableCollection (this ICollection instance) + public static JavaCollection ToInteroperableCollection< + [DynamicallyAccessedMembers (Constructors)] + T + > (this ICollection instance) { return instance is JavaCollection ? (JavaCollection) instance : new JavaCollection (instance); } @@ -29,7 +32,10 @@ public static JavaList ToInteroperableCollection (this IList instance) } [Obsolete ("Use Android.Runtime.JavaList.ToLocalJniHandle()")] - public static JavaList ToInteroperableCollection (this IList instance) + public static JavaList ToInteroperableCollection< + [DynamicallyAccessedMembers (Constructors)] + T + > (this IList instance) { return instance is JavaList ? (JavaList) instance : new JavaList (instance); } @@ -41,7 +47,12 @@ public static JavaDictionary ToInteroperableCollection (this IDictionary instanc } [Obsolete ("Use Android.Runtime.JavaDictionary.ToLocalJniHandle()")] - public static JavaDictionary ToInteroperableCollection (this IDictionary instance) + public static JavaDictionary ToInteroperableCollection< + [DynamicallyAccessedMembers (Constructors)] + K, + [DynamicallyAccessedMembers (Constructors)] + V + > (this IDictionary instance) { return instance is JavaDictionary ? (JavaDictionary) instance : new JavaDictionary (instance); } diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index 1c833d2cd75..1191832e9fd 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -3,6 +3,7 @@ + $(DotNetTargetFramework) diff --git a/src/Mono.Android/System.Linq/Extensions.cs b/src/Mono.Android/System.Linq/Extensions.cs index ac555e17949..c8bb0a4a740 100644 --- a/src/Mono.Android/System.Linq/Extensions.cs +++ b/src/Mono.Android/System.Linq/Extensions.cs @@ -9,6 +9,8 @@ namespace System.Linq { public static class Extensions { + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + static IntPtr id_next; static Extensions () @@ -40,7 +42,10 @@ internal static IEnumerator ToEnumerator_Dispose (this Java.Util.IIterator sourc } } - public static IEnumerable ToEnumerable (this Java.Lang.IIterable source) + public static IEnumerable ToEnumerable< + [DynamicallyAccessedMembers (Constructors)] + T + > (this Java.Lang.IIterable source) { if (source == null) throw new ArgumentNullException ("source"); @@ -52,7 +57,10 @@ internal static IEnumerator ToEnumerator_Dispose (this Java.Util.IIterator sourc } } - internal static IEnumerator ToEnumerator_Dispose (this Java.Util.IIterator source) + internal static IEnumerator ToEnumerator_Dispose< + [DynamicallyAccessedMembers (Constructors)] + T + > (this Java.Util.IIterator source) { using (source) while (source.HasNext) { From 0561c9196d4bfbf4a4e60a876077ac9a6d06b746 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:41:17 -0400 Subject: [PATCH 07/10] Bump to xamarin/Java.Interop/main@651de42 (#8809) Changes: https://github.com/xamarin/java.interop/compare/5bca8ad6e5cf28d1c1a0bac37d2e0aa311795aa8...651de42732d194cee5a45fae45feda37706a8c16 * xamarin/java.interop@651de427: [Java.Interop] supress one instance of IL2072 (xamarin/java.interop#1205) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index 5bca8ad6e5c..651de42732d 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 5bca8ad6e5cf28d1c1a0bac37d2e0aa311795aa8 +Subproject commit 651de42732d194cee5a45fae45feda37706a8c16 From 269bba653e1f662354c921b2e4e6a55d04867b8c Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 14 Mar 2024 09:44:07 -1000 Subject: [PATCH 08/10] [Microsoft.Android.Templates] Update EN l10n template strings (#8808) Context: 9d8ca6074b09be7aefad9266b2691fcff2ff5210 In 9d8ca607 we removed some redundant verbiage from our Android item templates. Unfortunatley, now a complete xamarin-android build produces generated file changes, leaving us with a dirty local tree. Commit the updated generated EN localization string files. --- .../.template.config/localize/templatestrings.en.json | 2 +- .../.template.config/localize/templatestrings.en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Android.Templates/android-activity/.template.config/localize/templatestrings.en.json b/src/Microsoft.Android.Templates/android-activity/.template.config/localize/templatestrings.en.json index 66a04db062c..2db2e351169 100644 --- a/src/Microsoft.Android.Templates/android-activity/.template.config/localize/templatestrings.en.json +++ b/src/Microsoft.Android.Templates/android-activity/.template.config/localize/templatestrings.en.json @@ -1,6 +1,6 @@ { "author": "Microsoft", - "name": "Android Activity template", + "name": "Android Activity", "description": "An Android Activity class", "symbols/namespace/description": "namespace for the generated code", "postActions/openInEditor/description": "Opens Activity1.cs in the editor" diff --git a/src/Microsoft.Android.Templates/android-layout/.template.config/localize/templatestrings.en.json b/src/Microsoft.Android.Templates/android-layout/.template.config/localize/templatestrings.en.json index 97dd8ac01e3..563d49a7536 100644 --- a/src/Microsoft.Android.Templates/android-layout/.template.config/localize/templatestrings.en.json +++ b/src/Microsoft.Android.Templates/android-layout/.template.config/localize/templatestrings.en.json @@ -1,6 +1,6 @@ { "author": "Microsoft", - "name": "Android Layout template", + "name": "Android Layout", "description": "An Android layout (XML) file", "postActions/openInEditor/description": "Opens Layout1.xml in the editor" } \ No newline at end of file From 60e8c3e5336694f62552248255cf39ace7101416 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Thu, 14 Mar 2024 13:46:51 -1000 Subject: [PATCH 09/10] [ci] Don't auto-retry APK test suites. (#8811) Context: https://github.com/xamarin/xamarin-android/issues/8687 In https://github.com/xamarin/xamarin-android/pull/7963, we added an automatic retry mechanism to the APK test suites. However this mechanism does not give us a chance to run any tasks between the retry. This means that when the tests are run a second time the output directories have not been cleaned and thus we are running incremental builds instead of full builds. We could unknowingly have tests that always fail on a clean build and succeed on an incremental build. Thus we are going to remove the automatic retries. The good news is these test suites seem to be much more stable now than when we implemented the retries, so hopefully this will not result in too many flaky CI builds. --- build-tools/automation/yaml-templates/apk-instrumentation.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-tools/automation/yaml-templates/apk-instrumentation.yaml b/build-tools/automation/yaml-templates/apk-instrumentation.yaml index b0958a7017a..ba75d63fd5c 100644 --- a/build-tools/automation/yaml-templates/apk-instrumentation.yaml +++ b/build-tools/automation/yaml-templates/apk-instrumentation.yaml @@ -10,7 +10,6 @@ parameters: artifactSource: "" artifactFolder: "" condition: succeeded() - retryCountOnTaskFailure: 1 steps: - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml @@ -25,7 +24,6 @@ steps: -v:n -c ${{ parameters.configuration }} ${{ parameters.extraBuildArgs }} condition: ${{ parameters.condition }} continueOnError: true - retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }} - script: > DEST="$(Build.StagingDirectory)/Test${{ parameters.configuration }}/${{ parameters.artifactFolder }}/" && From 6fde0f61b05b2562d3afcbfc50f74e4b3eeb7b70 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Fri, 15 Mar 2024 08:47:37 +0000 Subject: [PATCH 10/10] [runtime] Remove the last vestiges of desktop builds (#8810) Clean up `src/monodroid/CMakeLists.txt` by removing all the options to handle builds for macOS, Linux and Windows desktops. Also, bump C standard to C11 --- src/monodroid/CMakeLists.txt | 452 ++++++++--------------------------- 1 file changed, 101 insertions(+), 351 deletions(-) diff --git a/src/monodroid/CMakeLists.txt b/src/monodroid/CMakeLists.txt index 0947a0e9bd7..7994193121a 100644 --- a/src/monodroid/CMakeLists.txt +++ b/src/monodroid/CMakeLists.txt @@ -25,16 +25,10 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS OFF) -if(WIN32 AND NOT MINGW) - set(CCACHE_OPTION_DEFAULT OFF) -else() - set(CCACHE_OPTION_DEFAULT ON) -endif() - option(ENABLE_CLANG_ASAN "Enable the clang AddressSanitizer support" OFF) option(ENABLE_CLANG_UBSAN "Enable the clang UndefinedBehaviorSanitizer support" OFF) @@ -49,9 +43,9 @@ endif() option(ENABLE_TIMING "Build with timing support" OFF) option(STRIP_DEBUG "Strip debugging information when linking" ${STRIP_DEBUG_DEFAULT}) option(DISABLE_DEBUG "Disable the built-in debugging code" OFF) -option(USE_CCACHE "Use ccache, if found, to speed up recompilation" ${CCACHE_OPTION_DEFAULT}) +option(USE_CCACHE "Use ccache, if found, to speed up recompilation" ON) -if((MINGW OR NOT WIN32) AND USE_CCACHE) +if(USE_CCACHE) if(CMAKE_CXX_COMPILER MATCHES "/ccache/") message(STATUS "ccache: compiler already uses ccache") else() @@ -70,12 +64,10 @@ else() set(DEBUG_BUILD False) endif() -if(ANDROID) - if(ANDROID_STL STREQUAL none) - set(USES_LIBSTDCPP False) - else() - set(USES_LIBSTDCPP True) - endif() +if(ANDROID_STL STREQUAL none) + set(USES_LIBSTDCPP False) +else() + set(USES_LIBSTDCPP True) endif() # Environment checks @@ -102,25 +94,6 @@ if(NOT DEFINED XA_LIB_TOP_DIR) message(FATAL_ERROR "Please set the XA_LIB_TOP_DIR variable on command line (-DXA_LIB_TOP_DIR=path)") endif() -if(NOT ANDROID) - if (NOT DEFINED JDK_INCLUDE) - message(FATAL_ERROR "Please set the JDK_INCLUDE variable on command line (-DJDK_INCLUDE)") - endif() -endif() - -if(MINGW AND NOT WIN32) - if(NOT DEFINED MINGW_DEPENDENCIES_ROOT_DIR) - message(FATAL_ERROR "Please set the MINGW_DEPENDENCIES_ROOT_DIR variable on command line (-DMINGW_DEPENDENCIES_ROOT_DIR=PATH)") - endif() - - if(DEFINED MINGW_TARGET_32 AND DEFINED MINGW_TARGET_64) - message(FATAL_ERROR "Only one of the MINGW_TARGET_32 or MINGW_TARGET_64 variables can be defined") - endif() - if(NOT DEFINED MINGW_TARGET_32 AND NOT DEFINED MINGW_TARGET_64) - message(FATAL_ERROR "Either MINGW_TARGET_32 or MINGW_TARGET_64 variable must be defined") - endif() -endif() - # Needed modules include(CheckIncludeFile) @@ -140,17 +113,6 @@ else() set(IS_MACOS False) endif() -if(NOT ANDROID) - if(APPLE) - set(CMAKE_MACOSX_RPATH 1) - set(HOST_BUILD_NAME "host-Darwin") - endif() - - if(IS_LINUX AND NOT MINGW) - set(HOST_BUILD_NAME "host-Linux") - endif() -endif() - # Paths set(EXTERNAL_DIR "../../external") @@ -163,24 +125,6 @@ set(XA_BIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/${XA_BUILD_CONFIGURATION}" set(XA_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/Build${XA_BUILD_CONFIGURATION}") set(ROBIN_MAP_DIR "${EXTERNAL_DIR}/robin-map") -if(NOT ANDROID) - if(WIN32 OR MINGW) - if (MINGW_TARGET_32) - set(ANDROID_ABI "host-mxe-Win32") - endif() - - if (MINGW_TARGET_64) - set(ANDROID_ABI "host-mxe-Win64") - endif() - - set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_ABI}") - endif() - - if(DEFINED HOST_BUILD_NAME) - set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${HOST_BUILD_NAME}") - endif() -endif() - include("${XA_BUILD_DIR}/xa_build_configuration.cmake") if(ANDROID_ABI MATCHES "^arm64-v8a") @@ -201,48 +145,13 @@ set(LZ4_SOURCES # Include directories include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/ ${CMAKE_SOURCE_DIR}/include) -include_directories(${ROBIN_MAP_DIR}/include) - -if(NOT ANDROID) - string(REPLACE " " ";" JDK_INCLUDE_LIST ${JDK_INCLUDE}) - foreach(inc in ${JDK_INCLUDE_LIST}) - include_directories(${inc}) - endforeach() -endif() - -if(ANDROID) - include_directories(${CMAKE_SYSROOT}/usr/include/c++/v1/) - include_directories(${LZ4_INCLUDE_DIR}) -endif() - -if(MINGW) - if(MINGW_TARGET_32) - include_directories("${MINGW_DEPENDENCIES_ROOT_DIR}/x86/include") - if(IS_MACOS) - include_directories("/usr/local/opt/mingw-zlib/usr/i686-w64-mingw32/include") - endif() - endif() - - if (MINGW_TARGET_64) - include_directories("${MINGW_DEPENDENCIES_ROOT_DIR}/x86_64/include") - if(IS_MACOS) - include_directories("/usr/local/opt/mingw-zlib/usr/x86_64-w64-mingw32/include") - endif() - endif() -endif() - -if(NOT ANDROID AND DEFINED HOST_BUILD_NAME) - include_directories("${XA_BIN_DIR}/include/${HOST_BUILD_NAME}") - include_directories("${XA_BIN_DIR}/include/${HOST_BUILD_NAME}/eglib") - include_directories("../../bin/${CONFIGURATION}/include/${HOST_BUILD_NAME}") - include_directories("../../bin/${CONFIGURATION}/include/${HOST_BUILD_NAME}/eglib") -endif() - -if (WIN32) - include_directories(BEFORE "jni/win32") -endif() -include_directories("${NET_RUNTIME_DIR}/native/include/mono-2.0") +# The SYSTEM which will make clang skip warnings for the headers there. Since we can't do +# much about them, we can just as well avoid cluttered build output. +include_directories(SYSTEM ${ROBIN_MAP_DIR}/include) +include_directories(SYSTEM ${CMAKE_SYSROOT}/usr/include/c++/v1/) +include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) +include_directories(SYSTEM "${NET_RUNTIME_DIR}/native/include/mono-2.0") include_directories("jni") include_directories("${XA_BIN_DIR}/include") include_directories("${XA_BIN_DIR}/include/${ANDROID_ABI}/eglib") @@ -251,7 +160,6 @@ include_directories("${XA_BIN_DIR}/include/${ANDROID_ABI}/eglib") include_directories("../../bin/${CONFIGURATION}/include") include_directories("../../bin/${CONFIGURATION}/include/${ANDROID_ABI}/eglib") include_directories("${MONO_PATH}/mono/eglib") -include_directories("jni/zip") include_directories("${JAVA_INTEROP_SRC_PATH}") # Common preparation code @@ -279,48 +187,22 @@ if (ENABLE_TIMING) add_compile_definitions(MONODROID_TIMING) endif() -if(ANDROID) - add_compile_definitions(HAVE_LZ4) - add_compile_definitions(PLATFORM_ANDROID) - - if(ANDROID_ABI MATCHES "^(arm64-v8a|x86_64)") - add_compile_definitions(ANDROID64) - endif() - - if (ANDROID_NDK_MAJOR LESS 20) - add_compile_definitions(__ANDROID_API_Q__=29) - endif() -endif() - -if(NOT ANDROID) - set(CMAKE_REQUIRED_DEFINITIONS "-D__USE_GNU") - check_cxx_symbol_exists(gettid unistd.h HAVE_GETTID_IN_UNISTD_H) - if(HAVE_GETTID_IN_UNISTD_H) - add_compile_definitions(HAVE_GETTID_IN_UNISTD_H) - endif() - - # MinGW needs it for {v,a}sprintf - add_compile_definitions(_GNU_SOURCE) - - if(APPLE) - add_compile_definitions(APPLE_OS_X) - endif() +add_compile_definitions(HAVE_LZ4) +add_compile_definitions(PLATFORM_ANDROID) - if(IS_LINUX) - if(NOT MINGW AND NOT WIN32) - if(EXISTS "/.flatpak-info") - add_compile_definitions(LINUX_FLATPAK) - endif() - endif() - endif() +if(ANDROID_ABI MATCHES "^(arm64-v8a|x86_64)") + add_compile_definitions(ANDROID64) endif() -if(WIN32 OR MINGW) - add_compile_definitions(WINDOWS NTDDI_VERSION=NTDDI_VISTA _WINDOWS _WIN32_WINNT=_WIN32_WINNT_VISTA) +if (ANDROID_NDK_MAJOR LESS 20) + add_compile_definitions(__ANDROID_API_Q__=29) endif() # Compiler and linker flags -set(LINK_LIBS "") +set(LINK_LIBS + -lmonosgen-2.0 + -llog +) # # -Wformat-nonliteral is disabled as it's not very practical, because we use proxy functions to @@ -375,49 +257,38 @@ endif() if(COMPILER_DIAG_COLOR) list(APPEND LOCAL_COMMON_COMPILER_ARGS -fdiagnostics-color=always + -fcolor-diagnostics ) endif() -set(LOCAL_COMMON_LINKER_ARGS "") -if(ANDROID) - list(APPEND LOCAL_COMMON_LINKER_ARGS - -fstack-clash-protection - ) - - if (ENABLE_CLANG_ASAN OR ENABLE_CLANG_UBSAN) - list(APPEND LOCAL_COMMON_COMPILER_ARGS - -fno-omit-frame-pointer - -fno-optimize-sibling-calls - ) - endif() - - unset(SANITIZER_FLAGS) - if (ENABLE_CLANG_ASAN) - set(SANITIZER_FLAGS -fsanitize=address) - set(CHECKED_BUILD_INFIX "-checked+asan") - elseif(ENABLE_CLANG_UBSAN) - set(SANITIZER_FLAGS -fsanitize=undefined) - set(CHECKED_BUILD_INFIX "-checked+ubsan") - endif() - - if(SANITIZER_FLAGS) - message(STATUS "Got sanitizer: ${SANITIZER_FLAGS}") +set(LOCAL_COMMON_LINKER_ARGS + -shared + -fpic + -fstack-clash-protection +) - list(APPEND LOCAL_COMMON_COMPILER_ARGS ${SANITIZER_FLAGS}) - list(APPEND LOCAL_COMMON_LINKER_ARGS ${SANITIZER_FLAGS}) - list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${SANITIZER_FLAGS}) - endif() +if (ENABLE_CLANG_ASAN OR ENABLE_CLANG_UBSAN) + list(APPEND LOCAL_COMMON_COMPILER_ARGS + -fno-omit-frame-pointer + -fno-optimize-sibling-calls + ) endif() -if(WIN32 OR MINGW) - message(STATUS "Win32 or MinGW") - add_compile_options(-fomit-frame-pointer) - list(APPEND LOCAL_COMMON_LINKER_ARGS -static -pthread -dynamic) - list(APPEND LINK_LIBS -lmman -lkernel32 -lmswsock -lwsock32 -lshlwapi -lpsapi -lwinmm) +unset(SANITIZER_FLAGS) +if (ENABLE_CLANG_ASAN) + set(SANITIZER_FLAGS -fsanitize=address) + set(CHECKED_BUILD_INFIX "-checked+asan") +elseif(ENABLE_CLANG_UBSAN) + set(SANITIZER_FLAGS -fsanitize=undefined) + set(CHECKED_BUILD_INFIX "-checked+ubsan") endif() -if(UNIX) - list(APPEND LOCAL_COMMON_LINKER_ARGS -shared -fpic) +if(SANITIZER_FLAGS) + message(STATUS "Got sanitizer: ${SANITIZER_FLAGS}") + + list(APPEND LOCAL_COMMON_COMPILER_ARGS ${SANITIZER_FLAGS}) + list(APPEND LOCAL_COMMON_LINKER_ARGS ${SANITIZER_FLAGS}) + list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${SANITIZER_FLAGS}) endif() if(STRIP_DEBUG) @@ -441,40 +312,19 @@ if(DEBUG_BUILD) # Convince NDK to really optimize our Debug builds. Without this, NDK's cmake toolchain definition # will force a -O0 on us and our "debug" build is not really for debugging of our native code but # rather for "debug" builds of user apps - it has extra code but it has to be as fast as possible. - if(ANDROID) - # This is specific to clang, enable only for Android builds - set(XA_COMPILER_FLAGS_DEBUG "-fno-limit-debug-info -O2") - set(CMAKE_C_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG}) - set(CMAKE_CXX_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG}) - endif() + set(XA_COMPILER_FLAGS_DEBUG "-fno-limit-debug-info -O2") + set(CMAKE_C_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG}) + set(CMAKE_CXX_FLAGS_DEBUG ${XA_COMPILER_FLAGS_DEBUG}) endif() # Library directories -if(ANDROID) - set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_RID}") - set(XA_LIBRARY_STUBS_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/libstubs/${ANDROID_RID}") - link_directories("${NET_RUNTIME_DIR}/native") -endif() - -if(WIN32 OR MINGW) - if(MINGW_TARGET_32) - link_directories("${MINGW_DEPENDENCIES_ROOT_DIR}/x86/lib") - endif() - - if(MINGW_TARGET_64) - link_directories("${MINGW_DEPENDENCIES_ROOT_DIR}/x86_64/lib") - endif() - - link_directories("${XA_LIBRARY_OUTPUT_DIRECTORY}") -endif() - -if(NOT ANDROID AND DEFINED HOST_BUILD_NAME) - link_directories("${XA_LIB_TOP_DIR}/lib/${HOST_BUILD_NAME}") -endif() +set(XA_LIBRARY_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/lib/${ANDROID_RID}") +set(XA_LIBRARY_STUBS_OUTPUT_DIRECTORY "${XA_LIB_TOP_DIR}/libstubs/${ANDROID_RID}") +link_directories("${NET_RUNTIME_DIR}/native") # Header checks -if(ANDROID AND (ENABLE_CLANG_UBSAN OR ENABLE_CLANG_ASAN)) +if(ENABLE_CLANG_UBSAN OR ENABLE_CLANG_ASAN) set(OLD_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -llog") string(STRIP "${CMAKE_REQUIRED_FLAGS}" CMAKE_REQUIRED_FLAGS) @@ -484,7 +334,7 @@ check_include_file("linux/netlink.h" HAVE_LINUX_NETLINK_H) check_include_file("linux/rtnetlink.h" HAVE_LINUX_RTNETLINK_H) check_include_file("linux/if_arp.h" HAVE_LINUX_IF_ARP_H) -if(ANDROID AND (ENABLE_CLANG_UBSAN OR ENABLE_CLANG_ASAN)) +if(ENABLE_CLANG_UBSAN OR ENABLE_CLANG_ASAN) set(CMAKE_REQUIRED_FLAGS "${OLD_CMAKE_REQUIRED_FLAGS}") endif() @@ -498,81 +348,50 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} XAMARIN_MONO_ANDROID_SUFFIX) set(XAMARIN_MONO_ANDROID_LIB "mono-android${CHECKED_BUILD_INFIX}.${XAMARIN_MONO_ANDROID_SUFFIX}") set(XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/new_delete.cc + ${JAVA_INTEROP_SRC_PATH}/java-interop-dlfcn.cc + ${JAVA_INTEROP_SRC_PATH}/java-interop-mono.cc + ${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc + ${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc + ${JAVA_INTEROP_SRC_PATH}/java-interop.cc + ${LZ4_SOURCES} ${SOURCES_DIR}/android-system.cc ${SOURCES_DIR}/basic-android-system.cc ${SOURCES_DIR}/basic-utilities.cc ${SOURCES_DIR}/cpu-arch-detect.cc - ${SOURCES_DIR}/debug.cc ${SOURCES_DIR}/debug-constants.cc - ${SOURCES_DIR}/embedded-assemblies.cc + ${SOURCES_DIR}/debug.cc ${SOURCES_DIR}/embedded-assemblies-zip.cc + ${SOURCES_DIR}/embedded-assemblies.cc ${SOURCES_DIR}/globals.cc ${SOURCES_DIR}/helpers.cc - ${SOURCES_DIR}/logger.cc ${SOURCES_DIR}/jni-remapping.cc + ${SOURCES_DIR}/logger.cc + ${SOURCES_DIR}/mono-log-adapter.cc ${SOURCES_DIR}/monodroid-glue.cc + ${SOURCES_DIR}/monodroid-networkinfo.cc + ${SOURCES_DIR}/monovm-properties.cc + ${SOURCES_DIR}/new_delete.cc ${SOURCES_DIR}/osbridge.cc + ${SOURCES_DIR}/pinvoke-override-api.cc ${SOURCES_DIR}/shared-constants.cc ${SOURCES_DIR}/timezones.cc ${SOURCES_DIR}/timing-internal.cc ${SOURCES_DIR}/util.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-mono.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-dlfcn.cc - ) - -if(ANDROID) - list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/mono-log-adapter.cc - ${LZ4_SOURCES} - ) - - if(NOT DEBUG_BUILD) - list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/xamarin-android-app-context.cc - ) - endif() - - if(NOT USES_LIBSTDCPP) - list(APPEND XAMARIN_MONODROID_SOURCES - ${BIONIC_SOURCES_DIR}/cxa_guard.cc - ${SOURCES_DIR}/cxx-abi/string.cc - ${SOURCES_DIR}/cxx-abi/terminate.cc - ) - endif() -else() - list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/designer-assemblies.cc - ${SOURCES_DIR}/monodroid-glue-designer.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-gc-bridge-mono.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-jvm.cc - ) -endif() + ${SOURCES_DIR}/xamarin_getifaddrs.cc +) -if(UNIX) +if(NOT DEBUG_BUILD) list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/monodroid-networkinfo.cc - ${SOURCES_DIR}/xamarin_getifaddrs.cc - ) + ${SOURCES_DIR}/xamarin-android-app-context.cc + ) endif() -if(ANDROID) - list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/monovm-properties.cc - ${SOURCES_DIR}/pinvoke-override-api.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc - ) -else() +if(NOT USES_LIBSTDCPP) list(APPEND XAMARIN_MONODROID_SOURCES - ${SOURCES_DIR}/xa-internal-api.cc - ) - - set(XAMARIN_INTERNAL_API_SOURCES - ${SOURCES_DIR}/internal-pinvoke-api.cc - ${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc - ) + ${BIONIC_SOURCES_DIR}/cxa_guard.cc + ${SOURCES_DIR}/cxx-abi/string.cc + ${SOURCES_DIR}/cxx-abi/terminate.cc + ) endif() set(XAMARIN_APP_STUB_SOURCES @@ -596,139 +415,70 @@ set(XAMARIN_STUB_LIB_SOURCES # Build configure_file(jni/host-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/host-config.h) -if(MINGW OR WIN32) - list(APPEND MONOSGEN_LIB_LINK -lmonosgen-2.0.dll) -else() - list(APPEND MONOSGEN_LIB_LINK -lmonosgen-2.0) -endif() - -if(NOT (ANDROID)) - add_library( - ${XAMARIN_INTERNAL_API_LIB} - SHARED - ${XAMARIN_INTERNAL_API_SOURCES} - ) - - target_compile_options( - ${XAMARIN_INTERNAL_API_LIB} - PRIVATE -fvisibility=default - ) - - target_link_options( - ${XAMARIN_INTERNAL_API_LIB} - PRIVATE -fvisibility=default - ) -endif() - add_library( ${XAMARIN_APP_STUB_LIB} SHARED ${XAMARIN_APP_STUB_SOURCES} - ) +) target_link_options( ${XAMARIN_APP_STUB_LIB} PRIVATE ${XA_DEFAULT_SYMBOL_VISIBILITY} - ) +) -if(ANDROID) - # Only Android builds need to go in separate directories, desktop builds have the same ABI - set_target_properties( - ${XAMARIN_APP_STUB_LIB} - PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${XA_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}" - ) -elseif(APPLE) - set_target_properties( - ${XAMARIN_APP_STUB_LIB} - PROPERTIES - OSX_ARCHITECTURES "${XA_OSX_ARCHITECTURES}" - ) -endif() +set_target_properties( + ${XAMARIN_APP_STUB_LIB} + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${XA_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}" +) -if(NOT WIN32 AND NOT MINGW AND DEBUG_BUILD) +if(DEBUG_BUILD) add_library( ${XAMARIN_DEBUG_APP_HELPER_LIB} SHARED ${XAMARIN_DEBUG_APP_HELPER_SOURCES} - ) + ) target_link_options( ${XAMARIN_DEBUG_APP_HELPER_LIB} PRIVATE ${XA_SYMBOL_VISIBILITY} - ) + ) target_link_libraries( ${XAMARIN_DEBUG_APP_HELPER_LIB} -ldl - ) + ) - if(ANDROID) - target_link_libraries( - ${XAMARIN_DEBUG_APP_HELPER_LIB} - -llog - ) - endif() + target_link_libraries( + ${XAMARIN_DEBUG_APP_HELPER_LIB} + -llog + ) target_compile_options( ${XAMARIN_DEBUG_APP_HELPER_LIB} PRIVATE ${XA_SYMBOL_VISIBILITY} - ) + ) target_compile_definitions( ${XAMARIN_DEBUG_APP_HELPER_LIB} PUBLIC -DDEBUG_APP_HELPER - ) - - if(APPLE) - set_target_properties( - ${XAMARIN_DEBUG_APP_HELPER_LIB} - PROPERTIES - OSX_ARCHITECTURES "${XA_OSX_ARCHITECTURES}" - ) - endif() + ) endif() add_library( ${XAMARIN_MONO_ANDROID_LIB} SHARED ${XAMARIN_MONODROID_SOURCES} - ) +) -if(ANDROID) - # Ugly, but this is the only way to change LZ4 symbols visibility without modifying lz4.h - set(LZ4_VISIBILITY_OPTS "-DLZ4LIB_VISIBILITY=__attribute__ ((visibility (\"hidden\")))") -endif() +# Ugly, but this is the only way to change LZ4 symbols visibility without modifying lz4.h +set(LZ4_VISIBILITY_OPTS "-DLZ4LIB_VISIBILITY=__attribute__ ((visibility (\"hidden\")))") target_compile_options( ${XAMARIN_MONO_ANDROID_LIB} PRIVATE ${XA_DEFAULT_SYMBOL_VISIBILITY} "${LZ4_VISIBILITY_OPTS}" ) -if(APPLE) - set_target_properties( - ${XAMARIN_MONO_ANDROID_LIB} - PROPERTIES - OSX_ARCHITECTURES "${XA_OSX_ARCHITECTURES}" - ) - - add_custom_command( - TARGET ${XAMARIN_MONO_ANDROID_LIB} - POST_BUILD - COMMAND xcrun install_name_tool -change "@rpath/libxamarin-app.dylib" "@loader_path/libxamarin-app.dylib" $ - ) -endif() - -list(APPEND LINK_LIBS ${MONOSGEN_LIB_LINK}) - -if(NOT MINGW AND NOT WIN32) - set(DEBUG_HELPER_LINK_LIBS "-ldl") -endif() - -if(ANDROID) - list(APPEND LINK_LIBS -llog) -elseif(NOT ANDROID AND NOT MINGW AND NOT WIN32) - list(APPEND LINK_LIBS -pthread -ldl) -endif() +set(DEBUG_HELPER_LINK_LIBS "-ldl") target_link_options( ${XAMARIN_MONO_ANDROID_LIB} @@ -740,7 +490,7 @@ target_link_libraries( ${LINK_LIBS} xamarin-app ) -if(ANDROID AND (NOT ANALYZERS_ENABLED)) +if(NOT ANALYZERS_ENABLED) macro(xa_add_stub_library _libname) add_library( ${_libname}