|
1 | 1 | use std::env;
|
2 |
| -use std::path::PathBuf; |
| 2 | +use std::path::{Path, PathBuf}; |
3 | 3 | use std::process::{Command, Output};
|
4 | 4 |
|
5 | 5 | fn setup_common_build_cmd() -> Command {
|
@@ -88,36 +88,30 @@ impl AuxBuildInvocationBuilder {
|
88 | 88 | }
|
89 | 89 | }
|
90 | 90 |
|
91 |
| -fn path_sep(target: &str) -> char { |
92 |
| - if target.contains("windows") { ';' } else { ':' } |
93 |
| -} |
94 |
| - |
95 | 91 | fn run_common(bin_name: &str) -> (Command, Output) {
|
96 |
| - let target = std::env::var("TARGET").unwrap(); |
| 92 | + let target = env::var("TARGET").unwrap(); |
97 | 93 |
|
98 | 94 | let bin_name =
|
99 | 95 | if target.contains("windows") { format!("{}.exe", bin_name) } else { bin_name.to_owned() };
|
100 | 96 |
|
101 | 97 | let mut bin_path = PathBuf::new();
|
102 |
| - bin_path.push(std::env::var("TMPDIR").unwrap()); |
| 98 | + bin_path.push(env::var("TMPDIR").unwrap()); |
103 | 99 | bin_path.push(&bin_name);
|
104 |
| - let ld_lib_path_envvar = std::env::var("LD_LIB_PATH_ENVVAR").unwrap(); |
| 100 | + let ld_lib_path_envvar = env::var("LD_LIB_PATH_ENVVAR").unwrap(); |
105 | 101 | let mut cmd = Command::new(bin_path);
|
106 | 102 | cmd.env(&ld_lib_path_envvar, {
|
107 |
| - let mut target_rpath_env_path = String::new(); |
108 |
| - target_rpath_env_path.push_str(&std::env::var("TMPDIR").unwrap()); |
109 |
| - target_rpath_env_path.push(path_sep(&target)); |
110 |
| - target_rpath_env_path.push_str(&std::env::var("TARGET_RPATH_ENV").unwrap()); |
111 |
| - target_rpath_env_path.push(path_sep(&target)); |
112 |
| - target_rpath_env_path.push_str(&std::env::var(&ld_lib_path_envvar).unwrap()); |
113 |
| - target_rpath_env_path |
| 103 | + let mut paths = vec![]; |
| 104 | + paths.push(Path::new(&env::var("TMPDIR").unwrap())); |
| 105 | + paths.extend(env::split_paths(&env::var("TARGET_RPATH_ENV").unwrap())); |
| 106 | + paths.extend(env::split_paths(&env::var(&ld_lib_path_envvar).unwrap())); |
| 107 | + env::join_paths(paths.iter()).unwrap() |
114 | 108 | });
|
115 | 109 |
|
116 | 110 | if target.contains("windows") {
|
117 |
| - let mut path = std::env::var("PATH").unwrap_or(String::new()); |
118 |
| - path.push(path_sep(&target)); |
119 |
| - path.push_str(&std::env::var("TARGET_RPATH_DIR").unwrap()); |
120 |
| - cmd.env("PATH", &path); |
| 111 | + let mut paths = vec![]; |
| 112 | + paths.extend(env::split_paths(&std::env::var("PATH").unwrap_or(String::new()))); |
| 113 | + paths.push(Path::new(&std::env::var("TARGET_RPATH_DIR").unwrap())); |
| 114 | + cmd.env("PATH", env::join_paths(paths.iter()).unwrap()); |
121 | 115 | }
|
122 | 116 |
|
123 | 117 | let output = cmd.output().unwrap();
|
|
0 commit comments