Skip to content

Commit

Permalink
Fixed windows build, added new flags to usage
Browse files Browse the repository at this point in the history
  • Loading branch information
datawater committed Jul 6, 2024
1 parent fa8b8c6 commit 54dd849
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default = ["bitcode"]
bitcode = ["dep:bitcode"]

[target.'cfg(target_os = "windows")'.dependencies]
windows = "0.58.0"
windows = { version = "0.58.0", features = ["Win32", "Win32_System", "Win32_System_SystemInformation"] }

[profile.release]
lto = "fat"
Expand Down
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ fn parse_memory_amount(s: &str) -> Result<u64, ParseMemoryError> {

fn print_usage() {
// TODO(#20): A better usage/help command

println!("\nUsage: cmbr {{COMMAND}} [OPTIONS]");
println!("note: Options inside of square brackets ([]) are optional\n");
println!("Commands:");
println!(" cmbr2pgn --input {{INPUT_FILE}} [--output {{OUTPUT_FILE}} --threads_n {{AMOUNT_OF_THREADS}} --enable_compression ]");
println!(" pgn2cmbr --input {{INPUT_FILE}} [--output {{OUTPUT_FILE}} --threads_n {{AMOUNT_OF_THREADS}} ]");
println!(" cmbr2pgn --input {{INPUT_FILE}} [--output {{OUTPUT_FILE}} --threads_n {{AMOUNT_OF_THREADS}} --enable_compression --table-memory-limit {{LIMIT}} ]");
println!(" pgn2cmbr --input {{INPUT_FILE}} [--output {{OUTPUT_FILE}} --threads_n {{AMOUNT_OF_THREADS}} --table-memory-limit {{LIMIT}} ]");
println!(" license");
}

Expand Down
6 changes: 2 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use cfg_if::cfg_if;

cfg_if! {
if #[cfg(target_os = "windows")] {
use std::ptr;
use windows::Win32::System::SystemInformation::{
GlobalMemoryStatusEx, MEMORYSTATUSEX
};
Expand All @@ -11,7 +10,6 @@ cfg_if! {
} else if #[cfg(target_os = "macos")] {
use std::process::Command;
}

}

pub fn get_free_memory() -> Option<u64> {
Expand All @@ -21,9 +19,9 @@ pub fn get_free_memory() -> Option<u64> {
let mut mem_info = MEMORYSTATUSEX {
dwLength: std::mem::size_of::<MEMORYSTATUSEX>() as u32,
..Default::default()
}
};

return GlobalMemoryStatusEx(&mut mem_info) != 0 {
return if GlobalMemoryStatusEx(&mut mem_info).is_ok() {
Some(mem_info.ullAvailPhys / 1024)
} else {
None
Expand Down

0 comments on commit 54dd849

Please sign in to comment.