mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-12-02 23:37:10 +00:00
recursive processes use the current executable by default (#484)
- Recursive processes spawn the currently running executable by default, removing the annoyance of mixing different compiler builds during contract compilation. - Remove the unused `once_cell` dependency. Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
1 parent
971ab2c615
commit
073276696f
4 files changed
+23
-31
No files matched your search
@@ -4,10 +4,8 @@ use std::collections::BTreeMap;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use revive_common::MetadataHash;
|
||||
use revive_llvm_context::initialize_llvm;
|
||||
use revive_llvm_context::DebugConfig;
|
||||
@@ -24,16 +22,19 @@ use revive_solc_json_interface::SolcStandardJsonInputSettingsSelection;
|
||||
use revive_solc_json_interface::SolcStandardJsonInputSource;
|
||||
use revive_solc_json_interface::SolcStandardJsonOutput;
|
||||
use revive_solc_json_interface::SolcStandardJsonOutputErrorHandler;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use crate::project::Project;
|
||||
use crate::solc::solc_compiler::SolcCompiler;
|
||||
use crate::solc::Compiler;
|
||||
|
||||
static PVM_BLOB_CACHE: Lazy<Mutex<HashMap<CachedBlob, Vec<u8>>>> = Lazy::new(Default::default);
|
||||
static EVM_BLOB_CACHE: Lazy<Mutex<HashMap<CachedBlob, Vec<u8>>>> = Lazy::new(Default::default);
|
||||
static EVM_RUNTIME_BLOB_CACHE: Lazy<Mutex<HashMap<CachedBlob, Vec<u8>>>> =
|
||||
Lazy::new(Default::default);
|
||||
static YUL_IR_CACHE: Lazy<Mutex<HashMap<CachedBlob, String>>> = Lazy::new(Default::default);
|
||||
static PVM_BLOB_CACHE: LazyLock<Mutex<HashMap<CachedBlob, Vec<u8>>>> =
|
||||
LazyLock::new(Default::default);
|
||||
static EVM_BLOB_CACHE: LazyLock<Mutex<HashMap<CachedBlob, Vec<u8>>>> =
|
||||
LazyLock::new(Default::default);
|
||||
static EVM_RUNTIME_BLOB_CACHE: LazyLock<Mutex<HashMap<CachedBlob, Vec<u8>>>> =
|
||||
LazyLock::new(Default::default);
|
||||
static YUL_IR_CACHE: LazyLock<Mutex<HashMap<CachedBlob, String>>> = LazyLock::new(Default::default);
|
||||
|
||||
const DEBUG_CONFIG: revive_llvm_context::DebugConfig = DebugConfig::new(None, true);
|
||||
|
||||
@@ -78,9 +79,6 @@ pub fn build_solidity_with_options(
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
initialize_llvm(PolkaVMTarget::PVM, crate::DEFAULT_EXECUTABLE_NAME, &[]);
|
||||
|
||||
let _ = crate::process::native_process::EXECUTABLE
|
||||
.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
let solc_version = solc.version()?;
|
||||
|
||||
@@ -146,9 +144,6 @@ pub fn build_solidity_with_options_evm(
|
||||
check_dependencies();
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
initialize_llvm(PolkaVMTarget::PVM, crate::DEFAULT_EXECUTABLE_NAME, &[]);
|
||||
let _ = crate::process::native_process::EXECUTABLE
|
||||
.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
let mut input = SolcStandardJsonInput::try_from_solidity_sources(
|
||||
None,
|
||||
@@ -204,9 +199,6 @@ pub fn build_solidity_and_detect_missing_libraries<T: ToString>(
|
||||
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
initialize_llvm(PolkaVMTarget::PVM, crate::DEFAULT_EXECUTABLE_NAME, &[]);
|
||||
let _ = crate::process::native_process::EXECUTABLE
|
||||
.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
let solc_version = solc.version()?;
|
||||
let mut input = SolcStandardJsonInput::try_from_solidity_sources(
|
||||
@@ -249,9 +241,6 @@ pub fn build_yul<T: ToString + Display>(
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
initialize_llvm(PolkaVMTarget::PVM, crate::DEFAULT_EXECUTABLE_NAME, &[]);
|
||||
|
||||
let _ = crate::process::native_process::EXECUTABLE
|
||||
.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let mut build = Project::try_from_yul_sources(
|
||||
sources
|
||||
.iter()
|
||||
@@ -298,9 +287,6 @@ pub fn build_yul_standard_json(
|
||||
inkwell::support::enable_llvm_pretty_stack_trace();
|
||||
initialize_llvm(PolkaVMTarget::PVM, crate::DEFAULT_EXECUTABLE_NAME, &[]);
|
||||
|
||||
let _ = crate::process::native_process::EXECUTABLE
|
||||
.set(PathBuf::from(crate::r#const::DEFAULT_EXECUTABLE_NAME));
|
||||
|
||||
let solc = SolcCompiler::new(SolcCompiler::DEFAULT_EXECUTABLE_NAME.to_owned())?;
|
||||
let mut output = solc.validate_yul_standard_json(&mut solc_input, &mut vec![])?;
|
||||
if output.has_errors() {
|
||||
@@ -427,6 +413,8 @@ pub fn sources<T: ToString>(sources: &[(T, T)]) -> BTreeMap<String, SolcStandard
|
||||
}
|
||||
|
||||
/// Checks if the required executables are present in `${PATH}`.
|
||||
/// Also initializes the resolc executable path for subprocess spawning,
|
||||
/// since `std::env::current_exe()` returns the test runner binary in tests.
|
||||
fn check_dependencies() {
|
||||
for executable in [
|
||||
crate::r#const::DEFAULT_EXECUTABLE_NAME,
|
||||
@@ -439,6 +427,10 @@ fn check_dependencies() {
|
||||
"The `{executable}` executable not found in ${{PATH}}"
|
||||
);
|
||||
}
|
||||
|
||||
let _ = crate::process::native_process::EXECUTABLE.set(
|
||||
which::which(crate::r#const::DEFAULT_EXECUTABLE_NAME).expect("resolc should be in ${PATH}"),
|
||||
);
|
||||
}
|
||||
|
||||
/// The internal EVM bytecode compile helper.
|
||||
|
||||
Reference in new issue
Block a user