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

Implement local dependencies proposal #1583

Merged
merged 1 commit into from
May 24, 2018

Conversation

aciidgh
Copy link
Contributor

@aciidgh aciidgh commented May 22, 2018

rdar://problem/39418745 [SR-7433]: Implement SE-201 Package Manager Local Dependencies

@aciidgh
Copy link
Contributor Author

aciidgh commented May 22, 2018

This is mostly complete but needs actual tests and I need to make sure I didn't miss any edge case. @hartbit I'll appreciate if you can review the code

@aciidgh aciidgh requested a review from hartbit May 22, 2018 23:59
@aciidgh aciidgh force-pushed the local-packages branch 10 times, most recently from 9ddac0b to 40c7587 Compare May 24, 2018 01:46
@aciidgh
Copy link
Contributor Author

aciidgh commented May 24, 2018

@swift-ci please smoke test

@aciidgh aciidgh changed the title [WIP] Implement local dependencies proposal Implement local dependencies proposal May 24, 2018
<rdar://problem/39418745> [SR-7433]: Implement SE-201 Package Manager Local Dependencies
@aciidgh
Copy link
Contributor Author

aciidgh commented May 24, 2018

@swift-ci please smoke test

@aciidgh aciidgh merged commit 876746b into swiftlang:master May 24, 2018
@aciidgh aciidgh deleted the local-packages branch May 24, 2018 02:40
@@ -24,6 +24,12 @@ extension Package.Dependency: Equatable {
url: String,
_ requirement: Package.Dependency.Requirement
) -> Package.Dependency {
// FIXME: This is suboptimal but its the only way to do this right now.
Copy link
Contributor

@hartbit hartbit Jun 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird to encode local dependency as requirement. Could we have made dependency into an enum:

public enum Dependency {
    case remote(RemoteDependency)
    case local(LocalDependency)
}

public class RemoteDependency {
    /// The dependency requirement.
    public enum Requirement {
        case exactItem(Version)
        case rangeItem(Range<Version>)
        case revisionItem(String)
        case branchItem(String)
    }

    /// The url of the dependency.
    public let url: String

    /// The dependency requirement.
    public let requirement: Requirement

    /// Create a dependency.
    init(url: String, requirement: Requirement) {
        self.url = url
        self.requirement = requirement
    }
}

public class LocalDependency {
    public let path: String
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly...I plan to revisit these data structure as part of upcoming runtime refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note that we can't change the public facing data structures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can’t we change the public facing data structures as part of a 4.2 PD?

@@ -17,6 +17,7 @@ public enum DependencyResolverError: Error, Equatable, CustomStringConvertible {
case unsatisfiable

/// The resolver encountered a versioned container which has a revision dependency.
// FIXME: Rename this to incompatible constraints.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you want to rename it now?

@@ -133,6 +134,9 @@ extension PackageDescription4.Package.Dependency.Requirement {

case .exactItem(let version):
return .versionSet(.exact(Version(pdVersion: version)))

case .localPackageItem:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused as to why we're representing local packages through Requirement. Is this the only solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement is correct though as it is a requirement.

guard case .checkout(let currentState) = dependency.state else {
let error = WorkspaceDiagnostics.DependencyAlreadyInEditMode(dependencyName: packageName)
return diagnostics.emit(error)
// FIXME: This should be "can resolve" and not "can edit".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we're not renaming it now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just a low-priority change.

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

Successfully merging this pull request may close these issues.

2 participants