diff --git a/Cargo.toml b/Cargo.toml index 0c80e1f2f..0258f3d44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -93,6 +93,10 @@ optional = true # warnings. no-target-warning = [] +# Indicates to the build script that we're building docs, and it can skip +# whatever might not work or is not necessary. +docs = [] + # Internal implementation detail. Used by HAL code to determine the exact # hardware capabilites. 20 = [] @@ -188,4 +192,4 @@ opt-level = "s" [package.metadata.docs.rs] -features = ["845"] +features = ["845", "docs"] diff --git a/build.rs b/build.rs index fa464fb4a..0fa1e72f6 100644 --- a/build.rs +++ b/build.rs @@ -11,6 +11,16 @@ use termion::{color, style}; fn main() -> Result<(), Error> { let target = Target::read(); + // Nothing this build script does after this point is required when + // generating documentation. + // + // In addition, the docs.rs build environment has a read-only file system, + // meaning an attempt to run this build script will fail the whole build for + // no reason. + if cfg!(feature = "docs") { + return Ok(()); + } + copy_openocd_config(target)?; copy_memory_config(target)?;