Scaffold utility and library (#3)

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
xermicus
2025-03-31 11:40:05 +02:00
committed by GitHub
parent 4b7af83be6
commit c590fa7bfd
36 changed files with 6720 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
//! 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 cache::get_or_download;
use download::GHDownloader;
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 fn download_solc(
cache_directory: &Path,
version: Version,
wasm: bool,
) -> anyhow::Result<PathBuf> {
let downloader = if wasm {
GHDownloader::wasm(version)
} else if cfg!(target_os = "linux") {
GHDownloader::linux(version)
} else if cfg!(target_os = "macos") {
GHDownloader::macosx(version)
} else if cfg!(target_os = "windows") {
GHDownloader::windows(version)
} else {
unimplemented!()
};
get_or_download(cache_directory, &downloader)
}