Skip to content

Commit

Permalink
Add godot-coroutine-library to project
Browse files Browse the repository at this point in the history
  • Loading branch information
CedNaru committed Aug 15, 2024
1 parent d9b7cb3 commit 1b3ce84
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,cppcoreguidelines-pro-type-member-init,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements,readability-redundant-member-init'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: '1'
- key: cppcoreguidelines-pro-type-member-init.UseAssignment
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-bool-literals.IgnoreMacros
value: '0'
- key: modernize-use-default-member-init.IgnoreMacros
value: '0'
- key: modernize-use-default-member-init.UseAssignment
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
...

2 changes: 1 addition & 1 deletion harness/tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.konan.target.HostManager
import java.io.OutputStream

plugins {
// no need to apply kotlin jvm plugin. Our plugin already applies the correct version for you
Expand All @@ -14,6 +13,7 @@ repositories {
godot {
registrationFileBaseDir.set(projectDir.resolve("scripts").also { it.mkdirs() })
isRegistrationFileHierarchyEnabled.set(true)
enableGodotCoroutines.set(true)

//uncomment to test android
// isAndroidExportEnabled.set(true)
Expand Down
2 changes: 2 additions & 0 deletions harness/tests/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ includeBuild("../../kt") {
substitute(module("com.utopia-rise:godot-gradle-plugin")).using(project(":godot-gradle-plugin"))
substitute(module("com.utopia-rise:godot-library-debug")).using(project(":godot-library"))
substitute(module("com.utopia-rise:godot-library-release")).using(project(":godot-library"))
substitute(module("com.utopia-rise:godot-coroutine-library-debug")).using(project(":godot-coroutine-library"))
substitute(module("com.utopia-rise:godot-coroutine-library-release")).using(project(":godot-coroutine-library"))
substitute(module("com.utopia-rise:godot-kotlin-symbol-processor")).using(project(":godot-kotlin-symbol-processor"))
substitute(module("com.utopia-rise:godot-entry-generator")).using(project(":godot-entry-generator"))
}
Expand Down
2 changes: 1 addition & 1 deletion harness/tests/src/main/kotlin/godot/tests/Invocation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package godot.tests
import godot.Button
import godot.NavigationMesh
import godot.Node3D
import godot.XRServer
import godot.Object
import godot.XRServer
import godot.annotation.ColorNoAlpha
import godot.annotation.Dir
import godot.annotation.DoubleRange
Expand Down
53 changes: 53 additions & 0 deletions kt/godot-coroutine-library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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(11)
}

java {
withSourcesJar()
withJavadocJar()
}

dependencies {
// added here as a transitive dependency so the user can use reflection
// we need to add it here so reflection is available where the code is loaded (Bootstrap.kt) otherwise it will not work
api(kotlin("reflect", version = libs.versions.kotlin.get()))
implementation("com.utopia-rise:tools-common:$fullGodotKotlinJvmVersion")
testImplementation("junit", "junit", "4.12")
}

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

publishing {
publications {
@Suppress("UNUSED_VARIABLE")
val godotCoroutineLibraryPublication by creating(MavenPublication::class) {
pom {
name.set("${project.name}-$targetSuffix")
description.set("Godot library extension allowing the use of coroutines in a Godot context.")
}
artifactId = "godot-coroutine-library-$targetSuffix"
description = "Godot library extension allowing the use of coroutines in a Godot context."
artifact(tasks.jar)
artifact(tasks.getByName("sourcesJar"))
artifact(tasks.getByName("javadocJar"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,20 @@ open class GodotExtension(objects: ObjectFactory) {
val additionalGraalResourceConfigurationFiles = objects.property(Array<String>::class.java)

/**
* enable verbose mode on native image generation.
* Enable verbose mode on native image generation.
*
* if set to true, native-image tool will be in verbose mode.
* If set to true, native-image tool will be in verbose mode.
*/
val isGraalVmNativeImageGenerationVerbose: Property<Boolean> = objects.property(Boolean::class.java)


/**
* Enable the use of coroutines in the context of Godot lifecycle callbacks (signals)
*
* If set to true, import godot-coroutine-library
*/
val enableGodotCoroutines: Property<Boolean> = objects.property(Boolean::class.java)

internal fun configureExtensionDefaults(target: Project) {
val androidSdkRoot = System.getenv("ANDROID_SDK_ROOT")?.let { androidSdkRoot ->
File(androidSdkRoot)
Expand Down Expand Up @@ -218,6 +226,8 @@ open class GodotExtension(objects: ObjectFactory) {
additionalGraalResourceConfigurationFiles.set(arrayOf())
isGraalVmNativeImageGenerationVerbose.set(false)

enableGodotCoroutines.set(false)

System.getenv("VC_VARS_PATH")?.let {
windowsDeveloperVCVarsPath.set(File(it))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package godot.gradle

import godot.gradle.projectExt.checkKotlinVersionCompatibility
import godot.gradle.projectExt.configureThirdPartyPlugins
import godot.gradle.projectExt.godotCoroutineLibraryArtifactName
import godot.gradle.projectExt.godotJvmExtension
import godot.gradle.projectExt.setupConfigurationsAndCompilations
import godot.gradle.projectExt.setupTasks
import godot.gradle.properties.GodotKotlinJvmPropertiesFileImpl
import godot.plugins.common.GodotKotlinJvmPropertiesFile
import godot.utils.GodotBuildProperties
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.tooling.provider.model.ToolingModelBuilder
Expand All @@ -31,6 +34,12 @@ abstract class GodotPlugin : Plugin<Project> {

// registers the tooling model builder, so it can be used by the ide plugin
target.afterEvaluate {
if(target.godotJvmExtension.enableGodotCoroutines.get()){
target.dependencies.add(
"implementation",
target.dependencies.create("com.utopia-rise:${target.godotCoroutineLibraryArtifactName}:${GodotBuildProperties.assembledGodotKotlinJvmVersion}")
)
}
registry.register(
PropertiesModelBuilder(
isFqNameRegistrationEnabled = extension.isFqNameRegistrationEnabled.get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ val Project.isRelease: Boolean

val Project.godotLibraryArtifactName: String
get() = "godot-library-${if (isRelease) "release" else "debug"}"

val Project.godotCoroutineLibraryArtifactName: String
get() = "godot-coroutine-library-${if (isRelease) "release" else "debug"}"
1 change: 1 addition & 0 deletions kt/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ includeBuild("api-generator") {
}

include("godot-library")
include("godot-coroutine-library")

subdir("entry-generation") {
include("godot-kotlin-symbol-processor")
Expand Down

0 comments on commit 1b3ce84

Please sign in to comment.