diff --git a/Cargo.lock b/Cargo.lock index 31493fe..6f181ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "eric-bindings" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "bindgen", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "eric-sdk" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "eric-bindings", diff --git a/eric-bindings/CHANGELOG.md b/eric-bindings/CHANGELOG.md index 0d6dc66..8f86a42 100644 --- a/eric-bindings/CHANGELOG.md +++ b/eric-bindings/CHANGELOG.md @@ -6,6 +6,11 @@ - changed - removed +## v0.4.1 (2024-08-07) + +- changed + - Fix publishing on docs.rs + ## v0.4.0 (2024-08-07) - added diff --git a/eric-bindings/Cargo.toml b/eric-bindings/Cargo.toml index a5746ce..0e2faf8 100644 --- a/eric-bindings/Cargo.toml +++ b/eric-bindings/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eric-bindings" -version = "0.4.0" +version = "0.4.1" authors.workspace = true edition.workspace = true readme.workspace = true @@ -13,14 +13,20 @@ keywords = ["eric", "bindings", "taxes", "accounting"] categories = ["external-ffi-bindings"] build = "build.rs" +[lib] +path = "src/lib.rs" +name = "eric_bindings" + +[package.metadata.docs.rs] +features = ["docs-rs"] + [features] default = [] generate-bindings = ["dep:bindgen"] +# This feature is used in CI pipeline for unit tests. no-linking = [] - -[lib] -path = "src/lib.rs" -name = "eric_bindings" +# This feature is used to publish the documentation for `eric-bindings`. +docs-rs = [] [dependencies] anyhow = { workspace = true } diff --git a/eric-bindings/build.rs b/eric-bindings/build.rs index 9d6a436..b787518 100644 --- a/eric-bindings/build.rs +++ b/eric-bindings/build.rs @@ -29,13 +29,20 @@ pub fn main() -> io::Result<()> { generate_bindings()?; #[cfg(not(feature = "generate-bindings"))] - select_bindings()?; + { + #[cfg(not(feature = "docs-rs"))] + select_bindings()?; + + #[cfg(feature = "docs-rs")] + select_bindings_for_docs_rs()?; + } Ok(()) } /// Select existing bindings #[cfg(not(feature = "generate-bindings"))] +#[cfg(not(feature = "docs-rs"))] fn select_bindings() -> io::Result<()> { let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").expect("Set by cargo"); let is_windows = std::env::var("CARGO_CFG_WINDOWS").is_ok(); @@ -126,3 +133,24 @@ fn generate_bindings() -> io::Result<()> { Ok(()) } + +/// Select latest bindings for documentation on docs.rs +#[cfg(feature = "docs-rs")] +fn select_bindings_for_docs_rs() -> io::Result<()> { + let bindings_file = "bindings_eric_40_1_8_0_linux_x86_64.rs"; + + let root_dir = std::env::var("CARGO_MANIFEST_DIR").expect("Set by cargo"); + let bindings_path = Path::new(&root_dir).join("bindings").join(bindings_file); + + let out_dir = env::var("OUT_DIR").expect("Can't read environment variable 'OUT_DIR'"); + let bindings_target = PathBuf::from(out_dir).join("bindings.rs"); + + std::fs::copy(bindings_path.clone(), bindings_target.clone()).unwrap_or_else(|_| { + panic!( + "Can't copy file from {} to {}", + bindings_path.display(), + bindings_target.display(), + ) + }); + Ok(()) +} diff --git a/eric-sdk/CHANGELOG.md b/eric-sdk/CHANGELOG.md index 92c9ebe..3b51f8d 100644 --- a/eric-sdk/CHANGELOG.md +++ b/eric-sdk/CHANGELOG.md @@ -6,6 +6,11 @@ - changed - removed +## v0.3.1 (2024-08-07) + +- changed + - Fix publishing on docs.rs + ## v0.3.0 (2024-08-07) - added diff --git a/eric-sdk/Cargo.toml b/eric-sdk/Cargo.toml index bae4408..467f0fa 100644 --- a/eric-sdk/Cargo.toml +++ b/eric-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eric-sdk" -version = "0.3.0" +version = "0.3.1" authors.workspace = true edition.workspace = true readme.workspace = true @@ -16,13 +16,19 @@ categories = ["finance"] path = "src/lib.rs" name = "eric_sdk" +[package.metadata.docs.rs] +features = ["docs-rs"] + [features] default = [] -no-linking = ["eric-bindings/no-linking"] external-test = [] +# This feature is used in CI pipeline for unit tests. +no-linking = ["eric-bindings/no-linking"] +# This feature is used to publish the documentation for `eric-sdk`. +docs-rs = ["eric-bindings/docs-rs"] [dependencies] -eric-bindings = { version = "0.4.0", path = "../eric-bindings" } +eric-bindings = { version = "0.4.1", path = "../eric-bindings" } anyhow = { workspace = true } [dev-dependencies]