Skip to content

Commit

Permalink
Added github actions for PRs (#3)
Browse files Browse the repository at this point in the history
* Added github actions for PRs

* Added some rustfmt::skip attributes

* Applied formatting

* Added rustfmt component in action

* Configured to use rustfmt version 2 which fixes some comment formatting

* Removed ready_for_review condition for github actions

Since it has the synchronize condition, it will update after each
commit, whether in draft or not, so I think this should be alright
  • Loading branch information
transistorfet authored Mar 17, 2024
1 parent a2372d1 commit 7dac32d
Show file tree
Hide file tree
Showing 99 changed files with 2,389 additions and 1,567 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.60.0"
msrv = "1.70.0"
32 changes: 32 additions & 0 deletions .github/workflows/clippy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: clippy
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
- name: Select rust version
run: |
rustup toolchain install 1.70 --profile minimal --no-self-update
rustup default 1.70
rustup component add clippy
- name: Check clippy
run: |
cargo clippy
File renamed without changes.
32 changes: 32 additions & 0 deletions .github/workflows/rustdoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: rustdoc
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
rustdocs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
- name: Select rust version
run: |
rm Cargo.lock
rustup toolchain install nightly --profile minimal --no-self-update
rustup default nightly
- name: Build rustdoc
run: |
RUSTDOCFLAGS="--deny=warnings --cfg=docsrs" cargo doc --all-features
32 changes: 32 additions & 0 deletions .github/workflows/rustfmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: rustfmt
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
- name: Select rust version
run: |
rustup toolchain install nightly --profile minimal --no-self-update
rustup default nightly
rustup component add rustfmt
- name: Check rustfmt
run: |
cargo +nightly fmt --check
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

env:
RUSTFLAGS: '--deny warnings'

jobs:
test-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: |
sudo apt-get install -y alsa-base libasound2-dev libxkbcommon-dev
- name: Select rust version
run: |
rustup toolchain install 1.70 --profile minimal --no-self-update
rustup default 1.70
- name: Run tests with default features
run: |
cargo test
- name: Run tests with all features
run: |
cargo test #--features=std,fugit,femtos
- name: Run test with no_std
run: |
cargo test --no-default-features
24 changes: 24 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
edition = "2021"
version = "Two"

max_width = 132

struct_lit_width = 0 # default 18 (24)
fn_call_width=100 # default 60 (80)
array_width=132 # default 60 (80)
#chain_width=100 # default 60 (80)
#attr_fn_like_width=100 # default 70 (92)
#single_line_if_else_max_width=100 # default 50 (66)
#struct_variant_width = 0 # default 35 (46)

newline_style = "Unix"
reorder_imports = false
match_block_trailing_comma = true

## Experimental Features
unstable_features = true
blank_lines_upper_bound = 3
overflow_delimited_expr = true

# it would be nice to allow a newline at the top and bottom of file
# it would be nice to not erase the whitespace between the end of the code line and start of a comment on the same line
19 changes: 0 additions & 19 deletions Cargo.lock

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

21 changes: 6 additions & 15 deletions emulator/core/src/devices.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use std::rc::Rc;
use std::cell::{RefCell, RefMut, BorrowMutError};
use std::sync::atomic::{AtomicUsize, Ordering};
Expand All @@ -17,7 +16,7 @@ pub type Address = u64;
/// information that might be helpful for debugging.
pub trait Steppable {
fn step(&mut self, system: &System) -> Result<Duration, Error>;
fn on_error(&mut self, _system: &System) { }
fn on_error(&mut self, _system: &System) {}
}

/// A device that can receive an interrupt. The `interrupt_state_change()` method
Expand Down Expand Up @@ -104,30 +103,22 @@ pub trait Addressable {

#[inline]
pub fn read_beu16(data: &[u8]) -> u16 {
(data[0] as u16) << 8 |
(data[1] as u16)
(data[0] as u16) << 8 | (data[1] as u16)
}

#[inline]
pub fn read_leu16(data: &[u8]) -> u16 {
(data[1] as u16) << 8 |
(data[0] as u16)
(data[1] as u16) << 8 | (data[0] as u16)
}

#[inline]
pub fn read_beu32(data: &[u8]) -> u32 {
(data[0] as u32) << 24 |
(data[1] as u32) << 16 |
(data[2] as u32) << 8 |
(data[3] as u32)
(data[0] as u32) << 24 | (data[1] as u32) << 16 | (data[2] as u32) << 8 | (data[3] as u32)
}

#[inline]
pub fn read_leu32(data: &[u8]) -> u32 {
(data[3] as u32) << 24 |
(data[2] as u32) << 16 |
(data[1] as u32) << 8 |
(data[0] as u32)
(data[3] as u32) << 24 | (data[2] as u32) << 16 | (data[1] as u32) << 8 | (data[0] as u32)
}


Expand Down Expand Up @@ -239,7 +230,7 @@ pub struct Device(DeviceId, TransmutableBox);
impl Device {
pub fn new<T>(value: T) -> Self
where
T: Transmutable + 'static
T: Transmutable + 'static,
{
Self(DeviceId::new(), wrap_transmutable(value))
}
Expand Down
12 changes: 2 additions & 10 deletions emulator/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use std::fmt;
use moa_host::HostError;

Expand Down Expand Up @@ -52,10 +51,7 @@ impl Error {

pub fn msg(&self) -> &str {
match self {
Error::Assertion(msg) |
Error::Breakpoint(msg) |
Error::Other(msg) |
Error::Emulator(_, msg) => msg.as_str(),
Error::Assertion(msg) | Error::Breakpoint(msg) | Error::Other(msg) | Error::Emulator(_, msg) => msg.as_str(),
Error::Processor(_) => "native exception",
}
}
Expand All @@ -64,10 +60,7 @@ impl Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::Assertion(msg) |
Error::Breakpoint(msg) |
Error::Other(msg) |
Error::Emulator(_, msg) => write!(f, "{}", msg),
Error::Assertion(msg) | Error::Breakpoint(msg) | Error::Other(msg) | Error::Emulator(_, msg) => write!(f, "{}", msg),
Error::Processor(_) => write!(f, "native exception"),
}
}
Expand All @@ -78,4 +71,3 @@ impl<E> From<HostError<E>> for Error {
Self::Other("other".to_string())
}
}

2 changes: 0 additions & 2 deletions emulator/core/src/interrupts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use crate::error::Error;


Expand Down Expand Up @@ -43,4 +42,3 @@ impl InterruptController {
Ok(acknowledge)
}
}

10 changes: 6 additions & 4 deletions emulator/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#[macro_use]
mod error;

Expand All @@ -7,12 +6,15 @@ mod interrupts;
mod memory;
mod system;

pub use crate::devices::{Address, Addressable, Steppable, Interruptable, Debuggable, Inspectable, Transmutable, TransmutableBox, Device};
pub use crate::devices::{read_beu16, read_beu32, read_leu16, read_leu32, write_beu16, write_beu32, write_leu16, write_leu32, wrap_transmutable};
pub use crate::devices::{
Address, Addressable, Steppable, Interruptable, Debuggable, Inspectable, Transmutable, TransmutableBox, Device,
};
pub use crate::devices::{
read_beu16, read_beu32, read_leu16, read_leu32, write_beu16, write_beu32, write_leu16, write_leu32, wrap_transmutable,
};
pub use crate::error::Error;
pub use crate::interrupts::InterruptController;
pub use crate::memory::{MemoryBlock, AddressTranslator, AddressRepeater, Bus, BusPort, dump_slice, dump_memory};
pub use crate::system::System;

pub use emulator_hal::bus::{BusAccess};

Loading

0 comments on commit 7dac32d

Please sign in to comment.