Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

[WIP] Integrate Arbiter #1

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c22345c
Add Arbiter submodule
jspahrsummers Oct 2, 2016
e9a0f20
Integrate Arbiter.framework into Xcode project
jspahrsummers Oct 2, 2016
afa7673
Increase deployment target to match Arbiter
jspahrsummers Oct 2, 2016
a025fd1
Fix search paths crap added by Xcode
jspahrsummers Oct 2, 2016
676707d
Start bridging Arbiter and Carthage types
jspahrsummers Oct 2, 2016
c5851b3
Add Dependency and Cartfile conversions
jspahrsummers Oct 2, 2016
e95ac7b
Convert from a resolved graph, not an installer
jspahrsummers Oct 2, 2016
a8619e8
Gut Resolver and replace it with Arbiter callouts
jspahrsummers Oct 2, 2016
a0cdce6
Add TODO around GitReferences
jspahrsummers Oct 2, 2016
b32bb93
Use a Debug build for now
jspahrsummers Oct 2, 2016
5d3ee29
Remove preconditions which always fire
jspahrsummers Oct 2, 2016
a3a4ec7
Remove some force unwraps
jspahrsummers Oct 2, 2016
98fabe0
Permit pinned version -> semantic version conversion to fail
jspahrsummers Oct 2, 2016
36d82bb
++Arbiter
jspahrsummers Oct 2, 2016
42050f7
++Arbiter
jspahrsummers Oct 2, 2016
a87d20f
Use Resolver.resolve() from Arbiter
jspahrsummers Oct 2, 2016
c2209dc
++Arbiter
jspahrsummers Oct 2, 2016
8991489
++Arbiter to swift-bindings-fixes
jspahrsummers Oct 2, 2016
b957e21
Pass in nil for SelectedVersion(semanticVersion:) when parsing fails
jspahrsummers Oct 2, 2016
490dfff
Add a description to ArbiterValueBox
jspahrsummers Oct 2, 2016
5a25330
Attempt to implement Git reference resolution
jspahrsummers Oct 2, 2016
2e05a0c
Disable Git reference support until Arbiter can be improved
jspahrsummers Oct 2, 2016
49324ca
Reimplement lastResolved and dependenciesToUpdate
jspahrsummers Oct 2, 2016
9f39c09
Basic documentation for ArbiterBridge
jspahrsummers Oct 2, 2016
99853aa
++Arbiter to replace addRoot() with addNode()
jspahrsummers Oct 8, 2016
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "Carthage/Checkouts/Tentacle"]
path = Carthage/Checkouts/Tentacle
url = https://github.com/mdiep/Tentacle.git
[submodule "Carthage/Checkouts/Arbiter"]
path = Carthage/Checkouts/Arbiter
url = https://github.com/ArbiterLib/Arbiter.git
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ github "Carthage/Commandant" ~> 0.10.1
github "jdhealy/PrettyColors" ~> 4.0
github "ReactiveCocoa/ReactiveCocoa" ~> 4.2.2
github "mdiep/Tentacle" ~> 0.4.1
github "ArbiterLib/Arbiter" "multiple-dependents"
1 change: 1 addition & 0 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github "ArbiterLib/Arbiter" "045a731fab5f609dad082d77549d314813d511f0"
github "thoughtbot/Argo" "v3.1.0"
github "thoughtbot/Curry" "v2.3.3"
github "Quick/Nimble" "188caeb094bc342614d8a5c706cd8bb9a6c355eb"
Expand Down
18 changes: 14 additions & 4 deletions Carthage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
D074EDC51A049283001DE082 /* FrameworkExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074EDC41A049283001DE082 /* FrameworkExtensions.swift */; };
D095BA3C1A187D40007F15D6 /* Bootstrap.swift in Sources */ = {isa = PBXBuildFile; fileRef = D095BA3B1A187D40007F15D6 /* Bootstrap.swift */; };
D0A2025E1B114D1000C71375 /* ProducerQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0A2025D1B114D1000C71375 /* ProducerQueue.swift */; };
D0A397201DA14C7100A0CECC /* Arbiter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0A3971F1DA14C7100A0CECC /* Arbiter.framework */; };
D0A397221DA14C8000A0CECC /* Arbiter.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = D0A3971F1DA14C7100A0CECC /* Arbiter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D0A397241DA14D7400A0CECC /* ArbiterBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0A397231DA14D7400A0CECC /* ArbiterBridge.swift */; };
D0AAAB4A19FAEDB4007B24B3 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AAAB4919FAEDB4007B24B3 /* Errors.swift */; };
D0AAAB5019FB0960007B24B3 /* CarthageKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D0D1216D19E87B05005E4BAA /* CarthageKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
D0AAAB5519FB1062007B24B3 /* TestCartfile in Resources */ = {isa = PBXBuildFile; fileRef = D0AAAB5419FB1062007B24B3 /* TestCartfile */; };
Expand Down Expand Up @@ -139,6 +142,7 @@
67AFA98B1A79433900B7DA78 /* PrettyColors.framework in Copy Frameworks */,
D0F648831A4DD3EA00BCF808 /* Argo.framework in Copy Frameworks */,
D012AD111AF9844D00EE91DA /* Result.framework in Copy Frameworks */,
D0A397221DA14C8000A0CECC /* Arbiter.framework in Copy Frameworks */,
);
name = "Copy Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -202,6 +206,8 @@
D074EDC41A049283001DE082 /* FrameworkExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FrameworkExtensions.swift; sourceTree = "<group>"; };
D095BA3B1A187D40007F15D6 /* Bootstrap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bootstrap.swift; sourceTree = "<group>"; };
D0A2025D1B114D1000C71375 /* ProducerQueue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProducerQueue.swift; sourceTree = "<group>"; };
D0A3971F1DA14C7100A0CECC /* Arbiter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Arbiter.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D0A397231DA14D7400A0CECC /* ArbiterBridge.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArbiterBridge.swift; sourceTree = "<group>"; };
D0AAAB4919FAEDB4007B24B3 /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
D0AAAB5419FB1062007B24B3 /* TestCartfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TestCartfile; sourceTree = "<group>"; };
D0AAC23F1A14933100060F2E /* Update.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Update.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -260,6 +266,7 @@
D01F8A3F19EA28C400643E7C /* ReactiveCocoa.framework in Frameworks */,
67AFA98A1A79430B00B7DA78 /* PrettyColors.framework in Frameworks */,
D0F648821A4DD3D900BCF808 /* Argo.framework in Frameworks */,
D0A397201DA14C7100A0CECC /* Arbiter.framework in Frameworks */,
D012AD101AF9843700EE91DA /* Result.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -432,6 +439,7 @@
children = (
D0D1217119E87B05005E4BAA /* CarthageKit.h */,
3A0472F21C782B4000097EC7 /* Algorithms.swift */,
D0A397231DA14D7400A0CECC /* ArbiterBridge.swift */,
D069CA231A4E3B2700314A85 /* Archive.swift */,
89E80E601C754FFD000F8DCB /* BuildArguments.swift */,
CDF9D3701CF1E54200DF5A6F /* BuildOptions.swift */,
Expand Down Expand Up @@ -463,6 +471,7 @@
D01F8A3E19EA28C400643E7C /* ReactiveCocoa.framework */,
D0E0E1AF1A2D28AC0097BE2B /* ReactiveTask.framework */,
BEB076651C8A1FD800ABD373 /* Tentacle.framework */,
D0A3971F1DA14C7100A0CECC /* Arbiter.framework */,
D0D1217019E87B05005E4BAA /* Info.plist */,
);
name = "Supporting Files";
Expand Down Expand Up @@ -731,6 +740,7 @@
D0DE89441A0F2D9B0030A3EC /* Scannable.swift in Sources */,
D01D82D71A10160700F0DD94 /* Resolver.swift in Sources */,
D074EDC51A049283001DE082 /* FrameworkExtensions.swift in Sources */,
D0A397241DA14D7400A0CECC /* ArbiterBridge.swift in Sources */,
88ED56D619ECE34900CBF5C4 /* Git.swift in Sources */,
D0D1219219E88B8F005E4BAA /* GitHub.swift in Sources */,
CDF9D3711CF1E54200DF5A6F /* BuildOptions.swift in Sources */,
Expand Down Expand Up @@ -805,7 +815,7 @@
buildSettings = {
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.11;
ONLY_ACTIVE_ARCH = YES;
SWIFT_VERSION = 2.3;
};
Expand All @@ -816,7 +826,7 @@
baseConfigurationReference = D0D1212819E878CC005E4BAA /* Release.xcconfig */;
buildSettings = {
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.11;
SWIFT_VERSION = 2.3;
};
name = Release;
Expand Down Expand Up @@ -888,7 +898,7 @@
baseConfigurationReference = D0D1212719E878CC005E4BAA /* Profile.xcconfig */;
buildSettings = {
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.11;
SWIFT_VERSION = 2.3;
};
name = Profile;
Expand Down Expand Up @@ -929,7 +939,7 @@
baseConfigurationReference = D0D1212919E878CC005E4BAA /* Test.xcconfig */;
buildSettings = {
GCC_NO_COMMON_BLOCKS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MACOSX_DEPLOYMENT_TARGET = 10.11;
SWIFT_VERSION = 2.3;
};
name = Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down
3 changes: 3 additions & 0 deletions Carthage.xcworkspace/contents.xcworkspacedata

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

1 change: 1 addition & 0 deletions Carthage/Checkouts/Arbiter
Submodule Arbiter added at 045a73
153 changes: 153 additions & 0 deletions Source/CarthageKit/ArbiterBridge.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import Arbiter

// This file contains internal utilities for bridging between CarthageKit's
// public API and the use of Arbiter as an implementation detail.
//
// Even though Arbiter may offer richer features in some cases, we avoid them
// when necessary in favor of backwards compatibility for Carthage.

/**
* Used to give identity to CarthageKit value types, so they can be associated
* with Arbiter data types.
*/
class ArbiterValueBox<T: Comparable where T: Hashable>: ArbiterValue, CustomStringConvertible {
init(_ value: T) {
self.unbox = value
}

let unbox: T

var hashValue: Int {
return unbox.hashValue
}

var description: String {
return "\(unbox)"
}
}

func ==<T: Equatable>(lhs: ArbiterValueBox<T>, rhs: ArbiterValueBox<T>) -> Bool {
return lhs.unbox == rhs.unbox
}

func <<T: Comparable>(lhs: ArbiterValueBox<T>, rhs: ArbiterValueBox<T>) -> Bool {
return lhs.unbox < rhs.unbox
}

/**
* Extends PinnedVersion with the requirements needed for ArbiterValueBox.
*/
extension PinnedVersion: Hashable, Comparable {
public var hashValue: Int {
return commitish.hashValue
}
}

public func <(lhs: PinnedVersion, rhs: PinnedVersion) -> Bool {
return lhs.commitish < rhs.commitish
}

extension ProjectIdentifier {
typealias ArbiterType = Arbiter.ProjectIdentifier<ArbiterValueBox<ProjectIdentifier>>

func toArbiter() -> ArbiterType {
return Arbiter.ProjectIdentifier(value: ArbiterValueBox(self))
}

static func fromArbiter(x: ArbiterType) -> ProjectIdentifier {
return x.value.unbox
}
}

extension SemanticVersion {
typealias ArbiterType = Arbiter.SemanticVersion

func toArbiter() -> ArbiterType {
return Arbiter.SemanticVersion(major: major, minor: minor, patch: patch)
}

static func fromArbiter(x: ArbiterType) -> SemanticVersion {
precondition(x.prereleaseVersion == nil)
precondition(x.buildMetadata == nil)

return SemanticVersion(major: x.major, minor: x.minor, patch: x.patch)
}
}

extension PinnedVersion {
typealias ArbiterType = Arbiter.SelectedVersion<ArbiterValueBox<PinnedVersion>>

func toArbiter() -> ArbiterType {
let semVer = try? SemanticVersion.fromPinnedVersion(self).dematerialize()
return Arbiter.SelectedVersion(semanticVersion: semVer?.toArbiter(), metadata: ArbiterValueBox(self))
}

static func fromArbiter(x: ArbiterType) -> PinnedVersion {
return x.metadata.unbox
}
}

extension VersionSpecifier {
typealias ArbiterType = Arbiter.Requirement

func toArbiter() -> ArbiterType {
switch self {
case .Any:
return Arbiter.Requirement(Specifier.Any)

case let .AtLeast(version):
return Arbiter.Requirement(Specifier.AtLeast(version.toArbiter()))

case let .CompatibleWith(version):
return Arbiter.Requirement(Specifier.CompatibleWith(version.toArbiter(), ArbiterRequirementStrictnessAllowVersionZeroPatches))

case let .Exactly(version):
return Arbiter.Requirement(Specifier.Exactly(version.toArbiter()))

case let .GitReference(commitish):
return Arbiter.Requirement(Specifier.Any)
/*
TODO: This needs a rework in Arbiter, because as written here, the requirement is never satisfied
(consider commitishes specified here, but which get expanded into full commit hashes during lookup)

let pinnedVersion = PinnedVersion(commitish)
let unversionedSpecifier = Specifier.Unversioned(ArbiterValueBox<PinnedVersion>(pinnedVersion).toUserValue())
return Arbiter.Requirement(Specifier.Prioritized(unversionedSpecifier, 10))
*/
}
}
}

func dependencyToArbiter(dependency: Dependency<VersionSpecifier>) -> Arbiter.Dependency<ArbiterValueBox<ProjectIdentifier>> {
return Arbiter.Dependency(project: dependency.project.toArbiter(), requirement: dependency.version.toArbiter())
}

func dependencyToArbiter(dependency: Dependency<PinnedVersion>) -> Arbiter.ResolvedDependency<ArbiterValueBox<ProjectIdentifier>, ArbiterValueBox<PinnedVersion>> {
return Arbiter.ResolvedDependency(project: dependency.project.toArbiter(), version: dependency.version.toArbiter())
}

func dependencyFromArbiter(dependency: Arbiter.ResolvedDependency<ArbiterValueBox<ProjectIdentifier>, ArbiterValueBox<PinnedVersion>>) -> Dependency<PinnedVersion> {
let project = ProjectIdentifier.fromArbiter(dependency.project)
let version = PinnedVersion.fromArbiter(dependency.version)
return Dependency(project: project, version: version)
}

extension Cartfile {
typealias ArbiterType = Arbiter.DependencyList<ArbiterValueBox<ProjectIdentifier>>

func toArbiter() -> ArbiterType {
return Arbiter.DependencyList(dependencies.map(dependencyToArbiter))
}
}

extension ResolvedCartfile {
typealias ArbiterType = Arbiter.ResolvedDependencyGraph<ArbiterValueBox<ProjectIdentifier>, ArbiterValueBox<PinnedVersion>>

static func fromArbiter(x: ArbiterType) -> ResolvedCartfile {
let installer = Arbiter.ResolvedDependencyInstaller(graph: x)

return ResolvedCartfile(dependencies: installer.phases.flatMap { phase in
return phase.map(dependencyFromArbiter)
})
}
}
9 changes: 9 additions & 0 deletions Source/CarthageKit/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright (c) 2014 Carthage. All rights reserved.
//

import Arbiter
import Foundation
import ReactiveCocoa
import ReactiveTask
Expand Down Expand Up @@ -81,6 +82,8 @@ public enum CarthageError: ErrorType, Equatable {

/// An error occurred while shelling out.
case TaskError(ReactiveTask.TaskError)

case ResolverError(ArbiterError)
}

private func == (lhs: CarthageError.VersionRequirement, rhs: CarthageError.VersionRequirement) -> Bool {
Expand Down Expand Up @@ -138,6 +141,9 @@ public func == (lhs: CarthageError, rhs: CarthageError) -> Bool {
case let (.TaskError(left), .TaskError(right)):
return left == right

case let (.ResolverError(left), .ResolverError(right)):
return left.description == right.description

default:
return false
}
Expand Down Expand Up @@ -263,6 +269,9 @@ extension CarthageError: CustomStringConvertible {

case let .TaskError(taskError):
return taskError.description

case let .ResolverError(error):
return error.description
}
}
}
Expand Down
Loading