Skip to content

Commit c7c8c9c

Browse files
committed
Pull "cmake" Command construction into helpers
Soon these commands are going to become a bit different, make sure they can stay different.
1 parent 1813571 commit c7c8c9c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,10 +512,7 @@ impl Config {
512512
let cmake_prefix_path = env::join_paths(&cmake_prefix_path).unwrap();
513513

514514
// Build up the first cmake command to build the build system.
515-
let executable = self
516-
.getenv_target_os("CMAKE")
517-
.unwrap_or(OsString::from("cmake"));
518-
let mut cmd = Command::new(&executable);
515+
let mut cmd = self.cmake_configure_command();
519516

520517
if self.verbose_cmake {
521518
cmd.arg("-Wdev");
@@ -787,7 +784,7 @@ impl Config {
787784
}
788785

789786
// And build!
790-
let mut cmd = Command::new(&executable);
787+
let mut cmd = self.cmake_build_command();
791788
cmd.current_dir(&build);
792789

793790
for &(ref k, ref v) in c_compiler.env().iter().chain(&self.env) {
@@ -839,6 +836,19 @@ impl Config {
839836
return dst;
840837
}
841838

839+
fn cmake_executable(&mut self) -> OsString {
840+
self.getenv_target_os("CMAKE")
841+
.unwrap_or(OsString::from("cmake"))
842+
}
843+
844+
fn cmake_configure_command(&mut self) -> Command {
845+
Command::new(self.cmake_executable())
846+
}
847+
848+
fn cmake_build_command(&mut self) -> Command {
849+
Command::new(self.cmake_executable())
850+
}
851+
842852
fn getenv_os(&mut self, v: &str) -> Option<OsString> {
843853
if let Some(val) = self.env_cache.get(v) {
844854
return val.clone();

0 commit comments

Comments
 (0)