Skip to content

Commit

Permalink
Merge pull request #8070 from rolfbjarne/dotnet-bgen
Browse files Browse the repository at this point in the history
Build bgen and the product assemblies using/referencing netcore3.1.
  • Loading branch information
rolfbjarne authored Mar 12, 2020
2 parents 16a84bd + 800d63b commit 21f2160
Show file tree
Hide file tree
Showing 46 changed files with 1,358 additions and 101 deletions.
8 changes: 6 additions & 2 deletions Make.config
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ include $(TOP)/mk/mono.mk
MONO_HASH := $(NEEDED_MONO_VERSION)

# Minimum Mono version for building XI/XM
MIN_MONO_VERSION=6.10.0.1
MIN_MONO_VERSION=6.10.0.91
MAX_MONO_VERSION=6.10.99
MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-12/3/7eb7a82f09094facd8772dcb745fd16c7bd401c1/MonoFramework-MDK-6.10.0.1.macos10.xamarin.universal.pkg
MIN_MONO_URL=https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2019-12/94/b27b2d7f6118dff79cc238a22040ee93da39bab4/MonoFramework-MDK-6.10.0.91.macos10.xamarin.universal.pkg

# Minimum Mono version for Xamarin.Mac apps using the system mono
MIN_XM_MONO_VERSION=6.4.0.94
Expand Down Expand Up @@ -374,6 +374,10 @@ endif

DOTNET_VERSION=3.1.100
DOTNET_URL=https://download.visualstudio.microsoft.com/download/pr/787e81f1-f0da-4e3b-a989-8a199132ed8c/61a8dba81fbf2b3d533562d7b96443ec/dotnet-sdk-3.1.100-osx-x64.pkg
DOTNET=/usr/local/share/dotnet/dotnet
DOTNET_BCL_REF_URL=https://www.nuget.org/api/v2/package/Microsoft.NETCore.App.Ref/3.1.0
DOTNET_BCL_REF_NAME=microsoft.netcore.app.ref.3.1.0.nupkg
DOTNET_BCL_DIR:=$(abspath $(TOP)/builds/downloads/$(basename $(DOTNET_BCL_REF_NAME)))/ref/netcoreapp3.1

.SUFFIXES:
MAKEFLAGS += --no-builtin-rules
24 changes: 23 additions & 1 deletion builds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@ download-mono: downloads/$(basename $(MONO_IOS_FILENAME)) downloads/$(basename $

downloads/$(basename $(MONO_IOS_FILENAME)): MONO_URL=$(MONO_IOS_URL)
downloads/$(basename $(MONO_MAC_FILENAME)): MONO_URL=$(MONO_MAC_URL)
downloads/$(DOTNET_BCL_REF_NAME): MONO_URL=$(DOTNET_BCL_REF_URL)

include $(TOP)/mk/colors.mk

DOWNLOADS = \
downloads/$(MONO_IOS_FILENAME) \
downloads/$(MONO_MAC_FILENAME) \
downloads/$(DOTNET_BCL_REF_NAME) \

# This target downloads the mono archives, there's one for Xamarin.iOS and one for Xamarin.Mac.
# If doing many clean builds, it's possible to copy the downloaded zip file to ~/Library/Caches/xamarin-macios
# to avoid having to download it every time. The zip files have to be copied manually, otherwise
# we'd end up filling up a lot of hard drives around the world.
downloads/$(MONO_IOS_FILENAME) downloads/$(MONO_MAC_FILENAME):
$(DOWNLOADS):
$(Q) mkdir -p downloads
$(Q) echo "Downloading $(MONO_URL)..."
$(Q) if test -f ~/Library/Caches/xamarin-macios/$(notdir $@); then \
Expand All @@ -49,9 +55,25 @@ downloads/%: downloads/%.7z
$(Q) mv $@.tmp $@
$(Q) echo "Unzipped $*."

downloads/%: downloads/%.nupkg
$(Q) echo "Unzipping $*..."
$(Q) rm -Rf $@.tmp
$(Q) unzip -d $@.tmp $<
$(Q) find $@.tmp -exec touch {} +
$(Q) mv $@.tmp $@
$(Q) echo "Unzipped $*."

.stamp-download-mono: download-mono $(TOP)/Make.config $(TOP)/mk/mono.mk
$(Q) touch $@

DOTNET_DOWNLOADS = \
downloads/$(basename $(DOTNET_BCL_REF_NAME)) \

dotnet: $(DOTNET_DOWNLOADS)
ifdef ENABLE_DOTNET
all-local:: $(DOTNET_DOWNLOADS)
endif

clean-local::
$(Q) rm -Rf downloads .stamp-download-mono

Expand Down
3 changes: 3 additions & 0 deletions mk/quiet.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Q_XBUILD=$(if $(V),,@echo "XBUILD $(@F)";)
Q_TT= $(if $(V),,@echo "TT $(@F)";)
Q_BUILD=$(if $(V),,@echo "BUILD $(@F)";)

Q_DOTNET_BUILD=$(if $(V),,@echo "CSC [dotnet] $(@F)";)
Q_DOTNET_GEN =$(if $(V),,@echo "GEN [dotnet] $(@F)";)

Q_PROF_MCS = $(if $(V),,@echo "MCS [$(1)] $(@F)";)
Q_PROF_CSC = $(if $(V),,@echo "CSC [$(1)] $(@F)";)
Q_PROF_GEN = $(if $(V),,@echo "GEN [$(1)] $(@F)";)
Expand Down
2 changes: 1 addition & 1 deletion src/CFNetwork/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal Content (WebResponseStream stream)
this.responseStream = stream;
}

#if MONOMAC && XAMCORE_2_0
#if (MONOMAC && XAMCORE_2_0) && !NET
internal
#endif
protected override bool TryComputeLength (out long length)
Expand Down
2 changes: 1 addition & 1 deletion src/CFNetwork/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public WorkerThread WorkerThread {
CFHTTPAuthentication auth;

#region implemented abstract members of HttpMessageHandler
#if MONOMAC && XAMCORE_2_0
#if (MONOMAC && XAMCORE_2_0) && !NET
internal
#endif
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request,
Expand Down
129 changes: 129 additions & 0 deletions src/Compression/TaskToApm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

// Helper methods for using Tasks to implement the APM pattern.
//
// Example usage, wrapping a Task<int>-returning FooAsync method with Begin/EndFoo methods:
//
// public IAsyncResult BeginFoo(..., AsyncCallback callback, object state) =>
// TaskToApm.Begin(FooAsync(...), callback, state);
//
// public int EndFoo(IAsyncResult asyncResult) =>
// TaskToApm.End<int>(asyncResult);

//
// Xamarin:
// This is a copy of this file: https://github.com/dotnet/runtime/blob/25d316cefafc4c3884f38acf7bdef971d2b9fe4b/src/libraries/Common/src/System/Threading/Tasks/TaskToApm.cs
// We need it to be backwards compatible in .NET 5 for the implementations of Compression.[Begin|End]|[Read|Write].
//

#if NET
#nullable enable
using System.Diagnostics;

namespace System.Threading.Tasks
{
/// <summary>
/// Provides support for efficiently using Tasks to implement the APM (Begin/End) pattern.
/// </summary>
internal static class TaskToApm
{
/// <summary>
/// Marshals the Task as an IAsyncResult, using the supplied callback and state
/// to implement the APM pattern.
/// </summary>
/// <param name="task">The Task to be marshaled.</param>
/// <param name="callback">The callback to be invoked upon completion.</param>
/// <param name="state">The state to be stored in the IAsyncResult.</param>
/// <returns>An IAsyncResult to represent the task's asynchronous operation.</returns>
public static IAsyncResult Begin(Task task, AsyncCallback? callback, object? state) =>
new TaskAsyncResult(task, state, callback);

/// <summary>Processes an IAsyncResult returned by Begin.</summary>
/// <param name="asyncResult">The IAsyncResult to unwrap.</param>
public static void End(IAsyncResult asyncResult)
{
if (asyncResult is TaskAsyncResult twar)
{
twar._task.GetAwaiter().GetResult();
return;
}

throw new ArgumentNullException();
}

/// <summary>Processes an IAsyncResult returned by Begin.</summary>
/// <param name="asyncResult">The IAsyncResult to unwrap.</param>
public static TResult End<TResult>(IAsyncResult asyncResult)
{
if (asyncResult is TaskAsyncResult twar && twar._task is Task<TResult> task)
{
return task.GetAwaiter().GetResult();
}

throw new ArgumentNullException();
}

/// <summary>Provides a simple IAsyncResult that wraps a Task.</summary>
/// <remarks>
/// We could use the Task as the IAsyncResult if the Task's AsyncState is the same as the object state,
/// but that's very rare, in particular in a situation where someone cares about allocation, and always
/// using TaskAsyncResult simplifies things and enables additional optimizations.
/// </remarks>
internal sealed class TaskAsyncResult : IAsyncResult
{
/// <summary>The wrapped Task.</summary>
internal readonly Task _task;
/// <summary>Callback to invoke when the wrapped task completes.</summary>
private readonly AsyncCallback? _callback;

/// <summary>Initializes the IAsyncResult with the Task to wrap and the associated object state.</summary>
/// <param name="task">The Task to wrap.</param>
/// <param name="state">The new AsyncState value.</param>
/// <param name="callback">Callback to invoke when the wrapped task completes.</param>
internal TaskAsyncResult(Task task, object? state, AsyncCallback? callback)
{
Debug.Assert(task != null);
_task = task;
AsyncState = state;

if (task.IsCompleted)
{
// Synchronous completion. Invoke the callback. No need to store it.
CompletedSynchronously = true;
callback?.Invoke(this);
}
else if (callback != null)
{
// Asynchronous completion, and we have a callback; schedule it. We use OnCompleted rather than ContinueWith in
// order to avoid running synchronously if the task has already completed by the time we get here but still run
// synchronously as part of the task's completion if the task completes after (the more common case).
_callback = callback;
_task.ConfigureAwait(continueOnCapturedContext: false)
.GetAwaiter()
.OnCompleted(InvokeCallback); // allocates a delegate, but avoids a closure
}
}

/// <summary>Invokes the callback.</summary>
private void InvokeCallback()
{
Debug.Assert(!CompletedSynchronously);
Debug.Assert(_callback != null);
_callback.Invoke(this);
}

/// <summary>Gets a user-defined object that qualifies or contains information about an asynchronous operation.</summary>
public object? AsyncState { get; }
/// <summary>Gets a value that indicates whether the asynchronous operation completed synchronously.</summary>
/// <remarks>This is set lazily based on whether the <see cref="_task"/> has completed by the time this object is created.</remarks>
public bool CompletedSynchronously { get; }
/// <summary>Gets a value that indicates whether the asynchronous operation has completed.</summary>
public bool IsCompleted => _task.IsCompleted;
/// <summary>Gets a <see cref="WaitHandle"/> that is used to wait for an asynchronous operation to complete.</summary>
public WaitHandle AsyncWaitHandle => ((IAsyncResult)_task).AsyncWaitHandle;
}
}
}
#endif
7 changes: 5 additions & 2 deletions src/Foundation/NSUrlSessionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ async Task<NSUrlRequest> CreateRequest (HttpRequestMessage request)
return nsrequest;
}

#if SYSTEM_NET_HTTP || MONOMAC
#if (SYSTEM_NET_HTTP || MONOMAC) && !NET
internal
#endif
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
Expand Down Expand Up @@ -935,7 +935,10 @@ protected override Task SerializeToStreamAsync (Stream stream, TransportContext
return content.CopyToAsync (stream, bufferSize, cancellationToken);
}

protected internal override bool TryComputeLength (out long length)
#if !NET
internal
#endif
protected override bool TryComputeLength (out long length)
{
if (!content.CanSeek) {
length = 0;
Expand Down
Loading

3 comments on commit 21f2160

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚧 Experimental DDFun pipeline

🔥 Device tests completed (Failed) on iOS-DDFun on Azure DevOps(iOS-DDFun) 🔥

Test results

14 tests failed, 136 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - device/Debug: Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug): Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release: Crashed
  • monotouch-test/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (dynamic registrar): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release (all optimizations): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (all optimizations): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug: SGenConc: Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Debug (interpreter -mscorlib): Crashed
  • monotouch-test/iOS Unified 64-bits - device/Release (interpreter -mscorlib): Crashed

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Running XM tests on '10.10'' 🔥 : hudson.AbortException: Xamarin.Mac tests on macOS 10.10 failed (xammac_tests)

Build succeeded
✅ Packages:

API Diff (from stable)
API Diff (from PR only) (no change)
ℹ️ Generator Diff (please review changes)
🔥 Xamarin.Mac tests on 10.10 failed: Xamarin.Mac tests on macOS 10.10 failed (xammac_tests) 🔥
Test run succeeded

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 21f2160 Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

161 tests' device not found, 150 tests passed.

Ok

actually a success - 32bits tests should not have been executed -> #8103

Please sign in to comment.