mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
link to libtaskchampion separately from the unity tests
This commit is contained in:
parent
17ccaea096
commit
2c9d74515e
2 changed files with 26 additions and 19 deletions
|
@ -2,25 +2,29 @@ use std::env;
|
|||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
fn build_libtaskchampion(suites: &[&'static str]) {
|
||||
// This crate has taskchampion-lib in its build-dependencies, so
|
||||
// libtaskchampion.so should be built already. Hopefully it's in target/$PROFILE, and hopefully
|
||||
// it's named libtaskchampion.so and not something else
|
||||
let mut libtaskchampion = env::current_dir().unwrap();
|
||||
libtaskchampion.pop();
|
||||
libtaskchampion.push("target");
|
||||
libtaskchampion.push(env::var("PROFILE").unwrap());
|
||||
libtaskchampion.push("deps");
|
||||
libtaskchampion.push(if cfg!(target_os = "macos") {
|
||||
"libtaskchampion.dylib"
|
||||
} else {
|
||||
"libtaskchampion.so"
|
||||
});
|
||||
/// Link to the libtaskchampion library produced by the `taskchampion-lib` crate. This is done as
|
||||
/// a build dependency, rather than a cargo dependency, for unclear reasons. TODO
|
||||
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.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");
|
||||
}
|
||||
|
||||
/// 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]) {
|
||||
let mut build = cc::Build::new();
|
||||
build.shared_flag(true);
|
||||
build.object(libtaskchampion);
|
||||
build.include("../lib");
|
||||
build.include("../lib"); // include path for taskchampion.h
|
||||
build.include("src/bindings_tests/unity");
|
||||
build.define("UNITY_OUTPUT_CHAR", "test_output");
|
||||
build.define(
|
||||
|
@ -41,6 +45,8 @@ fn build_libtaskchampion(suites: &[&'static str]) {
|
|||
build.compile("bindings-tests");
|
||||
}
|
||||
|
||||
/// Make `bindings_test_suites.rs` listing all of the test suites, for use in building the
|
||||
/// bindings-test binary.
|
||||
fn make_suite_file(suites: &[&'static str]) {
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
let dest_path = Path::new(&out_dir).join("bindings_test_suites.rs");
|
||||
|
@ -55,6 +61,7 @@ fn main() {
|
|||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
let suites = &["uuid", "string", "task", "replica"];
|
||||
build_libtaskchampion(suites);
|
||||
link_libtaskchampion();
|
||||
build_bindings_tests(suites);
|
||||
make_suite_file(suites);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue