@@ -173,7 +173,8 @@ static bool
173
173
swiftModuleIsUpToDate (clang::vfs::FileSystem &FS,
174
174
StringRef ModuleCachePath,
175
175
StringRef OutPath,
176
- DiagnosticEngine &Diags) {
176
+ DiagnosticEngine &Diags,
177
+ DependencyTracker *OuterTracker) {
177
178
178
179
auto OutBuf = FS.getBufferForFile (OutPath);
179
180
if (!OutBuf)
@@ -189,6 +190,8 @@ swiftModuleIsUpToDate(clang::vfs::FileSystem &FS,
189
190
return false ;
190
191
191
192
for (auto In : AllDeps) {
193
+ if (OuterTracker)
194
+ OuterTracker->addDependency (In.Path , /* IsSystem=*/ false );
192
195
auto DepBuf = getBufferOfDependency (FS, OutPath, In.Path , Diags);
193
196
if (!DepBuf ||
194
197
DepBuf->getBufferSize () != In.Size ||
@@ -218,13 +221,16 @@ collectDepsForSerialization(clang::vfs::FileSystem &FS,
218
221
CompilerInstance &SubInstance,
219
222
StringRef InPath, StringRef ModuleCachePath,
220
223
SmallVectorImpl<FileDependency> &Deps,
221
- DiagnosticEngine &Diags) {
224
+ DiagnosticEngine &Diags,
225
+ DependencyTracker *OuterTracker) {
222
226
auto DTDeps = SubInstance.getDependencyTracker ()->getDependencies ();
223
227
SmallVector<StringRef, 16 > InitialDepNames (DTDeps.begin (), DTDeps.end ());
224
228
InitialDepNames.push_back (InPath);
225
229
llvm::StringSet<> AllDepNames;
226
230
for (auto const &DepName : InitialDepNames) {
227
231
AllDepNames.insert (DepName);
232
+ if (OuterTracker)
233
+ OuterTracker->addDependency (DepName, /* IsSystem=*/ false );
228
234
auto DepBuf = getBufferOfDependency (FS, InPath, DepName, Diags);
229
235
if (!DepBuf) {
230
236
return true ;
@@ -255,6 +261,8 @@ collectDepsForSerialization(clang::vfs::FileSystem &FS,
255
261
if (AllDepNames.count (SubDep.Path ) == 0 ) {
256
262
AllDepNames.insert (SubDep.Path );
257
263
Deps.push_back (SubDep);
264
+ if (OuterTracker)
265
+ OuterTracker->addDependency (SubDep.Path , /* IsSystem=*/ false );
258
266
}
259
267
}
260
268
}
@@ -265,7 +273,7 @@ collectDepsForSerialization(clang::vfs::FileSystem &FS,
265
273
static bool buildSwiftModuleFromSwiftInterface (
266
274
clang::vfs::FileSystem &FS, DiagnosticEngine &Diags,
267
275
CompilerInvocation &SubInvocation, StringRef InPath, StringRef OutPath,
268
- StringRef ModuleCachePath) {
276
+ StringRef ModuleCachePath, DependencyTracker *OuterTracker ) {
269
277
bool SubError = false ;
270
278
bool RunSuccess = llvm::CrashRecoveryContext ().RunSafelyOnThread ([&] {
271
279
@@ -328,7 +336,7 @@ static bool buildSwiftModuleFromSwiftInterface(
328
336
SerializationOpts.SerializeAllSIL = true ;
329
337
SmallVector<FileDependency, 16 > Deps;
330
338
if (collectDepsForSerialization (FS, SubInstance, InPath, ModuleCachePath,
331
- Deps, Diags)) {
339
+ Deps, Diags, OuterTracker )) {
332
340
SubError = true ;
333
341
return ;
334
342
}
@@ -369,9 +377,9 @@ std::error_code ParseableInterfaceModuleLoader::openModuleFiles(
369
377
configureSubInvocationAndOutputPaths (SubInvocation, InPath, OutPath);
370
378
371
379
// Evaluate if we need to run this sub-invocation, and if so run it.
372
- if (!swiftModuleIsUpToDate (FS, CacheDir, OutPath, Diags)) {
380
+ if (!swiftModuleIsUpToDate (FS, CacheDir, OutPath, Diags, dependencyTracker )) {
373
381
if (buildSwiftModuleFromSwiftInterface (FS, Diags, SubInvocation, InPath,
374
- OutPath, CacheDir))
382
+ OutPath, CacheDir, dependencyTracker ))
375
383
return std::make_error_code (std::errc::invalid_argument);
376
384
}
377
385
0 commit comments