-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skipping protobuf code generation on docs.rs (#74)
Signed-off-by: Max Lambrecht <[email protected]>
- Loading branch information
1 parent
7e18d55
commit 68f5dc6
Showing
2 changed files
with
35 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
use std::fs; | ||
use std::{env, fs}; | ||
|
||
fn main() -> Result<(), anyhow::Error> { | ||
let mut proto_config = prost_build::Config::new(); | ||
proto_config.bytes(["."]); | ||
tonic_build::configure() | ||
.build_client(true) | ||
.out_dir("src/proto") | ||
.compile_with_config(proto_config, &["src/proto/workload.proto"], &["src/proto"])?; | ||
|
||
fs::rename("src/proto/_.rs", "src/proto/workload.rs")?; | ||
// Check if this is a docs.rs build | ||
let is_docs_rs = env::var_os("DOCS_RS").is_some(); | ||
|
||
if !is_docs_rs { | ||
let mut proto_config = prost_build::Config::new(); | ||
proto_config.bytes(["."]); | ||
tonic_build::configure() | ||
.build_client(true) | ||
.out_dir("src/proto") | ||
.compile_with_config(proto_config, &["src/proto/workload.proto"], &["src/proto"])?; | ||
|
||
fs::rename("src/proto/_.rs", "src/proto/workload.rs")?; | ||
} else { | ||
println!("cargo:warning=Skipping protobuf code generation on docs.rs."); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
use std::env; | ||
|
||
fn main() -> Result<(), anyhow::Error> { | ||
let mut proto_config = prost_build::Config::new(); | ||
proto_config.bytes(["."]); | ||
tonic_build::configure() | ||
.build_client(true) | ||
.out_dir("src/proto") | ||
.compile_with_config( | ||
proto_config, | ||
&["spire-api-sdk/proto/spire/api/agent/delegatedidentity/v1/delegatedidentity.proto"], | ||
&["spire-api-sdk/proto"], | ||
)?; | ||
// Check if this is a docs.rs build | ||
let is_docs_rs = env::var_os("DOCS_RS").is_some(); | ||
|
||
if !is_docs_rs { | ||
let mut proto_config = prost_build::Config::new(); | ||
proto_config.bytes(["."]); | ||
tonic_build::configure() | ||
.build_client(true) | ||
.out_dir("src/proto") | ||
.compile_with_config( | ||
proto_config, | ||
&["spire-api-sdk/proto/spire/api/agent/delegatedidentity/v1/delegatedidentity.proto"], | ||
&["spire-api-sdk/proto"], | ||
)?; | ||
} else { | ||
println!("cargo:warning=Skipping protobuf code generation on docs.rs."); | ||
} | ||
|
||
Ok(()) | ||
} |