Use emulator executor for arm-based linux targets
This commit is contained in:
committed by
Stanislav Erokhin
parent
9e93ee81e3
commit
a664dbf07f
@@ -24,6 +24,7 @@ import org.gradle.process.ExecResult
|
|||||||
import org.gradle.process.ExecSpec
|
import org.gradle.process.ExecSpec
|
||||||
import org.gradle.util.ConfigureUtil
|
import org.gradle.util.ConfigureUtil
|
||||||
import org.jetbrains.kotlin.konan.target.Architecture
|
import org.jetbrains.kotlin.konan.target.Architecture
|
||||||
|
import org.jetbrains.kotlin.konan.target.ConfigurablesWithEmulator
|
||||||
|
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.konan.target.Xcode
|
import org.jetbrains.kotlin.konan.target.Xcode
|
||||||
@@ -52,7 +53,6 @@ fun create(project: Project): ExecutorService {
|
|||||||
val testTarget = project.testTarget
|
val testTarget = project.testTarget
|
||||||
val platform = platformManager.platform(testTarget)
|
val platform = platformManager.platform(testTarget)
|
||||||
val absoluteTargetToolchain = platform.absoluteTargetToolchain
|
val absoluteTargetToolchain = platform.absoluteTargetToolchain
|
||||||
val absoluteTargetSysRoot = platform.absoluteTargetSysRoot
|
|
||||||
|
|
||||||
return when (testTarget) {
|
return when (testTarget) {
|
||||||
KonanTarget.WASM32 -> object : ExecutorService {
|
KonanTarget.WASM32 -> object : ExecutorService {
|
||||||
@@ -68,22 +68,10 @@ fun create(project: Project): ExecutorService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KonanTarget.LINUX_MIPS32, KonanTarget.LINUX_MIPSEL32 -> object : ExecutorService {
|
KonanTarget.LINUX_MIPS32,
|
||||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec { execSpec ->
|
KonanTarget.LINUX_MIPSEL32,
|
||||||
action.execute(execSpec)
|
KonanTarget.LINUX_ARM32_HFP,
|
||||||
with(execSpec) {
|
KonanTarget.LINUX_ARM64 -> emulatorExecutor(project, testTarget)
|
||||||
val qemu = if (platform.target === KonanTarget.LINUX_MIPS32) "qemu-mips" else "qemu-mipsel"
|
|
||||||
val absoluteQemu = "$absoluteTargetToolchain/bin/$qemu"
|
|
||||||
val exe = executable
|
|
||||||
executable = absoluteQemu
|
|
||||||
args = listOf("-L", absoluteTargetSysRoot,
|
|
||||||
// This is to workaround an endianess issue.
|
|
||||||
// See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=731082 for details.
|
|
||||||
"$absoluteTargetSysRoot/lib/ld.so.1", "--inhibit-cache",
|
|
||||||
exe) + args
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
KonanTarget.IOS_X64,
|
KonanTarget.IOS_X64,
|
||||||
KonanTarget.TVOS_X64,
|
KonanTarget.TVOS_X64,
|
||||||
@@ -213,6 +201,34 @@ fun localExecutorService(project: Project): ExecutorService = object : ExecutorS
|
|||||||
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec(action)
|
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun emulatorExecutor(project: Project, target: KonanTarget) = object : ExecutorService {
|
||||||
|
val platformManager = project.platformManager
|
||||||
|
val configurables = platformManager.platform(target).configurables as? ConfigurablesWithEmulator
|
||||||
|
?: error("$target does not support emulation!")
|
||||||
|
val absoluteTargetSysRoot = configurables.absoluteTargetSysRoot
|
||||||
|
|
||||||
|
override fun execute(action: Action<in ExecSpec>): ExecResult? = project.exec { execSpec ->
|
||||||
|
action.execute(execSpec)
|
||||||
|
with(execSpec) {
|
||||||
|
val exe = executable
|
||||||
|
// TODO: Move these to konan.properties when when it will be possible
|
||||||
|
// to represent absolute path there.
|
||||||
|
val qemuSpecificArguments = listOf("-L", absoluteTargetSysRoot)
|
||||||
|
val targetSpecificArguments = when (target) {
|
||||||
|
KonanTarget.LINUX_MIPS32,
|
||||||
|
KonanTarget.LINUX_MIPSEL32 -> {
|
||||||
|
// This is to workaround an endianess issue.
|
||||||
|
// See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=731082 for details.
|
||||||
|
listOf("$absoluteTargetSysRoot/lib/ld.so.1", "--inhibit-cache")
|
||||||
|
}
|
||||||
|
else -> emptyList()
|
||||||
|
}
|
||||||
|
executable = configurables.absoluteEmulatorExecutable
|
||||||
|
args = qemuSpecificArguments + targetSpecificArguments + exe + args
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a given action with iPhone Simulator.
|
* Executes a given action with iPhone Simulator.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user