mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-01 21:17:46 -05:00
Support 23w16a & Windows ARM64, and fix regression when adding ARM support on older versions. (#870)
* Support 23w16a & Windows ARM64, and fix regression when adding ARM support on older versions. * Fix build
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.Arrays;
|
||||
import org.gradle.api.JavaVersion;
|
||||
|
||||
import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta;
|
||||
import net.fabricmc.loom.util.Platform;
|
||||
|
||||
public final class LibraryContext {
|
||||
private final MinecraftVersionMeta versionMeta;
|
||||
@@ -42,9 +43,15 @@ public final class LibraryContext {
|
||||
/**
|
||||
* @return True when the Minecraft libraries support ARM64 MacOS
|
||||
*/
|
||||
public boolean supportsArm64MacOS() {
|
||||
public boolean supportsArm64(Platform.OperatingSystem operatingSystem) {
|
||||
final String osName = switch (operatingSystem) {
|
||||
case MAC_OS -> "macos";
|
||||
case WINDOWS -> "windows";
|
||||
case LINUX -> "linux";
|
||||
};
|
||||
|
||||
return versionMeta.libraries().stream()
|
||||
.anyMatch(library -> library.name().startsWith("org.lwjgl:lwjgl:3") && library.name().endsWith(":natives-macos-arm64"));
|
||||
.anyMatch(library -> library.name().startsWith("org.lwjgl:lwjgl:3") && library.name().endsWith(":natives-%s-arm64".formatted(osName)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,13 +57,13 @@ public class ArmNativesLibraryProcessor extends LibraryProcessor {
|
||||
return ApplicationResult.DONT_APPLY;
|
||||
}
|
||||
|
||||
if (platform.getOperatingSystem().isMacOS()) {
|
||||
if (context.supportsArm64MacOS()) {
|
||||
// This version already supports arm64 macOS, nothing to do.
|
||||
return ApplicationResult.DONT_APPLY;
|
||||
}
|
||||
if (context.supportsArm64(platform.getOperatingSystem())) {
|
||||
// This version already supports arm64, nothing to do.
|
||||
return ApplicationResult.DONT_APPLY;
|
||||
}
|
||||
|
||||
// Must upgrade natives to support macos ARM
|
||||
if (platform.getOperatingSystem().isMacOS()) {
|
||||
// Must upgrade natives to support macos ARM, even if not using classpath natives.
|
||||
return ApplicationResult.MUST_APPLY;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,14 @@ public class ArmNativesLibraryProcessor extends LibraryProcessor {
|
||||
|
||||
@Override
|
||||
public Predicate<Library> apply(Consumer<Library> dependencyConsumer) {
|
||||
final String osName = switch (platform.getOperatingSystem()) {
|
||||
case MAC_OS -> "macos";
|
||||
case WINDOWS -> "windows";
|
||||
case LINUX -> "linux";
|
||||
};
|
||||
|
||||
return library -> {
|
||||
if (library.is(LWJGL_GROUP) && library.target() == Library.Target.NATIVES && (library.classifier() != null && library.classifier().startsWith("natives-"))) {
|
||||
if (library.is(LWJGL_GROUP) && library.target() == Library.Target.NATIVES && (library.classifier() != null && library.classifier().equals("natives-" + osName))) {
|
||||
// Add the arm64 natives.
|
||||
dependencyConsumer.accept(library.withClassifier(library.classifier() + "-arm64"));
|
||||
|
||||
|
||||
@@ -85,6 +85,6 @@ public class LWJGL3UpgradeLibraryProcessor extends LibraryProcessor {
|
||||
|
||||
// Add support for macOS
|
||||
private boolean upgradeMacOSArm() {
|
||||
return platform.getOperatingSystem().isMacOS() && platform.getArchitecture().isArm() && !context.supportsArm64MacOS() && !context.hasClasspathNatives();
|
||||
return platform.getOperatingSystem().isMacOS() && platform.getArchitecture().isArm() && !context.supportsArm64(Platform.OperatingSystem.MAC_OS) && !context.hasClasspathNatives();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LoomNativeSupportLibraryProcessor extends LibraryProcessor {
|
||||
return ApplicationResult.DONT_APPLY;
|
||||
}
|
||||
|
||||
if (platform.getOperatingSystem().isMacOS() && platform.getArchitecture().isArm() && !context.supportsArm64MacOS()) {
|
||||
if (platform.getOperatingSystem().isMacOS() && platform.getArchitecture().isArm() && !context.supportsArm64(Platform.OperatingSystem.MAC_OS)) {
|
||||
// Add the loom native support mod when adding ARM64 macOS support
|
||||
return ApplicationResult.MUST_APPLY;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ObjcBridgeUpgradeLibraryProcessor extends LibraryProcessor {
|
||||
}
|
||||
|
||||
// Apply when Arm64 macOS is unsupported by Minecraft
|
||||
return context.supportsArm64MacOS() ? ApplicationResult.DONT_APPLY : ApplicationResult.MUST_APPLY;
|
||||
return context.supportsArm64(Platform.OperatingSystem.MAC_OS) ? ApplicationResult.DONT_APPLY : ApplicationResult.MUST_APPLY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user