Rollup merge of #128611 - ChrisDenton:cygpath, r=jieyouxu
run-make: Remove cygpath Remove cygpath from run-make-support.
This commit is contained in:
commit
baa00e5fb2
@ -1,6 +1,5 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::cygpath::get_windows_path;
|
||||
use crate::artifact_names::{dynamic_lib_name, static_lib_name};
|
||||
use crate::external_deps::cc::{cc, cxx};
|
||||
use crate::external_deps::llvm::llvm_ar;
|
||||
@ -44,8 +43,7 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
|
||||
};
|
||||
let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
|
||||
if is_msvc() {
|
||||
let mut out_arg = "-out:".to_owned();
|
||||
out_arg.push_str(&get_windows_path(&lib_path));
|
||||
let out_arg = format!("-out:{lib_path}");
|
||||
cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run();
|
||||
} else if is_darwin() {
|
||||
cc().out_exe(&lib_path).input(&obj_file).args(&["-dynamiclib", "-Wl,-dylib"]).run();
|
||||
|
@ -1,7 +1,5 @@
|
||||
use std::path::Path;
|
||||
|
||||
// FIXME(jieyouxu): can we get rid of the `cygpath` external dependency?
|
||||
use super::cygpath::get_windows_path;
|
||||
use crate::command::Command;
|
||||
use crate::{env_var, is_msvc, is_windows, uname};
|
||||
|
||||
@ -97,12 +95,12 @@ pub fn out_exe(&mut self, name: &str) -> &mut Self {
|
||||
|
||||
if is_msvc() {
|
||||
path.set_extension("exe");
|
||||
let fe_path = get_windows_path(&path);
|
||||
let fe_path = path.clone();
|
||||
path.set_extension("");
|
||||
path.set_extension("obj");
|
||||
let fo_path = get_windows_path(path);
|
||||
self.cmd.arg(format!("-Fe:{fe_path}"));
|
||||
self.cmd.arg(format!("-Fo:{fo_path}"));
|
||||
let fo_path = path;
|
||||
self.cmd.arg(format!("-Fe:{}", fe_path.to_str().unwrap()));
|
||||
self.cmd.arg(format!("-Fo:{}", fo_path.to_str().unwrap()));
|
||||
} else {
|
||||
self.cmd.arg("-o");
|
||||
self.cmd.arg(name);
|
||||
|
@ -1,35 +0,0 @@
|
||||
use std::panic;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::command::Command;
|
||||
use crate::util::handle_failed_output;
|
||||
|
||||
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
|
||||
/// available on the platform!
|
||||
///
|
||||
/// # FIXME
|
||||
///
|
||||
/// FIXME(jieyouxu): we should consider not depending on `cygpath`.
|
||||
///
|
||||
/// > The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style
|
||||
/// > pathnames and vice versa.
|
||||
/// >
|
||||
/// > [irrelevant entries omitted...]
|
||||
/// >
|
||||
/// > `-w, --windows print Windows form of NAMEs (C:\WINNT)`
|
||||
/// >
|
||||
/// > -- *from [cygpath documentation](https://cygwin.com/cygwin-ug-net/cygpath.html)*.
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
pub fn get_windows_path<P: AsRef<Path>>(path: P) -> String {
|
||||
let caller = panic::Location::caller();
|
||||
let mut cygpath = Command::new("cygpath");
|
||||
cygpath.arg("-w");
|
||||
cygpath.arg(path.as_ref());
|
||||
let output = cygpath.run();
|
||||
if !output.status().success() {
|
||||
handle_failed_output(&cygpath, output, caller.line());
|
||||
}
|
||||
// cygpath -w can attach a newline
|
||||
output.stdout_utf8().trim().to_string()
|
||||
}
|
@ -9,6 +9,3 @@
|
||||
pub mod python;
|
||||
pub mod rustc;
|
||||
pub mod rustdoc;
|
||||
|
||||
// Library-internal external dependency.
|
||||
mod cygpath;
|
||||
|
Loading…
Reference in New Issue
Block a user