diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-07-02 19:59:52 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-07-02 20:07:43 +0200 |
| commit | ebfdb1dafa430786db10dad2ef7d5467c1bdbed1 (patch) | |
| tree | 2bbc24ddb4124c4bb14dec0e536129d4de37b056 /cli/build.rs | |
| parent | 3ab19185093d7709f824b95b979060ce125389d8 (diff) | |
Move everything into `crates/` directory
Diffstat (limited to 'cli/build.rs')
| -rw-r--r-- | cli/build.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/cli/build.rs b/cli/build.rs deleted file mode 100644 index 86325e1d..00000000 --- a/cli/build.rs +++ /dev/null @@ -1,60 +0,0 @@ -use std::env; -use std::fs::{create_dir_all, File}; -use std::path::Path; -use std::process::Command; - -use clap::{CommandFactory, ValueEnum}; -use clap_complete::{generate_to, Shell}; -use clap_mangen::Man; - -#[path = "src/args.rs"] -#[allow(dead_code)] -mod args; - -fn main() { - println!("cargo:rerun-if-env-changed=TYPST_VERSION"); - println!("cargo:rerun-if-env-changed=GEN_ARTIFACTS"); - - if option_env!("TYPST_VERSION").is_none() { - println!("cargo:rustc-env=TYPST_VERSION={}", typst_version()); - } - - if let Some(dir) = env::var_os("GEN_ARTIFACTS") { - let out = &Path::new(&dir); - create_dir_all(out).unwrap(); - let cmd = &mut args::CliArguments::command(); - - Man::new(cmd.clone()) - .render(&mut File::create(out.join("typst.1")).unwrap()) - .unwrap(); - - for subcmd in cmd.get_subcommands() { - let name = format!("typst-{}", subcmd.get_name()); - Man::new(subcmd.clone().name(&name)) - .render(&mut File::create(out.join(format!("{name}.1"))).unwrap()) - .unwrap(); - } - - for shell in Shell::value_variants() { - generate_to(*shell, cmd, "typst", out).unwrap(); - } - } -} - -/// Also used by `args.rs`. -fn typst_version() -> String { - if let Some(version) = option_env!("TYPST_VERSION") { - return version.to_owned(); - } - - let pkg = env!("CARGO_PKG_VERSION"); - let hash = Command::new("git") - .args(["rev-parse", "HEAD"]) - .output() - .ok() - .filter(|output| output.status.success()) - .and_then(|output| String::from_utf8(output.stdout.get(..8)?.into()).ok()) - .unwrap_or_else(|| "unknown hash".into()); - - format!("{pkg} ({hash})") -} |
