-
Notifications
You must be signed in to change notification settings - Fork 170
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
100 lines (85 loc) · 3.17 KB
/
build.gradle.kts
File metadata and controls
100 lines (85 loc) · 3.17 KB
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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "2.3.0"
application
}
repositories {
mavenLocal()
mavenCentral()
maven("https://redirector.kotlinlang.org/maven/compose-dev")
}
val osName = System.getProperty("os.name")
val targetOs = when {
osName == "Mac OS X" -> "macos"
osName.startsWith("Win") -> "windows"
osName.startsWith("Linux") -> "linux"
else -> error("Unsupported OS: $osName")
}
val osArch = System.getProperty("os.arch")
var targetArch = when (osArch) {
"x86_64", "amd64" -> "x64"
"aarch64" -> "arm64"
else -> error("Unsupported arch: $osArch")
}
val target = "${targetOs}-${targetArch}"
var version = "0.0.0-SNAPSHOT"
if (project.hasProperty("skiko.version")) {
version = project.properties["skiko.version"] as String
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-swing:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.0")
implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version")
implementation("org.jetbrains.runtime:jbr-api:1.5.0")
if (System.getProperty("os.name").startsWith("Win")) {
implementation("org.jetbrains.skiko:skiko-awt-runtime-angle-$target:$version")
}
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
application {
mainClass.set("SkiaAwtSample.AppKt")
}
val additionalArguments = mutableMapOf<String, String>()
val casualRun = tasks.named<JavaExec>("run") {
systemProperty("skiko.fps.enabled", "true")
systemProperty("skiko.linux.autodpi", "true")
systemProperty("skiko.hardwareInfo.enabled", "true")
systemProperty("skiko.win.exception.logger.enabled", "true")
systemProperty("skiko.win.exception.handler.enabled", "true")
jvmArgs("-ea")
// jvmArgs("-Xcheck:jni")
// Use systemProperty("skiko.library.path", "/tmp") to test loader.
System.getProperties().entries
.associate {
(it.key as String) to (it.value as String)
}
.filterKeys { it.startsWith("skiko.") }
.forEach { systemProperty(it.key, it.value) }
additionalArguments.forEach { systemProperty(it.key, it.value) }
}
tasks.register("runWithSoftwareRenderer") {
additionalArguments += mapOf("skiko.renderApi" to "DIRECT_SOFTWARE")
dependsOn(casualRun)
}
// Use Angle as a primary renderer for Windows. Renderers for the other OSes are not changing yet
tasks.register("runWithAngleEnabled") {
group = "application"
additionalArguments += mapOf("skiko.rendering.angle.enabled" to "true")
dependsOn(casualRun)
}
tasks.register("runWithTransparency") {
group = "application"
additionalArguments += mapOf("skiko.transparency" to "true")
dependsOn(casualRun)
}
tasks.register("runInterop") {
group = "application"
additionalArguments += mapOf("skiko.swing.interop" to "true")
dependsOn(casualRun)
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions.freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
}