-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
111 lines (96 loc) · 2.83 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
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
plugins {
kotlin("jvm") version "1.6.10"
antlr
id("com.palantir.graal") version "0.10.0"
}
group = "ml.dev.kotlin"
version = "1.0"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib"))
implementation("org.antlr:antlr4-runtime:4.9.3")
antlr("org.antlr:antlr4:4.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.8.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
}
tasks.test {
var failedTests = false
doFirst {
failedTests = false
}
useJUnitPlatform()
ignoreFailures = true
testLogging {
events = setOf(PASSED, SKIPPED, FAILED)
exceptionFormat = FULL
}
afterSuite(closure<TestDescriptor, TestResult> { suite, result ->
if (suite.parent == null) println(
"TEST RESULTS: ${suite.displayName}\n" +
"Passed: ${result.successfulTestCount}/${result.testCount}\t" +
"Failed: ${result.failedTestCount}/${result.testCount}\t" +
"Skipped: ${result.skippedTestCount}/${result.testCount}"
)
if (result.failedTestCount > 0) failedTests = true
})
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2 + 1
systemProperties["junit.jupiter.execution.parallel.enabled"] = "true"
systemProperties["junit.jupiter.execution.parallel.mode.default"] = "concurrent"
doLast {
if (failedTests) throw GradleException("Some tests failed")
}
}
val buildRuntime = task<Exec>("buildRuntime") {
commandLine("gcc", "-m32", "-c", "lib/runtime.c", "-o", "lib/runtime.o")
doLast {
copy {
from("$projectDir/lib/runtime.o")
into("$projectDir/src/main/resources/ml/dev/kotlin/latte/asm")
}
}
}
tasks.withType<KotlinCompile> {
dependsOn(buildRuntime)
kotlinOptions.jvmTarget = "${JavaVersion.VERSION_11}"
dependsOn(tasks.generateGrammarSource)
}
tasks.generateGrammarSource {
arguments = listOf("-visitor", "-package", "ml.dev.kotlin.latte.syntax")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
graal {
javaVersion("11")
graalVersion("21.2.0")
outputName("latc_x86")
mainClass("ml.dev.kotlin.latte.MainKt")
option("--verbose")
option("--no-fallback")
option("-H:IncludeResources=ml/dev/kotlin/latte/asm/runtime.o")
}
tasks.nativeImage {
doLast {
copy {
from("$buildDir/graal/latc_x86")
into("$projectDir")
}
}
}
tasks.clean {
doLast {
with(projectDir) {
resolve("lib/runtime.o").delete()
resolve("testData").delete()
resolve("latc_x86").delete()
}
}
}
fun <T, U> closure(c: (T, U) -> Unit): KotlinClosure2<T, U, Unit> = KotlinClosure2(c)