Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,37 @@ public extension Driver {
moduleDependencyGraphUse: .dependencyScan)
// FIXME: MSVC runtime flags

// Pass in external target dependencies to be treated as placeholder dependencies by the scanner
if let externalTargetPaths = externalTargetModulePathMap {
let dependencyPlaceholderMapFile =
try serializeExternalDependencyArtifacts(externalTargetPaths: externalTargetPaths)
commandLine.appendFlag("-placeholder-dependency-module-map-file")
commandLine.appendPath(dependencyPlaceholderMapFile)
}

// Pass on the input files
commandLine.append(contentsOf: inputFiles.map { .path($0.file) })
return (inputs, commandLine)
}

/// Serialize a map of placeholder (external) dependencies for the dependency scanner.
private func serializeExternalDependencyArtifacts(externalTargetPaths: ExternalTargetModulePathMap)
throws -> VirtualPath {
var placeholderArtifacts: [SwiftModuleArtifactInfo] = []
// Explicit external targets
for (moduleId, binaryModulePath) in externalTargetPaths {
let modPath = TextualVirtualPath(path: VirtualPath.absolute(binaryModulePath).intern())
placeholderArtifacts.append(
SwiftModuleArtifactInfo(name: moduleId.moduleName,
modulePath: modPath))
}
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted]
let contents = try encoder.encode(placeholderArtifacts)
return VirtualPath.createUniqueTemporaryFileWithKnownContents(.init("\(moduleOutputInfo.name)-external-modules.json"),
contents)
}

/// Returns false if the lib is available and ready to use
private func initSwiftScanLib() throws -> Bool {
// If `-nonlib-dependency-scanner` was specified or the libSwiftScan library cannot be found,
Expand Down