-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
140 lines (111 loc) · 2.94 KB
/
build.gradle.kts
File metadata and controls
140 lines (111 loc) · 2.94 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
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
plugins {
java
application
id("com.diffplug.spotless") version "8.2.1"
}
group = "dev.askov.mjcompiler"
version = "1.0"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(25))
}
}
application {
mainClass.set("dev.askov.mjcompiler.Compiler")
}
repositories {
mavenCentral()
flatDir {
dirs("libs")
}
}
dependencies {
testImplementation("junit:junit:4.13.1")
implementation("org.slf4j:slf4j-api:2.0.17")
implementation("org.apache.logging.log4j:log4j-core:2.25.3")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:2.25.3")
// Using flatDir dependencies (lookup by name only)
implementation(":JFlex")
implementation(":cup_v10k")
implementation(":mj-runtime-1.1")
implementation(":symboltable")
}
spotless {
java {
target("src/*/java/**/*.java")
googleJavaFormat("1.35.0")
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
kotlinGradle {
target("*.gradle.kts")
ktlint()
}
}
tasks.test {
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
tasks.build {
dependsOn("spotlessCheck")
}
val jflexDir: Directory = layout.buildDirectory.dir("generated/sources/jflex/java/main").get()
val cupDir: Directory = layout.buildDirectory.dir("generated/sources/cup/java/main").get()
sourceSets.main {
java.srcDirs(jflexDir, cupDir)
}
tasks.register<JavaExec>("lexer") {
group = "generation"
mainClass.set("JFlex.Main")
classpath = sourceSets.main.get().compileClasspath
val outputFile = jflexDir.file("dev/askov/mjcompiler/Lexer.java")
inputs.file("src/main/resources/lexer.flex")
outputs.file(outputFile)
args("-d", outputFile.asFile.parent, "src/main/resources/lexer.flex")
}
tasks.register<JavaExec>("parser") {
group = "generation"
dependsOn("lexer")
mainClass.set("java_cup.Main")
classpath =
sourceSets.main
.get()
.compileClasspath
.minus(files("libs/JFlex.jar"))
val genSourceRoot = cupDir.asFile
workingDir = genSourceRoot
inputs.file("src/main/resources/parser.cup")
outputs.dir(genSourceRoot)
doFirst {
file("${cupDir.asFile.path}/dev/askov/mjcompiler").mkdirs()
}
args(
"-destdir",
"dev/askov/mjcompiler",
"-parser",
"Parser",
"-ast",
"dev.askov.mjcompiler.ast",
"-buildtree",
file("src/main/resources/parser.cup").absolutePath,
)
}
tasks.compileJava {
dependsOn("lexer", "parser")
}
tasks.clean {
delete(
fileTree("src/main/resources") {
include("*_astbuild.cup")
},
)
}
tasks.register<JavaExec>("disassemble") {
group = "verification"
mainClass.set("rs.etf.pp1.mj.runtime.disasm")
classpath = sourceSets.main.get().runtimeClasspath
args("src/test/resources/simple_calculator.obj")
}