Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/clr-host
Browse files Browse the repository at this point in the history
* main:
  [NativeAOT] Add support for `Application` subclasses (#9716)
  Bump to dotnet/sdk@d6bc7918c0 10.0.100-preview.2.25102.3 (#9726)
  [xa-prep-tasks] fix build errors for long `darc-` branch names (#9740)
  • Loading branch information
grendello committed Feb 3, 2025
2 parents 69fbb7b + dbb0b92 commit 7e5035c
Show file tree
Hide file tree
Showing 19 changed files with 513 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override bool Execute ()
if (!string.IsNullOrEmpty (build_sourcebranchname) && build_sourcebranchname.IndexOf ("merge", StringComparison.OrdinalIgnoreCase) == -1) {
Branch = build_sourcebranchname.Replace ("refs/heads/", string.Empty);
Log.LogMessage ($"Using BUILD_SOURCEBRANCH value: {Branch}");
return true;
goto done;
}

string gitHeadFile = Path.Combine (WorkingDirectory.ItemSpec, ".git", "HEAD");
Expand All @@ -48,15 +48,27 @@ public override bool Execute ()
base.Execute ();
}

done:
CheckBranchLength ();
Log.LogMessage (MessageImportance.Low, $" [Output] {nameof (Branch)}: {Branch}");
return !Log.HasLoggedErrors;
}

void CheckBranchLength ()
{
// Trim generated dependabot branch names that are too long to produce useful package names
const int maxBranchLength = 32;
var lastSlashIndex = Branch.LastIndexOf ('/');
if (Branch.StartsWith ("dependabot") && lastSlashIndex != -1 && Branch.Length > 60) {
if (Branch.StartsWith ("dependabot") && lastSlashIndex != -1 && Branch.Length > maxBranchLength) {
Log.LogMessage ($"Trimming characters from the branch name at index {lastSlashIndex}: {Branch}");
Branch = Branch.Substring (lastSlashIndex + 1);
}

Log.LogMessage (MessageImportance.Low, $" [Output] {nameof (Branch)}: {Branch}");

return !Log.HasLoggedErrors;
// Trim darc/Maestro branch names that are too long
if (Branch.StartsWith ("darc-") && Branch.Length > maxBranchLength) {
Log.LogMessage ($"Trimming to {maxBranchLength} characters from the branch name: {Branch}");
Branch = Branch.Substring (0, maxBranchLength);
}
}

protected override string GenerateCommandLineCommands ()
Expand Down
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.NET.Sdk" Version="10.0.100-alpha.1.25069.2">
<Dependency Name="Microsoft.NET.Sdk" Version="10.0.100-preview.2.25102.3">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>aca4b810e2be4b6b8aed3bcaf9e36bf3d1962a47</Sha>
<Sha>d6bc7918c0be5005426fbbff43dfb622fc295142</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="10.0.0-alpha.1.25067.10" CoherentParentDependency="Microsoft.NET.Sdk">
<Dependency Name="Microsoft.NET.ILLink.Tasks" Version="10.0.0-preview.2.25101.4" CoherentParentDependency="Microsoft.NET.Sdk">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>6c58f7992cfd628a53d9b90f258ac123cb803644</Sha>
<Sha>e51af404d1ea26be4a3d8e51fe21cf2f09ad34dd</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="10.0.0-alpha.1.25067.10" CoherentParentDependency="Microsoft.NET.Sdk">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="10.0.0-preview.2.25101.4" CoherentParentDependency="Microsoft.NET.Sdk">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>6c58f7992cfd628a53d9b90f258ac123cb803644</Sha>
<Sha>e51af404d1ea26be4a3d8e51fe21cf2f09ad34dd</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-10.0.100.Transport" Version="10.0.0-alpha.1.25059.1" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>0de3165cb0d56323b6caaf8e9916d4d9e72da32d</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-alpha.24627.1" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Dependency Name="Microsoft.DotNet.Cecil" Version="0.11.5-alpha.25069.2" CoherentParentDependency="Microsoft.NET.ILLink.Tasks">
<Uri>https://github.com/dotnet/cecil</Uri>
<Sha>9e8bd520939ddfee686261267a1646c1b113d9e1</Sha>
<Sha>2d5c8fb9aa8bd4c7fc085a73520061075c601655</Sha>
</Dependency>
<!-- Previous .NET Android version -->
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="35.0.24">
Expand Down
8 changes: 4 additions & 4 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project>
<!--Package versions-->
<PropertyGroup>
<MicrosoftNETSdkPackageVersion>10.0.100-alpha.1.25069.2</MicrosoftNETSdkPackageVersion>
<MicrosoftNETSdkPackageVersion>10.0.100-preview.2.25102.3</MicrosoftNETSdkPackageVersion>
<MicrosoftDotnetSdkInternalPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftDotnetSdkInternalPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>10.0.0-alpha.1.25067.10</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>10.0.0-alpha.1.25067.10</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETILLinkTasksPackageVersion>10.0.0-preview.2.25101.4</MicrosoftNETILLinkTasksPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>10.0.0-preview.2.25101.4</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftDotNetApiCompatPackageVersion>7.0.0-beta.22103.1</MicrosoftDotNetApiCompatPackageVersion>
<MicrosoftDotNetBuildTasksFeedPackageVersion>10.0.0-beta.24476.2</MicrosoftDotNetBuildTasksFeedPackageVersion>
<MicrosoftNETWorkloadEmscriptenCurrentManifest100100TransportVersion>10.0.0-alpha.1.25059.1</MicrosoftNETWorkloadEmscriptenCurrentManifest100100TransportVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest100100TransportVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftTemplateEngineTasksPackageVersion>7.0.100-rc.1.22410.7</MicrosoftTemplateEngineTasksPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.5-alpha.24627.1</MicrosoftDotNetCecilPackageVersion>
<MicrosoftDotNetCecilPackageVersion>0.11.5-alpha.25069.2</MicrosoftDotNetCecilPackageVersion>
<SystemIOHashingPackageVersion>$(MicrosoftNETCoreAppRefPackageVersion)</SystemIOHashingPackageVersion>
<!-- Previous .NET Android version -->
<MicrosoftAndroidSdkWindowsPackageVersion>35.0.24</MicrosoftAndroidSdkWindowsPackageVersion>
Expand Down
5 changes: 3 additions & 2 deletions samples/NativeAOT/JavaInteropRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ static void JNI_OnUnload (IntPtr vm, IntPtr reserved)
static void init (IntPtr jnienv, IntPtr klass)
{
try {
var typeManager = new NativeAotTypeManager ();
var options = new JreRuntimeOptions {
EnvironmentPointer = jnienv,
TypeManager = new NativeAotTypeManager (),
ValueManager = new NativeAotValueManager (),
TypeManager = typeManager,
ValueManager = new NativeAotValueManager (typeManager),
UseMarshalMemberBuilder = false,
JniGlobalReferenceLogWriter = new LogcatTextWriter (AndroidLogLevel.Debug, "NativeAot:GREF"),
JniLocalReferenceLogWriter = new LogcatTextWriter (AndroidLogLevel.Debug, "NativeAot:LREF"),
Expand Down
7 changes: 5 additions & 2 deletions samples/NativeAOT/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using Android.Runtime;
using Android.Util;
using System.Reflection;
using System.Runtime.InteropServices;

namespace NativeAOT;

[Register("my/MainActivity")] // Required for typemap in NativeAotTypeManager
[Activity(Label = "@string/app_name", MainLauncher = true)]
// Name required for typemap in NativeAotTypeManager
[Activity (Label = "@string/app_name", MainLauncher = true, Name = "my.MainActivity")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
Log.Debug ("NativeAOT", "MainActivity.OnCreate()");

base.OnCreate(savedInstanceState);

// Set our view from the "main" layout resource
Expand Down
23 changes: 23 additions & 0 deletions samples/NativeAOT/MainApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Android.Runtime;
using Android.Util;

/// <summary>
/// NOTE: This class is not required, but used for testing Android.App.Application subclasses.
/// Name required for typemap in NativeAotTypeManager
/// </summary>
[Application (Name = "my.MainApplication")]
public class MainApplication : Application
{
public MainApplication (IntPtr handle, JniHandleOwnership transfer)
: base (handle, transfer)
{
Log.Debug ("NativeAOT", $"Application..ctor({handle.ToString ("x2")}, {transfer})");
}

public override void OnCreate ()
{
Log.Debug ("NativeAOT", "Application.OnCreate()");

base.OnCreate ();
}
}
2 changes: 2 additions & 0 deletions samples/NativeAOT/NativeAotRuntimeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public boolean onCreate() {
public void attachInfo(android.content.Context context, android.content.pm.ProviderInfo info) {
Log.d(TAG, "NativeAotRuntimeProvider.attachInfo(): calling JavaInteropRuntime.init()…");
JavaInteropRuntime.init();
// NOTE: only required for custom applications
net.dot.android.ApplicationRegistration.registerApplications();
super.attachInfo (context, info);
}

Expand Down
2 changes: 2 additions & 0 deletions samples/NativeAOT/NativeAotTypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ partial class NativeAotTypeManager : JniRuntime.JniTypeManager {
// TODO: list of types specific to this application
Dictionary<string, Type> typeMappings = new () {
["android/app/Activity"] = typeof (Android.App.Activity),
["android/app/Application"] = typeof (Android.App.Application),
["android/content/Context"] = typeof (Android.Content.Context),
["android/content/ContextWrapper"] = typeof (Android.Content.ContextWrapper),
["android/os/BaseBundle"] = typeof (Android.OS.BaseBundle),
["android/os/Bundle"] = typeof (Android.OS.Bundle),
["android/view/ContextThemeWrapper"] = typeof (Android.Views.ContextThemeWrapper),
["my/MainActivity"] = typeof (MainActivity),
["my/MainApplication"] = typeof (MainApplication),
};

public NativeAotTypeManager ()
Expand Down
Loading

0 comments on commit 7e5035c

Please sign in to comment.