Repository: tokio-rs/prost (language: rust)

Issue:
prost-build 0.2.0 docs.rs generation failed
https://docs.rs/crate/prost-build/0.2.0


Discussion / hints:
I looked into this a little bit.  I believe this can't be fixed until docs.rs has a way to inject environment variables into calls to `rustdoc`.  Docs.rs [recently landed](https://github.com/onur/docs.rs/pull/131) a bunch of support for options via a `[package.metadata.docs.rs]` section in the crate `Cargo.toml`, but environment variables aren't yet supported.

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index ea8692b71..dc06b324f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "prost"
 # NB: When modifying, also modify html_root_url in lib.rs
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Dan Burkert <dan@danburkert.com>"]
 license = "Apache-2.0"
 repository = "https://github.com/danburkert/prost"
diff --git a/prost-build/Cargo.toml b/prost-build/Cargo.toml
index e9f5e4bfd..2b7a48201 100644
--- a/prost-build/Cargo.toml
+++ b/prost-build/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "prost-build"
 # NB: When modifying, also modify html_root_url in lib.rs
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Dan Burkert <dan@danburkert.com>"]
 license = "Apache-2.0"
 repository = "https://github.com/danburkert/prost"
diff --git a/prost-build/build.rs b/prost-build/build.rs
index a83fb384b..629172165 100644
--- a/prost-build/build.rs
+++ b/prost-build/build.rs
@@ -39,6 +39,8 @@ fn main() {
 
     println!("cargo:rustc-env=PROTOC={}", protoc.display());
     println!("cargo:rustc-env=PROTOC_INCLUDE={}", protoc_dir.join("include").display());
+    println!("cargo:rerun-if-env-changed=PROTOC");
+    println!("cargo:rerun-if-env-changed=PROTOC_INCLUDE");
 }
 
 /// Returns `true` if the environment already contains the `PROTOC` and `PROTOC_INCLUDE` variables.
@@ -66,6 +68,8 @@ fn env_contains_protoc() -> bool {
     // Even if PROTOC and PROTOC_INCLUDE are set in the environment, still 
     println!("cargo:rustc-env=PROTOC={}", protoc.display());
     println!("cargo:rustc-env=PROTOC_INCLUDE={}", protoc_include.display());
+    println!("cargo:rerun-if-env-changed=PROTOC");
+    println!("cargo:rerun-if-env-changed=PROTOC_INCLUDE");
     true
 }
 
diff --git a/prost-build/src/lib.rs b/prost-build/src/lib.rs
index f9fc138e9..b07d1a93d 100644
--- a/prost-build/src/lib.rs
+++ b/prost-build/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/prost-build/0.2.1")]
+#![doc(html_root_url = "https://docs.rs/prost-build/0.2.2")]
 
 //! `prost-build` compiles `.proto` files into Rust.
 //!
@@ -142,11 +142,6 @@ use std::process::Command;
 use prost::Message;
 use prost_types::{FileDescriptorProto, FileDescriptorSet};
 
-/// Path to the `protoc` binary.
-pub const PROTOC: &'static str = env!("PROTOC");
-/// Path to the Protobuf include directory.
-pub const PROTOC_INCLUDE: &'static str = env!("PROTOC_INCLUDE");
-
 pub use ast::{
     Comments,
     Method,
@@ -295,7 +290,7 @@ impl Config {
         let tmp = tempdir::TempDir::new("prost-build")?;
         let descriptor_set = tmp.path().join("prost-descriptor-set");
 
-        let mut cmd = Command::new(PROTOC);
+        let mut cmd = Command::new(protoc());
         cmd.arg("--include_imports")
         .arg("--include_source_info")
         .arg("-o").arg(&descriptor_set);
@@ -306,7 +301,7 @@ impl Config {
 
         // Set the protoc include after the user includes in case the user wants to
         // override one of the built-in .protos.
-        cmd.arg("-I").arg(PROTOC_INCLUDE);
+        cmd.arg("-I").arg(protoc_include());
 
         for proto in protos {
             cmd.arg(proto.as_ref());
@@ -406,6 +401,16 @@ pub fn compile_protos<P>(protos: &[P], includes: &[P]) -> Result<()> where P: As
     Config::new().compile_protos(protos, includes)
 }
 
+/// Returns the path to the `protoc` binary.
+pub fn protoc() -> &'static Path {
+    Path::new(env!("PROTOC"))
+}
+
+/// Returns the path to the Protobuf include directory.
+pub fn protoc_include() -> &'static Path {
+    Path::new(env!("PROTOC_INCLUDE"))
+}
+
 #[cfg(test)]
 mod tests {
     extern crate env_logger;
diff --git a/prost-derive/Cargo.toml b/prost-derive/Cargo.toml
index c7f52a2cb..f08185c8d 100644
--- a/prost-derive/Cargo.toml
+++ b/prost-derive/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "prost-derive"
 # NB: When modifying, also modify html_root_url in lib.rs
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Dan Burkert <dan@danburkert.com>"]
 license = "Apache-2.0"
 repository = "https://github.com/danburkert/prost"
diff --git a/prost-derive/src/lib.rs b/prost-derive/src/lib.rs
index a0e14a188..820cf1e70 100644
--- a/prost-derive/src/lib.rs
+++ b/prost-derive/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/prost-derive/0.2.1")]
+#![doc(html_root_url = "https://docs.rs/prost-derive/0.2.2")]
 // The `quote!` macro requires deep recursion.
 #![recursion_limit = "4096"]
 
diff --git a/prost-types/Cargo.toml b/prost-types/Cargo.toml
index c3748e276..2785d6df7 100644
--- a/prost-types/Cargo.toml
+++ b/prost-types/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "prost-types"
 # NB: When modifying, also modify html_root_url in lib.rs
-version = "0.2.1"
+version = "0.2.2"
 authors = ["Dan Burkert <dan@danburkert.com>"]
 license = "Apache-2.0"
 repository = "https://github.com/danburkert/prost"
diff --git a/prost-types/src/lib.rs b/prost-types/src/lib.rs
index facb5c072..fe2cb7a9c 100644
--- a/prost-types/src/lib.rs
+++ b/prost-types/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/prost-codegen/0.2.1")]
+#![doc(html_root_url = "https://docs.rs/prost-codegen/0.2.2")]
 
 //! Protocol Buffers well-known types.
 //!
diff --git a/src/lib.rs b/src/lib.rs
index cb093d040..3eacfd5da 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/prost/0.2.1")]
+#![doc(html_root_url = "https://docs.rs/prost/0.2.2")]
 
 extern crate bytes;
 


Test patch:
diff --git a/tests/src/bootstrap.rs b/tests/src/bootstrap.rs
index 8745e3cf7..2ef0f779a 100644
--- a/tests/src/bootstrap.rs
+++ b/tests/src/bootstrap.rs
@@ -11,7 +11,7 @@ use prost_build;
 /// repo. Ensures that the checked-in compiled versions are up-to-date.
 #[test]
 fn bootstrap() {
-    let protobuf = Path::new(prost_build::PROTOC_INCLUDE).join("google").join("protobuf");
+    let protobuf = Path::new(prost_build::protoc_include()).join("google").join("protobuf");
 
     let tempdir = tempdir::TempDir::new("prost-types-bootstrap").unwrap();
     env::set_var("OUT_DIR", tempdir.path());