diff options
author | Andrew Gallant <jamslam@gmail.com> | 2023-10-14 09:31:19 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2023-11-20 23:51:53 -0500 |
commit | 5b88515faf67b1a9e5541a2130a6bebf3bd21c89 (patch) | |
tree | 0a7acc3a92250a0337966b3db1cf06f32e18d5a5 /build.rs | |
parent | 92c81b122548ab42586314ea535bb46ea41f1b10 (diff) |
build: a bit of clean-up
This does just a smidge of polishing in the build script source code.
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 50 |
1 files changed, 24 insertions, 26 deletions
@@ -1,12 +1,14 @@ -use std::env; -use std::fs::{self, File}; -use std::io::{self, Read, Write}; -use std::path::Path; -use std::process; +use std::{ + env, + fs::{self, File}, + io::{self, Read, Write}, + path::Path, + process, +}; use clap::Shell; -use app::{RGArg, RGArgKind}; +use crate::app::{RGArg, RGArgKind}; #[allow(dead_code)] #[path = "crates/core/app.rs"] @@ -15,16 +17,13 @@ mod app; fn main() { // OUT_DIR is set by Cargo and it's where any additional build artifacts // are written. - let outdir = match env::var_os("OUT_DIR") { - Some(outdir) => outdir, - None => { - eprintln!( - "OUT_DIR environment variable not defined. \ - Please file a bug: \ - https://github.com/BurntSushi/ripgrep/issues/new" - ); - process::exit(1); - } + let Some(outdir) = env::var_os("OUT_DIR") else { + eprintln!( + "OUT_DIR environment variable not defined. \ + Please file a bug: \ + https://github.com/BurntSushi/ripgrep/issues/new" + ); + process::exit(1); }; fs::create_dir_all(&outdir).unwrap(); @@ -79,17 +78,16 @@ fn set_windows_exe_options() { } fn git_revision_hash() -> Option<String> { - let result = process::Command::new("git") + let output = process::Command::new("git") .args(&["rev-parse", "--short=10", "HEAD"]) - .output(); - result.ok().and_then(|output| { - let v = String::from_utf8_lossy(&output.stdout).trim().to_string(); - if v.is_empty() { - None - } else { - Some(v) - } - }) + .output() + .ok()?; + let v = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if v.is_empty() { + None + } else { + Some(v) + } } fn generate_man_page<P: AsRef<Path>>(outdir: P) -> io::Result<()> { |