@@ -37,7 +37,8 @@ class Identifier;
37
37
// / Which kind of module dependencies we are looking for.
38
38
enum class ModuleDependenciesKind : int8_t {
39
39
FirstKind,
40
- SwiftTextual = FirstKind,
40
+ SwiftInterface = FirstKind,
41
+ SwiftSource,
41
42
SwiftBinary,
42
43
// Placeholder dependencies are a kind of dependencies used only by the
43
44
// dependency scanner. They are swift modules that the scanner will not be
@@ -97,14 +98,14 @@ class ModuleDependenciesStorageBase {
97
98
std::vector<std::string> moduleDependencies;
98
99
};
99
100
100
- // / Describes the dependencies of a Swift module.
101
+ // / Describes the dependencies of a Swift module described by an Swift interface file .
101
102
// /
102
103
// / This class is mostly an implementation detail for \c ModuleDependencies.
103
- class SwiftTextualModuleDependenciesStorage :
104
+ class SwiftInterfaceModuleDependenciesStorage :
104
105
public ModuleDependenciesStorageBase {
105
106
public:
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;
108
109
109
110
// / Potentially ready-to-use compiled modules for the interface file.
110
111
const std::vector<std::string> compiledModuleCandidates;
@@ -136,14 +137,14 @@ class SwiftTextualModuleDependenciesStorage :
136
137
// / (Clang) modules on which the bridging header depends.
137
138
std::vector<std::string> bridgingModuleDependencies;
138
139
139
- SwiftTextualModuleDependenciesStorage (
140
- const Optional< std::string> & swiftInterfaceFile,
140
+ SwiftInterfaceModuleDependenciesStorage (
141
+ const std::string swiftInterfaceFile,
141
142
ArrayRef<std::string> compiledModuleCandidates,
142
143
ArrayRef<StringRef> buildCommandLine,
143
144
ArrayRef<StringRef> extraPCMArgs,
144
145
StringRef contextHash,
145
146
bool isFramework
146
- ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftTextual ),
147
+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftInterface ),
147
148
swiftInterfaceFile (swiftInterfaceFile),
148
149
compiledModuleCandidates(compiledModuleCandidates.begin(),
149
150
compiledModuleCandidates.end()),
@@ -152,14 +153,51 @@ class SwiftTextualModuleDependenciesStorage :
152
153
contextHash(contextHash), isFramework(isFramework) { }
153
154
154
155
ModuleDependenciesStorageBase *clone () const override {
155
- return new SwiftTextualModuleDependenciesStorage (*this );
156
+ return new SwiftInterfaceModuleDependenciesStorage (*this );
156
157
}
157
158
158
159
static bool classof (const ModuleDependenciesStorageBase *base) {
159
- return base->dependencyKind == ModuleDependenciesKind::SwiftTextual ;
160
+ return base->dependencyKind == ModuleDependenciesKind::SwiftInterface ;
160
161
}
161
162
};
162
163
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
+
163
201
// / Describes the dependencies of a pre-built Swift module (with no .swiftinterface).
164
202
// /
165
203
// / This class is mostly an implementation detail for \c ModuleDependencies.
@@ -291,15 +329,15 @@ class ModuleDependencies {
291
329
292
330
// / Describe the module dependencies for a Swift module that can be
293
331
// / 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,
296
334
ArrayRef<std::string> compiledCandidates,
297
335
ArrayRef<StringRef> buildCommands,
298
336
ArrayRef<StringRef> extraPCMArgs,
299
337
StringRef contextHash,
300
338
bool isFramework) {
301
339
return ModuleDependencies (
302
- std::make_unique<SwiftTextualModuleDependenciesStorage >(
340
+ std::make_unique<SwiftInterfaceModuleDependenciesStorage >(
303
341
swiftInterfaceFile, compiledCandidates, buildCommands,
304
342
extraPCMArgs, contextHash, isFramework));
305
343
}
@@ -316,11 +354,9 @@ class ModuleDependencies {
316
354
}
317
355
318
356
// / Describe the main Swift module.
319
- static ModuleDependencies forMainSwiftModule (ArrayRef<StringRef> extraPCMArgs) {
357
+ static ModuleDependencies forSwiftSourceModule (ArrayRef<StringRef> extraPCMArgs) {
320
358
return ModuleDependencies (
321
- std::make_unique<SwiftTextualModuleDependenciesStorage>(
322
- None, ArrayRef<std::string>(), ArrayRef<StringRef>(),
323
- extraPCMArgs, StringRef (), false ));
359
+ std::make_unique<SwiftSourceModuleDependenciesStorage>(extraPCMArgs));
324
360
}
325
361
326
362
// / Describe the module dependencies for a Clang module that can be
@@ -350,11 +386,14 @@ class ModuleDependencies {
350
386
return storage->moduleDependencies ;
351
387
}
352
388
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.
354
390
bool isSwiftModule () const ;
355
391
356
392
// / 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 ;
358
397
359
398
// / Whether the dependencies are for a binary Swift module.
360
399
bool isSwiftBinaryModule () const ;
@@ -368,8 +407,11 @@ class ModuleDependencies {
368
407
ModuleDependenciesKind getKind () const {
369
408
return storage->dependencyKind ;
370
409
}
410
+ // / Retrieve the dependencies for a Swift textual-interface module.
411
+ const SwiftInterfaceModuleDependenciesStorage *getAsSwiftInterfaceModule () const ;
412
+
371
413
// / Retrieve the dependencies for a Swift module.
372
- const SwiftTextualModuleDependenciesStorage * getAsSwiftTextualModule () const ;
414
+ const SwiftSourceModuleDependenciesStorage * getAsSwiftSourceModule () const ;
373
415
374
416
// / Retrieve the dependencies for a binary Swift module.
375
417
const SwiftBinaryModuleDependencyStorage *getAsSwiftBinaryModule () const ;
0 commit comments