Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Fixed a compilation issue under Windows and MacOS, added safeguards
Browse files Browse the repository at this point in the history
  • Loading branch information
OLEGSHA committed Jan 15, 2022
1 parent 4a6aa5d commit 5472576
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions build_logic/lwjgl.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ switch (OperatingSystem.current()) {
: 'linux'
break
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = System.getProperty('os.arch').startsWith('aarch64') ? 'macos-arm64' : 'macos'
lwjgl.localArch = System.getProperty('os.arch').startsWith('aarch64') ? 'macos-arm64' : 'macos'
break
case OperatingSystem.WINDOWS:
def osArch = System.getProperty('os.arch')
project.ext.lwjglNatives = osArch.contains('64')
lwjgl.localArch = osArch.contains('64')
? "windows${osArch.startsWith('aarch64') ? '-arm64' : ''}"
: 'windows-x86'
break
default:
logger.info "Unknown or unsupported OS type according to Gradle's org.gradle.internal.os.OperatingSystem: ${OperatingSystem.current()}"
break
}

configurations {
Expand Down Expand Up @@ -94,6 +97,14 @@ task lwjgl_addNativesToRuntimeOnly {
logger.info 'Adding LWJGL native dependencies for platforms: {}', lwjgl.targets.sort().join(', ')
}

if (lwjgl.targets.contains(null)) {
if (lwjgl.localArch != null) {
throw new GradleException("Requested local LWJGL natives; could not determine local architecture for OS ${OperatingSystem.current()} with os.arch ${System.getProperty('os.arch')}")
} else {
throw new GradleException("LWJGL targets resolved to ${lwjgl.targets}")
}
}

dependencies {
lwjgl.targets.each { target ->
lwjglNatives "org.lwjgl:lwjgl::natives-$target"
Expand Down

0 comments on commit 5472576

Please sign in to comment.