mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Use anyhow in build script
This commit is contained in:
		
				
					committed by
					
						 Martin Nordholts
						Martin Nordholts
					
				
			
			
				
	
			
			
			
						parent
						
							b000db8f32
						
					
				
				
					commit
					28d947fd8b
				
			
							
								
								
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -74,6 +74,12 @@ dependencies = [ | ||||
|  "windows-sys 0.48.0", | ||||
| ] | ||||
|  | ||||
| [[package]] | ||||
| name = "anyhow" | ||||
| version = "1.0.75" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" | ||||
|  | ||||
| [[package]] | ||||
| name = "assert_cmd" | ||||
| version = "2.0.12" | ||||
| @@ -106,6 +112,7 @@ name = "bat" | ||||
| version = "0.24.0" | ||||
| dependencies = [ | ||||
|  "ansi_colours", | ||||
|  "anyhow", | ||||
|  "assert_cmd", | ||||
|  "bincode", | ||||
|  "bugreport", | ||||
|   | ||||
| @@ -98,6 +98,9 @@ tempfile = "3.8.1" | ||||
| [target.'cfg(unix)'.dev-dependencies] | ||||
| nix = { version = "0.26.4", default-features = false, features = ["term"] } | ||||
|  | ||||
| [build-dependencies] | ||||
| anyhow = "1.0.75" | ||||
|  | ||||
| [build-dependencies.clap] | ||||
| version = "4.4.6" | ||||
| optional = true | ||||
|   | ||||
							
								
								
									
										13
									
								
								build.rs
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								build.rs
									
									
									
									
									
								
							| @@ -4,9 +4,8 @@ | ||||
| fn main() {} | ||||
|  | ||||
| #[cfg(feature = "application")] | ||||
| fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
| fn main() -> anyhow::Result<()> { | ||||
|     use std::collections::HashMap; | ||||
|     use std::error::Error; | ||||
|     use std::fs; | ||||
|     use std::path::Path; | ||||
|  | ||||
| @@ -21,7 +20,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|         variables: &HashMap<&str, &str>, | ||||
|         in_file: &str, | ||||
|         out_file: impl AsRef<Path>, | ||||
|     ) -> Result<(), Box<dyn Error>> { | ||||
|     ) -> anyhow::Result<()> { | ||||
|         let mut content = fs::read_to_string(in_file)?; | ||||
|  | ||||
|         for (variable_name, value) in variables { | ||||
| @@ -40,9 +39,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|     variables.insert("PROJECT_EXECUTABLE_UPPERCASE", &executable_name_uppercase); | ||||
|     variables.insert("PROJECT_VERSION", PROJECT_VERSION); | ||||
|  | ||||
|     let out_dir_env = std::env::var_os("BAT_ASSETS_GEN_DIR") | ||||
|         .or_else(|| std::env::var_os("OUT_DIR")) | ||||
|         .expect("BAT_ASSETS_GEN_DIR or OUT_DIR to be set in build.rs"); | ||||
|     let Some(out_dir_env) = | ||||
|         std::env::var_os("BAT_ASSETS_GEN_DIR").or_else(|| std::env::var_os("OUT_DIR")) | ||||
|     else { | ||||
|         anyhow::bail!("BAT_ASSETS_GEN_DIR or OUT_DIR should be set for build.rs"); | ||||
|     }; | ||||
|     let out_dir = Path::new(&out_dir_env); | ||||
|  | ||||
|     fs::create_dir_all(out_dir.join("assets/manual")).unwrap(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user