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