Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/deploy_jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ jobs:
run: |
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-api-library:publish -Prelease
- name: Publish godot-bootstrap-library debug
shell: sh
run: |
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-bootstrap-library:publish -Pdebug
- name: Publish godot-bootstrap-library release
shell: sh
run: |
modules/kotlin_jvm/kt/gradlew -p modules/kotlin_jvm/kt/ :godot-bootstrap-library:publish -Prelease
- name: Publish godot-extension-library debug
shell: sh
run: |
Expand Down
23 changes: 23 additions & 0 deletions harness/tests/scripts/godot/tests/inheritance/InterfaceChild.gdj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// THIS FILE IS GENERATED! DO NOT EDIT OR DELETE IT. EDIT OR DELETE THE ASSOCIATED SOURCE CODE FILE INSTEAD
// Note: You can however freely move this file inside your godot project if you want. Keep in mind however, that if you rename the originating source code file, this file will be deleted and regenerated as a new file instead of being updated! Other modifications to the source file however, will result in this file being updated.

registeredName = InterfaceChild
fqName = godot.tests.inheritance.InterfaceChild
baseType = Node
supertypes = [
godot.api.Node,
godot.api.Object,
godot.core.KtObject,
godot.tests.inheritance.TestInterface,
godot.common.interop.NativeWrapper,
godot.common.interop.NativePointer
]
signals = [

]
properties = [

]
functions = [
do_thing
]
6 changes: 4 additions & 2 deletions harness/tests/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ includeBuild("../../kt/api-generator") {
includeBuild("../../kt") {
dependencySubstitution {
substitute(module("com.utopia-rise:godot-gradle-plugin")).using(project(":godot-gradle-plugin"))
substitute(module("com.utopia-rise:godot-internal-library-debug")).using(project(":godot-core-library"))
substitute(module("com.utopia-rise:godot-internal-library-release")).using(project(":godot-core-library"))
substitute(module("com.utopia-rise:godot-internal-library-debug")).using(project(":godot-internal-library"))
substitute(module("com.utopia-rise:godot-internal-library-release")).using(project(":godot-internal-library"))
substitute(module("com.utopia-rise:godot-core-library-debug")).using(project(":godot-core-library"))
substitute(module("com.utopia-rise:godot-core-library-release")).using(project(":godot-core-library"))
substitute(module("com.utopia-rise:godot-api-library-debug")).using(project(":godot-api-library"))
substitute(module("com.utopia-rise:godot-api-library-release")).using(project(":godot-api-library"))
substitute(module("com.utopia-rise:godot-bootstrap-library-debug")).using(project(":godot-bootstrap-library"))
substitute(module("com.utopia-rise:godot-bootstrap-library-release")).using(project(":godot-bootstrap-library"))
substitute(module("com.utopia-rise:godot-extension-library-debug")).using(project(":godot-extension-library"))
substitute(module("com.utopia-rise:godot-extension-library-release")).using(project(":godot-extension-library"))
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package godot.tests.args

import godot.api.Node
import godot.api.Resource
import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.core.Dictionary
import godot.core.VariantArray
import godot.core.variantArrayOf

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package godot.tests.coretypes
import godot.api.Node
import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.core.StringName
import godot.core.asStringName
import godot.core.Vector2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package godot.tests.inheritance

import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.api.Node

@RegisterClass
class InterfaceChild : Node(), TestInterface {
@RegisterFunction
override fun doThing() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package godot.tests.inheritance

import godot.annotation.RegisterFunction

interface TestInterface {
@RegisterFunction
fun doThing()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import godot.api.Node
import godot.api.ProjectSettings
import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction
import godot.core.Color

@RegisterClass
class CallStaticTest: Node() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package godot.tests.subpackage

import godot.api.Node
import godot.api.Node3D
import godot.annotation.RegisterClass
import godot.annotation.RegisterFunction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {

dependencies {
implementation("com.utopia-rise:tools-common:$fullGodotKotlinJvmVersion")
implementation(project(":godot-core-library"))
implementation(project(":godot-bootstrap-library"))
implementation(project(":godot-entry-generator"))

implementation(libs.classGraph)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ private fun ClassInfo.shouldBeRegistered(
registeredFunctions: List<RegisteredFunction>,
registeredProperties: List<RegisteredProperty>,
registeredSignals: List<RegisteredSignal>
) = hasAnnotation(RegisterClass::class.java) || isAbstractAndContainsRegisteredMembers(
registeredFunctions,
registeredProperties,
registeredSignals
) || isAbstractAndInheritsGodotObject
) = !isInterface && (
hasAnnotation(RegisterClass::class.java) ||
isAbstractAndContainsRegisteredMembers(
registeredFunctions,
registeredProperties,
registeredSignals
) ||
isAbstractAndInheritsGodotObject
)

private fun ClassInfo.isAbstractAndContainsRegisteredMembers(
registeredFunctions: List<RegisteredFunction>,
Expand Down
2 changes: 1 addition & 1 deletion kt/entry-generation/godot-entry-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlin {

dependencies {
implementation("com.utopia-rise:tools-common:$fullGodotKotlinJvmVersion")
implementation(project(":godot-core-library"))
implementation(project(":godot-bootstrap-library"))
implementation(libs.kotlinPoet)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ClassRegistrarFileBuilder(
.writeTo(bufferedWriter)
}

return "%T().register(registry)" to arrayOf(
return "%T().register(this)" to arrayOf(
ClassName(
godotEntryBasePackage,
"${registeredClass.registeredName}Registrar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,12 @@ import kotlin.reflect.KClass
class MainEntryFileBuilder {
private val initFunctionSpec = FunSpec
.builder("init")
.receiver(ClassName("$godotRegistrationPackage.${GodotKotlinJvmTypes.entry}", GodotKotlinJvmTypes.context))
.receiver(ClassName(godotRegistrationPackage, GodotKotlinJvmTypes.classRegistry))
.addModifiers(KModifier.OVERRIDE)

private val initEngineTypesFunSpec = FunSpec
.builder("initEngineTypes")
.receiver(ClassName("$godotRegistrationPackage.${GodotKotlinJvmTypes.entry}", GodotKotlinJvmTypes.context))
.addModifiers(KModifier.OVERRIDE)
.addStatement("%M()", MemberName(godotPackage, "registerVariantMapping"))
.addStatement("%M()", MemberName(godotPackage, "registerEngineTypes"))
.addStatement("%M()", MemberName(godotPackage, "registerEngineTypeMethods"))

private val registerUserTypesVariantMappingsFunSpec = FunSpec
.builder("getRegisteredClasses")
.receiver(ClassName("$godotRegistrationPackage.${GodotKotlinJvmTypes.entry}", GodotKotlinJvmTypes.context))
.receiver(ClassName(godotRegistrationPackage, GodotKotlinJvmTypes.classRegistry))
.addModifiers(KModifier.OVERRIDE)
.returns(
List::class
Expand Down Expand Up @@ -65,7 +57,6 @@ class MainEntryFileBuilder {
.classBuilder(ClassName("$godotEntryBasePackage.$randomPackageForEntryFile", GodotKotlinJvmTypes.entry))
.superclass(ClassName(godotRegistrationPackage, GodotKotlinJvmTypes.entry))
.addFunction(initFunctionSpec.build())
.addFunction(initEngineTypesFunSpec.build())
.addFunction(registerUserTypesVariantMappingsFunSpec.build())
.addProperty(classRegistrarCountPropertySpec.build())
.addProperty(projectNamePropertySpec.build())
Expand Down
54 changes: 54 additions & 0 deletions kt/godot-library/godot-bootstrap-library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import versioninfo.fullGodotKotlinJvmVersion

plugins {
alias(libs.plugins.kotlin.jvm)
id("com.utopia-rise.godot-publish")
id("com.utopia-rise.versioninfo")
alias(libs.plugins.kotlinPreProcessors)
}

val isRelease = project.hasProperty("release")

kotlinDefinitions {
definitionsObjectName.set("GodotJvmBuildConfig")
define("DEBUG", !isRelease)
}

kotlin {
jvmToolchain(libs.versions.toolchain.jvm.get().toInt())
}

dependencies {
api("com.utopia-rise:common:${fullGodotKotlinJvmVersion}")
api(project(":godot-api-library"))
implementation(project(":godot-internal-library"))
}

tasks {
compileKotlin {
dependsOn(":godot-library:generateAPI")
}

// here so the sourcesJar task has an explicit dependency on the generateApi task. Needed since gradle 8
withType<Jar> {
dependsOn(":godot-library:generateAPI")
}
}

val targetSuffix = if (isRelease) "release" else "debug"

publishing {
publications {
@Suppress("UNUSED_VARIABLE", "unused")
val godotBootstrapLibraryPublication by registering(MavenPublication::class) {
pom {
name.set("${project.name}-$targetSuffix")
description.set("Contains code needed to bootstrap godot kotlin.")
}
artifactId = "godot-bootstrap-library-$targetSuffix"
description = "Contains code needed to bootstrap godot kotlin."

from(components["java"])
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package godot.annotation


/**
* Mark a registered property as exported and thus visible in the inspector.
*
Expand All @@ -10,4 +9,4 @@ package godot.annotation
*/
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class Export
annotation class Export
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ package godot.annotation
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class RegisterClass(val className: String = "")
annotation class RegisterClass(val className: String = "")
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ annotation class RegisteredClassMetadata(
val properties: String,
val functions: String,
val isRegistrationFileHierarchyEnabled: Boolean
)
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package godot.annotation


/**
* Mark a class as tool class.
*
* The class needs to have the @[RegisterClass] annotation added as well
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class Tool
annotation class Tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package godot.registration

import kotlin.reflect.KClass

abstract class Entry {
abstract fun ClassRegistry.init()
abstract fun ClassRegistry.getRegisteredClasses(): List<KClass<*>>

abstract val classRegistrarCount: Int
abstract val projectName: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import godot.internal.reflection.TypeManager
import godot.core.VariantParser
import godot.core.toVariantArray
import godot.core.variantArrayOf
import godot.common.constants.Constraints
import godot.core.VariantCaster
import godot.core.enumFromGodotOrdinal
import godot.core.godotOrdinal
Expand Down
Loading
Loading