Skip to content

Commit 9778364

Browse files
committed
Additional CI fixes.
1 parent 479137c commit 9778364

File tree

13 files changed

+64
-51
lines changed

13 files changed

+64
-51
lines changed

.github/actions/setup/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Setup Build Environment'
2+
description: 'Install system dependencies and Rust toolchain'
3+
inputs:
4+
components:
5+
description: 'Rust components to install'
6+
required: false
7+
default: ''
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Install system dependencies
12+
run: sudo apt-get update && sudo apt-get install -y g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0 libwayland-dev libxkbcommon-dev libglfw3-dev
13+
shell: bash
14+
15+
- name: Install Rust
16+
uses: dtolnay/rust-toolchain@stable
17+
with:
18+
components: ${{ inputs.components }}

.github/workflows/ci.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Install Rust
20-
uses: dtolnay/rust-toolchain@stable
19+
- uses: ./.github/actions/setup
2120

2221
- name: Cache cargo registry
2322
uses: actions/cache@v4
@@ -46,8 +45,7 @@ jobs:
4645
steps:
4746
- uses: actions/checkout@v4
4847

49-
- name: Install Rust
50-
uses: dtolnay/rust-toolchain@stable
48+
- uses: ./.github/actions/setup
5149
with:
5250
components: rustfmt
5351

@@ -60,8 +58,7 @@ jobs:
6058
steps:
6159
- uses: actions/checkout@v4
6260

63-
- name: Install Rust
64-
uses: dtolnay/rust-toolchain@stable
61+
- uses: ./.github/actions/setup
6562
with:
6663
components: clippy
6764

@@ -92,8 +89,7 @@ jobs:
9289
steps:
9390
- uses: actions/checkout@v4
9491

95-
- name: Install Rust
96-
uses: dtolnay/rust-toolchain@stable
92+
- uses: ./.github/actions/setup
9793

9894
- name: Cache cargo registry
9995
uses: actions/cache@v4

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ name = "processing"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[lints]
7+
workspace = true
8+
69
[workspace]
710
resolver = "3"
811
members = ["crates/*"]
912

13+
[workspace.lints.clippy]
14+
type_complexity = "allow"
15+
too_many_arguments = "allow"
16+
1017
[workspace.dependencies]
1118
bevy = { version = "0.17", no-default-features = true, features = [
1219
"bevy_render",

crates/processing_ffi/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "processing_ffi"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[lints]
7+
workspace = true
8+
69
[lib]
710
name = "processing"
811
crate-type = ["cdylib"]

crates/processing_ffi/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use processing::prelude::error::ProcessingError;
88

99
thread_local! {
10-
static LAST_ERROR: RefCell<Option<CString>> = RefCell::new(None);
10+
static LAST_ERROR: RefCell<Option<CString>> = const { RefCell::new(None) };
1111
}
1212

1313
/// Check if the last operation resulted in an error. Returns a pointer to an error message, or null

crates/processing_ffi/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use bevy::prelude::Entity;
22
use processing::prelude::*;
3+
34
use crate::color::Color;
45

56
mod color;
@@ -13,7 +14,7 @@ mod error;
1314
#[unsafe(no_mangle)]
1415
pub extern "C" fn processing_init() {
1516
error::clear_error();
16-
error::check(|| init());
17+
error::check(init);
1718
}
1819

1920
/// Create a WebGPU surface from a native window handle.
@@ -33,7 +34,7 @@ pub extern "C" fn processing_create_surface(
3334
scale_factor: f32,
3435
) -> u64 {
3536
error::clear_error();
36-
error::check(|| create_surface(window_handle, width, height, scale_factor))
37+
error::check(|| create_surface(window_handle, display_handle, width, height, scale_factor))
3738
.map(|e| e.to_bits())
3839
.unwrap_or(0)
3940
}

crates/processing_render/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "processing_render"
33
version = "0.1.0"
44
edition = "2024"
55

6+
[lints]
7+
workspace = true
8+
69
[dependencies]
710
bevy = { workspace = true }
811
lyon = "1.0"

crates/processing_render/src/lib.rs

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727
static IS_INIT: OnceLock<()> = OnceLock::new();
2828

2929
thread_local! {
30-
static APP: RefCell<Option<App>> = RefCell::new(None);
30+
static APP: RefCell<Option<App>> = const { RefCell::new(None) };
3131
}
3232

3333
#[derive(Resource, Default)]
@@ -64,7 +64,7 @@ impl CameraProjection for ProcessingProjection {
6464
0.0,
6565
self.width,
6666
self.height, // bottom = height
67-
0.0, // top = 0
67+
0.0, // top = 0
6868
self.near,
6969
self.far,
7070
)
@@ -94,36 +94,25 @@ impl CameraProjection for ProcessingProjection {
9494

9595
[
9696
// near plane
97-
near_center + Vec3A::new(half_width, half_height, 0.0), // bottom-right
98-
near_center + Vec3A::new(half_width, -half_height, 0.0), // top-right
97+
near_center + Vec3A::new(half_width, half_height, 0.0), // bottom-right
98+
near_center + Vec3A::new(half_width, -half_height, 0.0), // top-right
9999
near_center + Vec3A::new(-half_width, -half_height, 0.0), // top-left
100-
near_center + Vec3A::new(-half_width, half_height, 0.0), // bottom-left
100+
near_center + Vec3A::new(-half_width, half_height, 0.0), // bottom-left
101101
// far plane
102-
far_center + Vec3A::new(half_width, half_height, 0.0), // bottom-right
103-
far_center + Vec3A::new(half_width, -half_height, 0.0), // top-right
104-
far_center + Vec3A::new(-half_width, -half_height, 0.0), // top-left
105-
far_center + Vec3A::new(-half_width, half_height, 0.0), // bottom-left
102+
far_center + Vec3A::new(half_width, half_height, 0.0), // bottom-right
103+
far_center + Vec3A::new(half_width, -half_height, 0.0), // top-right
104+
far_center + Vec3A::new(-half_width, -half_height, 0.0), // top-left
105+
far_center + Vec3A::new(-half_width, half_height, 0.0), // bottom-left
106106
]
107107
}
108108
}
109109

110-
fn app<T>(cb: impl FnOnce(&App) -> Result<T>) -> Result<T> {
111-
let res = APP.with(|app_cell| {
112-
let app_borrow = app_cell.borrow();
113-
let app = app_borrow
114-
.as_ref()
115-
.ok_or_else(|| error::ProcessingError::AppAccess)?;
116-
cb(app)
117-
})?;
118-
Ok(res)
119-
}
120-
121110
fn app_mut<T>(cb: impl FnOnce(&mut App) -> Result<T>) -> Result<T> {
122111
let res = APP.with(|app_cell| {
123112
let mut app_borrow = app_cell.borrow_mut();
124113
let app = app_borrow
125114
.as_mut()
126-
.ok_or_else(|| error::ProcessingError::AppAccess)?;
115+
.ok_or(error::ProcessingError::AppAccess)?;
127116
cb(app)
128117
})?;
129118
Ok(res)
@@ -195,10 +184,7 @@ pub fn create_surface(
195184
let content_view: Option<Retained<NSView>> = ns_window_ref.contentView();
196185

197186
match content_view {
198-
Some(view) => {
199-
let view_ptr = Retained::as_ptr(&view) as *mut std::ffi::c_void;
200-
view_ptr
201-
}
187+
Some(view) => Retained::as_ptr(&view) as *mut std::ffi::c_void,
202188
None => {
203189
return Err(error::ProcessingError::InvalidWindowHandle);
204190
}
@@ -215,10 +201,10 @@ pub fn create_surface(
215201

216202
#[cfg(target_os = "windows")]
217203
let (raw_window_handle, raw_display_handle) = {
218-
use raw_window_handle::{Win32WindowHandle, WindowsDisplayHandle};
219204
use std::num::NonZeroIsize;
220-
use windows::Win32::Foundation::HINSTANCE;
221-
use windows::Win32::System::LibraryLoader::GetModuleHandleW;
205+
206+
use raw_window_handle::{Win32WindowHandle, WindowsDisplayHandle};
207+
use windows::Win32::{Foundation::HINSTANCE, System::LibraryLoader::GetModuleHandleW};
222208

223209
if window_handle == 0 {
224210
return Err(error::ProcessingError::InvalidWindowHandle);
@@ -478,7 +464,6 @@ pub fn exit(exit_code: u8) -> Result<()> {
478464
Ok(())
479465
})?;
480466

481-
482467
// we need to drop the app in a deterministic manner to ensure resourcse are cleaned up
483468
// otherwise we'll get wgpu graphics backend errors on exit
484469
APP.with(|app_cell| {
@@ -492,7 +477,7 @@ pub fn exit(exit_code: u8) -> Result<()> {
492477
pub fn background_color(window_entity: Entity, color: Color) -> Result<()> {
493478
app_mut(|app| {
494479
let mut camera_query = app.world_mut().query::<(&mut Camera, &ChildOf)>();
495-
for (mut camera, parent) in camera_query.iter_mut(&mut app.world_mut()) {
480+
for (mut camera, parent) in camera_query.iter_mut(app.world_mut()) {
496481
if parent.parent() == window_entity {
497482
camera.clear_color = ClearColorConfig::Custom(color);
498483
}

crates/processing_render/src/render/primitive/rect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ fn simple_rect(mesh: &mut Mesh, x: f32, y: f32, w: f32, h: f32, color: Color) {
101101
}
102102

103103
if let Some(Indices::U32(indices)) = mesh.indices_mut() {
104-
indices.push(base_idx + 0);
104+
indices.push(base_idx);
105105
indices.push(base_idx + 1);
106106
indices.push(base_idx + 2);
107107

108-
indices.push(base_idx + 0);
108+
indices.push(base_idx);
109109
indices.push(base_idx + 2);
110110
indices.push(base_idx + 3);
111111
}

examples/glfw.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ impl GlfwContext {
2222
window.set_all_polling(true);
2323
window.show();
2424

25-
Ok(Self { glfw, window, events })
25+
Ok(Self {
26+
glfw,
27+
window,
28+
events,
29+
})
2630
}
2731

2832
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)