Skip to content

Commit

Permalink
PubGrub resolver
Browse files Browse the repository at this point in the history
commit-id:d55b5ecb
  • Loading branch information
maciektr committed Nov 13, 2024
1 parent aa612cb commit 4805d2b
Show file tree
Hide file tree
Showing 18 changed files with 906 additions and 95 deletions.
58 changes: 57 additions & 1 deletion Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ pathdiff = { version = "0.2", features = ["camino"] }
petgraph = "0.6"
predicates = "3"
proc-macro2 = "1"
pubgrub = { git = "https://github.com/pubgrub-rs/pubgrub.git", branch = "dev" }
quote = "1"
ra_ap_toolchain = "0.0.218"
rayon = "1.10"
redb = "2.2.0"
reqwest = { version = "0.11", features = ["gzip", "brotli", "deflate", "json", "stream", "multipart"], default-features = false }
salsa = { package = "rust-analyzer-salsa", version = "0.17.0-pre.6" }
semver = { version = "1", features = ["serde"] }
semver-pubgrub = { git = "https://github.com/software-mansion-labs/semver-pubgrub.git" }
serde = { version = "1", features = ["serde_derive"] }
serde-untagged = "0.1"
serde-value = "0.7"
Expand All @@ -125,6 +127,7 @@ test-case = "3"
thiserror = "1"
time = "0.3"
tokio = { version = "1", features = ["macros", "io-util", "process", "rt", "rt-multi-thread", "sync"] }
tokio-stream = "0.1"
toml = "0.8"
toml_edit = { version = "0.22", features = ["serde"] }
tower-http = { version = "0.4", features = ["fs"] }
Expand All @@ -142,6 +145,9 @@ xxhash-rust = { version = "0.8", features = ["xxh3"] }
zip = { version = "0.6", default-features = false, features = ["deflate"] }
zstd = "0.13"

[patch.'https://github.com/pubgrub-rs/pubgrub.git']
pubgrub = { git = 'https://github.com/software-mansion-labs/pubgrub.git', branch = 'dev' }

[profile.release]
lto = true

Expand Down
4 changes: 4 additions & 0 deletions scarb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ indoc.workspace = true
itertools.workspace = true
libloading.workspace = true
once_cell.workspace = true
once_map = { path = "../utils/once-map" }
pathdiff.workspace = true
petgraph.workspace = true
pubgrub.workspace = true
scarb-proc-macro-server-types = { path = "../utils/scarb-proc-macro-server-types" }
ra_ap_toolchain.workspace = true
redb.workspace = true
Expand All @@ -65,6 +67,7 @@ scarb-build-metadata = { path = "../utils/scarb-build-metadata" }
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-pubgrub.workspace = true
semver.workspace = true
serde-untagged.workspace = true
serde-value.workspace = true
Expand All @@ -77,6 +80,7 @@ smol_str.workspace = true
tar.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-stream.workspace = true
toml.workspace = true
toml_edit.workspace = true
tracing-subscriber.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum LockVersion {
V1 = 1,
}

#[derive(Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Lockfile {
pub version: LockVersion,
Expand Down
2 changes: 1 addition & 1 deletion scarb/src/core/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub(crate) mod mock {
let summary = Summary::builder()
.package_id(package_id)
.dependencies(dependencies)
.no_core(package_id.is_core())
.no_core(package_id.name == PackageName::CORE)
.build();

let manifest = Box::new(
Expand Down
29 changes: 29 additions & 0 deletions scarb/src/resolver/algorithm/in_memory_index.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::core::Summary;
use crate::resolver::algorithm::provider::PubGrubPackage;
use once_map::OnceMap;
use std::sync::Arc;

/// In-memory index of package metadata.
#[derive(Default, Clone)]
pub struct InMemoryIndex(Arc<SharedInMemoryIndex>);

#[derive(Default)]
struct SharedInMemoryIndex {
/// A map from package name to the metadata for that package and the index where the metadata
/// came from.
packages: FxOnceMap<PubGrubPackage, Arc<VersionsResponse>>,
}

pub(crate) type FxOnceMap<K, V> = OnceMap<K, V>;

impl InMemoryIndex {
/// Returns a reference to the package metadata.
pub fn packages(&self) -> &FxOnceMap<PubGrubPackage, Arc<VersionsResponse>> {
&self.0.packages
}
}

#[derive(Debug)]
pub enum VersionsResponse {
Found(Vec<Summary>),
}
Loading

0 comments on commit 4805d2b

Please sign in to comment.