-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
266 lines (227 loc) · 7.04 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform") version "2.0.21"
id("com.android.library") version "8.5.2"
id("org.jetbrains.kotlinx.benchmark") version "0.4.11"
id("maven-publish")
id("signing")
id("io.codearte.nexus-staging") version "0.30.0"
}
group = "com.huskerdev"
version = "1.0.3"
repositories {
google()
mavenCentral()
}
kotlin {
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
jvm {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
compilations.create("benchmark") {
associateWith(this@jvm.compilations.getByName("main"))
}
}
js {
browser()
binaries.executable()
}
macosArm64()
macosX64()
iosX64()
iosArm64()
linuxArm64 {
linkCUDA()
}
linuxX64 {
linkCUDA()
}
mingwX64 {
linkCUDA()
}
androidTarget {
publishLibraryVariants("release")
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
sourceSets {
val macosMain by creating {
macosX64Main.get().dependsOn(this)
macosArm64Main.get().dependsOn(this)
}
val iosMain by creating {
iosX64Main.get().dependsOn(this)
iosArm64Main.get().dependsOn(this)
}
val windowsMain by creating {
mingwX64Main.get().dependsOn(this)
}
val linuxMain by creating {
linuxX64Main.get().dependsOn(this)
linuxArm64Main.get().dependsOn(this)
}
val commonOpenCL by creating {
dependsOn(commonMain.get())
jvmMain.get().dependsOn(this)
androidMain.get().dependsOn(this)
}
val commonCUDA by creating {
dependsOn(commonMain.get())
jvmMain.get().dependsOn(this)
}
val commonCUDANative by creating {
dependsOn(commonCUDA)
windowsMain.dependsOn(this)
linuxMain.dependsOn(this)
}
val commonMetal by creating {
dependsOn(commonMain.get())
jvmMain.get().dependsOn(this)
}
val commonMetalNative by creating {
dependsOn(commonMetal)
macosMain.dependsOn(this)
iosMain.dependsOn(this)
}
commonTest.dependencies {
implementation(kotlin("test"))
}
jvmMain {
dependencies {
// JOCL (OpenCL)
api("org.jocl:jocl:2.0.4")
// JCuda (Cuda)
api("org.jcuda:jcuda:12.0.0") {
isTransitive = false
}
api("org.jcuda:jcuda-natives:12.0.0:windows-x86_64")
api("org.jcuda:jcuda-natives:12.0.0:linux-x86_64")
// Metal
api("ca.weblite:java-objc-bridge:1.2")
api("net.java.dev.jna:jna:5.15.0")
}
}
val jvmBenchmark by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.4.11")
}
}
}
}
android {
namespace = "com.huskerdev.gpkt"
compileSdk = 34
ndkVersion = "19.2.5345600"
defaultConfig {
minSdk = 19
}
externalNativeBuild {
cmake {
path("src/androidMain/cpp/CMakeLists.txt")
}
}
}
benchmark {
targets {
register("jvmBenchmark")
}
}
tasks.withType(KotlinJsCompile::class.java).configureEach {
compilerOptions {
target = "es2015"
}
}
publishing {
publications {
withType<MavenPublication> {
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier = "javadoc"
archiveAppendix = this@withType.name
})
pom {
name = "gpgpu-kt"
description = "Cross-platform general-purpose computing Kotlin Multiplatform library"
url = "https://github.com/husker-dev/gpgpu-kt"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "husker-dev"
name = "Nikita Shtengauer"
email = "redfancoestar@gmail.com"
}
}
scm {
connection = "https://github.com/husker-dev/gpgpu-kt.git"
developerConnection = "https://github.com/husker-dev/gpgpu-kt.git"
url = "https://github.com/husker-dev/gpgpu-kt"
}
}
}
}
repositories {
maven {
url = project.uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.properties["ossrhUsername"].toString()
password = project.properties["ossrhPassword"].toString()
}
}
}
}
project.signing {
if(project.hasProperty("ossrhUsername"))
sign(publishing.publications)
}
nexusStaging {
packageGroup = group.toString()
serverUrl = "https://s01.oss.sonatype.org/service/local/"
username = project.properties["ossrhUsername"].toString()
password = project.properties["ossrhPassword"].toString()
}
fun KotlinNativeTarget.linkCUDA(){
if(DefaultNativePlatform.getCurrentOperatingSystem().isMacOsX)
return
compilations.getByName("main"){
cinterops {
val dir = System.getenv()["CUDA_PATH"] ?: "/usr/local/cuda"
val libFolder = when{
DefaultNativePlatform.getCurrentOperatingSystem().isWindows -> "lib/x64"
else -> "lib64"
}
val cuda by creating {
includeDirs("$dir/include")
extraOpts(
"-libraryPath", "$dir/$libFolder",
"-staticLibrary", when{
DefaultNativePlatform.getCurrentOperatingSystem().isWindows -> "cuda.lib"
else -> "stubs/libcuda.so"
}
)
}
val nvrtc by creating {
includeDirs("$dir/include")
extraOpts(
"-libraryPath", "$dir/$libFolder",
"-staticLibrary", when{
DefaultNativePlatform.getCurrentOperatingSystem().isWindows -> "nvrtc.lib"
else -> "libnvrtc.so"
}
)
}
}
}
}