Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print Sierra version in scarb --version #578

Merged
merged 2 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ repository = "https://github.com/software-mansion/scarb"
anyhow = "1.0.72"
assert_fs = "1.0.13"
async-trait = "0.1.73"
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647" }
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "f42b647", features = ["env_logger"] }
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7" }
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "ad9dbb7", features = ["env_logger"] }
camino = { version = "1.1.6", features = ["serde1"] }
cargo_metadata = "0.17.0"
clap = { version = "4.3.21", features = ["derive", "env", "string"] }
Expand Down
3 changes: 3 additions & 0 deletions extensions/scarb-cairo-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ fn main() -> Result<()> {

let main_crate_ids = vec![db.intern_crate(CrateLongId::Real(package.name.clone().into()))];

let test_crate_ids = main_crate_ids.clone();

if DiagnosticsReporter::stderr().check(&db) {
bail!("could not compile `{}` due to previous error", package.name);
}

let runner = TestRunner {
db,
main_crate_ids,
test_crate_ids,
filter: args.filter.clone(),
include_ignored: args.include_ignored,
ignored: args.ignored,
Expand Down
38 changes: 32 additions & 6 deletions scarb/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use std::fmt;
use std::fmt::Write;

use indoc::formatdoc;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

use scarb_build_metadata::{
Expand All @@ -16,6 +18,7 @@ pub struct VersionInfo {
pub version: &'static str,
pub commit_info: Option<CommitInfo>,
pub cairo: CairoVersionInfo,
pub sierra: SierraVersionInfo,
}

/// Cairo's version.
Expand All @@ -25,6 +28,12 @@ pub struct CairoVersionInfo {
pub commit_info: Option<CommitInfo>,
}

/// Sierra version.
#[derive(Serialize, Deserialize, Debug)]
pub struct SierraVersionInfo {
pub version: &'static str,
}

/// Information about the Git repository where the crate was built from.
#[derive(Serialize, Deserialize, Debug)]
pub struct CommitInfo {
Expand Down Expand Up @@ -52,13 +61,15 @@ impl VersionInfo {
}

pub fn long(&self) -> String {
format!(
"\
{short}\n\
cairo: {cairo}\
",
formatdoc!(
r#"
{short}
cairo: {cairo}
sierra: {sierra}
"#,
short = self.short(),
cairo = self.cairo.short()
cairo = self.cairo.short(),
sierra = self.sierra.short(),
)
}
}
Expand All @@ -73,6 +84,12 @@ impl CairoVersionInfo {
}
}

impl SierraVersionInfo {
pub fn short(&self) -> &str {
self.version
}
}

fn display_version_and_commit_info(
version: &str,
commit_info: &Option<CommitInfo>,
Expand Down Expand Up @@ -114,9 +131,18 @@ pub fn get() -> VersionInfo {
}
};

static SIERRA_VERSION: Lazy<String> = Lazy::new(|| {
cairo_lang_starknet::compiler_version::current_sierra_version_id().to_string()
});

let sierra = SierraVersionInfo {
version: &SIERRA_VERSION,
};

VersionInfo {
version: SCARB_VERSION,
commit_info,
cairo,
sierra,
}
}