cyclonedds_src/lib.rs
1//! Source distribution of Eclipse CycloneDDS C library.
2//!
3//! This crate bundles the CycloneDDS C source code so that downstream
4//! `cyclonedds-rust-sys` can build it from source when no system library
5//! is available.
6//!
7//! # Usage
8//!
9//! Typically used as a `build-dependency` in `cyclonedds-rust-sys`:
10//!
11//! ```toml
12//! [build-dependencies]
13//! cyclonedds-src = "0.1"
14//! ```
15//!
16//! Then in `build.rs`:
17//!
18//! ```no_run
19//! let src = cyclonedds_src::source_dir();
20//! // build with cmake
21//! ```
22
23use std::path::PathBuf;
24
25/// Return the directory containing the CycloneDDS C source tree.
26///
27/// This can be passed to `cmake::Config` or used directly in a build script.
28pub fn source_dir() -> PathBuf {
29 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/cyclonedds")
30}
31
32/// Return the directory where the C headers are located.
33pub fn include_dir() -> PathBuf {
34 source_dir().join("src/core/ddsc/include")
35}
36
37/// Return the directory where the generated config header is expected.
38pub fn build_include_dir() -> PathBuf {
39 // This is set by the downstream build script after running cmake.
40 PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default())
41 .join("cyclonedds-build")
42 .join("src")
43 .join("core")
44}