From ede734d74cd06e18d20a597ea0a3bb6381ddad15 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Wed, 29 Jan 2020 12:43:32 +0100 Subject: Add support for cross building and support for future linux-arm64 version --- build.gradle.kts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'build.gradle.kts') diff --git a/build.gradle.kts b/build.gradle.kts index c48d384..1e69120 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,7 @@ import org.gradle.internal.os.OperatingSystem import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform + group = "org.openrndr.template" version = "0.3.9" @@ -24,10 +26,23 @@ val openrndrFeatures = setOf("video", "panel") // -------------------------------------------------------------------------------------------------------------------- -val openrndrOs = when (OperatingSystem.current()) { +val supportedPlatforms = setOf("windows", "macos", "linux-x64", "linux-arm64") + +val openrndrOs = if (project.hasProperty("targetPlatform")) { + val platform : String = project.property("targetPlatform") as String + if (platform !in supportedPlatforms) { + throw IllegalArgumentException("target platform not supported: $platform") + } else { + platform + } +} else when (OperatingSystem.current()) { OperatingSystem.WINDOWS -> "windows" OperatingSystem.MAC_OS -> "macos" - OperatingSystem.LINUX -> "linux-x64" + OperatingSystem.LINUX -> when(val h = DefaultNativePlatform("current").architecture.name) { + "x86-64" -> "linux-x64" + "arm64" -> "linux-arm64" + else ->throw IllegalArgumentException("architecture not supported: $h") + } else -> throw IllegalArgumentException("os not supported") } enum class Logging { -- cgit v1.3.1