|
|
@ -1,4 +1,5 @@ |
|
|
|
import dev.nokee.platform.jni.JniLibraryDependencies |
|
|
|
import dev.nokee.platform.jni.JniLibraryDependencies |
|
|
|
|
|
|
|
import org.gradle.nativeplatform.MachineArchitecture |
|
|
|
import dev.nokee.runtime.nativebase.OperatingSystemFamily |
|
|
|
import dev.nokee.runtime.nativebase.OperatingSystemFamily |
|
|
|
import dev.nokee.runtime.nativebase.TargetMachine |
|
|
|
import dev.nokee.runtime.nativebase.TargetMachine |
|
|
|
import org.gradle.api.Action |
|
|
|
import org.gradle.api.Action |
|
|
@ -9,6 +10,8 @@ import org.gradle.api.artifacts.ModuleDependency |
|
|
|
import org.gradle.api.artifacts.ModuleDependencyCapabilitiesHandler |
|
|
|
import org.gradle.api.artifacts.ModuleDependencyCapabilitiesHandler |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typealias OSFamily = org.gradle.nativeplatform.OperatingSystemFamily |
|
|
|
|
|
|
|
|
|
|
|
fun MinimalExternalModuleDependency.dependencyNotation() = |
|
|
|
fun MinimalExternalModuleDependency.dependencyNotation() = |
|
|
|
"${module.group}:${module.name}:${versionConstraint.requiredVersion}" |
|
|
|
"${module.group}:${module.name}:${versionConstraint.requiredVersion}" |
|
|
|
|
|
|
|
|
|
|
@ -32,31 +35,31 @@ fun ModuleDependencyCapabilitiesHandler.requireLibCapability(notation: Provider< |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val TargetMachine.variantName: String |
|
|
|
val TargetMachine.variantName: String |
|
|
|
get() { |
|
|
|
get() = "$osFamily-$architectureString" |
|
|
|
val osFamily = when { |
|
|
|
|
|
|
|
operatingSystemFamily.isWindows -> "windows" |
|
|
|
val TargetMachine.osFamily: String |
|
|
|
operatingSystemFamily.isLinux -> "linux" |
|
|
|
get() = when { |
|
|
|
operatingSystemFamily.isMacOS -> "macos" |
|
|
|
operatingSystemFamily.isWindows -> OSFamily.WINDOWS |
|
|
|
else -> GradleException("Unknown operating system family '${operatingSystemFamily}'.") |
|
|
|
operatingSystemFamily.isLinux -> OSFamily.LINUX |
|
|
|
} |
|
|
|
operatingSystemFamily.isMacOS -> OSFamily.MACOS |
|
|
|
return "$osFamily-$architectureString" |
|
|
|
else -> throw GradleException("Unknown operating system family '${operatingSystemFamily}'.") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val TargetMachine.architectureString: String |
|
|
|
|
|
|
|
get() = if (architecture.is32Bit) MachineArchitecture.X86 else MachineArchitecture.X86_64 |
|
|
|
|
|
|
|
|
|
|
|
val TargetMachine.targetsHost: Boolean |
|
|
|
val TargetMachine.targetsHost: Boolean |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val osName = System.getProperty("os.name").toLowerCase().replace(" ", "") |
|
|
|
val osName = System.getProperty("os.name").toLowerCase().replace(" ", "") |
|
|
|
val osFamily = operatingSystemFamily |
|
|
|
val osFamily = operatingSystemFamily |
|
|
|
return when { |
|
|
|
return when { |
|
|
|
osFamily.isWindows && osName.contains("windows") -> true |
|
|
|
osFamily.isWindows && osName.contains(OSFamily.WINDOWS) -> true |
|
|
|
osFamily.isLinux && osName.contains("linux") -> true |
|
|
|
osFamily.isLinux && osName.contains(OSFamily.LINUX) -> true |
|
|
|
osFamily.isMacOS && osName.contains("macos") -> true |
|
|
|
osFamily.isMacOS && osName.contains(OSFamily.MACOS) -> true |
|
|
|
else -> false |
|
|
|
else -> false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val TargetMachine.architectureString: String |
|
|
|
|
|
|
|
get() = if (architecture.is32Bit) "x86" else "x86-64" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun libraryFileNameFor(project: Project, osFamily: OperatingSystemFamily): String = when { |
|
|
|
fun libraryFileNameFor(project: Project, osFamily: OperatingSystemFamily): String = when { |
|
|
|
osFamily.isWindows -> "${project.name}.dll" |
|
|
|
osFamily.isWindows -> "${project.name}.dll" |
|
|
|
osFamily.isLinux -> "lib${project.name}.so" |
|
|
|
osFamily.isLinux -> "lib${project.name}.so" |
|
|
|