@@ -37,7 +37,8 @@ class Identifier;
3737// / Which kind of module dependencies we are looking for.
3838enum class ModuleDependenciesKind : int8_t {
3939 FirstKind,
40- SwiftTextual = FirstKind,
40+ SwiftInterface = FirstKind,
41+ SwiftSource,
4142 SwiftBinary,
4243 // Placeholder dependencies are a kind of dependencies used only by the
4344 // dependency scanner. They are swift modules that the scanner will not be
@@ -97,14 +98,14 @@ class ModuleDependenciesStorageBase {
9798 std::vector<std::string> moduleDependencies;
9899};
99100
100- // / Describes the dependencies of a Swift module.
101+ // / Describes the dependencies of a Swift module described by an Swift interface file .
101102// /
102103// / This class is mostly an implementation detail for \c ModuleDependencies.
103- class SwiftTextualModuleDependenciesStorage :
104+ class SwiftInterfaceModuleDependenciesStorage :
104105 public ModuleDependenciesStorageBase {
105106public:
106- // / The Swift interface file, if it can be used to generate the module file.
107- const Optional< std::string> swiftInterfaceFile;
107+ // / The Swift interface file to be used to generate the module file.
108+ const std::string swiftInterfaceFile;
108109
109110 // / Potentially ready-to-use compiled modules for the interface file.
110111 const std::vector<std::string> compiledModuleCandidates;
@@ -136,14 +137,14 @@ class SwiftTextualModuleDependenciesStorage :
136137 // / (Clang) modules on which the bridging header depends.
137138 std::vector<std::string> bridgingModuleDependencies;
138139
139- SwiftTextualModuleDependenciesStorage (
140- const Optional< std::string> & swiftInterfaceFile,
140+ SwiftInterfaceModuleDependenciesStorage (
141+ const std::string swiftInterfaceFile,
141142 ArrayRef<std::string> compiledModuleCandidates,
142143 ArrayRef<StringRef> buildCommandLine,
143144 ArrayRef<StringRef> extraPCMArgs,
144145 StringRef contextHash,
145146 bool isFramework
146- ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftTextual ),
147+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftInterface ),
147148 swiftInterfaceFile (swiftInterfaceFile),
148149 compiledModuleCandidates(compiledModuleCandidates.begin(),
149150 compiledModuleCandidates.end()),
@@ -152,14 +153,51 @@ class SwiftTextualModuleDependenciesStorage :
152153 contextHash(contextHash), isFramework(isFramework) { }
153154
154155 ModuleDependenciesStorageBase *clone () const override {
155- return new SwiftTextualModuleDependenciesStorage (*this );
156+ return new SwiftInterfaceModuleDependenciesStorage (*this );
156157 }
157158
158159 static bool classof (const ModuleDependenciesStorageBase *base) {
159- return base->dependencyKind == ModuleDependenciesKind::SwiftTextual ;
160+ return base->dependencyKind == ModuleDependenciesKind::SwiftInterface ;
160161 }
161162};
162163
164+ // / Describes the dependencies of a Swift module
165+ // /
166+ // / This class is mostly an implementation detail for \c ModuleDependencies.
167+ class SwiftSourceModuleDependenciesStorage :
168+ public ModuleDependenciesStorageBase {
169+ public:
170+ // / To build a PCM to be used by this Swift module, we need to append these
171+ // / arguments to the generic PCM build arguments reported from the dependency
172+ // / graph.
173+ const std::vector<std::string> extraPCMArgs;
174+
175+ // / Bridging header file, if there is one.
176+ Optional<std::string> bridgingHeaderFile;
177+
178+ // / Swift source files that are part of the Swift module, when known.
179+ std::vector<std::string> sourceFiles;
180+
181+ // / Source files on which the bridging header depends.
182+ std::vector<std::string> bridgingSourceFiles;
183+
184+ // / (Clang) modules on which the bridging header depends.
185+ std::vector<std::string> bridgingModuleDependencies;
186+
187+ SwiftSourceModuleDependenciesStorage (
188+ ArrayRef<StringRef> extraPCMArgs
189+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftSource),
190+ extraPCMArgs (extraPCMArgs.begin(), extraPCMArgs.end()) {}
191+
192+ ModuleDependenciesStorageBase *clone () const override {
193+ return new SwiftSourceModuleDependenciesStorage (*this );
194+ }
195+
196+ static bool classof (const ModuleDependenciesStorageBase *base) {
197+ return base->dependencyKind == ModuleDependenciesKind::SwiftSource;
198+ }
199+ };
200+
163201// / Describes the dependencies of a pre-built Swift module (with no .swiftinterface).
164202// /
165203// / This class is mostly an implementation detail for \c ModuleDependencies.
@@ -291,15 +329,15 @@ class ModuleDependencies {
291329
292330 // / Describe the module dependencies for a Swift module that can be
293331 // / built from a Swift interface file (\c .swiftinterface).
294- static ModuleDependencies forSwiftTextualModule (
295- const Optional< std::string> & swiftInterfaceFile,
332+ static ModuleDependencies forSwiftInterfaceModule (
333+ std::string swiftInterfaceFile,
296334 ArrayRef<std::string> compiledCandidates,
297335 ArrayRef<StringRef> buildCommands,
298336 ArrayRef<StringRef> extraPCMArgs,
299337 StringRef contextHash,
300338 bool isFramework) {
301339 return ModuleDependencies (
302- std::make_unique<SwiftTextualModuleDependenciesStorage >(
340+ std::make_unique<SwiftInterfaceModuleDependenciesStorage >(
303341 swiftInterfaceFile, compiledCandidates, buildCommands,
304342 extraPCMArgs, contextHash, isFramework));
305343 }
@@ -316,11 +354,9 @@ class ModuleDependencies {
316354 }
317355
318356 // / Describe the main Swift module.
319- static ModuleDependencies forMainSwiftModule (ArrayRef<StringRef> extraPCMArgs) {
357+ static ModuleDependencies forSwiftSourceModule (ArrayRef<StringRef> extraPCMArgs) {
320358 return ModuleDependencies (
321- std::make_unique<SwiftTextualModuleDependenciesStorage>(
322- None, ArrayRef<std::string>(), ArrayRef<StringRef>(),
323- extraPCMArgs, StringRef (), false ));
359+ std::make_unique<SwiftSourceModuleDependenciesStorage>(extraPCMArgs));
324360 }
325361
326362 // / Describe the module dependencies for a Clang module that can be
@@ -350,11 +386,14 @@ class ModuleDependencies {
350386 return storage->moduleDependencies ;
351387 }
352388
353- // / Whether the dependencies are for a Swift module: either Textual, Binary, or Placeholder.
389+ // / Whether the dependencies are for a Swift module: either Textual, Source, Binary, or Placeholder.
354390 bool isSwiftModule () const ;
355391
356392 // / Whether the dependencies are for a textual Swift module.
357- bool isSwiftTextualModule () const ;
393+ bool isSwiftInterfaceModule () const ;
394+
395+ // / Whether the dependencies are for a textual Swift module.
396+ bool isSwiftSourceModule () const ;
358397
359398 // / Whether the dependencies are for a binary Swift module.
360399 bool isSwiftBinaryModule () const ;
@@ -368,8 +407,11 @@ class ModuleDependencies {
368407 ModuleDependenciesKind getKind () const {
369408 return storage->dependencyKind ;
370409 }
410+ // / Retrieve the dependencies for a Swift textual-interface module.
411+ const SwiftInterfaceModuleDependenciesStorage *getAsSwiftInterfaceModule () const ;
412+
371413 // / Retrieve the dependencies for a Swift module.
372- const SwiftTextualModuleDependenciesStorage * getAsSwiftTextualModule () const ;
414+ const SwiftSourceModuleDependenciesStorage * getAsSwiftSourceModule () const ;
373415
374416 // / Retrieve the dependencies for a binary Swift module.
375417 const SwiftBinaryModuleDependencyStorage *getAsSwiftBinaryModule () const ;
0 commit comments