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::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn build_libtaskchampion(suites: &[&'static str]) {
|
/// Link to the libtaskchampion library produced by the `taskchampion-lib` crate. This is done as
|
||||||
// This crate has taskchampion-lib in its build-dependencies, so
|
/// a build dependency, rather than a cargo dependency, for unclear reasons. TODO
|
||||||
// libtaskchampion.so should be built already. Hopefully it's in target/$PROFILE, and hopefully
|
fn link_libtaskchampion() {
|
||||||
// it's named libtaskchampion.so and not something else
|
// This crate has taskchampion-lib in its build-dependencies, so libtaskchampion.so should be
|
||||||
let mut libtaskchampion = env::current_dir().unwrap();
|
// built already.
|
||||||
libtaskchampion.pop();
|
//
|
||||||
libtaskchampion.push("target");
|
// Shared libraries (crate-type=cdylib) appear to be placed in target/$PROFILE/deps.
|
||||||
libtaskchampion.push(env::var("PROFILE").unwrap());
|
let mut libtc_dir = env::current_dir().unwrap();
|
||||||
libtaskchampion.push("deps");
|
libtc_dir.pop();
|
||||||
libtaskchampion.push(if cfg!(target_os = "macos") {
|
libtc_dir.push("target");
|
||||||
"libtaskchampion.dylib"
|
libtc_dir.push(env::var("PROFILE").unwrap());
|
||||||
} else {
|
libtc_dir.push("deps");
|
||||||
"libtaskchampion.so"
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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();
|
let mut build = cc::Build::new();
|
||||||
build.shared_flag(true);
|
build.include("../lib"); // include path for taskchampion.h
|
||||||
build.object(libtaskchampion);
|
|
||||||
build.include("../lib");
|
|
||||||
build.include("src/bindings_tests/unity");
|
build.include("src/bindings_tests/unity");
|
||||||
build.define("UNITY_OUTPUT_CHAR", "test_output");
|
build.define("UNITY_OUTPUT_CHAR", "test_output");
|
||||||
build.define(
|
build.define(
|
||||||
|
@ -41,6 +45,8 @@ fn build_libtaskchampion(suites: &[&'static str]) {
|
||||||
build.compile("bindings-tests");
|
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]) {
|
fn make_suite_file(suites: &[&'static str]) {
|
||||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
let dest_path = Path::new(&out_dir).join("bindings_test_suites.rs");
|
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");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
let suites = &["uuid", "string", "task", "replica"];
|
let suites = &["uuid", "string", "task", "replica"];
|
||||||
build_libtaskchampion(suites);
|
link_libtaskchampion();
|
||||||
|
build_bindings_tests(suites);
|
||||||
make_suite_file(suites);
|
make_suite_file(suites);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "taskchampion"
|
name = "taskchampion"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["staticlib", "cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2.113"
|
libc = "0.2.113"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue