1212import Foundation
1313
1414
15- @ _spi ( Testing ) public enum ModuleDependencyId : Hashable {
15+ public enum ModuleDependencyId : Hashable {
1616 case swift( String )
17+ case swiftPlaceholder( String )
1718 case clang( String )
1819
1920 public var moduleName : String {
2021 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
2325 }
2426 }
2527}
2628
2729extension ModuleDependencyId : Codable {
2830 enum CodingKeys : CodingKey {
2931 case swift
32+ case swiftPlaceholder
3033 case clang
3134 }
3235
@@ -36,8 +39,13 @@ extension ModuleDependencyId: Codable {
3639 let moduleName = try container. decode ( String . self, forKey: . swift)
3740 self = . swift( moduleName)
3841 } 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+ }
4149 }
4250 }
4351
@@ -46,59 +54,81 @@ extension ModuleDependencyId: Codable {
4654 switch self {
4755 case . swift( let moduleName) :
4856 try container. encode ( moduleName, forKey: . swift)
57+ case . swiftPlaceholder( let moduleName) :
58+ try container. encode ( moduleName, forKey: . swift)
4959 case . clang( let moduleName) :
5060 try container. encode ( moduleName, forKey: . clang)
5161 }
5262 }
5363}
5464
65+ /// Bridging header
66+ public struct BridgingHeader : Codable {
67+ var path : String
68+ var sourceFiles : [ String ]
69+ var moduleDependencies : [ String ]
70+ }
71+
5572/// Details specific to Swift modules.
56- @ _spi ( Testing ) public struct SwiftModuleDetails : Codable {
73+ public struct SwiftModuleDetails : Codable {
5774 /// The module interface from which this module was built, if any.
58- public var moduleInterfacePath : String ?
75+ @ _spi ( Testing ) public var moduleInterfacePath : String ?
5976
6077 /// The paths of potentially ready-to-use compiled modules for the interface.
61- public var compiledModuleCandidates : [ String ] ?
78+ @ _spi ( Testing ) public var compiledModuleCandidates : [ String ] ?
6279
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 ?
6586
6687 /// The bridging header, if any.
67- public var bridgingHeaderPath : String ?
88+ var bridgingHeaderPath : String ?
6889
6990 /// The source files referenced by the bridging header.
70- public var bridgingSourceFiles : [ String ] ? = [ ]
91+ var bridgingSourceFiles : [ String ] ? = [ ]
7192
7293 /// Options to the compile command
73- public var commandLine : [ String ] ? = [ ]
94+ var commandLine : [ String ] ? = [ ]
7495
7596 /// To build a PCM to be used by this Swift module, we need to append these
7697 /// arguments to the generic PCM build arguments reported from the dependency
7798 /// 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 ?
79109}
80110
81111/// Details specific to Clang modules.
82- @ _spi ( Testing ) public struct ClangModuleDetails : Codable {
112+ public struct ClangModuleDetails : Codable {
83113 /// The path to the module map used to build this module.
84- public var moduleMapPath : String
114+ @ _spi ( Testing ) public var moduleMapPath : String
85115
86116 /// clang-generated context hash
87- public var contextHash : String ?
117+ var contextHash : String ?
88118
89119 /// Options to the compile command
90- public var commandLine : [ String ] ? = [ ]
120+ var commandLine : [ String ] ? = [ ]
91121}
92122
93- @ _spi ( Testing ) public struct ModuleInfo : Codable {
123+ public struct ModuleInfo : Codable {
94124 /// The path for the module.
95125 public var modulePath : String
96126
97127 /// The source files used to build this module.
98- public var sourceFiles : [ String ] = [ ]
128+ public var sourceFiles : [ String ] ? = [ ]
99129
100130 /// The set of direct module dependencies of this module.
101- public var directDependencies : [ ModuleDependencyId ] = [ ]
131+ public var directDependencies : [ ModuleDependencyId ] ? = [ ]
102132
103133 /// Specific details of a particular kind of module.
104134 public var details : Details
@@ -109,6 +139,10 @@ extension ModuleDependencyId: Codable {
109139 /// a bridging header.
110140 case swift( SwiftModuleDetails )
111141
142+ /// Swift external modules carry additional details that specify their
143+ /// module doc path and source info paths.
144+ case swiftPlaceholder( swiftPlaceholderModuleDetails )
145+
112146 /// Clang modules are built from a module map file.
113147 case clang( ClangModuleDetails )
114148 }
@@ -117,6 +151,7 @@ extension ModuleDependencyId: Codable {
117151extension ModuleInfo . Details : Codable {
118152 enum CodingKeys : CodingKey {
119153 case swift
154+ case swiftPlaceholder
120155 case clang
121156 }
122157
@@ -126,8 +161,13 @@ extension ModuleInfo.Details: Codable {
126161 let details = try container. decode ( SwiftModuleDetails . self, forKey: . swift)
127162 self = . swift( details)
128163 } 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+ }
131171 }
132172 }
133173
@@ -136,6 +176,8 @@ extension ModuleInfo.Details: Codable {
136176 switch self {
137177 case . swift( let details) :
138178 try container. encode ( details, forKey: . swift)
179+ case . swiftPlaceholder( let details) :
180+ try container. encode ( details, forKey: . swiftPlaceholder)
139181 case . clang( let details) :
140182 try container. encode ( details, forKey: . clang)
141183 }
@@ -144,7 +186,7 @@ extension ModuleInfo.Details: Codable {
144186
145187/// Describes the complete set of dependencies for a Swift module, including
146188/// 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 {
148190 /// The name of the main module.
149191 public var mainModuleName : String
150192
0 commit comments