diff --git a/tdlib-rs/build.rs b/tdlib-rs/build.rs index b358785..1e7d0d7 100644 --- a/tdlib-rs/build.rs +++ b/tdlib-rs/build.rs @@ -206,41 +206,43 @@ fn download_tdlib() { } fn main() -> std::io::Result<()> { - #[cfg(all(feature = "docs", feature = "pkg-config"))] - compile_error!( - "feature \"docs\" and feature \"pkg-config\" cannot be enabled at the same time" - ); - #[cfg(all(feature = "docs", feature = "download-tdlib"))] - compile_error!( - "feature \"docs\" and feature \"download-tdlib\" cannot be enabled at the same time" - ); - #[cfg(all(feature = "pkg-config", feature = "download-tdlib"))] - compile_error!( - "feature \"pkg-config\" and feature \"download-tdlib\" cannot be enabled at the same time" - ); + if cfg!(debug_assertions) { + #[cfg(all(feature = "docs", feature = "pkg-config"))] + compile_error!( + "feature \"docs\" and feature \"pkg-config\" cannot be enabled at the same time" + ); + #[cfg(all(feature = "docs", feature = "download-tdlib"))] + compile_error!( + "feature \"docs\" and feature \"download-tdlib\" cannot be enabled at the same time" + ); + #[cfg(all(feature = "pkg-config", feature = "download-tdlib"))] + compile_error!( + "feature \"pkg-config\" and feature \"download-tdlib\" cannot be enabled at the same time" + ); - #[cfg(not(any(feature = "docs", feature = "pkg-config", feature = "download-tdlib")))] - println!("cargo:rerun-if-env-changed=LOCAL_TDLIB_PATH"); + #[cfg(not(any(feature = "docs", feature = "pkg-config", feature = "download-tdlib")))] + println!("cargo:rerun-if-env-changed=LOCAL_TDLIB_PATH"); - println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=build.rs"); - // Prevent linking libraries to avoid documentation failure - #[cfg(not(feature = "docs"))] - { - // It requires the following variables to be set: - // - export PKG_CONFIG_PATH=$HOME/lib/tdlib/lib/pkgconfig/:$PKG_CONFIG_PATH - // - export LD_LIBRARY_PATH=$HOME/lib/tdlib/lib/:$LD_LIBRARY_PATH - #[cfg(feature = "pkg-config")] - system_deps::Config::new().probe().unwrap(); + // Prevent linking libraries to avoid documentation failure + #[cfg(not(feature = "docs"))] + { + // It requires the following variables to be set: + // - export PKG_CONFIG_PATH=$HOME/lib/tdlib/lib/pkgconfig/:$PKG_CONFIG_PATH + // - export LD_LIBRARY_PATH=$HOME/lib/tdlib/lib/:$LD_LIBRARY_PATH + #[cfg(feature = "pkg-config")] + system_deps::Config::new().probe().unwrap(); - #[cfg(feature = "download-tdlib")] - download_tdlib(); + #[cfg(feature = "download-tdlib")] + download_tdlib(); - #[cfg(not(feature = "pkg-config"))] - { - #[cfg(not(feature = "download-tdlib"))] - copy_local_tdlib(); - generic_build(); + #[cfg(not(feature = "pkg-config"))] + { + #[cfg(not(feature = "download-tdlib"))] + copy_local_tdlib(); + generic_build(); + } } } diff --git a/tdlib-rs/src/build.rs b/tdlib-rs/src/build.rs new file mode 100644 index 0000000..81948a7 --- /dev/null +++ b/tdlib-rs/src/build.rs @@ -0,0 +1,14 @@ +pub fn check_features() { + #[cfg(all(feature = "docs", feature = "pkg-config"))] + compile_error!( + "feature \"docs\" and feature \"pkg-config\" cannot be enabled at the same time" + ); + #[cfg(all(feature = "docs", feature = "download-tdlib"))] + compile_error!( + "feature \"docs\" and feature \"download-tdlib\" cannot be enabled at the same time" + ); + #[cfg(all(feature = "pkg-config", feature = "download-tdlib"))] + compile_error!( + "feature \"pkg-config\" and feature \"download-tdlib\" cannot be enabled at the same time" + ); +} diff --git a/tdlib-rs/src/lib.rs b/tdlib-rs/src/lib.rs index 3b2be81..67dacca 100644 --- a/tdlib-rs/src/lib.rs +++ b/tdlib-rs/src/lib.rs @@ -10,6 +10,7 @@ mod generated; mod observer; mod tdjson; +pub mod build; pub use generated::{enums, functions, types};