use std::path::PathBuf;
use std::sync::LazyLock;
use tracing::error;
use mago_php_version::PHPVersion;
pub const SUPPORTED_TARGETS: &[&str] = &[
"x86_64-pc-windows-msvc",
"aarch64-apple-darwin",
"x86_64-apple-darwin",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-pc-windows-gnu",
"x86_64-unknown-freebsd",
"arm-unknown-linux-gnueabi",
"arm-unknown-linux-gnueabihf",
"arm-unknown-linux-musleabi",
"arm-unknown-linux-musleabihf",
"armv7-unknown-linux-gnueabihf",
"armv7-unknown-linux-musleabihf",
];
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const TARGET: &str = env!("TARGET");
pub const BIN: &str = env!("CARGO_PKG_NAME");
#[cfg(target_os = "windows")]
pub const ARCHIVE_EXTENSION: &str = "zip";
#[cfg(not(target_os = "windows"))]
pub const ARCHIVE_EXTENSION: &str = "tar.gz";
pub const PHP_EXTENSION: &str = "php";
pub const REPO_OWNER: &str = "carthage-software";
pub const REPO_NAME: &str = "mago";
pub const ISSUE_URL: &str = "https://github.com/carthage-software/mago/issues/new";
pub const ENVIRONMENT_PREFIX: &str = "MAGO";
pub const CONFIGURATION_FILE_NAME: &str = "mago";
pub const CONFIGURATION_DIST_FILE_NAME: &str = "mago.dist";
pub const COMPOSER_JSON_FILE: &str = "composer.json";
pub const MINIMUM_STACK_SIZE: usize = 8 * 1024 * 1024;
pub const DEFAULT_STACK_SIZE: usize = 12 * 1024 * 1024;
pub const MAXIMUM_STACK_SIZE: usize = 256 * 1024 * 1024;
pub const DEFAULT_PHP_VERSION: PHPVersion = PHPVersion::LATEST;
pub const MINIMUM_PHP_VERSION: PHPVersion = PHPVersion::PHP80;
pub const MAXIMUM_PHP_VERSION: PHPVersion = PHPVersion::NEXT;
pub static LOGICAL_CPUS: LazyLock<usize> = LazyLock::new(|| {
std::thread::available_parallelism().map(|n| n.get()).unwrap_or_else(|e| {
error!("Failed to get the number of logical CPUs: {}", e);
error!("Falling back to 1 logical CPU. This might result in slower performance.");
error!("Need help? Open an issue at {}.", ISSUE_URL);
1
})
});
pub static CURRENT_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
std::env::current_dir().unwrap_or_else(|e| {
error!("Failed to get the current working directory: {}", e);
error!("This might occur if the directory has been deleted or if the process lacks the necessary permissions.");
error!("Please ensure that the directory exists and that you have the required permissions to access it.");
error!("Need help? Open an issue at {}.", ISSUE_URL);
std::process::exit(1);
})
});
pub const PRELUDE_BYTES: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/prelude.bin"));