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", |  "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]] | [[package]] | ||||||
| name = "assert_cmd" | name = "assert_cmd" | ||||||
| version = "2.0.12" | version = "2.0.12" | ||||||
| @@ -106,6 +112,7 @@ name = "bat" | |||||||
| version = "0.24.0" | version = "0.24.0" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "ansi_colours", |  "ansi_colours", | ||||||
|  |  "anyhow", | ||||||
|  "assert_cmd", |  "assert_cmd", | ||||||
|  "bincode", |  "bincode", | ||||||
|  "bugreport", |  "bugreport", | ||||||
|   | |||||||
| @@ -98,6 +98,9 @@ tempfile = "3.8.1" | |||||||
| [target.'cfg(unix)'.dev-dependencies] | [target.'cfg(unix)'.dev-dependencies] | ||||||
| nix = { version = "0.26.4", default-features = false, features = ["term"] } | nix = { version = "0.26.4", default-features = false, features = ["term"] } | ||||||
|  |  | ||||||
|  | [build-dependencies] | ||||||
|  | anyhow = "1.0.75" | ||||||
|  |  | ||||||
| [build-dependencies.clap] | [build-dependencies.clap] | ||||||
| version = "4.4.6" | version = "4.4.6" | ||||||
| optional = true | optional = true | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								build.rs
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								build.rs
									
									
									
									
									
								
							| @@ -4,9 +4,8 @@ | |||||||
| fn main() {} | fn main() {} | ||||||
|  |  | ||||||
| #[cfg(feature = "application")] | #[cfg(feature = "application")] | ||||||
| fn main() -> Result<(), Box<dyn std::error::Error>> { | fn main() -> anyhow::Result<()> { | ||||||
|     use std::collections::HashMap; |     use std::collections::HashMap; | ||||||
|     use std::error::Error; |  | ||||||
|     use std::fs; |     use std::fs; | ||||||
|     use std::path::Path; |     use std::path::Path; | ||||||
|  |  | ||||||
| @@ -21,7 +20,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||||||
|         variables: &HashMap<&str, &str>, |         variables: &HashMap<&str, &str>, | ||||||
|         in_file: &str, |         in_file: &str, | ||||||
|         out_file: impl AsRef<Path>, |         out_file: impl AsRef<Path>, | ||||||
|     ) -> Result<(), Box<dyn Error>> { |     ) -> anyhow::Result<()> { | ||||||
|         let mut content = fs::read_to_string(in_file)?; |         let mut content = fs::read_to_string(in_file)?; | ||||||
|  |  | ||||||
|         for (variable_name, value) in variables { |         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_EXECUTABLE_UPPERCASE", &executable_name_uppercase); | ||||||
|     variables.insert("PROJECT_VERSION", PROJECT_VERSION); |     variables.insert("PROJECT_VERSION", PROJECT_VERSION); | ||||||
|  |  | ||||||
|     let out_dir_env = std::env::var_os("BAT_ASSETS_GEN_DIR") |     let Some(out_dir_env) = | ||||||
|         .or_else(|| std::env::var_os("OUT_DIR")) |         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"); |     else { | ||||||
|  |         anyhow::bail!("BAT_ASSETS_GEN_DIR or OUT_DIR should be set for build.rs"); | ||||||
|  |     }; | ||||||
|     let out_dir = Path::new(&out_dir_env); |     let out_dir = Path::new(&out_dir_env); | ||||||
|  |  | ||||||
|     fs::create_dir_all(out_dir.join("assets/manual")).unwrap(); |     fs::create_dir_all(out_dir.join("assets/manual")).unwrap(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user