Skip to content

Commit

Permalink
feature: make it possible to override generate dirs via env
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimian committed Jan 7, 2025
1 parent c9ffc41 commit 527646b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 9 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
mod args;

use std::{
env, fs, io,
env,
ffi::OsString,
fs, io,
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -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)?;
Expand Down
3 changes: 3 additions & 0 deletions docs/content/contribution/packaging-and-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down

0 comments on commit 527646b

Please sign in to comment.