Skip to content

Commit 4aec1a5

Browse files
BurntSushikbknapp
authored andcommitted
Query OUT_DIR at runtime. (#770)
It seems that Cargo no longer sets OUT_DIR when compiling build.rs, but it's still available at runtime. Therefore, switch `env!` to `env::var_os`.
1 parent b225cdb commit 4aec1a5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/app/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,14 @@ impl<'a, 'b> App<'a, 'b> {
11111111
/// include!("src/cli.rs");
11121112
///
11131113
/// fn main() {
1114+
/// let outdir = match env::var_os("OUT_DIR") {
1115+
/// None => return,
1116+
/// Some(outdir) => outdir,
1117+
/// };
11141118
/// let mut app = build_cli();
1115-
/// app.gen_completions("myapp", // We need to specify the bin name manually
1116-
/// Shell::Bash, // Then say which shell to build completions for
1117-
/// env!("OUT_DIR")); // Then say where write the completions to
1119+
/// app.gen_completions("myapp", // We need to specify the bin name manually
1120+
/// Shell::Bash, // Then say which shell to build completions for
1121+
/// outdir); // Then say where write the completions to
11181122
/// }
11191123
/// ```
11201124
/// Now, once we combile there will be a `{bin_name}.bash-completion` file in the directory.

0 commit comments

Comments
 (0)