Skip to content
Open
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
61 changes: 39 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,18 @@ jobs:
vendor: unknown
env: -gnu
lib: libnative.so
editor_lib: libeditor.so
- platform: windows
os: windows-2025
vendor: pc
env: '-msvc'
lib: native.dll
editor_lib: editor.dll
- platform: darwin
os: macos-14
vendor: apple
lib: libnative.dylib
editor_lib: libeditor.dylib
exclude:
- platform: linux
arch: aarch64
Expand Down Expand Up @@ -78,12 +81,20 @@ jobs:
run: |
cd native/
${{ env.CARGO_BUILD }} ${{ env.TARGET_TRIPLET}} --release
- name: Debug Artifacts

- name: Debug libnative Artifact
uses: actions/upload-artifact@v4
if: ${{ !inputs.release }}
with:
name: libnative-${{ matrix.platform }}-${{ matrix.arch }}-debug
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.lib }}
- name: Release Artifacts
- name: Debug libeditor Artifact
uses: actions/upload-artifact@v4
with:
name: libeditor-${{ matrix.platform }}-${{ matrix.arch }}-debug
path: native/target/${{ env.TARGET_TRIPLET }}/debug/${{ matrix.editor_lib }}

- name: Release libnative Artifacts
uses: actions/upload-artifact@v4
if: inputs.release
with:
Expand All @@ -104,6 +115,7 @@ jobs:
aarch64: true
extension: '.dmg'
lib: libnative.dylib
editor_lib: "libeditor.dylib"
template_dir: '$HOME/Library/Application\ Support/Godot/export_templates'
godot_artefact: 'macOS.universal'
- profile: 'Windows'
Expand All @@ -115,6 +127,7 @@ jobs:
aarch64: true
extension: '.exe'
lib: native.dll
editor_lib: "libeditor.so"
template_dir: '$HOME/.local/share/godot/export_templates'
godot_artefact: 'linux.x86_64'
- profile: 'Linux'
Expand All @@ -123,6 +136,7 @@ jobs:
vendor: 'unknown'
os: ubuntu-24.04
lib: libnative.so
editor_lib: "libeditor.so"
template_dir: '$HOME/.local/share/godot/export_templates'
godot_artefact: 'linux.x86_64'
x86_64: true
Expand Down Expand Up @@ -162,38 +176,42 @@ jobs:
cd ${{ matrix.template_dir }}/${{ matrix.version }}.stable
curl -LO https://github.com/godotengine/godot/releases/download/${{ matrix.version }}-stable/Godot_v${{ matrix.version }}-stable_export_templates.tpz
unzip -j Godot_v${{ matrix.version }}-stable_export_templates.tpz
- name: download host libs
if: ${{ matrix.platform != 'linux' && startsWith(matrix.os, 'ubuntu') }}
uses: actions/download-artifact@v5
- name: download editor lib
uses: actions/download-artifact@v8
with:
name: libnative-linux-x86_64-debug
path: native/target/x86_64-unknown-linux-gnu/debug/

name: libeditor-${{ startsWith(matrix.os, 'ubuntu') && 'linux' || matrix.platform }}-${{ startsWith(matrix.os, 'ubuntu') && 'x86_64' || 'aarch64' }}-debug
path: native/target/${{ startsWith(matrix.os, 'ubuntu') && 'x86_64-unknown-linux-gnu' || 'aarch64-apple-darwin' }}/debug/
merge-multiple: true

- name: download x86_64 debug libs
if: matrix.x86_64
uses: actions/download-artifact@v5
if: ${{ matrix.x86_64 && !inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-x86_64-debug
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
merge-multiple: true
- name: download x86_64 release libs
if: ${{ matrix.x86_64 && inputs.release }}
uses: actions/download-artifact@v5
if: ${{ matrix.x86_64 && inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-x86_64-release
path: native/target/x86_64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
merge-multiple: true

- name: download aarch64 debug libs
if: matrix.aarch64
uses: actions/download-artifact@v5
if: ${{ matrix.aarch64 && !inputs.release }}
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-aarch64-debug
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/debug/
merge-multiple: true
- name: download aarch64 release libs
if: ${{ matrix.aarch64 && inputs.release }}
uses: actions/download-artifact@v5
uses: actions/download-artifact@v8
with:
name: libnative-${{ matrix.platform }}-aarch64-release
path: native/target/aarch64-${{ matrix.vendor }}-${{ matrix.platform }}${{ matrix.env }}/release/
merge-multiple: true

- name: create universal libnative
if: matrix.platform == 'darwin'
Expand All @@ -210,8 +228,10 @@ jobs:
let aarch64_debug = $"($aarch64_path)/debug/${{ matrix.lib }}"
let aarch64_release = $"($aarch64_path)/release/${{ matrix.lib }}"

mkdir $"native/target/universal-($platform_dir)/debug/"
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
if not $release {
mkdir $"native/target/universal-($platform_dir)/debug/"
lipo -create $x86_debug $aarch64_debug -output $"native/target/universal-($platform_dir)/debug/${{ matrix.lib }}"
}

if $release {
mkdir $"native/target/universal-($platform_dir)/release/"
Expand All @@ -234,10 +254,7 @@ jobs:
let profile = if $release { "release" } else { "debug" }

rm -r $"native/target/x86_64-($platform_dir)/($profile)/"

if $release {
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"
}
rm -r $"native/target/aarch64-($platform_dir)/($profile)/"

- name: export-debug
shell: nu {0}
Expand Down Expand Up @@ -272,4 +289,4 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: SimChopper_${{ matrix.profile }}_${{ steps.describe.outputs.ref }}
path: ${{ env.EXPORT_DIR }}
path: ${{ env.EXPORT_DIR }}
21 changes: 21 additions & 0 deletions native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "native"
version = "0.5.0"
edition = "2021"
[workspace]
members = ["game", "editor"]
resolver = "3"

[lib]
crate-type = ["cdylib"]
[workspace.package]
edition = "2024"
version = "0.5.0"

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

[lints.clippy]
[workspace.lints.clippy]
pedantic = "deny"
used_underscore_items = { level = "allow", priority = 1 }
27 changes: 27 additions & 0 deletions native/editor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "editor"
version.workspace = true
edition.workspace = true

[lib]
crate-type = ["cdylib"]

[dependencies]
godot.workspace = true
godot-rust-script.workspace = true
lerp.workspace = true
backtrace.workspace = true
num.workspace = true
rayon.workspace = true
itertools.workspace = true
num_enum.workspace = true
derive-debug.workspace = true
thiserror.workspace = true
anyhow.workspace = true
rand.workspace = true
pomsky-macro.workspace = true
regex.workspace = true
kanal.workspace = true

[lints]
workspace = true
45 changes: 23 additions & 22 deletions native/src/editor/ao_baker.rs → native/editor/src/ao_baker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ use std::{
process::{Command, Stdio},
};

use godot::builtin::{GString, PackedStringArray, VariantType};
use godot::classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree};
use godot::obj::{Base, Gd, Singleton};
use godot::prelude::{godot_api, GodotClass};
use godot::prelude::{GodotClass, godot_api};
use godot::register::info::PropertyHint;
use godot::task;
use godot::{
builtin::{GString, PackedStringArray, VariantType},
global::godot_error,
};
use godot::{
classes::{EditorInterface, ProjectSettings, RefCounted, SceneTree},
global::godot_print,
};

use crate::editor::new_non_zero;
use crate::editor::ui::{ForgroundProcess, ProgressDialog};
use crate::util::logger;
use crate::new_non_zero;
use crate::ui::{ForgroundProcess, ProgressDialog};

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

if blender_path_variant.is_nil() {
logger::error!("Unable to get blender path!");
godot_error!("Unable to get blender path!");
return;
}

Expand Down Expand Up @@ -114,18 +119,14 @@ impl AoBaker {

std::fs::read_dir(system_path.to_string())
.inspect_err(|err| {
logger::error!(
"unable to read directory: {}.\nError: {}",
system_path,
err
);
godot_error!("Unable to read directory: {}.\nError: {}", system_path, err);
})
.ok()
})
.flatten()
.filter_map(|entry| {
entry
.inspect_err(|err| logger::error!("Failed to enumerate directory entry: {err}"))
.inspect_err(|err| godot_error!("Failed to enumerate directory entry: {err}"))
.ok()
})
.filter(|entry| {
Expand Down Expand Up @@ -168,14 +169,14 @@ impl AoBaker {
.stdout(Stdio::piped())
.stdin(Stdio::null());

logger::debug!("invoking blender: {:?}", blender_command);
godot_print!("invoking blender: {:?}", blender_command);

let blender = blender_command.spawn();

let mut blender = match blender {
Ok(child) => child,
Err(err) => {
logger::error!("Failed to spawn blender process: {}", err);
godot_error!("Failed to spawn blender process: {}", err);
return;
}
};
Expand All @@ -191,14 +192,14 @@ impl AoBaker {
// We are not done yet.
Ok(None) => (),

// we are done and it was a success
// We are done and it was a success
Ok(Some(status)) if status.success() => {
break;
}

// we are done but blender failed.
// We are done but blender failed.
Ok(Some(status)) => {
logger::error!(
godot_error!(
"Blender exited with status {}",
status.code().unwrap_or_default()
);
Expand All @@ -207,7 +208,7 @@ impl AoBaker {

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

if let Err(err) = line_error {
logger::error!("failed to read from blender stdout: {err}");
godot_error!("failed to read from blender stdout: {err}");
continue;
}

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

dialog.bind_mut().push_task_step(label);
logger::info!("Blender: {read_buffer}");
godot_print!("Blender: {read_buffer}");
}

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

dialog.bind_mut().push_task(label);
logger::info!("Blender: {read_buffer}");
godot_print!("Blender: {read_buffer}");
}

let _: () = next_frame.to_future().await;
Expand Down
File renamed without changes.
Loading
Loading