Skip to content

Commit

Permalink
Aarch64 windows support
Browse files Browse the repository at this point in the history
Adding support for AARCH64 architectures on windows
  • Loading branch information
DariusIMP committed Dec 19, 2024
1 parent 30af980 commit b972a62
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 36 deletions.
56 changes: 31 additions & 25 deletions .github/workflows/publish-jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,41 @@ jobs:
job:
# In order to load any added target at runtime, editing the Zenoh class under jvmMain is required.
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
- {
target: aarch64-pc-windows-msvc,
arch: arm64,
os: windows-2019,
build-cmd: "cargo",
}
steps:
- name: Checkout source code
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion zenoh-java/src/jvmMain/kotlin/io/zenoh/Target.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

package io.zenoh

enum class Target {
internal enum class Target {
WINDOWS_X86_64_MSVC,
WINDOWS_AARCH64_MSVC,
LINUX_X86_64,
LINUX_AARCH64,
APPLE_AARCH64,
Expand All @@ -24,6 +25,7 @@ enum class Target {
override fun toString(): String {
return when (this) {
WINDOWS_X86_64_MSVC -> "x86_64-pc-windows-msvc"
WINDOWS_AARCH64_MSVC -> "aarch64-pc-windows-msvc"
LINUX_X86_64 -> "x86_64-unknown-linux-gnu"
LINUX_AARCH64 -> "aarch64-unknown-linux-gnu"
APPLE_AARCH64 -> "aarch64-apple-darwin"
Expand Down
33 changes: 23 additions & 10 deletions zenoh-java/src/jvmMain/kotlin/io/zenoh/Zenoh.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,37 @@ internal actual object ZenohLoad {
*/
private fun determineTarget(): Result<Target> = runCatching {
val osName = System.getProperty("os.name").lowercase()
val osArch = System.getProperty("os.arch")
val osArch = System.getProperty("os.arch").lowercase()

val target = when {
osName.contains("win") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.WINDOWS_X86_64_MSVC
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.WINDOWS_X86_64_MSVC

osArch.contains("aarch64") || osArch.contains("arm64") ->
Target.WINDOWS_AARCH64_MSVC

else -> throw UnsupportedOperationException("Unsupported architecture on Windows: $osArch")
}

osName.contains("mac") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.APPLE_X86_64
osArch.contains("aarch64") -> Target.APPLE_AARCH64
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osName.contains("mac") || osName.contains("darwin") || osName.contains("os x") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.APPLE_X86_64

osArch.contains("aarch64") || osArch.contains("arm64") ->
Target.APPLE_AARCH64

else -> throw UnsupportedOperationException("Unsupported architecture on macOS: $osArch")
}

osName.contains("nix") || osName.contains("nux") || osName.contains("aix") -> when {
osArch.contains("x86_64") || osArch.contains("amd64") -> Target.LINUX_X86_64
osArch.contains("aarch64") -> Target.LINUX_AARCH64
else -> throw UnsupportedOperationException("Unsupported architecture: $osArch")
osArch.contains("x86_64") || osArch.contains("amd64") || osArch.contains("x64") ->
Target.LINUX_X86_64

osArch.contains("aarch64") || osArch.contains("arm64") ->
Target.LINUX_AARCH64

else -> throw UnsupportedOperationException("Unsupported architecture on Linux/Unix: $osArch")
}

else -> throw UnsupportedOperationException("Unsupported platform: $osName")
Expand Down

0 comments on commit b972a62

Please sign in to comment.