-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.rs
34 lines (30 loc) · 949 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-FileCopyrightText: 2022 Shun Sakai
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
use std::{
env, io,
process::{Command, ExitStatus},
};
fn generate_man_page(out_dir: &str) -> io::Result<ExitStatus> {
let man_dir = env::current_dir()?.join("docs/man/man1");
let mut command = Command::new("asciidoctor");
command
.args(["-b", "manpage"])
.args(["-D", out_dir])
.arg(man_dir.join("*.1.adoc"))
.status()
}
fn main() {
println!("cargo:rerun-if-changed=docs/man");
let out_dir = env::var("OUT_DIR").expect("environment variable `OUT_DIR` not defined");
match generate_man_page(&out_dir) {
Ok(exit_status) => {
if !exit_status.success() {
println!("cargo:warning=Asciidoctor failed: {exit_status}");
}
}
Err(err) => {
println!("cargo:warning=failed to execute Asciidoctor: {err}");
}
}
}