Skip to content

Commit

Permalink
offer convenience function for querying host binary suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Pennebaker committed Nov 1, 2018
1 parent 1f47af8 commit 703b357
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ lazy_static::lazy_static! {
pub static ref PHONY_TASK_MUTEX : Mutex<Vec<fn()>> = Mutex::new(Vec::new());
}

/// Query common host binary suffix
pub fn binary_suffix() -> String {
if cfg!(windows) {
".exe".to_string()
} else {
"".to_string()
}
}

/// Declare a dependency on a task that may panic
pub fn deps(task: fn()) {
let phony : bool = PHONY_TASK_MUTEX
Expand Down
8 changes: 1 addition & 7 deletions src/tinyrick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,11 @@ fn main() {
]
);

let suffix : &str = if cfg!(windows) {
".exe"
} else {
""
};

let target_path : &path::Path = path::Path::new("target");

let rick_pathbuf : path::PathBuf = target_path
.join("debug")
.join(&format!("{}{}", env!("CARGO_PKG_NAME"), suffix));
.join(&format!("{}{}", env!("CARGO_PKG_NAME"), tinyrick::binary_suffix()));

let rick_path : &str = rick_pathbuf
.to_str()
Expand Down

0 comments on commit 703b357

Please sign in to comment.