diff --git a/Cargo.lock b/Cargo.lock index 1bc3c9e3e..f940c4984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4443,7 +4443,6 @@ dependencies = [ "cairo-lang-macro", "cairo-lang-macro-stable", "cairo-lang-semantic", - "cairo-lang-sierra", "cairo-lang-sierra-to-casm", "cairo-lang-starknet", "cairo-lang-starknet-classes", @@ -4481,6 +4480,7 @@ dependencies = [ "reqwest", "scarb-build-metadata", "scarb-metadata 1.11.1", + "scarb-stable-hash", "scarb-test-support", "scarb-ui", "semver", @@ -4510,7 +4510,6 @@ dependencies = [ "walkdir", "which", "windows-sys 0.52.0", - "xxhash-rust", "zip", "zstd", ] @@ -4528,9 +4527,6 @@ name = "scarb-cairo-language-server" version = "2.6.1" dependencies = [ "cairo-lang-language-server", - "cairo-lang-utils", - "log", - "tokio", ] [[package]] @@ -4560,9 +4556,6 @@ name = "scarb-cairo-test" version = "2.6.1" dependencies = [ "anyhow", - "cairo-lang-compiler", - "cairo-lang-filesystem", - "cairo-lang-starknet", "cairo-lang-test-plugin", "cairo-lang-test-runner", "clap", @@ -4608,7 +4601,6 @@ dependencies = [ "anyhow", "assert_fs", "cairo-felt", - "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-debug", "cairo-lang-defs", @@ -4644,6 +4636,14 @@ dependencies = [ "walkdir", ] +[[package]] +name = "scarb-stable-hash" +version = "1.0.0" +dependencies = [ + "data-encoding", + "xxhash-rust", +] + [[package]] name = "scarb-test-support" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index fbb9ce006..592f3877f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "plugins/cairo-lang-macro-stable", "utils/create-output-dir", "utils/scarb-build-metadata", + "utils/scarb-stable-hash", "utils/scarb-test-support", "utils/scarb-ui", "utils/test-for-each-example", diff --git a/extensions/scarb-cairo-language-server/Cargo.toml b/extensions/scarb-cairo-language-server/Cargo.toml index cb8e250e9..8d06295d3 100644 --- a/extensions/scarb-cairo-language-server/Cargo.toml +++ b/extensions/scarb-cairo-language-server/Cargo.toml @@ -6,6 +6,3 @@ publish = false [dependencies] cairo-lang-language-server.workspace = true -cairo-lang-utils.workspace = true -log.workspace = true -tokio.workspace = true diff --git a/extensions/scarb-cairo-test/Cargo.toml b/extensions/scarb-cairo-test/Cargo.toml index 8c8bfe121..f4cb381e3 100644 --- a/extensions/scarb-cairo-test/Cargo.toml +++ b/extensions/scarb-cairo-test/Cargo.toml @@ -8,9 +8,6 @@ authors.workspace = true [dependencies] anyhow.workspace = true -cairo-lang-compiler.workspace = true -cairo-lang-filesystem.workspace = true -cairo-lang-starknet.workspace = true cairo-lang-test-plugin.workspace = true cairo-lang-test-runner.workspace = true clap.workspace = true diff --git a/extensions/scarb-snforge-test-collector/Cargo.toml b/extensions/scarb-snforge-test-collector/Cargo.toml index fb52c6e26..d4d917d23 100644 --- a/extensions/scarb-snforge-test-collector/Cargo.toml +++ b/extensions/scarb-snforge-test-collector/Cargo.toml @@ -9,7 +9,6 @@ authors.workspace = true [dependencies] anyhow.workspace = true cairo-felt.workspace = true -cairo-lang-casm.workspace = true cairo-lang-compiler.workspace = true cairo-lang-debug.workspace = true cairo-lang-defs.workspace = true diff --git a/scarb/Cargo.toml b/scarb/Cargo.toml index 77223bcfb..8588535f5 100644 --- a/scarb/Cargo.toml +++ b/scarb/Cargo.toml @@ -21,9 +21,10 @@ cairo-lang-defs.workspace = true cairo-lang-diagnostics.workspace = true cairo-lang-filesystem.workspace = true cairo-lang-formatter.workspace = true +cairo-lang-macro = { path = "../plugins/cairo-lang-macro" } +cairo-lang-macro-stable = { path = "../plugins/cairo-lang-macro-stable" } cairo-lang-semantic.workspace = true cairo-lang-sierra-to-casm.workspace = true -cairo-lang-sierra.workspace = true cairo-lang-starknet-classes.workspace = true cairo-lang-starknet.workspace = true cairo-lang-syntax.workspace = true @@ -53,9 +54,8 @@ petgraph.workspace = true redb.workspace = true reqwest.workspace = true scarb-build-metadata = { path = "../utils/scarb-build-metadata" } -cairo-lang-macro = { path = "../plugins/cairo-lang-macro" } -cairo-lang-macro-stable = { path = "../plugins/cairo-lang-macro-stable" } scarb-metadata = { path = "../scarb-metadata", default-features = false, features = ["builder"] } +scarb-stable-hash = { path = "../utils/scarb-stable-hash" } scarb-ui = { path = "../utils/scarb-ui" } semver.workspace = true serde-untagged.workspace = true @@ -79,7 +79,6 @@ url.workspace = true walkdir.workspace = true which.workspace = true windows-sys.workspace = true -xxhash-rust.workspace = true zip.workspace = true zstd.workspace = true diff --git a/scarb/src/compiler/compilation_unit.rs b/scarb/src/compiler/compilation_unit.rs index 18a805300..55514c7d9 100644 --- a/scarb/src/compiler/compilation_unit.rs +++ b/scarb/src/compiler/compilation_unit.rs @@ -8,7 +8,7 @@ use typed_builder::TypedBuilder; use crate::compiler::Profile; use crate::core::{ManifestCompilerConfig, Package, PackageId, Target, Workspace}; use crate::flock::Filesystem; -use crate::internal::stable_hash::StableHasher; +use scarb_stable_hash::StableHasher; /// An object that has enough information so that Scarb knows how to build it. pub enum CompilationUnit { diff --git a/scarb/src/compiler/compilers/starknet_contract.rs b/scarb/src/compiler/compilers/starknet_contract.rs index f01ba79ec..53af95c4c 100644 --- a/scarb/src/compiler/compilers/starknet_contract.rs +++ b/scarb/src/compiler/compilers/starknet_contract.rs @@ -26,7 +26,7 @@ use crate::compiler::helpers::{build_compiler_config, collect_main_crate_ids, wr use crate::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; use crate::core::{PackageName, TargetKind, Utf8PathWorkspaceExt, Workspace}; use crate::internal::serdex::RelativeUtf8PathBuf; -use crate::internal::stable_hash::short_hash; +use scarb_stable_hash::short_hash; const CAIRO_PATH_SEPARATOR: &str = "::"; const GLOB_PATH_SELECTOR: &str = "*"; diff --git a/scarb/src/core/source/id.rs b/scarb/src/core/source/id.rs index 298795624..fcc5387f6 100644 --- a/scarb/src/core/source/id.rs +++ b/scarb/src/core/source/id.rs @@ -14,9 +14,9 @@ use crate::core::registry::DEFAULT_REGISTRY_INDEX; use crate::core::source::Source; use crate::core::Config; use crate::internal::fsx::PathBufUtf8Ext; -use crate::internal::stable_hash::short_hash; use crate::internal::static_hash_cache::StaticHashCache; use crate::sources::canonical_url::CanonicalUrl; +use scarb_stable_hash::short_hash; /// Unique identifier for a source of packages. /// diff --git a/scarb/src/internal/mod.rs b/scarb/src/internal/mod.rs index 856691b91..bcbd5d048 100644 --- a/scarb/src/internal/mod.rs +++ b/scarb/src/internal/mod.rs @@ -4,6 +4,5 @@ pub mod fsx; pub mod lazy_directory_creator; pub mod restricted_names; pub mod serdex; -pub mod stable_hash; pub mod static_hash_cache; pub mod to_version; diff --git a/scarb/src/sources/git/canonical_url.rs b/scarb/src/sources/git/canonical_url.rs index 65149f96e..6ca8af11a 100644 --- a/scarb/src/sources/git/canonical_url.rs +++ b/scarb/src/sources/git/canonical_url.rs @@ -3,7 +3,7 @@ use std::fmt; use anyhow::{ensure, Result}; use url::Url; -use crate::internal::stable_hash::short_hash; +use scarb_stable_hash::short_hash; /// A newtype wrapper around [`Url`] which represents a _canonical_ version of an original URL. /// diff --git a/utils/scarb-stable-hash/Cargo.toml b/utils/scarb-stable-hash/Cargo.toml new file mode 100644 index 000000000..bfd28812e --- /dev/null +++ b/utils/scarb-stable-hash/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "scarb-stable-hash" +version = "1.0.0" +edition.workspace = true +authors.workspace = true +homepage.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true +publish = false + +[dependencies] +xxhash-rust.workspace = true +data-encoding.workspace = true diff --git a/scarb/src/internal/stable_hash.rs b/utils/scarb-stable-hash/src/lib.rs similarity index 95% rename from scarb/src/internal/stable_hash.rs rename to utils/scarb-stable-hash/src/lib.rs index a4ce9768f..0a7fb3ce7 100644 --- a/scarb/src/internal/stable_hash.rs +++ b/utils/scarb-stable-hash/src/lib.rs @@ -7,11 +7,12 @@ use xxhash_rust::xxh3::Xxh3; /// /// The hasher should be fast and have a low chance of collisions (but is not sufficient for /// cryptographic purposes). +#[derive(Default)] pub struct StableHasher(Xxh3); impl StableHasher { pub fn new() -> Self { - Self(Default::default()) + Default::default() } pub fn finish_as_short_hash(&self) -> String {