From 4eb31cda34f7f43054840f5ae36ea110223d76c9 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 23 Apr 2022 16:26:27 +0100 Subject: [PATCH 1/5] Add deny warnings and clippy::all to build script --- justfile | 1 + 1 file changed, 1 insertion(+) diff --git a/justfile b/justfile index fe40dc5..b06dc87 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,5 @@ export CARGO_TARGET_DIR := env_var_or_default('CARGO_TARGET_DIR', justfile_directory() + "/target") +export RUSTFLAGS := "-D warnings -D clippy::all" build: build-roms From a32bb2125bf49cb3832d8a25fbc7788bd94c939f Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 23 Apr 2022 16:26:42 +0100 Subject: [PATCH 2/5] Remove deny clippy::all from lib.rs to ensure it always builds for users --- agb/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/agb/src/lib.rs b/agb/src/lib.rs index 9eb473c..739e01d 100644 --- a/agb/src/lib.rs +++ b/agb/src/lib.rs @@ -4,7 +4,6 @@ #![cfg_attr(test, feature(custom_test_frameworks))] #![cfg_attr(test, test_runner(crate::test_runner::test_runner))] #![cfg_attr(test, reexport_test_harness_main = "test_main")] -#![deny(clippy::all)] #![feature(alloc_error_handler)] //! # agb From 3143d89359f9bb7c9ca8ac9074c7b43bc0a11201 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 23 Apr 2022 17:10:17 +0100 Subject: [PATCH 3/5] Fiddle around with the build script to try and speed it up --- justfile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/justfile b/justfile index b06dc87..f9ac1b0 100644 --- a/justfile +++ b/justfile @@ -1,10 +1,20 @@ export CARGO_TARGET_DIR := env_var_or_default('CARGO_TARGET_DIR', justfile_directory() + "/target") -export RUSTFLAGS := "-D warnings -D clippy::all" build: build-roms +build-debug: + just _all-crates _build-debug +build-release: + just _build-release agb +clippy: + just _all-crates _clippy + test: - just _all-crates _test-debug + just _test-debug agb + just _test-debug agb-fixnum + +test-release: + just _test-release agb clean: just _all-crates _clean @@ -23,11 +33,7 @@ run-game game: run-game-debug game: (cd "examples/{{game}}" && cargo run) -ci: && build-roms build-book - just _all-crates _build - just _all-crates _test-debug - just _all-crates _test-release - just _all-crates _clippy +ci: build-debug clippy test build-release test-release build-roms build-book build-roms: just _build-rom "examples/the-purple-night" "PURPLENIGHT" @@ -55,7 +61,7 @@ _build-rom folder name: TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}" GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba" - (cd "$GAME_FOLDER" && cargo build --release --target thumbv4t-none-eabi) + (cd "$GAME_FOLDER" && cargo clippy && cargo build --release --target thumbv4t-none-eabi) mkdir -p examples/target/examples @@ -65,17 +71,21 @@ _build-rom folder name: cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba" _all-crates target: - for CARGO_PROJECT_FILE in agb-*/Cargo.toml agb/Cargo.toml examples/*/Cargo.toml book/games/*/Cargo.toml; do \ + for CARGO_PROJECT_FILE in agb-*/Cargo.toml agb/Cargo.toml; do \ PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE"); \ just "{{target}}" "$PROJECT_DIR" || exit $?; \ done -_build crate: - (cd "{{crate}}" && cargo build) +_build-debug crate: + (cd "{{crate}}" && cargo build --examples --tests) +_build-release crate: + (cd "{{crate}}" && cargo build --release --examples --tests) _test-release crate: - {{ if crate =~ 'agb.*' { "cd " + crate + " && cargo test --release" } else { "" } }} + just _build-release {{crate}} + (cd "{{crate}}" && cargo test --release) _test-debug crate: - {{ if crate =~ 'agb.*' { "cd " + crate + " && cargo test" } else { "" } }} + just _build-debug {{crate}} + (cd "{{crate}}" && cargo test) _clippy crate: {{ if crate =~ 'agb.*' { "cd " + crate + " && cargo clippy" } else { "" } }} _clean crate: From 1593c0e8b69fe74d42f4533093c2089355606978 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 23 Apr 2022 17:10:29 +0100 Subject: [PATCH 4/5] Move clippy deny to config.toml and fix warnings --- agb/.cargo/config.toml | 2 +- agb/src/display/object.rs | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/agb/.cargo/config.toml b/agb/.cargo/config.toml index 54493f4..528c72a 100644 --- a/agb/.cargo/config.toml +++ b/agb/.cargo/config.toml @@ -6,5 +6,5 @@ build-std-features = ["compiler-builtins-mem"] target = "thumbv4t-none-eabi" [target.thumbv4t-none-eabi] -rustflags = ["-Clink-arg=-Tgba.ld", "-Ctarget-cpu=arm7tdmi"] +rustflags = ["-Clink-arg=-Tgba.ld", "-Ctarget-cpu=arm7tdmi", "-Dwarnings", "-Dclippy::all"] runner = "mgba-test-runner" diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 7336e91..4982b70 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -19,10 +19,6 @@ use crate::agb_alloc::bump_allocator::StartEnd; use crate::dma; use crate::fixnum::Vector2D; use crate::hash_map::HashMap; -use crate::interrupt::free; - -use bare_metal::Mutex; -use core::cell::RefCell; use attributes::*; @@ -52,13 +48,14 @@ impl DerefMut for ObjectControllerRef { } #[cfg(debug_assertions)] -static OBJECT_REFS_CURRENT: Mutex> = Mutex::new(RefCell::new(0)); +static OBJECT_REFS_CURRENT: bare_metal::Mutex> = + bare_metal::Mutex::new(core::cell::RefCell::new(0)); impl ObjectControllerRef { fn new() -> Self { #[cfg(debug_assertions)] { - let a = free(|c| { + let a = crate::interrupt::free(|c| { let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut(); let a = *b; *b += 1; @@ -78,7 +75,7 @@ impl ObjectControllerRef { #[cfg(debug_assertions)] impl Drop for ObjectControllerRef { fn drop(&mut self) { - free(|c| { + crate::interrupt::free(|c| { let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut(); *b -= 1; }) @@ -444,7 +441,7 @@ struct ObjectInner { } struct ObjectControllerStatic { - free_affine_matricies: Vec, + _free_affine_matricies: Vec, free_object: Vec, shadow_oam: Vec>, z_order: Vec, @@ -457,7 +454,7 @@ impl ObjectControllerStatic { shadow_oam: (0..128).map(|_| None).collect(), z_order: (0..128).collect(), free_object: (0..128).collect(), - free_affine_matricies: (0..32).collect(), + _free_affine_matricies: (0..32).collect(), sprite_controller: SpriteControllerInner::new(), } } From 98a55b3ce27b01328f736eeb3f44d19a8632f62b Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 23 Apr 2022 17:24:55 +0100 Subject: [PATCH 5/5] Reduce what gets built quite a lot more --- justfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index f9ac1b0..08ef20b 100644 --- a/justfile +++ b/justfile @@ -3,9 +3,9 @@ export CARGO_TARGET_DIR := env_var_or_default('CARGO_TARGET_DIR', justfile_direc build: build-roms build-debug: - just _all-crates _build-debug + just _build-debug agb build-release: - just _build-release agb + just _build-release agb clippy: just _all-crates _clippy @@ -61,7 +61,7 @@ _build-rom folder name: TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}" GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba" - (cd "$GAME_FOLDER" && cargo clippy && cargo build --release --target thumbv4t-none-eabi) + (cd "$GAME_FOLDER" && cargo build --release --target thumbv4t-none-eabi && cargo clippy --release --target thumbv4t-none-eabi) mkdir -p examples/target/examples