parent
2580e26ba5
commit
0ea5ef9fad
@ -29,4 +29,7 @@ cargo build
|
||||
```
|
||||
|
||||
The above creates the `sq` executable, the manual pages, and its shell
|
||||
completions.
|
||||
completions. By default, the manual pages and shell completions are
|
||||
put into the `cargo` target directory, but the exact location is
|
||||
unpredictable. To write the assets to a predictable location, set the
|
||||
environment variable `ASSET_OUT_DIR` to a suitable location.
|
||||
|
14
build.rs
14
build.rs
@ -30,11 +30,21 @@ fn main() {
|
||||
generate_man_pages(&sq).unwrap();
|
||||
}
|
||||
|
||||
/// Variable name to control the asset out directory with.
|
||||
const ASSET_OUT_DIR: &str = "ASSET_OUT_DIR";
|
||||
|
||||
/// Returns the directory to write the given assets to.
|
||||
fn asset_out_dir(asset: &str) -> Result<PathBuf> {
|
||||
println!("cargo:rerun-if-env-changed={}", ASSET_OUT_DIR);
|
||||
let outdir: PathBuf =
|
||||
env::var_os("OUT_DIR").expect("OUT_DIR not set").into();
|
||||
assert!(outdir.is_dir());
|
||||
env::var_os(ASSET_OUT_DIR).unwrap_or_else(
|
||||
|| env::var_os("OUT_DIR").expect("OUT_DIR not set")).into();
|
||||
if outdir.exists() && ! outdir.is_dir() {
|
||||
return Err(
|
||||
anyhow::anyhow!("{}={:?} is not a directory",
|
||||
ASSET_OUT_DIR, outdir));
|
||||
}
|
||||
|
||||
let path = outdir.join(asset);
|
||||
fs::create_dir_all(&path)?;
|
||||
Ok(path)
|
||||
|
Loading…
Reference in New Issue
Block a user