reduced binary size

This commit is contained in:
Mateusz Faderewski 2023-03-10 14:12:18 +01:00
parent c8952b4ee8
commit 1fa1240dad
3 changed files with 84 additions and 4 deletions

77
sw/deployer/Cargo.lock generated
View File

@ -29,6 +29,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler32"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]] [[package]]
name = "ahash" name = "ahash"
version = "0.7.6" version = "0.7.6"
@ -536,6 +542,40 @@ dependencies = [
"tiff", "tiff",
] ]
[[package]]
name = "include-flate"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e11569346406931d20276cc460215ee2826e7cad43aa986999cb244dd7adb0"
dependencies = [
"include-flate-codegen-exports",
"lazy_static",
"libflate",
]
[[package]]
name = "include-flate-codegen"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a7d6e1419fa3129eb0802b4c99603c0d425c79fb5d76191d5a20d0ab0d664e8"
dependencies = [
"libflate",
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "include-flate-codegen-exports"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75657043ffe3d8280f1cb8aef0f505532b392ed7758e0baeac22edadcee31a03"
dependencies = [
"include-flate-codegen",
"proc-macro-hack",
]
[[package]] [[package]]
name = "io-lifetimes" name = "io-lifetimes"
version = "1.0.6" version = "1.0.6"
@ -590,9 +630,29 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.139" version = "0.2.140"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
[[package]]
name = "libflate"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97822bf791bd4d5b403713886a5fbe8bf49520fe78e323b0dc480ca1a03e50b0"
dependencies = [
"adler32",
"crc32fast",
"libflate_lz77",
]
[[package]]
name = "libflate_lz77"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf"
dependencies = [
"rle-decode-fast",
]
[[package]] [[package]]
name = "libudev" name = "libudev"
@ -847,6 +907,12 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "proc-macro-hack"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.51" version = "1.0.51"
@ -904,6 +970,12 @@ version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "rle-decode-fast"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422"
[[package]] [[package]]
name = "rust-ini" name = "rust-ini"
version = "0.18.0" version = "0.18.0"
@ -941,6 +1013,7 @@ dependencies = [
"encoding_rs", "encoding_rs",
"hex", "hex",
"image", "image",
"include-flate",
"md5", "md5",
"panic-message", "panic-message",
"rust-ini", "rust-ini",

View File

@ -16,7 +16,12 @@ ctrlc = "3.2.5"
encoding_rs = "0.8.32" encoding_rs = "0.8.32"
hex = "0.4.3" hex = "0.4.3"
image = "0.24.5" image = "0.24.5"
include-flate = { version = "0.2.0", features = ["stable"] }
md5 = "0.7.0" md5 = "0.7.0"
panic-message = "0.3.0" panic-message = "0.3.0"
rust-ini = "0.18.0" rust-ini = "0.18.0"
serialport = { git = "https://github.com/serialport/serialport-rs", branch = "main" } serialport = { git = "https://github.com/serialport/serialport-rs", branch = "main" }
[profile.release]
lto = true
strip = true

View File

@ -1,5 +1,8 @@
use include_flate::flate;
use std::io::{Error, Read, Seek, SeekFrom}; use std::io::{Error, Read, Seek, SeekFrom};
flate!(static MUPEN64PLUS_INI: str from "data/mupen64plus.ini");
pub enum SaveType { pub enum SaveType {
None, None,
Eeprom4k, Eeprom4k,
@ -67,8 +70,7 @@ pub fn guess_save_type<T: Read + Seek>(
let hash = hex::encode_upper(hasher.compute().0); let hash = hex::encode_upper(hasher.compute().0);
let database_ini = include_str!("../data/mupen64plus.ini"); let database = ini::Ini::load_from_str(MUPEN64PLUS_INI.as_str())
let database = ini::Ini::load_from_str(database_ini)
.expect("Error during mupen64plus.ini parse operation"); .expect("Error during mupen64plus.ini parse operation");
if let Some(section) = database.section(Some(hash)) { if let Some(section) = database.section(Some(hash)) {
let save_type = section.get("SaveType").map_or(SaveType::None, |t| match t { let save_type = section.get("SaveType").map_or(SaveType::None, |t| match t {