@@ -52,11 +52,37 @@ public extension Driver {
52
52
moduleDependencyGraphUse: . dependencyScan)
53
53
// FIXME: MSVC runtime flags
54
54
55
+ // Pass in external target dependencies to be treated as placeholder dependencies by the scanner
56
+ if let externalTargetPaths = externalTargetModulePathMap {
57
+ let dependencyPlaceholderMapFile =
58
+ try serializeExternalDependencyArtifacts ( externalTargetPaths: externalTargetPaths)
59
+ commandLine. appendFlag ( " -placeholder-dependency-module-map-file " )
60
+ commandLine. appendPath ( dependencyPlaceholderMapFile)
61
+ }
62
+
55
63
// Pass on the input files
56
64
commandLine. append ( contentsOf: inputFiles. map { . path( $0. file) } )
57
65
return ( inputs, commandLine)
58
66
}
59
67
68
+ /// Serialize a map of placeholder (external) dependencies for the dependency scanner.
69
+ private func serializeExternalDependencyArtifacts( externalTargetPaths: ExternalTargetModulePathMap )
70
+ throws -> VirtualPath {
71
+ var placeholderArtifacts : [ SwiftModuleArtifactInfo ] = [ ]
72
+ // Explicit external targets
73
+ for (moduleId, binaryModulePath) in externalTargetPaths {
74
+ let modPath = TextualVirtualPath ( path: VirtualPath . absolute ( binaryModulePath) . intern ( ) )
75
+ placeholderArtifacts. append (
76
+ SwiftModuleArtifactInfo ( name: moduleId. moduleName,
77
+ modulePath: modPath) )
78
+ }
79
+ let encoder = JSONEncoder ( )
80
+ encoder. outputFormatting = [ . prettyPrinted]
81
+ let contents = try encoder. encode ( placeholderArtifacts)
82
+ return VirtualPath . createUniqueTemporaryFileWithKnownContents ( . init( " \( moduleOutputInfo. name) -external-modules.json " ) ,
83
+ contents)
84
+ }
85
+
60
86
/// Returns false if the lib is available and ready to use
61
87
private func initSwiftScanLib( ) throws -> Bool {
62
88
// If `-nonlib-dependency-scanner` was specified or the libSwiftScan library cannot be found,
0 commit comments