diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index 61132e4be..2ea4f3dc1 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -243,19 +243,12 @@ namespace Flax.Build dotnetPath = string.Empty; } } - - bool isRunningOnArm64Targetx64 = architecture == TargetArchitecture.ARM64 && (Configuration.BuildArchitectures != null && Configuration.BuildArchitectures[0] == TargetArchitecture.x64); - - // We need to support two paths here: - // 1. We are running an x64 binary and we are running on an arm64 host machine - // 2. We are running an Arm64 binary and we are targeting an x64 host machine - if (Flax.Build.Platforms.MacPlatform.GetProcessIsTranslated() || isRunningOnArm64Targetx64) + if (Flax.Build.Platforms.MacPlatform.BuildingForx64) { rid = "osx-x64"; dotnetPath = Path.Combine(dotnetPath, "x64"); architecture = TargetArchitecture.x64; } - break; } default: throw new InvalidPlatformException(platform); @@ -472,6 +465,8 @@ namespace Flax.Build { var versions = GetVersions(root); var version = GetVersion(versions); + if (version == null) + throw new Exception($"Failed to select dotnet version from '{root}' ({string.Join(", ", versions)})"); return Path.Combine(root, version); } diff --git a/Source/Tools/Flax.Build/Platforms/Mac/MacPlatform.cs b/Source/Tools/Flax.Build/Platforms/Mac/MacPlatform.cs index 4a8115fcd..764ac81c7 100644 --- a/Source/Tools/Flax.Build/Platforms/Mac/MacPlatform.cs +++ b/Source/Tools/Flax.Build/Platforms/Mac/MacPlatform.cs @@ -73,6 +73,19 @@ namespace Flax.Build.Platforms Utilities.Run("codesign", cmdLine, null, null, Utilities.RunOptions.Default | Utilities.RunOptions.ThrowExceptionOnError); } + internal static bool BuildingForx64 + { + get + { + // We need to support two paths here: + // 1. We are running an x64 binary and we are running on an arm64 host machine + // 2. We are running an Arm64 binary and we are targeting an x64 host machine + var architecture = Platform.BuildTargetArchitecture; + bool isRunningOnArm64Targetx64 = architecture == TargetArchitecture.ARM64 && (Configuration.BuildArchitectures != null && Configuration.BuildArchitectures[0] == TargetArchitecture.x64); + return GetProcessIsTranslated() || isRunningOnArm64Targetx64; + } + } + /// /// Returns true if running an x64 binary an arm64 host machine. /// diff --git a/Source/Tools/Flax.Build/Platforms/iOS/iOSToolchain.cs b/Source/Tools/Flax.Build/Platforms/iOS/iOSToolchain.cs index fd4370e05..fb25560ec 100644 --- a/Source/Tools/Flax.Build/Platforms/iOS/iOSToolchain.cs +++ b/Source/Tools/Flax.Build/Platforms/iOS/iOSToolchain.cs @@ -65,8 +65,11 @@ namespace Flax.Build.Platforms switch (options.Action) { case CSharpOptions.ActionTypes.GetPlatformTools: - options.PlatformToolsPath = Path.Combine(DotNetSdk.SelectVersionFolder(Path.Combine(DotNetSdk.Instance.RootPath, "packs/Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.ios-arm64")), "tools"); + { + var arch = Flax.Build.Platforms.MacPlatform.BuildingForx64 ? "x64" : "arm64"; + options.PlatformToolsPath = Path.Combine(DotNetSdk.SelectVersionFolder(Path.Combine(DotNetSdk.Instance.RootPath, $"packs/Microsoft.NETCore.App.Runtime.AOT.osx-{arch}.Cross.ios-arm64")), "tools"); return false; + } case CSharpOptions.ActionTypes.MonoCompile: { var aotCompilerPath = Path.Combine(options.PlatformToolsPath, "mono-aot-cross");