Use the workspace from CMake

- Make CMake use the correct target-path
- Make build.rs use the correct target dir

Workspaces place it in the project root by default, the alternative to making
this change is to add a `.cargo/config.toml` file with

```toml
[build]
target-dir = "fish-rust/target"
```

Which I think is unnecessary, as we likely want to use the new location anyways.
This commit is contained in:
Henrik Hørlück Berg 2023-08-13 15:33:36 +02:00 committed by Johannes Altmanninger
parent 824e76ebe4
commit c23f419af1
3 changed files with 7 additions and 6 deletions

View file

@ -37,7 +37,8 @@ if(DEFINED ASAN)
endif()
corrosion_import_crate(
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/fish-rust/Cargo.toml"
MANIFEST_PATH "${CMAKE_SOURCE_DIR}/Cargo.toml"
CRATES "fish-rust"
FEATURES "${FISH_CRATE_FEATURES}"
FLAGS "${CARGO_FLAGS}"
)

View file

@ -193,8 +193,8 @@ endif()
if(NOT DEFINED ASAN)
add_test(
NAME "cargo-test"
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust"
COMMAND cargo test ${CARGO_FLAGS} --package fish-rust --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})
add_test_target("cargo-test")
@ -202,7 +202,7 @@ endif()
add_test(
NAME "cargo-test-widestring"
COMMAND cargo test ${CARGO_FLAGS} --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/fish-rust/widestring-suffix/"
COMMAND cargo test ${CARGO_FLAGS} --package widestring-suffix --target-dir target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
add_test_target("cargo-test-widestring")

View file

@ -6,7 +6,7 @@ fn main() {
let rust_dir = std::env::var("CARGO_MANIFEST_DIR").expect("Env var CARGO_MANIFEST_DIR missing");
let target_dir =
std::env::var("FISH_RUST_TARGET_DIR").unwrap_or(format!("{}/{}", rust_dir, "target/"));
std::env::var("FISH_RUST_TARGET_DIR").unwrap_or(format!("{}/../{}", rust_dir, "target/"));
let fish_src_dir = format!("{}/{}", rust_dir, "../src/");
// Where cxx emits its header.