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

Install dependencies from GitHub #67

Closed
4 tasks done
adlerjohn opened this issue Jun 2, 2021 · 1 comment · Fixed by #101
Closed
4 tasks done

Install dependencies from GitHub #67

adlerjohn opened this issue Jun 2, 2021 · 1 comment · Fixed by #101
Assignees
Labels

Comments

@adlerjohn
Copy link
Contributor

adlerjohn commented Jun 2, 2021

Problem

We would like to have a way for projects to install Sway project dependencies, so that Sway contract devs can share and re-use code. While eventually a central repository of published authenticated packages will be nice, in the meantime installing packages from simple GitHub repo URLs will suffice.

Proposal

A field in the manifest file already exists for dependencies, however only handles local dependencies.

#[derive(Deserialize, Debug)]
#[serde(untagged)]
pub enum Dependency {
/// In the simple format, only a version is specified, eg.
/// `package = "<version>"`
Simple(String),
/// The simple format is equivalent to a detailed dependency
/// specifying only a version, eg.
/// `package = { version = "<version>" }`
Detailed(DependencyDetails),
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct DependencyDetails {
pub(crate) version: Option<String>,
pub(crate) path: Option<String>,
pub(crate) git: Option<String>,
}

These dependencies are compiled when running forc build.

if let Some(ref deps) = manifest.dependencies {
for (dependency_name, dependency_details) in deps.iter() {
compile_dependency_lib(
&this_dir,
&dependency_name,
&dependency_details,
&mut namespace,
)?;
}
}

forc build must be modified to additionally:

Refs

Tracked by #27

@sezna
Copy link
Contributor

sezna commented Jun 2, 2021

I got most of that configuration manifest stuff from the Cargo repository itself. If desired, we could just continue to use that code to do this feature.

The specification of the dep: https://github.com/rust-lang/cargo/blob/2f3df16921deb34a92700f4d5a7ecfb424739558/src/cargo/core/dependency.rs#L32

The Registry abstraction: https://github.com/rust-lang/cargo/blob/e870eac9967b132825116525476d6875c305e4d8/crates/crates-io/lib.rs#L16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants