diff --git a/Cargo.lock b/Cargo.lock index b763839..49fd8c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -297,7 +297,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "phnt" -version = "0.0.19" +version = "0.0.20" dependencies = [ "bindgen", "chrono", diff --git a/Cargo.toml b/Cargo.toml index f1ca64f..fae5746 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,12 +10,14 @@ build = "src/build.rs" description = "Rust bindings to the System Informer's (formerly known as Process Hacker) `phnt` native Windows headers" # exclude = ["deps"] +[features] +vendored = [] + [package.metadata.docs.rs] all-features = true default-target = "x86_64-pc-windows-msvc" targets = ["x86_64-pc-windows-msvc"] -rustdoc-args = ["--cfg=docsrs"] -rustc-args = ["--cfg=docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [build-dependencies] windows.features = ["Win32_Foundation"] diff --git a/src/build.rs b/src/build.rs index aa0a683..ff8ac4d 100644 --- a/src/build.rs +++ b/src/build.rs @@ -109,13 +109,15 @@ impl BindgenConfig { } } -#[cfg(not(docsrs))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "vendored", docsrs))))] +#[cfg(any(feature = "vendored", docsrs))] fn main() { - if cfg!(docsrs) { - println!("Skipping regeneration of bindings for docs.rs."); - return; - } + println!("Using vendored bindings, build script skipped."); +} +#[cfg_attr(docsrs, doc(cfg(all(not(feature = "vendored"), not(docsrs)))))] +#[cfg(all(not(feature = "vendored"), not(docsrs)))] +fn main() { std::process::Command::new("git") .args(["submodule", "update", "--remote", "--recursive"]) .output() diff --git a/src/lib.rs b/src/lib.rs index 58356ec..0d3a876 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // +#![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] #![allow( warnings, @@ -31,12 +32,14 @@ /// Bindings for `phnt` (nightly) generated by `bindgen` pub mod ffi { - // use vendored `generated.rs` for docs.rs - #[cfg(docsrs)] + // use vendored bindings + #[cfg_attr(docsrs, doc(cfg(any(feature = "vendored", docsrs))))] + #[cfg(any(feature = "vendored", docsrs))] include!("ffi/generated.rs"); - // use regenerated bindings in production - #[cfg(not(docsrs))] + // use re-generated bindings + #[cfg_attr(docsrs, doc(cfg(all(not(feature = "vendored"), not(docsrs)))))] + #[cfg(all(not(feature = "vendored"), not(docsrs)))] include!(concat!(env!("OUT_DIR"), "\\generated.rs")); }