Skip to content

Commit

Permalink
feat: improve release profile (#145)
Browse files Browse the repository at this point in the history
Closes #144
  • Loading branch information
DaniPopes authored Oct 9, 2024
1 parent 7879b68 commit 764a8ac
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 213 deletions.
325 changes: 141 additions & 184 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/alloy-rs/svm-rs"
homepage = "https://github.com/alloy-rs/svm-rs"

[workspace.lints.clippy]
dbg-macro = "warn"
manual-string-new = "warn"
uninlined-format-args = "warn"
use-self = "warn"
redundant-clone = "warn"
missing-const-for-fn = "warn"
needless-return = "allow"

[workspace.lints.rust]
# missing-copy-implementations = "warn"
# missing-debug-implementations = "warn"
# missing-docs = "warn"
rust-2018-idioms = "warn"
# unreachable-pub = "warn"
unused-must-use = "warn"
redundant-lifetimes = "warn"
unnameable-types = "warn"

[workspace.lints.rustdoc]
all = "warn"

[workspace.dependencies]
svm = { package = "svm-rs", version = "0.5.7", path = "crates/svm-rs", default-features = false }

Expand All @@ -23,3 +45,9 @@ semver = "1"
serde = "1"
serde_json = "1"
reqwest = { version = "0.12", default-features = false, features = ["socks"] }

[profile.release]
lto = "fat"
debug = 0
strip = "debuginfo"
codegen-units = 1
8 changes: 7 additions & 1 deletion crates/svm-builds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ license.workspace = true
repository.workspace = true
homepage.workspace = true

[lints]
workspace = true

[build-dependencies]
svm = { workspace = true, default-features = false, features = ["blocking", "rustls"] }
svm = { workspace = true, default-features = false, features = [
"blocking",
"rustls",
] }

build_const = "0.2"
hex.workspace = true
Expand Down
15 changes: 4 additions & 11 deletions crates/svm-builds/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ fn add_platform_const(writer: &mut build_const::ConstValueWriter, platform: svm:
writer.add_raw(&format!(
r#"
/// The `svm::Platform` all constants were built for
pub const TARGET_PLATFORM: &str = "{}";
"#,
platform
pub const TARGET_PLATFORM: &str = "{platform}";
"#
));
}

Expand All @@ -125,17 +124,11 @@ fn generate() {

let releases: Releases = if let Ok(file_path) = std::env::var(SVM_RELEASES_LIST_JSON) {
let file = File::open(file_path).unwrap_or_else(|_| {
panic!(
"{:?} defined, but cannot read the file referenced",
SVM_RELEASES_LIST_JSON
)
panic!("{SVM_RELEASES_LIST_JSON:?} defined, but cannot read the file referenced")
});

serde_json::from_reader(file).unwrap_or_else(|_| {
panic!(
"Failed to parse the JSON from {:?} file",
SVM_RELEASES_LIST_JSON
)
panic!("Failed to parse the JSON from {SVM_RELEASES_LIST_JSON:?} file")
})
} else {
svm::blocking_all_releases(platform).expect("Failed to fetch releases")
Expand Down
16 changes: 13 additions & 3 deletions crates/svm-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ license.workspace = true
repository.workspace = true
homepage.workspace = true

[lints]
workspace = true

[lib]
name = "svm"

Expand All @@ -24,10 +27,14 @@ path = "src/bin/solc/main.rs"
required-features = ["solc"]

[build-dependencies]
vergen = { version = "8", optional = true, features = ["build", "git", "gitcl"] }
vergen = { version = "8", optional = true, features = [
"build",
"git",
"gitcl",
] }

[dependencies]
fs4 = "0.9"
fs4 = "0.10"
hex.workspace = true
dirs = "5.0"
reqwest = { workspace = true, default-features = false, features = ["json"] }
Expand All @@ -46,7 +53,10 @@ console = { version = "0.15", default-features = false, optional = true }
dialoguer = { version = "0.11", default-features = false, optional = true }
indicatif = { version = "0.17", default-features = false, optional = true }
itertools = { version = "0.13", optional = true }
tokio = { version = "1", features = ["rt-multi-thread", "macros"], optional = true }
tokio = { version = "1", features = [
"rt-multi-thread",
"macros",
], optional = true }

[target.'cfg(all(target_os = "windows", target_arch = "x86_64"))'.dependencies]
zip = { version = "2", default-features = false, features = ["deflate"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/svm-rs/src/bin/solc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
let code = match main_() {
Ok(code) => code,
Err(err) => {
eprintln!("svm: error: {err:?}");
eprintln!("svm: error: {err}");
1
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/svm-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod platform;
pub use platform::{platform, Platform};

mod releases;
pub use releases::{all_releases, Releases};
pub use releases::{all_releases, BuildInfo, Releases};

#[cfg(feature = "blocking")]
pub use releases::blocking_all_releases;
Expand Down
22 changes: 11 additions & 11 deletions crates/svm-rs/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ pub enum Platform {
impl fmt::Display for Platform {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let s = match self {
Platform::LinuxAmd64 => "linux-amd64",
Platform::LinuxAarch64 => "linux-aarch64",
Platform::MacOsAmd64 => "macosx-amd64",
Platform::MacOsAarch64 => "macosx-aarch64",
Platform::WindowsAmd64 => "windows-amd64",
Platform::Unsupported => "Unsupported-platform",
Self::LinuxAmd64 => "linux-amd64",
Self::LinuxAarch64 => "linux-aarch64",
Self::MacOsAmd64 => "macosx-amd64",
Self::MacOsAarch64 => "macosx-aarch64",
Self::WindowsAmd64 => "windows-amd64",
Self::Unsupported => "Unsupported-platform",
};
f.write_str(s)
}
Expand All @@ -32,11 +32,11 @@ impl FromStr for Platform {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"linux-amd64" => Ok(Platform::LinuxAmd64),
"linux-aarch64" => Ok(Platform::LinuxAarch64),
"macosx-amd64" => Ok(Platform::MacOsAmd64),
"macosx-aarch64" => Ok(Platform::MacOsAarch64),
"windows-amd64" => Ok(Platform::WindowsAmd64),
"linux-amd64" => Ok(Self::LinuxAmd64),
"linux-aarch64" => Ok(Self::LinuxAarch64),
"macosx-amd64" => Ok(Self::MacOsAmd64),
"macosx-aarch64" => Ok(Self::MacOsAarch64),
"windows-amd64" => Ok(Self::WindowsAmd64),
s => Err(format!("unsupported platform {s}")),
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/svm-rs/src/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ mod tests {
.await
.expect("could not fetch releases for macos-aarch64");
let rosetta = Version::new(0, 8, 4);
let native = MACOS_AARCH64_NATIVE.clone();
let native = MACOS_AARCH64_NATIVE;
let url1 = artifact_url(
Platform::MacOsAarch64,
&rosetta,
Expand Down

0 comments on commit 764a8ac

Please sign in to comment.