Skip to content

Commit f8e654e

Browse files
committed
Split gdextension into two
1 parent eb3554f commit f8e654e

131 files changed

Lines changed: 364 additions & 247 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ jobs:
3333
vendor: unknown
3434
env: -gnu
3535
lib: libnative.so
36+
editor_lib: libeditor.so
3637
- platform: windows
3738
os: windows-2025
3839
vendor: pc
3940
env: '-msvc'
4041
lib: native.dll
42+
editor_lib: editor.dll
4143
- platform: darwin
4244
os: macos-14
4345
vendor: apple
4446
lib: libnative.dylib
47+
editor_lib: libeditor.dylib
4548
exclude:
4649
- platform: linux
4750
arch: aarch64
@@ -70,6 +73,7 @@ jobs:
7073
cd native/
7174
rustup target add ${{ env.TARGET_TRIPLET }}
7275
- name: Build Debug
76+
if: ${{ !inputs.release }}
7377
run: |
7478
cd native/
7579
${{ env.CARGO_BUILD}} ${{ env.TARGET_TRIPLET}}
@@ -78,12 +82,20 @@ jobs:
7882
run: |
7983
cd native/
8084
${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release
81-
- name: Debug Artifacts
85+
86+
- name: Debug libnative Artifact
8287
uses: actions/upload-artifact@v4
88+
if: ${{ !inputs.release }}
8389
with:
8490
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-debug
8591
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.lib }}
86-
- name: Release Artifacts
92+
- name: Debug libeditor Artifact
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: libeditor-${{ matrix.platform }}-${{ matrix.arch }}-debug
96+
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.editor_lib }}
97+
98+
- name: Release libnative Artifacts
8799
uses: actions/upload-artifact@v4
88100
if: inputs.release
89101
with:
@@ -104,6 +116,7 @@ jobs:
104116
aarch64: true
105117
extension: '.dmg'
106118
lib: libnative.dylib
119+
editor_lib: "libeditor.dylib"
107120
template_dir: '$HOME/Library/Application\ Support/Godot/export_templates'
108121
godot_artefact: 'macOS.universal'
109122
- profile: 'Windows'
@@ -115,6 +128,7 @@ jobs:
115128
aarch64: true
116129
extension: '.exe'
117130
lib: native.dll
131+
editor_lib: "libeditor.so"
118132
template_dir: '$HOME/.local/share/godot/export_templates'
119133
godot_artefact: 'linux.x86_64'
120134
- profile: 'Linux'
@@ -123,6 +137,7 @@ jobs:
123137
vendor: 'unknown'
124138
os: ubuntu-24.04
125139
lib: libnative.so
140+
editor_lib: "libeditor.so"
126141
template_dir: '$HOME/.local/share/godot/export_templates'
127142
godot_artefact: 'linux.x86_64'
128143
x86_64: true
@@ -162,38 +177,42 @@ jobs:
162177
cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable
163178
curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz
164179
unzip -j Godot_v${{ matrix.version }}-stable_export_templates.tpz
165-
- name: download host libs
166-
if: ${{ matrix.platform != 'linux' && startsWith(matrix.os, 'ubuntu') }}
167-
uses: actions/download-artifact@v5
180+
- name: download editor lib
181+
uses: actions/download-artifact@v8
168182
with:
169-
name: libnative-linux-x86_64-debug
170-
path: native/target/x86_64-unknown-linux-gnu/debug/
171-
183+
name: libeditor-${{ startsWith(matrix.os, 'ubuntu') && 'linux' || matrix.platform }}-${{ startsWith(matrix.os, 'ubuntu') && 'x86_64' || 'aarch64' }}-debug
184+
path: native/target/${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-unknown-linux-gnu' || 'aarch64-apple-darwin' }}/debug/
185+
merge-multiple: true
186+
172187
- name: download x86_64 debug libs
173-
if: matrix.x86_64
174-
uses: actions/download-artifact@v5
188+
if: ${{ matrix.x86_64 && !inputs.release }}
189+
uses: actions/download-artifact@v8
175190
with:
176191
name: libnative-${{ matrix.platform }}-x86_64-debug
177192
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
193+
merge-multiple: true
178194
- name: download x86_64 release libs
179-
if: ${{ matrix.x86_64 && inputs.release }}
180-
uses: actions/download-artifact@v5
195+
if: ${{ matrix.x86_64 && inputs.release }}
196+
uses: actions/download-artifact@v8
181197
with:
182198
name: libnative-${{ matrix.platform }}-x86_64-release
183199
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
200+
merge-multiple: true
184201

185202
- name: download aarch64 debug libs
186-
if: matrix.aarch64
187-
uses: actions/download-artifact@v5
203+
if: ${{ matrix.aarch64 && !inputs.release }}
204+
uses: actions/download-artifact@v8
188205
with:
189206
name: libnative-${{ matrix.platform }}-aarch64-debug
190207
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
208+
merge-multiple: true
191209
- name: download aarch64 release libs
192210
if: ${{ matrix.aarch64 && inputs.release }}
193-
uses: actions/download-artifact@v5
211+
uses: actions/download-artifact@v8
194212
with:
195213
name: libnative-${{ matrix.platform }}-aarch64-release
196214
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
215+
merge-multiple: true
197216

198217
- name: create universal libnative
199218
if: matrix.platform == 'darwin'
@@ -210,8 +229,10 @@ jobs:
210229
let aarch64_debug = $"($aarch64_path)/debug/${{ matrix.lib }}"
211230
let aarch64_release = $"($aarch64_path)/release/${{ matrix.lib }}"
212231
213-
mkdir $"native/target/universal-($platform_dir)/debug/"
214-
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
232+
if !$release {
233+
mkdir $"native/target/universal-($platform_dir)/debug/"
234+
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
235+
}
215236
216237
if $release {
217238
mkdir $"native/target/universal-($platform_dir)/release/"
@@ -234,10 +255,7 @@ jobs:
234255
let profile = if $release { "release" } else { "debug" }
235256
236257
rm -r $"native/target/x86_64-($platform_dir)/($profile)/"
237-
238-
if $release {
239-
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
240-
}
258+
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
241259
242260
- name: export-debug
243261
shell: nu {0}
@@ -272,4 +290,4 @@ jobs:
272290
- uses: actions/upload-artifact@v4
273291
with:
274292
name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }}
275-
path: ${{ env.EXPORT_DIR }}
293+
path: ${{ env.EXPORT_DIR }}

native/Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

native/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
[package]
2-
name = "native"
3-
version = "0.5.0"
4-
edition = "2021"
1+
[workspace]
2+
members = ["game", "editor"]
3+
resolver = "3"
54

6-
[lib]
7-
crate-type = ["cdylib"]
5+
[workspace.package]
6+
edition = "2024"
7+
version = "0.5.0"
88

9-
[dependencies]
9+
[workspace.dependencies]
1010
godot = { version = "0.5.0", features = ["experimental-threads", "api-4-5", "register-docs"] }
1111
godot-rust-script = { git = "https://github.com/titannano/godot-rust-script", rev = "ca89cf182f6b9e051b66e1e52e23489e25f9077c" }
1212
lerp = "0.4.0"
@@ -23,6 +23,6 @@ pomsky-macro = "0.11.0"
2323
regex = "1.10.5"
2424
kanal = { version = "0.1.1", features = ["async"] }
2525

26-
[lints.clippy]
26+
[workspace.lints.clippy]
2727
pedantic = "deny"
2828
used_underscore_items = { level = "allow", priority = 1 }

native/editor/Cargo.toml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[package]
2+
name = "editor"
3+
version.workspace = true
4+
edition.workspace = true
5+
6+
[lib]
7+
crate-type = ["cdylib"]
8+
9+
[dependencies]
10+
godot.workspace = true
11+
godot-rust-script.workspace = true
12+
lerp.workspace = true
13+
backtrace.workspace = true
14+
num.workspace = true
15+
rayon.workspace = true
16+
itertools.workspace = true
17+
num_enum.workspace = true
18+
derive-debug.workspace = true
19+
thiserror.workspace = true
20+
anyhow.workspace = true
21+
rand.workspace = true
22+
pomsky-macro.workspace = true
23+
regex.workspace = true
24+
kanal.workspace = true
25+
26+
[lints]
27+
workspace = true
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@ use std::{
1010
process::{Command, Stdio},
1111
};
1212

13-
use godot::builtin::{GString, PackedStringArray, VariantType};
14-
use godot::classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree};
1513
use godot::obj::{Base, Gd, Singleton};
16-
use godot::prelude::{godot_api, GodotClass};
14+
use godot::prelude::{GodotClass, godot_api};
1715
use godot::register::info::PropertyHint;
1816
use godot::task;
17+
use godot::{
18+
builtin::{GString, PackedStringArray, VariantType},
19+
global::godot_error,
20+
};
21+
use godot::{
22+
classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree},
23+
global::godot_print,
24+
};
1925

20-
use crate::editor::new_non_zero;
21-
use crate::editor::ui::{ForgroundProcess, ProgressDialog};
22-
use crate::util::logger;
26+
use crate::new_non_zero;
27+
use crate::ui::{ForgroundProcess, ProgressDialog};
2328

2429
#[derive(GodotClass)]
2530
#[class(base = RefCounted, no_init)]
@@ -85,7 +90,7 @@ impl AoBaker {
8590
editor_settings.get_setting("filesystem/import/blender/blender_path");
8691

8792
if blender_path_variant.is_nil() {
88-
logger::error!("Unable to get blender path!");
93+
godot_error!("Unable to get blender path!");
8994
return;
9095
}
9196

@@ -114,18 +119,14 @@ impl AoBaker {
114119

115120
std::fs::read_dir(system_path.to_string())
116121
.inspect_err(|err| {
117-
logger::error!(
118-
"unable to read directory: {}.\nError: {}",
119-
system_path,
120-
err
121-
);
122+
godot_error!("Unable to read directory: {}.\nError: {}", system_path, err);
122123
})
123124
.ok()
124125
})
125126
.flatten()
126127
.filter_map(|entry| {
127128
entry
128-
.inspect_err(|err| logger::error!("Failed to enumerate directory entry: {err}"))
129+
.inspect_err(|err| godot_error!("Failed to enumerate directory entry: {err}"))
129130
.ok()
130131
})
131132
.filter(|entry| {
@@ -168,14 +169,14 @@ impl AoBaker {
168169
.stdout(Stdio::piped())
169170
.stdin(Stdio::null());
170171

171-
logger::debug!("invoking blender: {:?}", blender_command);
172+
godot_print!("invoking blender: {:?}", blender_command);
172173

173174
let blender = blender_command.spawn();
174175

175176
let mut blender = match blender {
176177
Ok(child) => child,
177178
Err(err) => {
178-
logger::error!("Failed to spawn blender process: {}", err);
179+
godot_error!("Failed to spawn blender process: {}", err);
179180
return;
180181
}
181182
};
@@ -191,14 +192,14 @@ impl AoBaker {
191192
// We are not done yet.
192193
Ok(None) => (),
193194

194-
// we are done and it was a success
195+
// We are done and it was a success
195196
Ok(Some(status)) if status.success() => {
196197
break;
197198
}
198199

199-
// we are done but blender failed.
200+
// We are done but blender failed.
200201
Ok(Some(status)) => {
201-
logger::error!(
202+
godot_error!(
202203
"Blender exited with status {}",
203204
status.code().unwrap_or_default()
204205
);
@@ -207,7 +208,7 @@ impl AoBaker {
207208

208209
// getting the status didn't work
209210
Err(err) => {
210-
logger::error!("Failed to check blender exit status: {err}");
211+
godot_error!("Failed to check blender exit status: {err}");
211212
break;
212213
}
213214
}
@@ -216,22 +217,22 @@ impl AoBaker {
216217
let line_error = stdreader.read_line(&mut read_buffer);
217218

218219
if let Err(err) = line_error {
219-
logger::error!("failed to read from blender stdout: {err}");
220+
godot_error!("failed to read from blender stdout: {err}");
220221
continue;
221222
}
222223

223224
if read_buffer.starts_with("Progress|") {
224225
let label = read_buffer.split('|').nth(1).unwrap_or_default();
225226

226227
dialog.bind_mut().push_task_step(label);
227-
logger::info!("Blender: {read_buffer}");
228+
godot_print!("Blender: {read_buffer}");
228229
}
229230

230231
if read_buffer.starts_with("File|") {
231232
let label = read_buffer.split('|').nth(1).unwrap_or_default();
232233

233234
dialog.bind_mut().push_task(label);
234-
logger::info!("Blender: {read_buffer}");
235+
godot_print!("Blender: {read_buffer}");
235236
}
236237

237238
let _: () = next_frame.to_future().await;

0 commit comments

Comments
 (0)