Skip to content

Commit

Permalink
Panic with clear message when tonic_build OUT env is not set
Browse files Browse the repository at this point in the history
Summary:
I was sloppy in D44322620 and:

1. Used `std::env::var` instead of `std::env::var_os`. The former does
   `OsString` to `String` conversion, which we don't care about because
   `.out_dir` expects `AsRef<Path>`.
2. Used `.unwrap` without including a message as to what expectation is
   being violated.

In D44324686 I was sloppy by leaving a needless borrow.

Reviewed By: yuyashiraki

Differential Revision: D44324930

fbshipit-source-id: f5b0152793d8537c70398ed83402fb6301b72f16
  • Loading branch information
zertosh authored and facebook-github-bot committed Mar 23, 2023
1 parent d4eba22 commit 9b1a2fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions protocol-rpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
"suidcreate.proto",
];
let out_env = if cfg!(fbcode_build) { "OUT" } else { "OUT_DIR" };
let out_dir = std::env::var_os(out_env).unwrap_or_else(|| panic!("env `{out_env}` not set"));
let out_dir = std::env::var_os(out_env).unwrap_or_else(|| panic!("env `{out_env}` is not set"));

tonic_build::configure()
.out_dir(&out_dir)
.out_dir(out_dir)
.compile(
proto_files,
// HACK: we need '.' directory for build with Buck
Expand Down

0 comments on commit 9b1a2fc

Please sign in to comment.