mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 12:11:16 -03:00
Stop using Cargo's OUT_DIR
(Note: this commit should technically have preceded the "Fix config paths for disjoint build-dirs and in-tree installs" one, to make that one easier to follow, but I wasn't 100% sure if this commit is right.) From https://doc.rust-lang.org/cargo/reference/environment-variables.html > OUT_DIR — If the package has a build script, this is set to the folder > where the build script should place its output. See below for more > information. (Only set during compilation.) so OUT_DIR is something like "target/debug/build/fish-41da27d587f48978". Whenever build.rs is re-run, we get a new one. I don't think we need this flexibility anywhere. It wouldn't protect concurrent "cargo test" from interfering with each other - that's handled by a file lock taken by Cargo. Use "target/" instead (or CMAKE_BINARY_DIR if set). Namespace the files better, so we don't create weird paths like target/test/complete_test/... target/fish_root/
This commit is contained in:
8
build.rs
8
build.rs
@@ -25,14 +25,8 @@ fn main() {
|
||||
.unwrap_or(canonicalize(MANIFEST_DIR).join("target"));
|
||||
|
||||
// FISH_BUILD_DIR is set by CMake, if we are using it.
|
||||
// OUT_DIR is set by Cargo when the build script is running (not compiling)
|
||||
let default_build_dir = env::var("OUT_DIR").unwrap();
|
||||
let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&default_build_dir);
|
||||
let build_dir = canonicalize_str(build_dir);
|
||||
rsconf::set_env_value("FISH_BUILD_DIR", &build_dir);
|
||||
|
||||
rsconf::set_env_value(
|
||||
"FISH_BUILD_OUTPUT_DIR",
|
||||
"FISH_BUILD_DIR",
|
||||
option_env!("FISH_BUILD_DIR").unwrap_or(cargo_target_dir.to_str().unwrap()),
|
||||
);
|
||||
|
||||
|
||||
2
src/env/config_paths.rs
vendored
2
src/env/config_paths.rs
vendored
@@ -32,7 +32,7 @@
|
||||
// TODO: we should determine program_name from argv0 somewhere in this file
|
||||
|
||||
// Detect if we're running right out of the CMAKE build directory
|
||||
if exec_path.starts_with(env!("FISH_BUILD_OUTPUT_DIR")) {
|
||||
if exec_path.starts_with(env!("FISH_BUILD_DIR")) {
|
||||
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
FLOG!(
|
||||
config,
|
||||
|
||||
@@ -600,7 +600,7 @@ fn make_base_directory(xdg_var: &wstr, non_xdg_homepath: &wstr) -> BaseDirectory
|
||||
use std::path::PathBuf;
|
||||
|
||||
let mut build_dir = PathBuf::from(env!("FISH_BUILD_DIR"));
|
||||
build_dir.push("fish_root");
|
||||
build_dir.push("fish-test-home");
|
||||
|
||||
let err = match std::fs::create_dir_all(&build_dir) {
|
||||
Ok(_) => 0,
|
||||
|
||||
@@ -42,6 +42,7 @@ pub mod prelude {
|
||||
use std::cell::RefCell;
|
||||
use std::env::set_current_dir;
|
||||
use std::ffi::CString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// A wrapper around a Parser with some test helpers.
|
||||
pub struct TestParser {
|
||||
@@ -89,8 +90,10 @@ pub fn test_init() -> impl ScopeGuarding<Target = ()> {
|
||||
DONE.get_or_init(|| {
|
||||
// If we are building with `cargo build` and have build w/ `cmake`, FISH_BUILD_DIR might
|
||||
// not yet exist.
|
||||
std::fs::create_dir_all(env!("FISH_BUILD_DIR")).unwrap();
|
||||
set_current_dir(env!("FISH_BUILD_DIR")).unwrap();
|
||||
let mut test_dir = PathBuf::from(env!("FISH_BUILD_DIR"));
|
||||
test_dir.push("fish-test");
|
||||
std::fs::create_dir_all(&test_dir).unwrap();
|
||||
set_current_dir(&test_dir).unwrap();
|
||||
{
|
||||
let s = CString::new("").unwrap();
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user