| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | use std::error::Error;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 00:22:24 +01:00
										 |  |  | use vergen::EmitBuilder;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | fn download(url: &str, to: &str) -> Result<(), Box<dyn Error>> {
 | 
					
						
							|  |  |  |     let content = reqwest::blocking::get(url)
 | 
					
						
							|  |  |  |         .unwrap_or_else(|_| panic!("Downloading \"{to}\""))
 | 
					
						
							|  |  |  |         .text()
 | 
					
						
							|  |  |  |         .expect("Convert response to text");
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     std::fs::write(to, content)
 | 
					
						
							| 
									
										
										
										
											2023-11-28 01:14:37 +01:00
										 |  |  |     .expect("Write to file");
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Ok(())
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | fn main() -> Result<(), Box<dyn Error>> {
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     download(
 | 
					
						
							|  |  |  |         "https://raw.githubusercontent.com/a2x/cs2-dumper/main/generated/client.dll.rs",
 | 
					
						
							| 
									
										
										
										
											2024-01-08 00:22:24 +01:00
										 |  |  |         "./src/dma/cs2dumper/client.rs"
 | 
					
						
							| 
									
										
										
										
											2023-11-28 01:14:37 +01:00
										 |  |  |     ).expect("Failed to download build file \"client.dll.rs\"");
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     download(
 | 
					
						
							|  |  |  |         "https://raw.githubusercontent.com/a2x/cs2-dumper/main/generated/offsets.rs",
 | 
					
						
							| 
									
										
										
										
											2024-01-08 00:22:24 +01:00
										 |  |  |         "./src/dma/cs2dumper/offsets.rs"
 | 
					
						
							| 
									
										
										
										
											2023-11-28 01:14:37 +01:00
										 |  |  |     ).expect("Failed to download build file \"offsets.rs\"");
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     download(
 | 
					
						
							|  |  |  |         "https://raw.githubusercontent.com/a2x/cs2-dumper/main/generated/engine2.dll.rs",
 | 
					
						
							| 
									
										
										
										
											2024-01-08 00:22:24 +01:00
										 |  |  |         "./src/dma/cs2dumper/engine2.rs"
 | 
					
						
							| 
									
										
										
										
											2023-11-28 01:14:37 +01:00
										 |  |  |     ).expect("Failed to download build file \"engine2.dll.rs\"");
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-08 00:22:24 +01:00
										 |  |  |     EmitBuilder::builder()
 | 
					
						
							|  |  |  |         .git_sha(true)
 | 
					
						
							|  |  |  |         .git_commit_date()
 | 
					
						
							|  |  |  |         .cargo_debug()
 | 
					
						
							|  |  |  |         .cargo_target_triple()
 | 
					
						
							|  |  |  |         .rustc_semver()
 | 
					
						
							|  |  |  |         .rustc_llvm_version()
 | 
					
						
							|  |  |  |         .emit()?;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-31 17:23:15 +01:00
										 |  |  |     Ok(())
 | 
					
						
							|  |  |  | }
 |