Skip to content

Commit b095a74

Browse files
committed
Remove KSP (#823)
1 parent 8b8feeb commit b095a74

File tree

39 files changed

+44
-1290
lines changed

39 files changed

+44
-1290
lines changed

.github/workflows/build_jvm.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ jobs:
5555
name: jvm_entry-generator
5656
path: kt/entry-generation/godot-entry-generator/build/libs/godot-entry-generator-*.jar
5757

58-
- name: Upload ksp-symbol-processor artifact
58+
- name: Upload class-graph-symbol-processor artifact
5959
uses: actions/upload-artifact@v4
6060
with:
61-
name: jvm_ksp-symbol-processor
62-
path: kt/entry-generation/godot-kotlin-symbol-processor/build/libs/godot-kotlin-symbol-processor-*.jar
61+
name: jvm_class-graph-symbol-processor
62+
path: kt/entry-generation/godot-class-graph-symbol-processor/build/libs/godot-class-graph-symbol-processor-*.jar
6363

6464
- name: Upload gradle-plugin artifact
6565
uses: actions/upload-artifact@v4

.github/workflows/deploy_jvm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
run: |
6868
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-entry-generator:publish
6969
70-
- name: Publish godot-kotlin-symbol-processor
70+
- name: Publish godot-class-graph-symbol-processor
7171
shell: sh
7272
run: |
73-
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-kotlin-symbol-processor:publish
73+
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-class-graph-symbol-processor:publish
7474
7575
- name: Publish godot-internal-library debug
7676
shell: sh

docs/src/doc/contribution/knowledge-base/entry-generation.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,30 @@
22

33
## General
44

5-
To make it more language agnostic, the entry generator provides a set of model classes which represent the needed information about the source code by the entry genenerator.
5+
To make it more language agnostic, the entry generator provides a set of model classes which represent the needed information about the source code by the entry generator.
66
It expects this information to be gathered and assembled by the calling tool and to be provided in the entry point of the entry generator.
77

88
For Kotlin, Java and Scala, this tool is `godot-class-graph-symbol-processor`, which analyses the byte code, and gathers the information needed by the entry generator.
99
It then calls the entry generator which in turn generates the needed entry files.
1010

11-
## The godot-kotlin-symbol-processor
11+
## The godot-class-graph-symbol-processor
1212

13-
Previously, we implemented our own compiler plugin based on the [mpapt](https://github.com/Foso/MpApt) project.
13+
Previously, we implemented our own compiler plugin based on the [mpapt](https://github.com/Foso/MpApt) and [ksp](https://github.com/google/ksp) project.
1414
Even though it worked very well, the code was far from easy to understand and as the compiler plugin API is not stable yet.
15-
Furthermore, `MpApt` introduced a lot of maintenance work to keep it up to date with the ever evolving Kotlin compiler.
15+
Furthermore, `MpApt` introduced a lot of maintenance work to keep it up to date with the ever evolving Kotlin compiler and `Ksp` wasn't able to process Scala files.
1616

17-
To mitigate that problem we switched to [KSP (Kotlin Symbol Processing API)](https://github.com/google/ksp) which is basically a Kotlin Annotation Processor (KAPT) on steroids.
18-
Meaning it in essence is a compiler plugin which lets you inspect the source code being compiled through a abstracted and simplified API.
19-
This means for us that we can work against a more stable API and the work of keeping it up to date with Kotlin compiler changes is offloaded
20-
to a well maintained open source project with far more people with better knowledge about the internal workings of the Kotlin compiler.
17+
To mitigate that problem we switched to [ClassGraph](https://github.com/classgraph/classgraph) which is Bytecode processor.
18+
Meaning it in essence is a compiler plugin which lets you inspect the compiled bytecode with an abstracted and simplified API.
19+
This means for us that we can work against a more stable API and the work of keeping it up to date with the Kotlin language is removed.
2120

22-
We use our implementation of a Kotlin Symbol Processing to gather all needed information for the entry generator and convert it into the format it understands.
23-
With this it should be more easy to implement additional JVM languages as the entry generator itself can stay the same for all languages. Only the symbol processor has to change per language.
24-
25-
## Default Value Extraction
26-
27-
We extract the default values with the help of JetBrains' [Program Structure Interface (PSI)](https://plugins.jetbrains.com/docs/intellij/psi.html),
28-
that is a language specific AST (Abstract Syntax Tree). But as the simplified API of KSP does not allow the introspection of the source code representation,
29-
we implemented this ourselves in the `godot-kotlin-symbol-processor` as well.
21+
We use ClassGraph to gather all needed information for the entry generator and convert it into the format it understands.
22+
With this it should be far easier to implement additional JVM languages as ClassGraph is language agnostic and only minor tweak are necessary to support additional static languages.
3023

3124
## Debugging
3225

33-
As `godot-kotlin-symbol-processor` is a Kotlin compiler plugin and thus the execution context of the entry generator is as well,
26+
TODO: Write the new way to debug the bytecode processing
27+
28+
As `godot-class-graph-symbol-processor` is a Kotlin compiler plugin and thus the execution context of the entry generator is as well,
3429
it cannot be debugged traditionally by just clicking the Debug button on the `build` task in IntelliJ IDEA like you would do normally for KAPT annotation processors.
3530

3631
To debug a project, open a terminal, change to project's root directory and type the following command:

harness/benchmarks/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ includeBuild("../../kt") {
1010
substitute(module("com.utopia-rise:godot-gradle-plugin")).using(project(":godot-gradle-plugin"))
1111
substitute(module("com.utopia-rise:godot-library-debug")).using(project(":godot-library"))
1212
substitute(module("com.utopia-rise:godot-library-release")).using(project(":godot-library"))
13-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
13+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
1414
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
1515
}
1616
}

harness/bunnymark/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ includeBuild("../../kt") {
1010
substitute(module("com.utopia-rise:godot-gradle-plugin")).using(project(":godot-gradle-plugin"))
1111
substitute(module("com.utopia-rise:godot-library-debug")).using(project(":godot-library"))
1212
substitute(module("com.utopia-rise:godot-library-release")).using(project(":godot-library"))
13-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
13+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
1414
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
1515
}
1616
}

harness/flattened-library-tests/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ includeBuild("../../kt") {
1616
substitute(module("com.utopia-rise:godot-extension-library-release")).using(project(":godot-extension-library"))
1717
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
1818
substitute(module("com.utopia-rise:godot-coroutine-library-release")).using(project(":godot-coroutine-library"))
19-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
19+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
2020
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
2121
substitute(module("com.utopia-rise:godot-build-props")).using(project(":godot-build-props"))
2222
}

harness/fqname-library-tests/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ includeBuild("../../kt") {
1616
substitute(module("com.utopia-rise:godot-extension-library-release")).using(project(":godot-extension-library"))
1717
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
1818
substitute(module("com.utopia-rise:godot-coroutine-library-release")).using(project(":godot-coroutine-library"))
19-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
19+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
2020
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
2121
substitute(module("com.utopia-rise:godot-build-props")).using(project(":godot-build-props"))
2222
}

harness/hierarchical-library-tests/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ includeBuild("../../kt") {
1616
substitute(module("com.utopia-rise:godot-extension-library-release")).using(project(":godot-extension-library"))
1717
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
1818
substitute(module("com.utopia-rise:godot-coroutine-library-release")).using(project(":godot-coroutine-library"))
19-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
19+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
2020
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
2121
substitute(module("com.utopia-rise:godot-build-props")).using(project(":godot-build-props"))
2222
}

harness/tests/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ includeBuild("../../kt") {
1818
substitute(module("com.utopia-rise:godot-extension-library-release")).using(project(":godot-extension-library"))
1919
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
2020
substitute(module("com.utopia-rise:godot-coroutine-library-release")).using(project(":godot-coroutine-library"))
21-
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
21+
substitute(module("com.utopia-rise:godot-class-graph-symbol-processor")).using(project(":godot-class-graph-symbol-processor"))
2222
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
2323
substitute(module("com.utopia-rise:godot-build-props")).using(project(":godot-build-props"))
2424
}

kt/entry-generation/godot-entry-generator/src/main/kotlin/godot/entrygenerator/EntryGenerator.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ object EntryGenerator {
126126
initialRegistrationFilesOutDir: File,
127127
existingRegistrationFilesMap: Map<String, File>
128128
) {
129-
val kspRegistrationFiles = generatedRegistrationFilesBaseDir
129+
val registrationFiles = generatedRegistrationFilesBaseDir
130130
.walkTopDown()
131131
.filter { file ->
132132
file.extension == FileExtensions.GodotKotlinJvm.registrationFile
@@ -135,15 +135,15 @@ object EntryGenerator {
135135
file.name
136136
}
137137

138-
// compare ksp and existing registration files
138+
// compare new and existing registration files
139139
val deletedRegistrationFiles = existingRegistrationFilesMap
140-
.filterKeys { registrationFileName -> !kspRegistrationFiles.containsKey(registrationFileName) }
140+
.filterKeys { registrationFileName -> !registrationFiles.containsKey(registrationFileName) }
141141
.values
142142

143143
val updatedRegistrationFiles = existingRegistrationFilesMap
144-
.filterKeys { registrationFileName -> kspRegistrationFiles.containsKey(registrationFileName) }
144+
.filterKeys { registrationFileName -> registrationFiles.containsKey(registrationFileName) }
145145

146-
val newRegistrationFiles = kspRegistrationFiles
146+
val newRegistrationFiles = registrationFiles
147147
.filterKeys { registrationFileName -> !existingRegistrationFilesMap.containsKey(registrationFileName) }
148148

149149

@@ -169,7 +169,7 @@ object EntryGenerator {
169169

170170
// replace existing registration files
171171
updatedRegistrationFiles.forEach { (registrationFileName, registrationFile) ->
172-
kspRegistrationFiles[registrationFileName]?.copyTo(registrationFile, overwrite = true)
172+
registrationFiles[registrationFileName]?.copyTo(registrationFile, overwrite = true)
173173
}
174174

175175
// copy new registration files

0 commit comments

Comments
 (0)