1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-22 20:57:46 +00:00

Allow cutting out a large amount of dependencies

Before this change, if you wanted to include physis you had to include
a bunch of dependencies you didn't need. For example, a launcher would
have to pull in texpresso which is completely useless. By default,
the features from before (excluding game_install) are included.

Also this creates a game_install feature for eventual Windows builds,
where unshield is not supported.
This commit is contained in:
Joshua Goins 2022-10-25 13:53:24 -04:00
parent 8ad2283179
commit 6da9057d1e
4 changed files with 36 additions and 20 deletions

View file

@ -19,18 +19,33 @@ harness = false
system-deps = "6"
[package.metadata.system-deps]
libunshield = "1.4"
libunshield = { version = "1.4", feature = "game_install" }
[dev-dependencies]
# used for patch install checking
walkdir = "2"
hmac-sha512 = "1"
# used while rust doesn't have native benchmarking capability
criterion = "0.4"
# used for testing our jamcrc implementation
crc = "3"
[features]
default = ["visual_data"]
# enables game install support using unshield (only supported on Linux and macOS)
game_install = []
# enables support for extracting visual data, such as models, textures, materials, etc
# this enables a whole bunch of dependencies!
# tip: can be safely turned off for launchers and other tools that simply need to extract the bare minimum of data
visual_data = ["dep:half", "dep:hard-xml", "dep:serde_json", "dep:serde", "dep:glam", "dep:bitflags", "dep:texpresso"]
# testing only features
retail_game_testing = []
patch_testing = []
patch_testing = ["game_install"]
[dependencies]
# amazing binary parsing/writing library
@ -44,20 +59,20 @@ bitfield-struct = "0.1"
paste = "1"
# needed for half-float support which FFXIV uses in it's model data
half = "2"
half = { version = "2", optional = true }
# needed for havok xml parsing
hard-xml = "1"
hard-xml = { version = "1", optional = true }
# needed for textools skel parsing
serde_json = "1"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", optional = true }
serde = { version = "1", optional = true, features = ["derive"] }
# needed for deconstructing skeleton pose matrices
glam = "0.22"
glam = { version = "0.22", optional = true }
# needed for c-style bitflags used in some formats (such as tex files)
bitflags = "1.3"
bitflags = { version = "1.3", optional = true }
# needed for dxt/bc decompression
texpresso = "2"
texpresso = { version = "2", optional = true }

View file

@ -19,6 +19,7 @@ mod compression;
mod dat;
/// Reading model (MDL) files.
#[cfg(feature = "visual_data")]
pub mod model;
/// All of the races in Eorzea in a nice enum package.
@ -45,6 +46,7 @@ pub mod blowfish;
mod blowfish_constants;
/// Initializing a new retail game install from the official retail installer. No execution required!
#[cfg(feature = "game_install")]
pub mod installer;
/// Reading Excel header files (EXH).
@ -54,6 +56,7 @@ pub mod exh;
pub mod exd;
/// Reading Havok XML sidecar files.
#[cfg(feature = "visual_data")]
pub mod skeleton;
/// Reading file into files (FIIN).
@ -63,9 +66,11 @@ pub mod fiin;
pub mod log;
/// Reading textures (TEX).
#[cfg(feature = "visual_data")]
pub mod tex;
/// Reading material files (MTRL)
#[cfg(feature = "visual_data")]
pub mod mtrl;
mod crc;

View file

@ -6,15 +6,6 @@
//!
//! This implementation supports no_std.
//!
//! ## Example
//!
//! ```rust
//! let mut m = sha1_smol::Sha1::new();
//! m.update(b"Hello World!");
//! assert_eq!(m.digest().to_string(),
//! "2ef7bde608ce5404e97d5f042f95f89f1c232871");
//! ```
//!
//! The sha1 object can be updated multiple times.
#![deny(missing_docs)]

View file

@ -1,7 +1,6 @@
use hmac_sha512::Hash;
use physis::fiin::FileInfo;
use physis::index;
use physis::installer::install_game;
use physis::patch::apply_patch;
use std::collections::HashMap;
use std::env;
@ -44,7 +43,10 @@ fn test_fiin() {
assert_eq!(fiin.entries[1].file_name, "steam_api64.dll");
}
#[cfg(feature = "patch_testing")]
fn make_temp_install_dir(name: &str) -> String {
use physis::installer::install_game;
let installer_exe = env::var("FFXIV_INSTALLER").unwrap();
let mut game_dir = env::home_dir().unwrap();
@ -63,6 +65,7 @@ fn make_temp_install_dir(name: &str) -> String {
game_dir.as_path().to_str().unwrap().parse().unwrap()
}
#[cfg(feature = "patch_testing")]
fn fill_dir_hash(game_dir: &str) -> HashMap<String, [u8; 64]> {
let mut file_hashes: HashMap<String, [u8; 64]> = HashMap::new();
@ -86,6 +89,7 @@ fn fill_dir_hash(game_dir: &str) -> HashMap<String, [u8; 64]> {
file_hashes
}
#[cfg(feature = "patch_testing")]
fn physis_install_patch(game_directory: &str, data_directory: &str, patch_name: &str) {
let patch_dir = env::var("FFXIV_PATCH_DIR").unwrap();
@ -95,6 +99,7 @@ fn physis_install_patch(game_directory: &str, data_directory: &str, patch_name:
apply_patch(&data_dir, &patch_path).unwrap();
}
#[cfg(feature = "patch_testing")]
fn xivlauncher_install_patch(game_directory: &str, data_directory: &str, patch_name: &str) {
let patch_dir = env::var("FFXIV_PATCH_DIR").unwrap();
let patcher_exe = env::var("FFXIV_XIV_LAUNCHER_PATCHER").unwrap();
@ -110,7 +115,7 @@ fn xivlauncher_install_patch(game_directory: &str, data_directory: &str, patch_n
}
#[test]
#[cfg_attr(not(feature = "patch_testing"), ignore)]
#[cfg(feature = "patch_testing")]
fn test_patching() {
println!("Beginning game installation...");