From 9694971743d896f6e1635c02f21281129a8b4651 Mon Sep 17 00:00:00 2001 From: Rasmus Mikkelsen Date: Thu, 4 Apr 2024 21:26:11 +0200 Subject: [PATCH 1/3] Fix and feature for OS X arm64 builds --- RELEASE_NOTES.md | 3 ++- .../IntegrationTests/BakeTests/NetCoreConsoleTests.cs | 6 ++++++ Source/Bake/ValueObjects/Platform.cs | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index ef228a78..e563656f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,7 @@ # 0.25-beta -* *Nothing notable yet...* +* Feature: `osx-arm64` now built by default for .NET projects +* Fix: `arm64` and `arm` are now valid target platforms and correctly parsed # 0.24-beta diff --git a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs index d89f8352..67d3c448 100644 --- a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs +++ b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs @@ -107,6 +107,12 @@ private void AssertSuccessfulArtifacts() AssertFileExists( 50L.MB(), "bin", "Release", "publish", "linux-x64", "NetCore.Console"); + AssertFileExists( + 50L.MB(), + "bin", "Release", "publish", "osx-x64", "NetCore.Console"); + AssertFileExists( + 50L.MB(), + "bin", "Release", "publish", "osx-arm64", "NetCore.Console"); AssertFileExists( 50L.MB(), "bin", "Release", "publish", "win-x64", "NetCore.Console.exe"); diff --git a/Source/Bake/ValueObjects/Platform.cs b/Source/Bake/ValueObjects/Platform.cs index 01df1025..f68245f3 100644 --- a/Source/Bake/ValueObjects/Platform.cs +++ b/Source/Bake/ValueObjects/Platform.cs @@ -23,6 +23,8 @@ using System.Collections.Concurrent; using YamlDotNet.Serialization; +// https://learn.microsoft.com/en-us/dotnet/core/rid-catalog#known-rids + namespace Bake.ValueObjects { public class Platform @@ -32,6 +34,7 @@ public class Platform new(ExecutableOperatingSystem.Windows, ExecutableArchitecture.Intel64), new(ExecutableOperatingSystem.Linux, ExecutableArchitecture.Intel64), new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Intel64), + new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Arm64), }; public static Platform Any { get; } = new(ExecutableOperatingSystem.Any, ExecutableArchitecture.Any); @@ -44,9 +47,10 @@ public class Platform private static readonly IReadOnlyDictionary DotNetArchMoniker = new ConcurrentDictionary { [ExecutableArchitecture.Intel64] = "x64", + [ExecutableArchitecture.Arm32] = "arm", + [ExecutableArchitecture.Arm64] = "arm64", }; - [YamlMember] public ExecutableOperatingSystem Os { get; [Obsolete] set; } From 9e4a8c09e456e371d064982f4f5251187f77e151 Mon Sep 17 00:00:00 2001 From: Rasmus Mikkelsen Date: Thu, 4 Apr 2024 21:49:03 +0200 Subject: [PATCH 2/3] Only add ARM64 by default on Mac OS X --- Source/Bake/ValueObjects/Platform.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/Bake/ValueObjects/Platform.cs b/Source/Bake/ValueObjects/Platform.cs index f68245f3..63613964 100644 --- a/Source/Bake/ValueObjects/Platform.cs +++ b/Source/Bake/ValueObjects/Platform.cs @@ -21,6 +21,7 @@ // SOFTWARE. using System.Collections.Concurrent; +using System.Runtime.InteropServices; using YamlDotNet.Serialization; // https://learn.microsoft.com/en-us/dotnet/core/rid-catalog#known-rids @@ -29,13 +30,7 @@ namespace Bake.ValueObjects { public class Platform { - public static Platform[] Defaults { get; } = - { - new(ExecutableOperatingSystem.Windows, ExecutableArchitecture.Intel64), - new(ExecutableOperatingSystem.Linux, ExecutableArchitecture.Intel64), - new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Intel64), - new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Arm64), - }; + public static Platform[] Defaults { get; } public static Platform Any { get; } = new(ExecutableOperatingSystem.Any, ExecutableArchitecture.Any); private static readonly IReadOnlyDictionary DotNetOsMoniker = new ConcurrentDictionary @@ -51,6 +46,23 @@ public class Platform [ExecutableArchitecture.Arm64] = "arm64", }; + static Platform() + { + var platforms = new List + { + new(ExecutableOperatingSystem.Windows, ExecutableArchitecture.Intel64), + new(ExecutableOperatingSystem.Linux, ExecutableArchitecture.Intel64), + new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Intel64), + }; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + platforms.Add(new(ExecutableOperatingSystem.MacOSX, ExecutableArchitecture.Arm64)); + } + + Defaults = platforms.ToArray(); + } + [YamlMember] public ExecutableOperatingSystem Os { get; [Obsolete] set; } From 6c16df4a6a37da1d76a09e090a89f118df948aed Mon Sep 17 00:00:00 2001 From: Rasmus Mikkelsen Date: Fri, 5 Apr 2024 08:19:07 +0200 Subject: [PATCH 3/3] This is only on OS X --- .../IntegrationTests/BakeTests/NetCoreConsoleTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs index 67d3c448..97bc3688 100644 --- a/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs +++ b/Source/Bake.Tests/IntegrationTests/BakeTests/NetCoreConsoleTests.cs @@ -110,9 +110,12 @@ private void AssertSuccessfulArtifacts() AssertFileExists( 50L.MB(), "bin", "Release", "publish", "osx-x64", "NetCore.Console"); - AssertFileExists( - 50L.MB(), - "bin", "Release", "publish", "osx-arm64", "NetCore.Console"); + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + AssertFileExists( + 50L.MB(), + "bin", "Release", "publish", "osx-arm64", "NetCore.Console"); + } AssertFileExists( 50L.MB(), "bin", "Release", "publish", "win-x64", "NetCore.Console.exe");