Skip to content

Commit 14c62d1

Browse files
committed
Split gdextension into two
1 parent eb3554f commit 14c62d1

131 files changed

Lines changed: 363 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: 39 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
@@ -78,12 +81,20 @@ jobs:
7881
run: |
7982
cd native/
8083
${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release
81-
- name: Debug Artifacts
84+
85+
- name: Debug libnative Artifact
8286
uses: actions/upload-artifact@v4
87+
if: ${{ !inputs.release }}
8388
with:
8489
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-debug
8590
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.lib }}
86-
- name: Release Artifacts
91+
- name: Debug libeditor Artifact
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: libeditor-${{ matrix.platform }}-${{ matrix.arch }}-debug
95+
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.editor_lib }}
96+
97+
- name: Release libnative Artifacts
8798
uses: actions/upload-artifact@v4
8899
if: inputs.release
89100
with:
@@ -104,6 +115,7 @@ jobs:
104115
aarch64: true
105116
extension: '.dmg'
106117
lib: libnative.dylib
118+
editor_lib: "libeditor.dylib"
107119
template_dir: '$HOME/Library/Application\ Support/Godot/export_templates'
108120
godot_artefact: 'macOS.universal'
109121
- profile: 'Windows'
@@ -115,6 +127,7 @@ jobs:
115127
aarch64: true
116128
extension: '.exe'
117129
lib: native.dll
130+
editor_lib: "libeditor.so"
118131
template_dir: '$HOME/.local/share/godot/export_templates'
119132
godot_artefact: 'linux.x86_64'
120133
- profile: 'Linux'
@@ -123,6 +136,7 @@ jobs:
123136
vendor: 'unknown'
124137
os: ubuntu-24.04
125138
lib: libnative.so
139+
editor_lib: "libeditor.so"
126140
template_dir: '$HOME/.local/share/godot/export_templates'
127141
godot_artefact: 'linux.x86_64'
128142
x86_64: true
@@ -162,38 +176,42 @@ jobs:
162176
cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable
163177
curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz
164178
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
179+
- name: download editor lib
180+
uses: actions/download-artifact@v8
168181
with:
169-
name: libnative-linux-x86_64-debug
170-
path: native/target/x86_64-unknown-linux-gnu/debug/
171-
182+
name: libeditor-${{ startsWith(matrix.os, 'ubuntu') && 'linux' || matrix.platform }}-${{ startsWith(matrix.os, 'ubuntu') && 'x86_64' || 'aarch64' }}-debug
183+
path: native/target/${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-unknown-linux-gnu' || 'aarch64-apple-darwin' }}/debug/
184+
merge-multiple: true
185+
172186
- name: download x86_64 debug libs
173-
if: matrix.x86_64
174-
uses: actions/download-artifact@v5
187+
if: ${{ matrix.x86_64 && !inputs.release }}
188+
uses: actions/download-artifact@v8
175189
with:
176190
name: libnative-${{ matrix.platform }}-x86_64-debug
177191
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
192+
merge-multiple: true
178193
- name: download x86_64 release libs
179-
if: ${{ matrix.x86_64 && inputs.release }}
180-
uses: actions/download-artifact@v5
194+
if: ${{ matrix.x86_64 && inputs.release }}
195+
uses: actions/download-artifact@v8
181196
with:
182197
name: libnative-${{ matrix.platform }}-x86_64-release
183198
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
199+
merge-multiple: true
184200

185201
- name: download aarch64 debug libs
186-
if: matrix.aarch64
187-
uses: actions/download-artifact@v5
202+
if: ${{ matrix.aarch64 && !inputs.release }}
203+
uses: actions/download-artifact@v8
188204
with:
189205
name: libnative-${{ matrix.platform }}-aarch64-debug
190206
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
207+
merge-multiple: true
191208
- name: download aarch64 release libs
192209
if: ${{ matrix.aarch64 && inputs.release }}
193-
uses: actions/download-artifact@v5
210+
uses: actions/download-artifact@v8
194211
with:
195212
name: libnative-${{ matrix.platform }}-aarch64-release
196213
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
214+
merge-multiple: true
197215

198216
- name: create universal libnative
199217
if: matrix.platform == 'darwin'
@@ -210,8 +228,10 @@ jobs:
210228
let aarch64_debug = $"($aarch64_path)/debug/${{ matrix.lib }}"
211229
let aarch64_release = $"($aarch64_path)/release/${{ matrix.lib }}"
212230
213-
mkdir $"native/target/universal-($platform_dir)/debug/"
214-
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
231+
if !$release {
232+
mkdir $"native/target/universal-($platform_dir)/debug/"
233+
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
234+
}
215235
216236
if $release {
217237
mkdir $"native/target/universal-($platform_dir)/release/"
@@ -234,10 +254,7 @@ jobs:
234254
let profile = if $release { "release" } else { "debug" }
235255
236256
rm -r $"native/target/x86_64-($platform_dir)/($profile)/"
237-
238-
if $release {
239-
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
240-
}
257+
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
241258
242259
- name: export-debug
243260
shell: nu {0}
@@ -272,4 +289,4 @@ jobs:
272289
- uses: actions/upload-artifact@v4
273290
with:
274291
name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }}
275-
path: ${{ env.EXPORT_DIR }}
292+
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)