From ae3851f5a6293ab5889cc56f67505c57408a6e90 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sat, 9 Apr 2022 20:15:00 +0000 Subject: [PATCH 1/3] export taskchampion-lib as an rlib, too --- README.md | 9 ++++++++- lib/Cargo.toml | 2 +- lib/src/lib.rs | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3622cc50e..bc076c792 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ To regenerate this file, run `cargo xtask codegen`. ## C libraries +NOTE: support for linking against taskchampion is a work in progress. +Contributions and pointers to best practices are appreciated! + The `taskchampion-lib` crate generates libraries suitable for use from C (or any C-compatible language). The necessary bits are: @@ -44,8 +47,12 @@ Downstream consumers may use either the static or dynamic library, as they prefe NOTE: on Windows, the "BCrypt" library must be included when linking to taskchampion. +### As a Rust dependency + +If you would prefer to build Taskchampion directly into your project, and have a build system capable of building Rust libraries (such as CMake), the `taskchampion-lib` crate can be referenced as an `rlib` dependency. + ## Documentation Generation The `mdbook` configuration contains a "preprocessor" implemented in the `taskchampion-cli` crate in order to reflect CLI usage information into the generated book. -Tihs preprocessor is not built by default. +This preprocessor is not built by default. To (re)build it, run `cargo build -p taskchampion-cli --features usage-docs --bin usage-docs`. diff --git a/lib/Cargo.toml b/lib/Cargo.toml index af920e560..6f023e859 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -5,7 +5,7 @@ edition = "2018" [lib] name = "taskchampion" -crate-type = ["staticlib", "cdylib"] +crate-type = ["staticlib", "cdylib", "rlib"] [dependencies] libc = "0.2.113" diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 58ab5e6b1..69b83d64b 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -17,17 +17,29 @@ mod traits; mod util; pub mod annotation; +pub use annotation::*; pub mod atomic; +pub use atomic::*; pub mod kv; +pub use kv::*; pub mod replica; +pub use replica::*; pub mod result; +pub use result::*; pub mod server; +pub use server::*; pub mod status; +pub use status::*; pub mod string; +pub use string::*; pub mod task; +pub use task::*; pub mod uda; +pub use uda::*; pub mod uuid; +pub use uuid::*; pub mod workingset; +pub use workingset::*; pub(crate) mod types { pub(crate) use crate::annotation::{TCAnnotation, TCAnnotationList}; From 716a558ba2dfe19c22e122476b67bdd544d2cd06 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 24 Apr 2022 22:49:23 +0000 Subject: [PATCH 2/3] ignore a C code example --- lib/src/string.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/string.rs b/lib/src/string.rs index 65c9dfd9e..de090116b 100644 --- a/lib/src/string.rs +++ b/lib/src/string.rs @@ -411,7 +411,7 @@ impl CList for TCStringList { /// /// For example: /// -/// ``` +/// ```text /// char *url = get_item_url(..); // dynamically allocate C string /// tc_task_annotate(task, tc_string_borrow(url)); // TCString created, passed, and freed /// free(url); // string is no longer referenced and can be freed From ac172b100830a2eabb93762100fd04b925132421 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 24 Apr 2022 22:48:48 +0000 Subject: [PATCH 3/3] Name the C library differently from the crate --- integration-tests/build.rs | 2 +- lib/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/build.rs b/integration-tests/build.rs index 90165f6d0..face5701d 100644 --- a/integration-tests/build.rs +++ b/integration-tests/build.rs @@ -18,7 +18,7 @@ fn link_libtaskchampion() { 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"); + println!("cargo:rustc-link-lib=dylib=taskchampionlib"); // on windows, it appears that rust std requires BCrypt if cfg!(target_os = "windows") { diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 6f023e859..bfc8cc829 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2018" [lib] -name = "taskchampion" +name = "taskchampionlib" crate-type = ["staticlib", "cdylib", "rlib"] [dependencies]