Generate man pages to non-Cargo directory
This is much less fragile than messing with `OUT_DIR`, whose location relative to the `target` directory is purposefully underspecified.
This commit is contained in:
parent
64e1a04c40
commit
d7f6757a78
3 changed files with 13 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ target
|
|||
*.out.png
|
||||
/.idea
|
||||
/node_modules
|
||||
/generated
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ panic = "abort"
|
|||
[package.metadata.deb]
|
||||
assets = [
|
||||
["target/release/oxipng", "usr/bin/", "755"],
|
||||
["target/assets/oxipng.1", "usr/share/man/man1/", "644"],
|
||||
["generated/assets/oxipng.1", "usr/share/man/man1/", "644"],
|
||||
["README.md", "usr/share/doc/oxipng/", "644"],
|
||||
["CHANGELOG.md", "usr/share/doc/oxipng/", "644"],
|
||||
]
|
||||
|
|
|
|||
23
build.rs
23
build.rs
|
|
@ -1,5 +1,11 @@
|
|||
use std::{
|
||||
env,
|
||||
fs::File,
|
||||
io::{BufWriter, Error},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use clap_mangen::Man;
|
||||
use std::{env, fs::File, io::Error, path::Path};
|
||||
|
||||
include!("src/cli.rs");
|
||||
|
||||
|
|
@ -7,7 +13,7 @@ fn build_manpages(outdir: &Path) -> Result<(), Error> {
|
|||
let app = build_command();
|
||||
|
||||
let file = Path::new(&outdir).join("oxipng.1");
|
||||
let mut file = File::create(file)?;
|
||||
let mut file = BufWriter::new(File::create(file)?);
|
||||
|
||||
Man::new(app).render(&mut file)?;
|
||||
|
||||
|
|
@ -16,17 +22,10 @@ fn build_manpages(outdir: &Path) -> Result<(), Error> {
|
|||
|
||||
fn main() -> Result<(), Error> {
|
||||
println!("cargo:rerun-if-changed=src/cli.rs");
|
||||
println!("cargo:rerun-if-changed=man");
|
||||
println!("cargo:rerun-if-changed=src/display_chunks.rs");
|
||||
|
||||
let outdir = match env::var_os("OUT_DIR") {
|
||||
None => return Ok(()),
|
||||
Some(outdir) => outdir,
|
||||
};
|
||||
|
||||
// Create `target/assets/` folder.
|
||||
let out_path = PathBuf::from(outdir);
|
||||
let mut path = out_path.ancestors().nth(4).unwrap().to_owned();
|
||||
path.push("assets");
|
||||
// Create `generated/assets/` folder.
|
||||
let path = env::current_dir()?.join("generated").join("assets");
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
|
||||
build_manpages(&path)?;
|
||||
|
|
|
|||
Loading…
Reference in a new issue