diff --git a/build.rs b/build.rs index fa08efebf..1529d23fb 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,9 @@ mod args; use std::{ - env, fs, io, + env, + ffi::OsString, + fs, io, path::{Path, PathBuf}, }; @@ -38,11 +40,13 @@ fn btm_generate() -> io::Result<()> { match env::var_os(ENV_KEY) { Some(var) if !var.is_empty() => { - const COMPLETION_DIR: &str = "./target/tmp/bottom/completion/"; - const MANPAGE_DIR: &str = "./target/tmp/bottom/manpage/"; + let completion_dir = env::var_os("COMPLETION_DIR") + .unwrap_or(OsString::from("./target/tmp/bottom/completion/")); + let manpage_dir = env::var_os("MANPAGE_DIR") + .unwrap_or(OsString::from("./target/tmp/bottom/manpage/")); - let completion_out_dir = PathBuf::from(COMPLETION_DIR); - let manpage_out_dir = PathBuf::from(MANPAGE_DIR); + let completion_out_dir = PathBuf::from(completion_dir); + let manpage_out_dir = PathBuf::from(manpage_dir); create_dir(&completion_out_dir)?; create_dir(&manpage_out_dir)?; diff --git a/docs/content/contribution/packaging-and-distribution.md b/docs/content/contribution/packaging-and-distribution.md index a41384c31..0107465ba 100644 --- a/docs/content/contribution/packaging-and-distribution.md +++ b/docs/content/contribution/packaging-and-distribution.md @@ -54,6 +54,9 @@ This will automatically generate completion and manpage files in `target/tmp/bot files, modify/delete either these files or set `BTM_GENERATE` to some other non-empty value to retrigger the build script. +You may override the default diretories used to generate both completion and manpage files by specifying the +`COMPLETION_DIR` and `MANPAGE_DIR` environment variables respectively. + For more information, you may want to look at either the [`build.rs`](https://github.com/ClementTsang/bottom/blob/main/build.rs) file or the [binary build CI workflow](https://github.com/ClementTsang/bottom/blob/main/.github/workflows/build_releases.yml).