Files
revive-differential-tests/crates/solc-binaries/src/lib.rs
T
Omar c2526e48e7 Refactor the Global Configuration & Context (#157)
* Cleanup the config

* Update usage guides

* Update the run script

* Fix tests

* Use kitchensink in tests

* Use shared node more often in tests
2025-09-04 14:25:05 +00:00

44 lines
1.2 KiB
Rust

//! This crates provides serializable Rust type definitions for the [solc binary lists][0]
//! and download helpers.
//!
//! [0]: https://binaries.soliditylang.org
use std::path::{Path, PathBuf};
use anyhow::Context as _;
use cache::get_or_download;
use download::SolcDownloader;
use revive_dt_common::types::VersionOrRequirement;
use semver::Version;
pub mod cache;
pub mod download;
pub mod list;
/// Downloads the solc binary for Wasm is `wasm` is set, otherwise for
/// the target platform.
///
/// Subsequent calls for the same version will use a cached artifact
/// and not download it again.
pub async fn download_solc(
cache_directory: &Path,
version: impl Into<VersionOrRequirement>,
wasm: bool,
) -> anyhow::Result<(Version, PathBuf)> {
let downloader = if wasm {
SolcDownloader::wasm(version).await
} else if cfg!(target_os = "linux") {
SolcDownloader::linux(version).await
} else if cfg!(target_os = "macos") {
SolcDownloader::macosx(version).await
} else if cfg!(target_os = "windows") {
SolcDownloader::windows(version).await
} else {
unimplemented!()
}
.context("Failed to initialize the Solc Downloader")?;
get_or_download(cache_directory, &downloader).await
}