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

Move Scarb StableHash to separate crate #1187

Merged
merged 1 commit into from
Mar 15, 2024
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
18 changes: 9 additions & 9 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions extensions/scarb-cairo-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ publish = false

[dependencies]
cairo-lang-language-server.workspace = true
cairo-lang-utils.workspace = true
log.workspace = true
tokio.workspace = true
3 changes: 0 additions & 3 deletions extensions/scarb-cairo-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion extensions/scarb-snforge-test-collector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions scarb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scarb/src/compiler/compilation_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/compiler/compilers/starknet_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "*";
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/source/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
1 change: 0 additions & 1 deletion scarb/src/internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion scarb/src/sources/git/canonical_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
14 changes: 14 additions & 0 deletions utils/scarb-stable-hash/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
maciektr marked this conversation as resolved.
Show resolved Hide resolved
pub struct StableHasher(Xxh3);

impl StableHasher {
pub fn new() -> Self {
Self(Default::default())
Default::default()
}

pub fn finish_as_short_hash(&self) -> String {
Expand Down
Loading