forked from tuist/tuist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGraphDependency.swift
137 lines (121 loc) · 4.21 KB
/
GraphDependency.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import Foundation
import TSCBasic
public enum GraphDependency: Hashable, CustomStringConvertible, Comparable, Codable {
/// A dependency that represents a pre-compiled .xcframework.
case xcframework(
path: AbsolutePath,
infoPlist: XCFrameworkInfoPlist,
primaryBinaryPath: AbsolutePath,
linking: BinaryLinking
)
/// A dependency that represents a pre-compiled framework.
case framework(
path: AbsolutePath,
binaryPath: AbsolutePath,
dsymPath: AbsolutePath?,
bcsymbolmapPaths: [AbsolutePath],
linking: BinaryLinking,
architectures: [BinaryArchitecture],
isCarthage: Bool
)
/// A dependency that represents a pre-compiled library.
case library(
path: AbsolutePath,
publicHeaders: AbsolutePath,
linking: BinaryLinking,
architectures: [BinaryArchitecture],
swiftModuleMap: AbsolutePath?
)
/// A dependency that represents a pre-compiled bundle.
case bundle(path: AbsolutePath)
/// A dependency that represents a package product.
case packageProduct(path: AbsolutePath, product: String)
/// A dependency that represents a target that is defined in the project at the given path.
case target(name: String, path: AbsolutePath)
/// A dependency that represents an SDK
case sdk(name: String, path: AbsolutePath, status: SDKStatus, source: SDKSource)
public func hash(into hasher: inout Hasher) {
switch self {
case let .xcframework(path, _, _, _):
hasher.combine("xcframework")
hasher.combine(path)
case let .framework(path, _, _, _, _, _, _):
hasher.combine("framework")
hasher.combine(path)
case let .library(path, _, _, _, _):
hasher.combine("library")
hasher.combine(path)
case let .bundle(path):
hasher.combine("bundle")
hasher.combine(path)
case let .packageProduct(path, product):
hasher.combine("package")
hasher.combine(path)
hasher.combine(product)
case let .target(name, path):
hasher.combine("target")
hasher.combine(name)
hasher.combine(path)
case let .sdk(name, path, status, source):
hasher.combine("sdk")
hasher.combine(name)
hasher.combine(path)
hasher.combine(status)
hasher.combine(source)
}
}
public var isTarget: Bool {
switch self {
case .xcframework: return false
case .framework: return false
case .library: return false
case .bundle: return false
case .packageProduct: return false
case .target: return true
case .sdk: return false
}
}
public var isPrecompiled: Bool {
switch self {
case .xcframework: return true
case .framework: return true
case .library: return true
case .bundle: return true
case .packageProduct: return false
case .target: return false
case .sdk: return false
}
}
// MARK: - Internal
public var targetDependency: (name: String, path: AbsolutePath)? {
switch self {
case let .target(name: name, path: path):
return (name, path)
default:
return nil
}
}
// MARK: - CustomStringConvertible
public var description: String {
switch self {
case let .xcframework(path, _, _, _):
return "xcframework '\(path.basename)'"
case let .framework(path, _, _, _, _, _, _):
return "framework '\(path.basename)'"
case let .library(path, _, _, _, _):
return "library '\(path.basename)'"
case let .bundle(path):
return "bundle '\(path.basename)'"
case let .packageProduct(_, product):
return "package '\(product)'"
case let .target(name, _):
return "target '\(name)'"
case let .sdk(name, _, _, _):
return "sdk '\(name)'"
}
}
// MARK: - Comparable
public static func < (lhs: GraphDependency, rhs: GraphDependency) -> Bool {
lhs.description < rhs.description
}
}