Merge pull request #216 from gwilymk/deny-warnings

Deny warnings and try to make the build a bit faster
This commit is contained in:
Gwilym Kuiper 2022-04-23 17:34:05 +01:00 committed by GitHub
commit fba087f2ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 23 deletions

View file

@ -6,5 +6,5 @@ build-std-features = ["compiler-builtins-mem"]
target = "thumbv4t-none-eabi" target = "thumbv4t-none-eabi"
[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" runner = "mgba-test-runner"

View file

@ -19,10 +19,6 @@ use crate::agb_alloc::bump_allocator::StartEnd;
use crate::dma; use crate::dma;
use crate::fixnum::Vector2D; use crate::fixnum::Vector2D;
use crate::hash_map::HashMap; use crate::hash_map::HashMap;
use crate::interrupt::free;
use bare_metal::Mutex;
use core::cell::RefCell;
use attributes::*; use attributes::*;
@ -52,13 +48,14 @@ impl DerefMut for ObjectControllerRef {
} }
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
static OBJECT_REFS_CURRENT: Mutex<RefCell<i32>> = Mutex::new(RefCell::new(0)); static OBJECT_REFS_CURRENT: bare_metal::Mutex<core::cell::RefCell<i32>> =
bare_metal::Mutex::new(core::cell::RefCell::new(0));
impl ObjectControllerRef { impl ObjectControllerRef {
fn new() -> Self { fn new() -> Self {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
{ {
let a = free(|c| { let a = crate::interrupt::free(|c| {
let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut(); let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut();
let a = *b; let a = *b;
*b += 1; *b += 1;
@ -78,7 +75,7 @@ impl ObjectControllerRef {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
impl Drop for ObjectControllerRef { impl Drop for ObjectControllerRef {
fn drop(&mut self) { fn drop(&mut self) {
free(|c| { crate::interrupt::free(|c| {
let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut(); let mut b = OBJECT_REFS_CURRENT.borrow(*c).borrow_mut();
*b -= 1; *b -= 1;
}) })
@ -444,7 +441,7 @@ struct ObjectInner {
} }
struct ObjectControllerStatic { struct ObjectControllerStatic {
free_affine_matricies: Vec<u8>, _free_affine_matricies: Vec<u8>,
free_object: Vec<u8>, free_object: Vec<u8>,
shadow_oam: Vec<Option<ObjectInner>>, shadow_oam: Vec<Option<ObjectInner>>,
z_order: Vec<u8>, z_order: Vec<u8>,
@ -457,7 +454,7 @@ impl ObjectControllerStatic {
shadow_oam: (0..128).map(|_| None).collect(), shadow_oam: (0..128).map(|_| None).collect(),
z_order: (0..128).collect(), z_order: (0..128).collect(),
free_object: (0..128).collect(), free_object: (0..128).collect(),
free_affine_matricies: (0..32).collect(), _free_affine_matricies: (0..32).collect(),
sprite_controller: SpriteControllerInner::new(), sprite_controller: SpriteControllerInner::new(),
} }
} }

View file

@ -4,7 +4,6 @@
#![cfg_attr(test, feature(custom_test_frameworks))] #![cfg_attr(test, feature(custom_test_frameworks))]
#![cfg_attr(test, test_runner(crate::test_runner::test_runner))] #![cfg_attr(test, test_runner(crate::test_runner::test_runner))]
#![cfg_attr(test, reexport_test_harness_main = "test_main")] #![cfg_attr(test, reexport_test_harness_main = "test_main")]
#![deny(clippy::all)]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
//! # agb //! # agb

View file

@ -2,8 +2,19 @@ export CARGO_TARGET_DIR := env_var_or_default('CARGO_TARGET_DIR', justfile_direc
build: build-roms build: build-roms
build-debug:
just _build-debug agb
build-release:
just _build-release agb
clippy:
just _all-crates _clippy
test: test:
just _all-crates _test-debug just _test-debug agb
just _test-debug agb-fixnum
test-release:
just _test-release agb
clean: clean:
just _all-crates _clean just _all-crates _clean
@ -22,11 +33,7 @@ run-game game:
run-game-debug game: run-game-debug game:
(cd "examples/{{game}}" && cargo run) (cd "examples/{{game}}" && cargo run)
ci: && build-roms build-book ci: build-debug clippy test build-release test-release build-roms build-book
just _all-crates _build
just _all-crates _test-debug
just _all-crates _test-release
just _all-crates _clippy
build-roms: build-roms:
just _build-rom "examples/the-purple-night" "PURPLENIGHT" just _build-rom "examples/the-purple-night" "PURPLENIGHT"
@ -54,7 +61,7 @@ _build-rom folder name:
TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}" TARGET_FOLDER="${CARGO_TARGET_DIR:-$GAME_FOLDER/target}"
GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba" GBA_FILE="$TARGET_FOLDER/$GAME_NAME.gba"
(cd "$GAME_FOLDER" && 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 mkdir -p examples/target/examples
@ -64,17 +71,21 @@ _build-rom folder name:
cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba" cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba"
_all-crates target: _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"); \ PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE"); \
just "{{target}}" "$PROJECT_DIR" || exit $?; \ just "{{target}}" "$PROJECT_DIR" || exit $?; \
done done
_build crate: _build-debug crate:
(cd "{{crate}}" && cargo build) (cd "{{crate}}" && cargo build --examples --tests)
_build-release crate:
(cd "{{crate}}" && cargo build --release --examples --tests)
_test-release crate: _test-release crate:
{{ if crate =~ 'agb.*' { "cd " + crate + " && cargo test --release" } else { "" } }} just _build-release {{crate}}
(cd "{{crate}}" && cargo test --release)
_test-debug crate: _test-debug crate:
{{ if crate =~ 'agb.*' { "cd " + crate + " && cargo test" } else { "" } }} just _build-debug {{crate}}
(cd "{{crate}}" && cargo test)
_clippy crate: _clippy crate:
{{ if crate =~ 'agb.*' { "cd " + crate + " && cargo clippy" } else { "" } }} {{ if crate =~ 'agb.*' { "cd " + crate + " && cargo clippy" } else { "" } }}
_clean crate: _clean crate: