@@ -309,36 +309,41 @@ class ExplicitModuleDependencyResolver {
309
309
llvm::Error handleSwiftInterfaceModuleDependency (
310
310
ModuleDependencyID depModuleID,
311
311
const SwiftInterfaceModuleDependenciesStorage &interfaceDepDetails) {
312
- auto &path = interfaceDepDetails.moduleCacheKey .empty ()
313
- ? interfaceDepDetails.moduleOutputPath
314
- : interfaceDepDetails.moduleCacheKey ;
315
- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
316
- path);
312
+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
313
+ auto &path = interfaceDepDetails.moduleCacheKey .empty ()
314
+ ? interfaceDepDetails.moduleOutputPath
315
+ : interfaceDepDetails.moduleCacheKey ;
316
+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
317
+ " =" + path);
318
+ }
317
319
addMacroDependencies (depModuleID, interfaceDepDetails);
318
320
return llvm::Error::success ();
319
321
}
320
322
321
323
llvm::Error handleSwiftBinaryModuleDependency (
322
324
ModuleDependencyID depModuleID,
323
325
const SwiftBinaryModuleDependencyStorage &binaryDepDetails) {
324
- auto &path = binaryDepDetails.moduleCacheKey .empty ()
325
- ? binaryDepDetails.compiledModulePath
326
- : binaryDepDetails.moduleCacheKey ;
327
- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
328
- path);
329
- // If this binary module was built with a header, the header's module
330
- // dependencies must also specify a .modulemap to the compilation, in
331
- // order to resolve the header's own header include directives.
332
- for (const auto &bridgingHeaderDepID :
333
- binaryDepDetails.headerModuleDependencies ) {
334
- auto optionalBridgingHeaderDepModuleInfo = cache.findKnownDependency (
335
- bridgingHeaderDepID);
336
- const auto bridgingHeaderDepModuleDetails =
337
- optionalBridgingHeaderDepModuleInfo.getAsClangModule ();
338
- commandline.push_back (" -Xcc" );
339
- commandline.push_back (" -fmodule-map-file=" +
340
- cache.getScanService ().remapPath (
341
- bridgingHeaderDepModuleDetails->moduleMapFile ));
326
+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
327
+ auto &path = binaryDepDetails.moduleCacheKey .empty ()
328
+ ? binaryDepDetails.compiledModulePath
329
+ : binaryDepDetails.moduleCacheKey ;
330
+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
331
+ " =" + path);
332
+ // If this binary module was built with a header, the header's module
333
+ // dependencies must also specify a .modulemap to the compilation, in
334
+ // order to resolve the header's own header include directives.
335
+ for (const auto &bridgingHeaderDepID :
336
+ binaryDepDetails.headerModuleDependencies ) {
337
+ auto optionalBridgingHeaderDepModuleInfo =
338
+ cache.findKnownDependency (bridgingHeaderDepID);
339
+ const auto bridgingHeaderDepModuleDetails =
340
+ optionalBridgingHeaderDepModuleInfo.getAsClangModule ();
341
+ commandline.push_back (" -Xcc" );
342
+ commandline.push_back (
343
+ " -fmodule-map-file=" +
344
+ cache.getScanService ().remapPath (
345
+ bridgingHeaderDepModuleDetails->moduleMapFile ));
346
+ }
342
347
}
343
348
addMacroDependencies (depModuleID, binaryDepDetails);
344
349
return llvm::Error::success ();
@@ -347,26 +352,29 @@ class ExplicitModuleDependencyResolver {
347
352
llvm::Error handleSwiftPlaceholderModuleDependency (
348
353
ModuleDependencyID depModuleID,
349
354
const SwiftPlaceholderModuleDependencyStorage &placeholderDetails) {
350
- commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName + " =" +
351
- placeholderDetails.compiledModulePath );
355
+ if (!resolvingDepInfo.isSwiftSourceModule ())
356
+ commandline.push_back (" -swift-module-file=" + depModuleID.ModuleName +
357
+ " =" + placeholderDetails.compiledModulePath );
352
358
return llvm::Error::success ();
353
359
}
354
360
355
361
llvm::Error handleClangModuleDependency (
356
362
ModuleDependencyID depModuleID,
357
363
const ClangModuleDependencyStorage &clangDepDetails) {
358
- if (!resolvingDepInfo.isClangModule ()) {
359
- commandline.push_back (" -Xcc" );
360
- commandline.push_back (" -fmodule-file=" + depModuleID.ModuleName + " =" +
361
- clangDepDetails.mappedPCMPath );
362
- }
363
- if (!clangDepDetails.moduleCacheKey .empty ()) {
364
- commandline.push_back (" -Xcc" );
365
- commandline.push_back (" -fmodule-file-cache-key" );
366
- commandline.push_back (" -Xcc" );
367
- commandline.push_back (clangDepDetails.mappedPCMPath );
368
- commandline.push_back (" -Xcc" );
369
- commandline.push_back (clangDepDetails.moduleCacheKey );
364
+ if (!resolvingDepInfo.isSwiftSourceModule ()) {
365
+ if (!resolvingDepInfo.isClangModule ()) {
366
+ commandline.push_back (" -Xcc" );
367
+ commandline.push_back (" -fmodule-file=" + depModuleID.ModuleName + " =" +
368
+ clangDepDetails.mappedPCMPath );
369
+ }
370
+ if (!clangDepDetails.moduleCacheKey .empty ()) {
371
+ commandline.push_back (" -Xcc" );
372
+ commandline.push_back (" -fmodule-file-cache-key" );
373
+ commandline.push_back (" -Xcc" );
374
+ commandline.push_back (clangDepDetails.mappedPCMPath );
375
+ commandline.push_back (" -Xcc" );
376
+ commandline.push_back (clangDepDetails.moduleCacheKey );
377
+ }
370
378
}
371
379
372
380
// Collect CAS deppendencies from clang modules.
@@ -1304,7 +1312,7 @@ bool swift::dependencies::scanDependencies(CompilerInstance &instance) {
1304
1312
*service, instance.getMainModule ()->getNameStr ().str (),
1305
1313
instance.getInvocation ().getFrontendOptions ().ExplicitModulesOutputPath ,
1306
1314
instance.getInvocation ().getModuleScanningHash ());
1307
-
1315
+
1308
1316
if (opts.ReuseDependencyScannerCache )
1309
1317
deserializeDependencyCache (instance, cache);
1310
1318
@@ -1391,7 +1399,7 @@ bool swift::dependencies::batchScanDependencies(
1391
1399
return true ;
1392
1400
1393
1401
auto batchScanResults = performBatchModuleScan (
1394
- instance, /* DependencyScanDiagnosticCollector*/ nullptr ,
1402
+ instance, /* DependencyScanDiagnosticCollector*/ nullptr ,
1395
1403
cache, /* versionedPCMInstanceCache*/ nullptr , saver,
1396
1404
*batchInput);
1397
1405
@@ -1652,7 +1660,7 @@ swift::dependencies::performBatchModuleScan(
1652
1660
}
1653
1661
allDependencies = scanner.performDependencyScan (moduleID, cache);
1654
1662
}
1655
-
1663
+
1656
1664
batchScanResult.push_back (
1657
1665
generateFullDependencyGraph (instance, diagnosticCollector, cache,
1658
1666
allDependencies));
0 commit comments