generated from Kotlin/kmp-native-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
70 lines (55 loc) · 1.6 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
import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.antlr.kotlin)
}
val antlrDir = "antlr"
val antlrGeneratedDir = "generatedAntlr"
group = "me.user"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
listOf(
mingwX64(),
linuxX64(),
linuxArm64()
).forEach {
it.apply {
binaries {
executable {
entryPoint = "pl.lemanski.logik.main"
}
}
}
}
applyDefaultHierarchyTemplate()
sourceSets {
nativeMain {
kotlin {
srcDir(layout.buildDirectory.dir(antlrGeneratedDir))
}
dependencies {
implementation(libs.antlr.kotlin)
}
}
}
}
val generateKotlinGrammarSource = tasks.register<AntlrKotlinTask>("generateKotlinGrammarSource") {
dependsOn("cleanGenerateKotlinGrammarSource")
// We want to process all .g4 files in the antlr directory
source = fileTree(layout.projectDirectory.dir(antlrDir)) {
include("**/*.g4")
}
// We want the generated source files to have this package name
val pkgName = "pl.lemanski.logik.antlr"
packageName = pkgName
arguments = listOf("-visitor")
val outDir = "$antlrGeneratedDir/${pkgName.replace(".", "/")}"
outputDirectory = layout.buildDirectory.dir(outDir).get().asFile
}
tasks.withType<KotlinCompilationTask<*>> {
dependsOn(generateKotlinGrammarSource)
}