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