mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanner] Refactor ModuleDependencies to represent binary-only Swift modules explicitly
This matches the behavior of the current client (`swift-driver`) and reduces ambiguity in how the nodes in the graph are to be treated. Swift dependencies with a textual interface, for example, must be built into a binary module by clients. Swift dependencies without a textual interface, with only a binary module, are to be used directly, without any up-to-date checks. Note, this is distinct from Swift dependencies that have a textual interface, for which we also detect potential pre-build binary module candidates. Those are still reported in the `details` field of textual Swift dependencies as `prebuiltModuleCandidates`.
This commit is contained in:
@@ -179,17 +179,22 @@ ModuleDependencies::collectCrossImportOverlayNames(ASTContext &ctx,
|
||||
// A map from secondary module name to a vector of overlay names.
|
||||
llvm::StringMap<llvm::SmallSetVector<Identifier, 4>> result;
|
||||
// Mimic getModuleDefiningPath() for Swift and Clang module.
|
||||
if (auto *swiftDep = dyn_cast<SwiftModuleDependenciesStorage>(storage.get())) {
|
||||
if (auto *swiftDep = getAsSwiftTextualModule()) {
|
||||
// Prefer interface path to binary module path if we have it.
|
||||
modulePath = swiftDep->swiftInterfaceFile;
|
||||
if (!modulePath.hasValue())
|
||||
modulePath = swiftDep->compiledModulePath;
|
||||
assert(modulePath.hasValue());
|
||||
StringRef parentDir = llvm::sys::path::parent_path(*modulePath);
|
||||
if (llvm::sys::path::extension(parentDir) == ".swiftmodule") {
|
||||
modulePath = parentDir.str();
|
||||
}
|
||||
} else if (auto *clangDep = dyn_cast<ClangModuleDependenciesStorage>(storage.get())){
|
||||
} else if (auto *swiftBinaryDep = getAsSwiftBinaryModule()) {
|
||||
modulePath = swiftBinaryDep->compiledModulePath;
|
||||
assert(modulePath.hasValue());
|
||||
StringRef parentDir = llvm::sys::path::parent_path(*modulePath);
|
||||
if (llvm::sys::path::extension(parentDir) == ".swiftmodule") {
|
||||
modulePath = parentDir.str();
|
||||
}
|
||||
} else if (auto *clangDep = getAsClangModule()) {
|
||||
modulePath = clangDep->moduleMapFile;
|
||||
assert(modulePath.hasValue());
|
||||
} else { // PlaceholderSwiftModuleDependencies
|
||||
|
||||
Reference in New Issue
Block a user