Workspaces (#626)

We can put everything except 'agb' and the 'agb-tracker' crates in a
workspace for hopefully easier management :)

- [x] no changelog update needed
This commit is contained in:
Gwilym Inzani 2024-04-09 21:45:59 +01:00 committed by GitHub
commit 11b51e0a75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 63 additions and 42 deletions

44
Cargo.toml Normal file
View file

@ -0,0 +1,44 @@
[workspace]
resolver = "2"
# unfortunately we can't include 'agb' or anything which compiles to non-native code
# in the workspace here, and they need to be tracked separately.
members = [
# "agb"
"agb-debug",
"agb-fixnum",
"agb-gbafix",
"agb-hashmap",
"agb-image-converter",
"agb-macros",
"agb-sound-converter",
"tracker/agb-midi",
"tracker/agb-midi-core",
"tracker/agb-tracker-interop",
# "tracker/agb-tracker",
"tracker/agb-xm",
"tracker/agb-xm-core",
"tools",
"emulator/mgba",
"emulator/mgba-sys",
"emulator/test-runner",
]
exclude = [
"agb",
"tracker/agb-tracker",
"examples/amplitude",
"examples/combo",
"examples/hyperspace-roll",
"examples/the-dungeon-puzzlers-lament",
"examples/the-hat-chooses-the-wizard",
"examples/the-purple-night",
"book/games/pong",
]

View file

@ -1,6 +0,0 @@
[workspace]
members = [
"mgba",
"mgba-sys",
"test-runner"
]

View file

@ -15,7 +15,6 @@ pub enum LogLevel {
Unknown,
}
#[derive(Debug, Error)]
#[error("A log level of {provided_log_level} does not match any known log level")]
pub struct LogLevelIsNotValid {
@ -34,9 +33,11 @@ impl TryFrom<mgba_sys::mLogLevel> for LogLevel {
mgba_sys::mLogLevel_mLOG_DEBUG => LogLevel::Debug,
mgba_sys::mLogLevel_mLOG_STUB => LogLevel::Stub,
mgba_sys::mLogLevel_mLOG_GAME_ERROR => LogLevel::GameError,
_ => return Err(LogLevelIsNotValid {
provided_log_level: value
})
_ => {
return Err(LogLevelIsNotValid {
provided_log_level: value,
})
}
})
}
}
@ -95,7 +96,11 @@ extern "C" fn log_string_wrapper(
unsafe { CStr::from_ptr(category_c_name).to_str() }.unwrap_or(UNKNOWN)
};
logger(category_name, LogLevel::try_from(level).unwrap_or(LogLevel::Unknown), s);
logger(
category_name,
LogLevel::try_from(level).unwrap_or(LogLevel::Unknown),
s,
);
}
}
}

View file

@ -113,14 +113,14 @@ impl<V: VFile> VFileAlloc<V> {
}
pub(crate) fn into_mgba(self) -> *mut mgba_sys::VFile {
let f = Box::into_raw(self.0) as *mut VFileInner<V>;
let f = Box::into_raw(self.0);
f.cast()
}
}
mod vfile_extern {
use std::io::SeekFrom;
use super::VFileExtensions;
use std::io::SeekFrom;
/// Safety: Must be part of a VFileInner
pub unsafe fn create_vfile<V: super::VFile>() -> mgba_sys::VFile {

View file

@ -1,20 +1,15 @@
use std::path::Path;
use image::{io::Reader, DynamicImage};
use image::io::Reader;
pub struct ComparisonResult {
matches: bool,
image: DynamicImage,
}
impl ComparisonResult {
pub fn success(&self) -> bool {
self.matches
}
pub fn image(&self) -> &DynamicImage {
&self.image
}
}
const WIDTH: usize = 240;
@ -36,10 +31,7 @@ pub fn compare_image(
let (exp_dim_x, exp_dim_y) = expected_buffer.dimensions();
if exp_dim_x != WIDTH as u32 || exp_dim_y != HEIGHT as u32 {
return Ok(ComparisonResult {
matches: false,
image: expected,
});
return Ok(ComparisonResult { matches: false });
}
for y in 0..HEIGHT {
@ -49,16 +41,10 @@ pub fn compare_image(
let image_pixel = convert_rgba_to_nearest_gba_colour(image_pixel.0);
if image_pixel[0..3] != video_pixel.to_le_bytes()[0..3] {
return Ok(ComparisonResult {
matches: false,
image: expected,
});
return Ok(ComparisonResult { matches: false });
}
}
}
Ok(ComparisonResult {
matches: true,
image: expected,
})
Ok(ComparisonResult { matches: true })
}

View file

@ -11,21 +11,15 @@ build-release:
just _build-release tracker/agb-tracker
clippy:
just _all-crates _clippy
just _clippy tools
test:
just _test-debug agb
just _test-multiboot
just _test-debug agb-fixnum
just _test-debug agb-hashmap
just _test-debug tracker/agb-tracker
just _test-debug-arm agb
just _test-debug tools
just _test-debug emulator
test-release:
just _test-release agb
just _test-release agb-fixnum
just _test-release tracker/agb-tracker
just _test-release-arm agb
@ -35,8 +29,7 @@ doctest-agb:
check-docs:
(cd agb && cargo doc --target=thumbv4t-none-eabi --no-deps)
(cd tracker/agb-tracker && cargo doc --target=thumbv4t-none-eabi --no-deps)
just _build_docs agb-fixnum
just _build_docs agb-hashmap
cargo doc --no-deps
_build_docs crate:
(cd "{{crate}}" && cargo doc --no-deps)
@ -46,10 +39,9 @@ clean:
fmt:
just _all-crates _fmt
just _fmt tools
fmt-check:
just _all-crates _fmt-check
just _fmt-check tools
run-example example:
just _build-example "{{example}}"
@ -148,7 +140,7 @@ debug *args:
(cd agb-debug && cargo build --release && cd "{{invocation_directory()}}" && "$CARGO_TARGET_DIR/release/agb-debug" {{args}})
_all-crates target:
for CARGO_PROJECT_FILE in agb-*/Cargo.toml agb/Cargo.toml tracker/agb-*/Cargo.toml; do \
for CARGO_PROJECT_FILE in agb/Cargo.toml tracker/agb-tracker/Cargo.toml ./Cargo.toml; do \
PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE"); \
just "{{target}}" "$PROJECT_DIR" || exit $?; \
done