mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Remove unnecessary copies in build.rs
This commit is contained in:
parent
38397734e2
commit
15a82b462f
1 changed files with 8 additions and 7 deletions
15
build.rs
15
build.rs
|
@ -8,10 +8,10 @@ use std::path::{Path, PathBuf};
|
||||||
fn main() {
|
fn main() {
|
||||||
setup_paths();
|
setup_paths();
|
||||||
|
|
||||||
let rust_dir = env!("CARGO_MANIFEST_DIR");
|
|
||||||
// Add our default to enable tools that don't go through CMake, like "cargo test" and the
|
// Add our default to enable tools that don't go through CMake, like "cargo test" and the
|
||||||
// language server.
|
// language server.
|
||||||
let build_dir = std::env::var("FISH_BUILD_DIR").unwrap_or(format!("{rust_dir}/build"));
|
let build_dir = format!("{}/build", env!("CARGO_MANIFEST_DIR"));
|
||||||
|
let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&build_dir);
|
||||||
rsconf::set_env_value("FISH_BUILD_DIR", &build_dir);
|
rsconf::set_env_value("FISH_BUILD_DIR", &build_dir);
|
||||||
|
|
||||||
cc::Build::new()
|
cc::Build::new()
|
||||||
|
@ -30,13 +30,14 @@ fn main() {
|
||||||
|
|
||||||
// Handle case where CMake has found curses for us and where we have to find it ourselves.
|
// Handle case where CMake has found curses for us and where we have to find it ourselves.
|
||||||
rsconf::rebuild_if_env_changed("CURSES_LIBRARY_LIST");
|
rsconf::rebuild_if_env_changed("CURSES_LIBRARY_LIST");
|
||||||
let curses_libraries = if let Ok(lib_path_list) = env::var("CURSES_LIBRARY_LIST") {
|
let curses_lib_list = env::var("CURSES_LIBRARY_LIST");
|
||||||
|
let curses_libraries = if let Ok(lib_path_list) = curses_lib_list.as_ref() {
|
||||||
let lib_paths = lib_path_list.split(',').filter(|s| !s.is_empty());
|
let lib_paths = lib_path_list.split(',').filter(|s| !s.is_empty());
|
||||||
let curses_libnames: Vec<_> = lib_paths
|
let curses_libnames: Vec<_> = lib_paths
|
||||||
.map(|libpath| {
|
.map(|libpath| {
|
||||||
let stem = Path::new(libpath).file_stem().unwrap().to_str().unwrap();
|
let stem = Path::new(libpath).file_stem().unwrap().to_str().unwrap();
|
||||||
// Ubuntu-32bit-fetched-pcre2's ncurses doesn't have the "lib" prefix.
|
// Ubuntu-32bit-fetched-pcre2's ncurses doesn't have the "lib" prefix.
|
||||||
stem.strip_prefix("lib").unwrap_or(stem).to_string()
|
stem.strip_prefix("lib").unwrap_or(stem)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
// We don't need to test the libs because presumably CMake already did
|
// We don't need to test the libs because presumably CMake already did
|
||||||
|
@ -48,7 +49,7 @@ fn main() {
|
||||||
for lib in libs {
|
for lib in libs {
|
||||||
if target.has_library(lib) && target.has_symbol("setupterm", lib) {
|
if target.has_library(lib) && target.has_symbol("setupterm", lib) {
|
||||||
rsconf::link_library(lib, LinkType::Default);
|
rsconf::link_library(lib, LinkType::Default);
|
||||||
curses_libraries.push(lib.to_string());
|
curses_libraries.push(lib);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,9 +61,9 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
for lib in curses_libraries {
|
for lib in curses_libraries {
|
||||||
if target.has_symbol("_nc_cur_term", &lib) {
|
if target.has_symbol("_nc_cur_term", lib) {
|
||||||
rsconf::enable_cfg("have_nc_cur_term");
|
rsconf::enable_cfg("have_nc_cur_term");
|
||||||
if target.has_symbol("cur_term", &lib) {
|
if target.has_symbol("cur_term", lib) {
|
||||||
rsconf::warn!("curses provides both cur_term and _nc_cur_term");
|
rsconf::warn!("curses provides both cur_term and _nc_cur_term");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue