mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-30 18:47:56 +00:00
7f81f37e0c
Pre-eliminary support for LLVM releases and resolc binary releases by streamlining the build process for all supported hosts platforms. - Introduce the revive-llvm-builder crate with the revive-llvm builder utilty. - Do not rely on the LLVM dependency in $PATH to decouple the system LLVM installation from the LLVM host dependency. - Fix the emscripten build by decoupling the host and native LLVM dependencies. Thus allowing a single LLVM emscripten release that can be used on any host platform. - An example Dockerfile building an alpine container with a fully statically linked resolc ELF binary. - Remove the Debian builder utilities and workflow.
49 lines
1.7 KiB
Rust
49 lines
1.7 KiB
Rust
//! The compiler build utilities library.
|
|
|
|
/// The revive LLVM host dependency directory prefix environment variable.
|
|
pub const REVIVE_LLVM_HOST_PREFIX: &str = "LLVM_SYS_181_PREFIX";
|
|
|
|
/// The revive LLVM target dependency directory prefix environment variable.
|
|
pub const REVIVE_LLVM_TARGET_PREFIX: &str = "REVIVE_LLVM_TARGET_PREFIX";
|
|
|
|
/// Constructs a path to the LLVM tool `name`.
|
|
///
|
|
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
|
pub fn llvm_host_tool(name: &str) -> std::path::PathBuf {
|
|
std::env::var_os(REVIVE_LLVM_HOST_PREFIX)
|
|
.map(Into::<std::path::PathBuf>::into)
|
|
.unwrap_or_else(|| {
|
|
panic!(
|
|
"install LLVM using the revive-llvm builder and export {REVIVE_LLVM_HOST_PREFIX}",
|
|
)
|
|
})
|
|
.join("bin")
|
|
.join(name)
|
|
}
|
|
|
|
/// Returns the LLVM lib dir.
|
|
///
|
|
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
|
pub fn llvm_lib_dir() -> std::path::PathBuf {
|
|
std::path::PathBuf::from(llvm_config("--libdir").trim())
|
|
}
|
|
|
|
/// Returns the LLVM CXX compiler flags.
|
|
///
|
|
/// Respects the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
|
pub fn llvm_cxx_flags() -> String {
|
|
llvm_config("--cxxflags")
|
|
}
|
|
|
|
/// Execute the `llvm-config` utility respecting the [`REVIVE_LLVM_HOST_PREFIX`] environment variable.
|
|
fn llvm_config(arg: &str) -> String {
|
|
let llvm_config = llvm_host_tool("llvm-config");
|
|
let output = std::process::Command::new(&llvm_config)
|
|
.arg(arg)
|
|
.output()
|
|
.unwrap_or_else(|error| panic!("`{} {arg}` failed: {error}", llvm_config.display()));
|
|
|
|
String::from_utf8(output.stdout)
|
|
.unwrap_or_else(|_| panic!("output of `{} {arg}` should be utf8", llvm_config.display()))
|
|
}
|