From b3081de2583e8c57611179a646c3d82d43cbd516 Mon Sep 17 00:00:00 2001 From: Joey Eamigh <55670930+JoeyEamigh@users.noreply.github.com> Date: Fri, 10 Oct 2025 14:37:16 -0400 Subject: [PATCH] add godot tokio license --- .vscode/settings.json | 3 ++- rust/src/lib.rs | 18 +++++++++++------- rust/src/runtime/mod.rs | 1 + rust/src/{ => runtime}/tokio.rs | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 rust/src/runtime/mod.rs rename rust/src/{ => runtime}/tokio.rs (67%) diff --git a/.vscode/settings.json b/.vscode/settings.json index b1e1376..c4a528b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,6 @@ "description": "Build (Debug)", "color": "default" } - ] + ], + "VsCodeTaskButtons.showCounter": false } diff --git a/rust/src/lib.rs b/rust/src/lib.rs index b739559..869eea1 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,8 +1,6 @@ use godot::{classes::Engine, prelude::*}; -use crate::tokio::AsyncRuntime; - -mod tokio; +mod runtime; mod player; @@ -15,7 +13,10 @@ unsafe impl ExtensionLibrary for MyExtension { let mut engine = Engine::singleton(); // This is where we register our async runtime singleton. - engine.register_singleton(AsyncRuntime::SINGLETON, &AsyncRuntime::new_alloc()); + engine.register_singleton( + crate::runtime::tokio::AsyncRuntime::SINGLETON, + &crate::runtime::tokio::AsyncRuntime::new_alloc(), + ); } } @@ -24,11 +25,14 @@ unsafe impl ExtensionLibrary for MyExtension { let mut engine = Engine::singleton(); // Here is where we free our async runtime singleton from memory. - if let Some(async_singleton) = engine.get_singleton(AsyncRuntime::SINGLETON) { - engine.unregister_singleton(AsyncRuntime::SINGLETON); + if let Some(async_singleton) = engine.get_singleton(crate::runtime::tokio::AsyncRuntime::SINGLETON) { + engine.unregister_singleton(crate::runtime::tokio::AsyncRuntime::SINGLETON); async_singleton.free(); } else { - godot_warn!("Failed to find & free singleton -> {}", AsyncRuntime::SINGLETON); + godot_warn!( + "Failed to find & free singleton -> {}", + crate::runtime::tokio::AsyncRuntime::SINGLETON + ); } } } diff --git a/rust/src/runtime/mod.rs b/rust/src/runtime/mod.rs new file mode 100644 index 0000000..dc18c92 --- /dev/null +++ b/rust/src/runtime/mod.rs @@ -0,0 +1 @@ +pub mod tokio; diff --git a/rust/src/tokio.rs b/rust/src/runtime/tokio.rs similarity index 67% rename from rust/src/tokio.rs rename to rust/src/runtime/tokio.rs index b45b7a0..44d7e2d 100644 --- a/rust/src/tokio.rs +++ b/rust/src/runtime/tokio.rs @@ -1,3 +1,28 @@ +// Copied here because the original crate pins the wrong version of godot. +// Source: https://github.com/2-3-5-41/godot_tokio/ +// +// MIT License + +// Copyright (c) 2025 2-3-5-41 + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + use std::{future::Future, rc::Rc}; use godot::{classes::Engine, prelude::*};