1#![doc = "README.md"]
2#![cfg_attr(not(test), no_main)]
3#![cfg_attr(test, allow(dead_code))]
4
5mod build;
6
7use std::ffi::c_char;
8
9use build::{Build, Executable};
10
11#[unsafe(no_mangle)]
30#[cfg(not(test))]
31pub unsafe extern "C" fn main(argc: i32, argv: *const *const c_char, envp: *const *const c_char) {
32 let result = unsafe { run(argc, argv, envp) };
33
34 proc_exit::exit(result);
35}
36
37unsafe fn run(
38 argc: i32,
39 argv: *const *const c_char,
40 envp: *const *const c_char,
41) -> proc_exit::ExitResult {
42 #[cfg(feature = "debug")]
43 env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init();
44
45 let build = Build::find().unwrap_or_default();
46
47 #[cfg(feature = "debug")]
48 log::debug!(
49 "Executing build with the following CPU features: {}",
50 build.features()
51 );
52
53 unsafe { build.exec(argc, argv, envp) }?;
54
55 Ok(())
56}