From 7d9ad1e3d58774c06bd5b189336a8211d0caee9c Mon Sep 17 00:00:00 2001 From: Kesavan Yogeswaran Date: Thu, 15 Apr 2021 18:08:19 -0400 Subject: [PATCH] Bypass codegen for docs.rs build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The codegen performed in the build script returns an error in the docs.rs build environment, as write permissions seem to be locked down. This PR skips the codegen steps in the build script if the `DOCS_RS` environment variable is set. #### Testing I didn't want to pull the 10GB needed to run the Docker images that docs.rs uses. Instead, as a sanity check, I ran `cargo doc --all-features` with and without the `DOCS_RS` environment set and verified via strategically placed `panic!` macros that the build script was bypassed when the variable was set 😬 #### References * * docs.rs page: * Failed build: --- google-cloud/build.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/google-cloud/build.rs b/google-cloud/build.rs index 7c7af44a..695cd780 100644 --- a/google-cloud/build.rs +++ b/google-cloud/build.rs @@ -1,6 +1,13 @@ +use std::env; use std::fs; fn main() -> Result<(), Box> { + // The docs.rs build locks down write permissions and causes codegen to fail. Skip it since + // it's not really needed for rustdoc anyway. + if env::var("DOCS_RS").is_ok() { + return Ok(()); + } + let protos = [ (["protos/google/pubsub/v1/pubsub.proto"], "src/pubsub/api"), (