12
12
import Foundation
13
13
14
14
15
- @ _spi ( Testing ) public enum ModuleDependencyId : Hashable {
15
+ public enum ModuleDependencyId : Hashable {
16
16
case swift( String )
17
+ case swiftPlaceholder( String )
17
18
case clang( String )
18
19
19
20
public var moduleName : String {
20
21
switch self {
21
- case . swift( let name) : return name
22
- case . clang( let name) : return name
22
+ case . swift( let name) : return name
23
+ case . swiftPlaceholder( let name) : return name
24
+ case . clang( let name) : return name
23
25
}
24
26
}
25
27
}
26
28
27
29
extension ModuleDependencyId : Codable {
28
30
enum CodingKeys : CodingKey {
29
31
case swift
32
+ case swiftPlaceholder
30
33
case clang
31
34
}
32
35
@@ -36,8 +39,13 @@ extension ModuleDependencyId: Codable {
36
39
let moduleName = try container. decode ( String . self, forKey: . swift)
37
40
self = . swift( moduleName)
38
41
} catch {
39
- let moduleName = try container. decode ( String . self, forKey: . clang)
40
- self = . clang( moduleName)
42
+ do {
43
+ let moduleName = try container. decode ( String . self, forKey: . swiftPlaceholder)
44
+ self = . swiftPlaceholder( moduleName)
45
+ } catch {
46
+ let moduleName = try container. decode ( String . self, forKey: . clang)
47
+ self = . clang( moduleName)
48
+ }
41
49
}
42
50
}
43
51
@@ -46,59 +54,81 @@ extension ModuleDependencyId: Codable {
46
54
switch self {
47
55
case . swift( let moduleName) :
48
56
try container. encode ( moduleName, forKey: . swift)
57
+ case . swiftPlaceholder( let moduleName) :
58
+ try container. encode ( moduleName, forKey: . swift)
49
59
case . clang( let moduleName) :
50
60
try container. encode ( moduleName, forKey: . clang)
51
61
}
52
62
}
53
63
}
54
64
65
+ /// Bridging header
66
+ public struct BridgingHeader : Codable {
67
+ var path : String
68
+ var sourceFiles : [ String ]
69
+ var moduleDependencies : [ String ]
70
+ }
71
+
55
72
/// Details specific to Swift modules.
56
- @ _spi ( Testing ) public struct SwiftModuleDetails : Codable {
73
+ public struct SwiftModuleDetails : Codable {
57
74
/// The module interface from which this module was built, if any.
58
- public var moduleInterfacePath : String ?
75
+ @ _spi ( Testing ) public var moduleInterfacePath : String ?
59
76
60
77
/// The paths of potentially ready-to-use compiled modules for the interface.
61
- public var compiledModuleCandidates : [ String ] ?
78
+ @ _spi ( Testing ) public var compiledModuleCandidates : [ String ] ?
62
79
63
- /// The path to the already-compiled module.
64
- public var compiledModulePath : String ?
80
+ /// The path to the already-compiled module that must be used instead of
81
+ /// generating a job to build this module. In standard compilation, the dependency scanner
82
+ /// may discover compiled module candidates to be used instead of re-compiling from interface.
83
+ /// In contrast, this explicitCompiledModulePath is only to be used for precompiled modules
84
+ /// external dependencies in Explicit Module Build mode
85
+ @_spi ( Testing) public var explicitCompiledModulePath : String ?
65
86
66
87
/// The bridging header, if any.
67
- public var bridgingHeaderPath : String ?
88
+ var bridgingHeaderPath : String ?
68
89
69
90
/// The source files referenced by the bridging header.
70
- public var bridgingSourceFiles : [ String ] ? = [ ]
91
+ var bridgingSourceFiles : [ String ] ? = [ ]
71
92
72
93
/// Options to the compile command
73
- public var commandLine : [ String ] ? = [ ]
94
+ var commandLine : [ String ] ? = [ ]
74
95
75
96
/// To build a PCM to be used by this Swift module, we need to append these
76
97
/// arguments to the generic PCM build arguments reported from the dependency
77
98
/// graph.
78
- public var extraPcmArgs : [ String ] ? = [ ]
99
+ @_spi ( Testing) public var extraPcmArgs : [ String ] ?
100
+ }
101
+
102
+ /// Details specific to Swift external modules.
103
+ public struct swiftPlaceholderModuleDetails : Codable {
104
+ /// The path to the .swiftModuleDoc file.
105
+ var moduleDocPath : String ?
106
+
107
+ /// The path to the .swiftSourceInfo file.
108
+ var moduleSourceInfoPath : String ?
79
109
}
80
110
81
111
/// Details specific to Clang modules.
82
- @ _spi ( Testing ) public struct ClangModuleDetails : Codable {
112
+ public struct ClangModuleDetails : Codable {
83
113
/// The path to the module map used to build this module.
84
- public var moduleMapPath : String
114
+ @ _spi ( Testing ) public var moduleMapPath : String
85
115
86
116
/// clang-generated context hash
87
- public var contextHash : String ?
117
+ var contextHash : String ?
88
118
89
119
/// Options to the compile command
90
- public var commandLine : [ String ] ? = [ ]
120
+ var commandLine : [ String ] ? = [ ]
91
121
}
92
122
93
- @ _spi ( Testing ) public struct ModuleInfo : Codable {
123
+ public struct ModuleInfo : Codable {
94
124
/// The path for the module.
95
125
public var modulePath : String
96
126
97
127
/// The source files used to build this module.
98
- public var sourceFiles : [ String ] = [ ]
128
+ public var sourceFiles : [ String ] ? = [ ]
99
129
100
130
/// The set of direct module dependencies of this module.
101
- public var directDependencies : [ ModuleDependencyId ] = [ ]
131
+ public var directDependencies : [ ModuleDependencyId ] ? = [ ]
102
132
103
133
/// Specific details of a particular kind of module.
104
134
public var details : Details
@@ -109,6 +139,10 @@ extension ModuleDependencyId: Codable {
109
139
/// a bridging header.
110
140
case swift( SwiftModuleDetails )
111
141
142
+ /// Swift external modules carry additional details that specify their
143
+ /// module doc path and source info paths.
144
+ case swiftPlaceholder( swiftPlaceholderModuleDetails )
145
+
112
146
/// Clang modules are built from a module map file.
113
147
case clang( ClangModuleDetails )
114
148
}
@@ -117,6 +151,7 @@ extension ModuleDependencyId: Codable {
117
151
extension ModuleInfo . Details : Codable {
118
152
enum CodingKeys : CodingKey {
119
153
case swift
154
+ case swiftPlaceholder
120
155
case clang
121
156
}
122
157
@@ -126,8 +161,13 @@ extension ModuleInfo.Details: Codable {
126
161
let details = try container. decode ( SwiftModuleDetails . self, forKey: . swift)
127
162
self = . swift( details)
128
163
} catch {
129
- let details = try container. decode ( ClangModuleDetails . self, forKey: . clang)
130
- self = . clang( details)
164
+ do {
165
+ let details = try container. decode ( swiftPlaceholderModuleDetails. self, forKey: . swiftPlaceholder)
166
+ self = . swiftPlaceholder( details)
167
+ } catch {
168
+ let details = try container. decode ( ClangModuleDetails . self, forKey: . clang)
169
+ self = . clang( details)
170
+ }
131
171
}
132
172
}
133
173
@@ -136,6 +176,8 @@ extension ModuleInfo.Details: Codable {
136
176
switch self {
137
177
case . swift( let details) :
138
178
try container. encode ( details, forKey: . swift)
179
+ case . swiftPlaceholder( let details) :
180
+ try container. encode ( details, forKey: . swiftPlaceholder)
139
181
case . clang( let details) :
140
182
try container. encode ( details, forKey: . clang)
141
183
}
@@ -144,7 +186,7 @@ extension ModuleInfo.Details: Codable {
144
186
145
187
/// Describes the complete set of dependencies for a Swift module, including
146
188
/// all of the Swift and C modules and source files it depends on.
147
- @ _spi ( Testing ) public struct InterModuleDependencyGraph : Codable {
189
+ public struct InterModuleDependencyGraph : Codable {
148
190
/// The name of the main module.
149
191
public var mainModuleName : String
150
192
0 commit comments