mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Link against curses in build.rs too
This will allow to use "cargo test" for unit tests that depend on our curses.rs. This means that Rust.cmake depends on ConfigureChecks, so move that one to the front.
This commit is contained in:
parent
cc93a6b073
commit
b2d4619125
3 changed files with 41 additions and 7 deletions
|
@ -24,6 +24,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
include(cmake/ConfigureChecks.cmake)
|
||||
include(cmake/gettext.cmake)
|
||||
|
||||
include(cmake/Rust.cmake)
|
||||
|
||||
# Error out when linking statically, it doesn't work.
|
||||
|
@ -123,8 +126,6 @@ set(FISH_SRCS
|
|||
file(GLOB FISH_HEADERS src/*.h)
|
||||
|
||||
# Set up config.h
|
||||
include(cmake/ConfigureChecks.cmake)
|
||||
include(cmake/gettext.cmake)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
|
|
@ -62,6 +62,8 @@ endif()
|
|||
# CMAKE_BINARY_DIR can include symlinks, since we want to compare this to the dir fish is executed in we need to canonicalize it.
|
||||
file(REAL_PATH "${CMAKE_BINARY_DIR}" fish_binary_dir)
|
||||
|
||||
string(JOIN "," CURSES_LIBRARY_LIST ${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY})
|
||||
|
||||
# Tell Cargo where our build directory is so it can find config.h.
|
||||
corrosion_set_env_vars(${fish_rust_target}
|
||||
"FISH_BUILD_DIR=${fish_binary_dir}"
|
||||
|
@ -75,6 +77,7 @@ corrosion_set_env_vars(${fish_rust_target}
|
|||
"SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}"
|
||||
"BINDIR=${CMAKE_INSTALL_FULL_BINDIR}"
|
||||
"LOCALEDIR=${CMAKE_INSTALL_FULL_LOCALEDIR}"
|
||||
"CURSES_LIBRARY_LIST=${CURSES_LIBRARY_LIST}"
|
||||
)
|
||||
|
||||
# this needs an extra fish-rust due to the poor source placement
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use rsconf::{LinkType, Target};
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Stdio;
|
||||
|
||||
fn main() {
|
||||
|
@ -11,13 +12,42 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
let build_dir = PathBuf::from(
|
||||
std::env::var("FISH_BUILD_DIR")
|
||||
// Add our default to enable tools that don't go through CMake, like "cargo test"
|
||||
// and the language server.
|
||||
.unwrap_or("./build".into()),
|
||||
);
|
||||
|
||||
let cached_curses_libnames = Path::join(&build_dir, "cached-curses-libnames");
|
||||
let curses_libnames: Vec<String> = if let Ok(lib_path_list) = env::var("CURSES_LIBRARY_LIST") {
|
||||
let lib_paths = lib_path_list
|
||||
.split(',')
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.to_string());
|
||||
let curses_libnames: Vec<_> = lib_paths
|
||||
.map(|libpath| {
|
||||
let stem = Path::new(&libpath).file_stem().unwrap().to_str().unwrap();
|
||||
// Ubuntu-32bit-fetched-pcre2's ncurses doesn't have the "lib" prefix.
|
||||
stem.strip_prefix("lib").unwrap_or(stem).to_owned()
|
||||
})
|
||||
.collect();
|
||||
std::fs::write(cached_curses_libnames, curses_libnames.join("\n") + "\n").unwrap();
|
||||
curses_libnames
|
||||
} else {
|
||||
let lib_cache = std::fs::read(cached_curses_libnames).unwrap_or_default();
|
||||
let lib_cache = String::from_utf8(lib_cache).unwrap();
|
||||
lib_cache
|
||||
.split('\n')
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| s.to_owned())
|
||||
.collect()
|
||||
};
|
||||
rsconf::link_libraries(&curses_libnames, LinkType::Default);
|
||||
|
||||
cc::Build::new()
|
||||
.file("fish-rust/src/compat.c")
|
||||
.include(
|
||||
&std::env::var("FISH_BUILD_DIR")
|
||||
// Add our default to potentially help tools that don't go through CMake.
|
||||
.unwrap_or("./build".into()),
|
||||
)
|
||||
.include(&build_dir)
|
||||
.compile("libcompat.a");
|
||||
|
||||
if compiles("fish-rust/src/cfg/w_exitcode.cpp") {
|
||||
|
|
Loading…
Reference in a new issue