From ccb9a0fdfbdc68bde0be73c3aee93b3ddab8934c Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 10 Jul 2022 16:12:35 +0000 Subject: [PATCH] Import taskchampion-lib into integration-tests as rust symbols This allows Cargo to handle the linking peculiarities of platforms. --- rust/integration-tests/Cargo.toml | 2 +- rust/integration-tests/build.rs | 26 -------------------------- rust/integration-tests/src/lib.rs | 1 + rust/lib/Cargo.toml | 4 ---- 4 files changed, 2 insertions(+), 31 deletions(-) diff --git a/rust/integration-tests/Cargo.toml b/rust/integration-tests/Cargo.toml index 74eac8995..115066014 100644 --- a/rust/integration-tests/Cargo.toml +++ b/rust/integration-tests/Cargo.toml @@ -8,6 +8,7 @@ build = "build.rs" [dependencies] taskchampion = { path = "../taskchampion" } +taskchampion-lib = { path = "../lib" } taskchampion-sync-server = { path = "../sync-server" } [dev-dependencies] @@ -22,4 +23,3 @@ lazy_static = "1" [build-dependencies] cc = "1.0.73" -taskchampion-lib = { path = "../lib" } diff --git a/rust/integration-tests/build.rs b/rust/integration-tests/build.rs index 0907f3d1b..deb72448c 100644 --- a/rust/integration-tests/build.rs +++ b/rust/integration-tests/build.rs @@ -2,31 +2,6 @@ use std::env; use std::fs; use std::path::Path; -/// Link to the libtaskchampion library produced by the `taskchampion-lib` crate. This is done as -/// a build dependency, rather than a cargo dependency, so that the symbols are available to -/// bindings-tests. -fn link_libtaskchampion() { - // This crate has taskchampion-lib in its build-dependencies, so libtaskchampion.so should be - // built already. - // - // Shared libraries (crate-type=cdylib) appear to be placed in target/$PROFILE/deps. - let mut libtc_dir = env::current_dir().unwrap(); - libtc_dir.pop(); - libtc_dir.pop(); - libtc_dir.push("target"); - libtc_dir.push(env::var("PROFILE").unwrap()); - libtc_dir.push("deps"); - - let libtc_dir = libtc_dir.to_str().expect("path is valid utf-8"); - println!("cargo:rustc-link-search={}", libtc_dir); - println!("cargo:rustc-link-lib=dylib=taskchampion_lib"); - - // on windows, it appears that rust std requires BCrypt - if cfg!(target_os = "windows") { - println!("cargo:rustc-link-lib=dylib=bcrypt"); - } -} - /// Build the Unity-based C test suite in `src/bindings_tests`, linking the result with this /// package's library crate. fn build_bindings_tests(suites: &[&'static str]) { @@ -68,7 +43,6 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let suites = &["uuid", "string", "task", "replica"]; - link_libtaskchampion(); build_bindings_tests(suites); make_suite_file(suites); } diff --git a/rust/integration-tests/src/lib.rs b/rust/integration-tests/src/lib.rs index 71b0b274c..3d76f3008 100644 --- a/rust/integration-tests/src/lib.rs +++ b/rust/integration-tests/src/lib.rs @@ -1 +1,2 @@ pub mod bindings_tests; +pub use taskchampion_lib::*; diff --git a/rust/lib/Cargo.toml b/rust/lib/Cargo.toml index f7405cc30..d0e2f4bd6 100644 --- a/rust/lib/Cargo.toml +++ b/rust/lib/Cargo.toml @@ -3,10 +3,6 @@ name = "taskchampion-lib" version = "0.1.0" edition = "2018" -[lib] -# staticlib is used for integration-tests, and is not exported. -crate-type = ["cdylib", "lib"] - [dependencies] libc = "0.2.126" taskchampion = { path = "../taskchampion" }