Otherwise, changing the current working directory can mess up runtime linking.
#[derive(Clone)]
pub struct Config {
// The library paths required for running the compiler
- pub compile_lib_path: String,
+ pub compile_lib_path: PathBuf,
// The library paths required for running compiled programs
- pub run_lib_path: String,
+ pub run_lib_path: PathBuf,
// The rustc executable
pub rustc_path: PathBuf,
}
}
+ fn make_absolute(path: PathBuf) -> PathBuf {
+ if path.is_relative() {
+ env::current_dir().unwrap().join(path)
+ } else {
+ path
+ }
+ }
+
+ let filter = if !matches.free.is_empty() {
+ Some(matches.free[0].clone())
+ } else {
+ None
+ };
+
Config {
- compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
- run_lib_path: matches.opt_str("run-lib-path").unwrap(),
+ compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
+ run_lib_path: make_absolute(opt_path(matches, "run-lib-path")),
rustc_path: opt_path(matches, "rustc-path"),
rustdoc_path: opt_path(matches, "rustdoc-path"),
python: matches.opt_str("python").unwrap(),
testpaths,
pretty_type.to_owned()),
props.exec_env.clone(),
- &config.compile_lib_path,
+ config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
Some(src))
}
testpaths,
proc_args,
environment,
- &config.run_lib_path,
+ config.run_lib_path.to_str().unwrap(),
None,
None);
}
testpaths,
make_run_args(config, props, testpaths),
env,
- &config.run_lib_path,
+ config.run_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
None)
}
&aux_testpaths,
aux_args,
Vec::new(),
- &config.compile_lib_path,
+ config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
None);
if !auxres.status.success() {
testpaths,
args,
props.rustc_env.clone(),
- &config.compile_lib_path,
+ config.compile_lib_path.to_str().unwrap(),
Some(aux_dir.to_str().unwrap()),
input)
}