-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathbuild.gradle.kts
114 lines (97 loc) · 3.31 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
@file:Suppress("UnstableApiUsage")
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
alias(libs.plugins.gradle.doctor)
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.plugin.serialization)
}
group = "co.touchlab"
version = "2.1.0"
kotlin {
listOf(macosX64(), macosArm64()).forEach {
it.binaries {
executable {
entryPoint = "co.touchlab.xcode.cli.main"
runTask?.run {
val args = providers.gradleProperty("runArgs")
args(args.getOrElse("").split(' '))
standardOutput = System.out
errorOutput = System.err
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.kotlinx.cli)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kermit)
implementation(libs.kotlinx.coroutines.core)
}
}
val macosMain by creating {
dependsOn(commonMain)
}
val macosX64Main by getting {
dependsOn(macosMain)
}
val macosArm64Main by getting {
dependsOn(macosMain)
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val macosTest by creating {
dependsOn(commonTest)
}
val macosX64Test by getting {
dependsOn(macosTest)
}
val macosArm64Test by getting {
dependsOn(macosTest)
}
all {
languageSettings.optIn("kotlinx.cli.ExperimentalCli")
languageSettings.optIn("kotlinx.cinterop.BetaInteropApi")
languageSettings.optIn("kotlin.experimental.ExperimentalNativeApi")
}
}
}
tasks.register<Exec>("assembleReleaseExecutableMacos") {
dependsOn("linkReleaseExecutableMacosX64", "linkReleaseExecutableMacosArm64")
commandLine(
"lipo", "-create", "-o", "xcode-kotlin",
"bin/macosX64/releaseExecutable/xcode-kotlin.kexe",
"bin/macosArm64/releaseExecutable/xcode-kotlin.kexe",
)
workingDir(layout.buildDirectory)
group = "build"
description = "Builds an universal macOS binary for both x86_64 and arm64 architectures."
}
val copyIdeSupport = tasks.register<Sync>("copyIdeSupport") {
description = "Copies Xcode plugin and language specification to build dir."
from(layout.projectDirectory.dir("data")) {
include("Kotlin.ideplugin/**", "Kotlin.xclangspec")
filter(
ReplaceTokens::class,
"tokens" to mapOf(
"version" to version,
)
)
}
into(layout.buildDirectory.dir("share"))
}
val copyLldbModule = tasks.register<Sync>("copyLldbModule") {
description = "Copies LLDB module to build dir."
mustRunAfter(copyIdeSupport)
from(layout.projectDirectory.dir("LLDBPlugin/touchlab_kotlin_lldb"))
into(layout.buildDirectory.dir("share/Kotlin.ideplugin/Contents/Resources/touchlab_kotlin_lldb"))
}
tasks.register("preparePlugin") {
group = "build"
description = "Prepares plugin, language specification and LLDB module in build dir."
dependsOn(copyIdeSupport, copyLldbModule)
}