Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure #11

Merged
merged 24 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
experimental = ["setup-scripts"]

[[profile.default.scripts]]
filter = 'all()'
setup = 'test-data-setup'

[script.test-data-setup]
command = 'cargo run -p aff-test-data-setup'
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
* text=auto eol=lf

tests/test-data/** linguist-generated
* text=auto eol=lf
45 changes: 45 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on:
pull_request:
branches:
- main

name: Test coverage

jobs:
coverage:
name: Collect test coverage
runs-on: ubuntu-latest

env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2

- name: Install latest nextest release
uses: taiki-e/install-action@af5d802f13195cc3a6becf3d19d72f7de93908d8 # v2
with:
tool: nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@af5d802f13195cc3a6becf3d19d72f7de93908d8 # v2
with:
tool: cargo-llvm-cov

- name: Collect coverage data
run: |
cargo llvm-cov --no-report nextest
cargo llvm-cov report --lcov --output-path lcov.info
env:
AFF_TEST_DATA_PW: ${{ secrets.AFF_TEST_DATA_PW }}

- name: Upload coverage data to codecov
uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
17 changes: 5 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/target
/Cargo.lock

tarpaulin-report.html
*.profraw
/arma-file-formats/tests/real_virtuality/test-data/*

/tests/test-data/paa_out
/tests/test-data/pbo_out

/tests/test-data/p3d_in
/tests/test-data/wrp_in
/tests/test-data/util_out
/target
Cargo.lock

/tests/test-data/pbo_in/projeta3-10.pbo
.env
lcov.info
61 changes: 8 additions & 53 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,53 +1,8 @@
[package]
name = "rvff"
version = "0.1.0"
edition = "2021"
description = "Pure rust implementation of most of the Real Virtuality file formats."
license = "MIT"
repository = "https://github.com/arma-tools/rvff/"
readme = "README.md"
keywords = ["pbo", "paa", "p3d", "wrp", "real-virtuality", "decoding"]
categories = ["decoding", "parser-implementations", "parsing"]

[lib]
crate-type = ["lib", "staticlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
byteorder = "1.4.3"
num_enum = "0.6.1"

binrw = "0.11.2"

rayon = { version = "1.5.1", optional = true }
anyhow = "1.0.53"
thiserror = "1.0.30"

derivative = "2.2.0"

# Paa
squish = "2.0.0-beta1"

# PBO
indexmap = "2.0.0"
sha-1 = "0.10.1"

# Sign
rsa = { version = "0.9.2" }
rand = { version = "0.8.5" }
getrandom = { version = "0.2", features = ["js"] }

# Rap
ariadne = "0.3.0"
chumsky = "0.9.0"

# LZO
lzokay-native = "0.1"

[dev-dependencies]
image = "0.24.6"
serial_test = "2.0.0"

[features]
parallel = ["squish/rayon", "rayon"]
[workspace]
members = [
"arma-file-formats",
"arma-file-formats-cli",
"arma-file-formats/tests/test-data-setup",
]

resolver = "2"
16 changes: 16 additions & 0 deletions arma-file-formats-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "arma-file-formats-cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arma-file-formats = { path = "../arma-file-formats" }
clap = { version = "4.5.4", features = ["derive"] }

[features]
default = ["real_virtuality", "enfusion"]

real_virtuality = []
enfusion = []
3 changes: 3 additions & 0 deletions arma-file-formats-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

Check warning on line 3 in arma-file-formats-cli/src/main.rs

View check run for this annotation

Codecov / codecov/patch

arma-file-formats-cli/src/main.rs#L1-L3

Added lines #L1 - L3 were not covered by tests
57 changes: 57 additions & 0 deletions arma-file-formats/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[package]
name = "arma-file-formats"
version = "0.1.0"
edition = "2021"
description = "Pure rust implementation of most of the Real Virtuality & Enfusion file formats."
license = "MIT"
repository = "https://github.com/arma-tools/arma-file-formats/"
readme = "README.md"
keywords = ["pbo", "paa", "p3d", "wrp", "real-virtuality", "decoding"]
categories = ["decoding", "parser-implementations", "parsing"]

[lib]
crate-type = ["lib", "staticlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
byteorder = "1.4.3"
num_enum = "0.6.1"

binrw = "0.11.2"

rayon = { version = "1.5.1", optional = true }
anyhow = "1.0.53"
thiserror = "1.0.30"

derivative = "2.2.0"

# Paa
squish = "2.0.0-beta1"

# PBO
indexmap = "2.0.0"
sha-1 = "0.10.1"

# Sign
rsa = { version = "0.9.2" }
rand = { version = "0.8.5" }
getrandom = { version = "0.2", features = ["js"] }

# Rap
ariadne = "0.3.0"
chumsky = "0.9.0"

# LZO
lzokay-native = "0.1"

[dev-dependencies]
image = "0.24.6"
serial_test = "2.0.0"

[features]
default = ["real_virtuality", "enfusion"]

parallel = ["squish/rayon", "rayon"]
real_virtuality = []
enfusion = []
Empty file.
25 changes: 14 additions & 11 deletions src/errors/mod.rs → arma-file-formats/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PaaLzoErr(#[from] lzokay_native::Error),

#[error("LZSS Error")]
RvffLzssError(#[from] RvffLzssError),
LzssError(#[from] LzssError),

#[error("Invalid state")]
InvalidState,
Expand All @@ -26,8 +26,11 @@
Unknown,
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Error)]
pub enum RvffLzssError {
#[derive(Debug, Error)]

Check warning on line 29 in arma-file-formats/src/errors/mod.rs

View check run for this annotation

Codecov / codecov/patch

arma-file-formats/src/errors/mod.rs#L29

Added line #L29 was not covered by tests
pub enum LzssError {
#[error("IO failed")]
IOError(#[from] io::Error),

#[error("LZSS Checksum Missmatch")]
ChecksumMissmatch,

Expand All @@ -36,7 +39,7 @@
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Error)]
pub enum RvffOdolError {
pub enum OdolError {
#[error("Signature Missing")]
SignatureMissing,

Expand All @@ -48,21 +51,21 @@
}

#[derive(Debug, Error)]
pub enum RvffError {
pub enum AffError {
#[error("IO failed {0}")]
RvffIOError(#[from] io::Error),
IOError(#[from] io::Error),

#[error("FromUTF8 failed {0}")]
RvffUTFError(#[from] FromUtf8Error),
UTFError(#[from] FromUtf8Error),

#[error("Binrw failed {0}")]
RvffBinrwError(#[from] binrw::Error),
BinrwError(#[from] binrw::Error),

#[error("LZSS Error")]
RvffLzssError(#[from] RvffLzssError),
LzssError(#[from] LzssError),

#[error("ODOL Error")]
RvffOdolError(#[from] RvffOdolError),
OdolError(#[from] OdolError),

#[error("Invalid file")]
InvalidFileError,
Expand All @@ -74,5 +77,5 @@
Unknown,

#[error("Parsing failed: {0}")]
RvffParseError(String),
ParseError(String),
}
13 changes: 5 additions & 8 deletions src/lib.rs → arma-file-formats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
#![allow(clippy::float_cmp)]
#![allow(clippy::multiple_crate_versions)]

pub mod core;
pub mod errors;

pub mod p3d;
pub mod paa;
pub mod pbo;
pub mod rap;
pub mod sign;
pub mod wrp;
#[cfg(feature = "real_virtuality")]
pub mod real_virtuality;

pub mod errors;
#[cfg(feature = "enfusion")]
pub mod enfusion;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use binrw::Endian;
use lzokay_native::decompress;
use rsa::BigUint;

use crate::p3d::ODOLArgs;
use crate::real_virtuality::p3d::ODOLArgs;

use super::decompress_lzss;
use super::types::STPair;
Expand Down
Loading