This repository has been archived by the owner on Aug 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 569
/
build.gradle.kts
49 lines (41 loc) · 1.61 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
}
val kotlinNativeDataPath = System.getenv("KONAN_DATA_DIR")?.let { File(it) }
?: File(System.getProperty("user.home")).resolve(".konan")
val tensorflowHome = kotlinNativeDataPath.resolve("third-party/tensorflow")
kotlin {
// Determine host preset.
val hostOs = System.getProperty("os.name")
// Create target for the host platform.
val hostTarget = when {
hostOs == "Mac OS X" -> macosX64("tensorflow")
hostOs == "Linux" -> linuxX64("tensorflow")
// Windows is not supported
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
}
hostTarget.apply {
binaries {
executable {
entryPoint = "sample.tensorflow.main"
linkerOpts("-L${tensorflowHome.resolve("lib")}", "-ltensorflow")
runTask?.environment(
"LD_LIBRARY_PATH" to tensorflowHome.resolve("lib"),
"DYLD_LIBRARY_PATH" to tensorflowHome.resolve("lib")
)
}
}
compilations["main"].cinterops {
val tensorflow by creating {
includeDirs(tensorflowHome.resolve("include"))
}
}
}
}
val downloadTensorflow by tasks.creating(Exec::class) {
workingDir = projectDir
commandLine("./downloadTensorflow.sh")
}
val tensorflow: KotlinNativeTarget by kotlin.targets
tasks[tensorflow.compilations["main"].cinterops["tensorflow"].interopProcessingTaskName].dependsOn(downloadTensorflow)