diff --git a/include/swift/AST/DiagnosticsFrontend.def b/include/swift/AST/DiagnosticsFrontend.def index d9c4fd7e074..080d8d7cac5 100644 --- a/include/swift/AST/DiagnosticsFrontend.def +++ b/include/swift/AST/DiagnosticsFrontend.def @@ -110,6 +110,8 @@ ERROR(error_cannot_direct_cc1_pcm_build_in_mode,none, "'-direct-clang-cc1-module-build' only supported when building a PCM ('-emit-pcm')'", ()) ERROR(error_unsupported_option_argument,none, "unsupported argument '%1' to option '%0'", (StringRef, StringRef)) +ERROR(error_swift_module_file_requires_delimeter,none, + "-swift-module-file= argument requires format =, got: '%0'", (StringRef)) ERROR(error_immediate_mode_missing_stdlib,none, "could not load the swift standard library", ()) ERROR(error_immediate_mode_missing_library,none, diff --git a/include/swift/AST/ModuleDependencies.h b/include/swift/AST/ModuleDependencies.h index 434f48282c9..66fbe9938c1 100644 --- a/include/swift/AST/ModuleDependencies.h +++ b/include/swift/AST/ModuleDependencies.h @@ -150,7 +150,7 @@ public: /// The Swift frontend invocation arguments to build the Swift module from the /// interface. - const std::vector buildCommandLine; + std::vector buildCommandLine; /// The hash value that will be used for the generated module const std::string contextHash; @@ -186,6 +186,10 @@ public: static bool classof(const ModuleDependencyInfoStorageBase *base) { return base->dependencyKind == ModuleDependencyKind::SwiftInterface; } + + void updateCommandLine(const std::vector &newCommandLine) { + buildCommandLine = newCommandLine; + } }; /// Describes the dependencies of a Swift module @@ -433,6 +437,11 @@ public: storage->resolvedModuleDependencies.assign(dependencyIDs.begin(), dependencyIDs.end()); } + void updateCommandLine(const std::vector &newCommandLine) { + assert(isSwiftInterfaceModule() && "Can only update command line on Swift interface dependency"); + cast(storage.get())->updateCommandLine(newCommandLine); + } + bool isResolved() const { return storage->resolved; } @@ -752,4 +761,17 @@ public: } // namespace swift +namespace std { +template <> +struct hash { + using UnderlyingKindType = std::underlying_type::type; + std::size_t operator()(const swift::ModuleDependencyID &id) const { + auto underlyingKindValue = static_cast(id.second); + + return (hash()(id.first) ^ + (hash()(underlyingKindValue))); + } +}; +} // namespace std + #endif /* SWIFT_AST_MODULE_DEPENDENCIES_H */ diff --git a/include/swift/AST/SearchPathOptions.h b/include/swift/AST/SearchPathOptions.h index ab8b0d23ff3..e1d68dc50c2 100644 --- a/include/swift/AST/SearchPathOptions.h +++ b/include/swift/AST/SearchPathOptions.h @@ -355,6 +355,10 @@ public: /// A map of explicit Swift module information. std::string ExplicitSwiftModuleMap; + /// Module inputs specified with -swift-module-input, + /// + std::vector> ExplicitSwiftModuleInputs; + /// A map of placeholder Swift module dependency information. std::string PlaceholderDependencyModuleMap; diff --git a/include/swift/Frontend/ModuleInterfaceLoader.h b/include/swift/Frontend/ModuleInterfaceLoader.h index ee16da87208..a1546384d0c 100644 --- a/include/swift/Frontend/ModuleInterfaceLoader.h +++ b/include/swift/Frontend/ModuleInterfaceLoader.h @@ -129,7 +129,8 @@ class SearchPathOptions; class CompilerInvocation; /// A ModuleLoader that loads explicitly built Swift modules specified via -/// -swift-module-file +/// -swift-module-file or modules found in a provided +/// -explicit-swift-module-map-file JSON input. class ExplicitSwiftModuleLoader: public SerializedModuleLoaderBase { explicit ExplicitSwiftModuleLoader(ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode, @@ -164,6 +165,7 @@ public: create(ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode, StringRef ExplicitSwiftModuleMap, + const std::vector> &ExplicitSwiftModuleInputs, bool IgnoreSwiftSourceInfoFile); /// Append visible module names to \p names. Note that names are possibly diff --git a/include/swift/Option/FrontendOptions.td b/include/swift/Option/FrontendOptions.td index 6938ce5fa4c..a4294a76de8 100644 --- a/include/swift/Option/FrontendOptions.td +++ b/include/swift/Option/FrontendOptions.td @@ -185,6 +185,10 @@ def disable_typo_correction : Flag<["-"], "disable-typo-correction">, def disable_implicit_swift_modules: Flag<["-"], "disable-implicit-swift-modules">, HelpText<"Disable building Swift modules implicitly by the compiler">; +def swift_module_file: Joined<["-"], "swift-module-file=">, + MetaVarName<"=">, + HelpText<"Specify Swift module input explicitly built from textual interface">; + def explicit_swift_module_map : Separate<["-"], "explicit-swift-module-map-file">, MetaVarName<"">, HelpText<"Specify a JSON file containing information of explicit Swift modules">; diff --git a/lib/ClangImporter/ClangModuleDependencyScanner.cpp b/lib/ClangImporter/ClangModuleDependencyScanner.cpp index 29f47d1e9b4..6e0349a4b3b 100644 --- a/lib/ClangImporter/ClangModuleDependencyScanner.cpp +++ b/lib/ClangImporter/ClangModuleDependencyScanner.cpp @@ -153,15 +153,15 @@ void ClangImporter::recordModuleDependencies( // We are using Swift frontend mode. swiftArgs.push_back("-frontend"); - // We pass the entire argument list via -Xcc, so the invocation should - // use extra clang options alone. - swiftArgs.push_back("-only-use-extra-clang-opts"); - // Swift frontend action: -emit-pcm swiftArgs.push_back("-emit-pcm"); swiftArgs.push_back("-module-name"); swiftArgs.push_back(clangModuleDep.ID.ModuleName); + // We pass the entire argument list via -Xcc, so the invocation should + // use extra clang options alone. + swiftArgs.push_back("-only-use-extra-clang-opts"); + auto pcmPath = moduleCacheRelativeLookupModuleOutput( clangModuleDep.ID, ModuleOutputKind::ModuleFile, getModuleCachePathFromClang(getClangInstance())); diff --git a/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp b/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp index 6140d903642..f9e749c04a4 100644 --- a/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp +++ b/lib/DependencyScan/ModuleDependencyCacheSerialization.cpp @@ -656,19 +656,6 @@ struct llvm::DenseMapInfo { } }; -namespace std { -template <> -struct hash { - using UnderlyingKindType = std::underlying_type::type; - std::size_t operator()(const ModuleDependencyID &id) const { - auto underlyingKindValue = static_cast(id.second); - - return (hash()(id.first) ^ - (hash()(underlyingKindValue))); - } -}; -} // namespace std - namespace swift { class ModuleDependenciesCacheSerializer { diff --git a/lib/DependencyScan/ScanDependencies.cpp b/lib/DependencyScan/ScanDependencies.cpp index b2a1e1a426d..23345444ac9 100644 --- a/lib/DependencyScan/ScanDependencies.cpp +++ b/lib/DependencyScan/ScanDependencies.cpp @@ -36,6 +36,7 @@ #include "swift/Strings.h" #include "clang/Basic/Module.h" #include "llvm/ADT/SetVector.h" +#include "llvm/ADT/SetOperations.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" @@ -47,6 +48,7 @@ #include #include #include +#include using namespace swift; using namespace swift::dependencies; @@ -157,6 +159,149 @@ static void findAllImportedClangModules(ASTContext &ctx, StringRef moduleName, } } +// Get all dependencies's IDs of this module from its cached +// ModuleDependencyInfo +static ArrayRef +getDependencies(const ModuleDependencyID &moduleID, + const ModuleDependenciesCache &cache) { + const auto &optionalModuleInfo = + cache.findDependency(moduleID.first, moduleID.second); + assert(optionalModuleInfo.has_value()); + return optionalModuleInfo.value()->getModuleDependencies(); +} + +/// Implements a topological sort via recursion and reverse postorder DFS. +/// Does not bother handling cycles, relying on a DAG guarantee by the client. +static std::vector +computeTopologicalSortOfExplicitDependencies( + const ModuleDependencyIDSetVector &allModules, + const ModuleDependenciesCache &cache) { + std::unordered_set visited; + std::vector result; + std::stack stack; + + // Must be explicitly-typed to allow recursion + std::function visit; + visit = [&visit, &cache, &visited, &result, + &stack](const ModuleDependencyID &moduleID) { + // Mark this node as visited -- we are done if it already was. + if (!visited.insert(moduleID).second) + return; + + // Otherwise, visit each adjacent node. + for (const auto &succID : getDependencies(moduleID, cache)) { + // We don't worry if successor is already in this current stack, + // since that would mean we have found a cycle, which should not + // be possible because we checked for cycles earlier. + stack.push(succID); + visit(succID); + auto top = stack.top(); + stack.pop(); + assert(top == succID); + } + + // Add to the result. + result.push_back(moduleID); + }; + + for (const auto &modID : allModules) { + assert(stack.empty()); + stack.push(modID); + visit(modID); + auto top = stack.top(); + stack.pop(); + assert(top == modID); + } + + std::reverse(result.begin(), result.end()); + return result; +} + +/// For each module in the graph, compute a set of all its dependencies, +/// direct *and* transitive. +static std::unordered_map> +computeTransitiveClosureOfExplicitDependencies( + const std::vector &topologicallySortedModuleList, + const ModuleDependenciesCache &cache) { + // The usage of an ordered ::set is important to ensure the + // dependencies are listed in a deterministic order. + std::unordered_map> + result; + for (const auto &modID : topologicallySortedModuleList) + result[modID] = {modID}; + + // Traverse the set of modules in reverse topological order, assimilating + // transitive closures + for (auto it = topologicallySortedModuleList.rbegin(), + end = topologicallySortedModuleList.rend(); + it != end; ++it) { + const auto &modID = *it; + auto &modReachableSet = result[modID]; + for (const auto &succID : getDependencies(modID, cache)) { + const auto &succReachableSet = result[succID]; + llvm::set_union(modReachableSet, succReachableSet); + } + } + return result; +} + +static void +resolveExplicitModuleInputs(ModuleDependencyID moduleID, + const ModuleDependencyInfo &resolvingDepInfo, + const std::set &dependencies, + ModuleDependenciesCache &cache) { + auto resolvingInterfaceDepDetails = + resolvingDepInfo.getAsSwiftInterfaceModule(); + assert(resolvingInterfaceDepDetails && + "Expected Swift Interface dependency."); + + auto commandLine = resolvingInterfaceDepDetails->buildCommandLine; + for (const auto &depModuleID : dependencies) { + const auto optionalDepInfo = + cache.findDependency(depModuleID.first, depModuleID.second); + assert(optionalDepInfo.has_value()); + const auto depInfo = optionalDepInfo.value(); + switch (depModuleID.second) { + case swift::ModuleDependencyKind::SwiftInterface: { + auto interfaceDepDetails = depInfo->getAsSwiftInterfaceModule(); + assert(interfaceDepDetails && "Expected Swift Interface dependency."); + commandLine.push_back("-swift-module-file=" + depModuleID.first + "=" + + interfaceDepDetails->moduleOutputPath); + } break; + case swift::ModuleDependencyKind::SwiftBinary: { + auto binaryDepDetails = depInfo->getAsSwiftBinaryModule(); + assert(binaryDepDetails && "Expected Swift Binary Module dependency."); + commandLine.push_back("-swift-module-file=" + depModuleID.first + "=" + + binaryDepDetails->compiledModulePath); + } break; + case swift::ModuleDependencyKind::SwiftPlaceholder: { + auto placeholderDetails = depInfo->getAsPlaceholderDependencyModule(); + assert(placeholderDetails && "Expected Swift Placeholder dependency."); + commandLine.push_back("-swift-module-file=" + depModuleID.first + "=" + + placeholderDetails->compiledModulePath); + } break; + case swift::ModuleDependencyKind::Clang: { + auto clangDepDetails = depInfo->getAsClangModule(); + assert(clangDepDetails && "Expected Clang Module dependency."); + commandLine.push_back("-Xcc"); + commandLine.push_back("-fmodule-file=" + depModuleID.first + "=" + + clangDepDetails->pcmOutputPath); + commandLine.push_back("-Xcc"); + commandLine.push_back("-fmodule-map-file=" + + clangDepDetails->moduleMapFile); + } break; + default: + llvm_unreachable("Unhandled dependency kind."); + } + } + + // Update the dependency in the cache with the modified command-line. + auto dependencyInfoCopy = resolvingDepInfo; + dependencyInfoCopy.updateCommandLine(commandLine); + cache.updateDependency(moduleID, dependencyInfoCopy); +} + /// Resolve the direct dependencies of the given module. static ArrayRef resolveDirectDependencies(CompilerInstance &instance, ModuleDependencyID module, @@ -1475,8 +1620,29 @@ swift::dependencies::performModuleScan(CompilerInstance &instance, if (diagnoseCycle(instance, cache, mainModuleID, ASTDelegate)) return std::make_error_code(std::errc::not_supported); + // Resolve Swift dependency command-line arguments + // Must happen after cycle detection, because it relies on + // the DAG property of the dependency graph. + auto topoSortedModuleList = + computeTopologicalSortOfExplicitDependencies(allModules, cache); + auto moduleTransitiveClosures = + computeTransitiveClosureOfExplicitDependencies(topoSortedModuleList, + cache); + for (const auto &dependencyClosure : moduleTransitiveClosures) { + auto &modID = dependencyClosure.first; + // For main module or binary modules, no command-line to resolve. + // For Clang modules, their dependencies are resolved by the clang Scanner + // itself for us. + if (modID.second != ModuleDependencyKind::SwiftInterface) + continue; + auto optionalDeps = cache.findDependency(modID.first, modID.second); + assert(optionalDeps.has_value()); + auto deps = optionalDeps.value(); + resolveExplicitModuleInputs(modID, *deps, dependencyClosure.second, cache); + } + auto dependencyGraph = generateFullDependencyGraph( - instance, cache, ASTDelegate, allModules.getArrayRef()); + instance, cache, ASTDelegate, topoSortedModuleList); // Update the dependency tracker. if (auto depTracker = instance.getDependencyTracker()) { for (auto module : allModules) { diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 18686bc5e71..21064e9bc8a 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1363,6 +1363,25 @@ static void ParseSymbolGraphArgs(symbolgraphgen::SymbolGraphOptions &Opts, Opts.IncludeClangDocs = false; } +static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModuleArgument, + DiagnosticEngine &Diags, + std::vector> &ExplicitSwiftModuleInputs) { + std::size_t foundDelimeterPos = swiftModuleArgument.find_first_of("="); + if (foundDelimeterPos == std::string::npos) { + Diags.diagnose(SourceLoc(), diag::error_swift_module_file_requires_delimeter, + swiftModuleArgument); + return true; + } + std::string moduleName = swiftModuleArgument.substr(0, foundDelimeterPos), + modulePath = swiftModuleArgument.substr(foundDelimeterPos+1); + if (!Lexer::isIdentifier(moduleName)) { + Diags.diagnose(SourceLoc(), diag::error_bad_module_name, moduleName, false); + return true; + } + ExplicitSwiftModuleInputs.emplace_back(std::make_pair(moduleName, modulePath)); + return false; +} + static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, DiagnosticEngine &Diags, @@ -1415,6 +1434,11 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, if (const Arg *A = Args.getLastArg(OPT_explicit_swift_module_map)) Opts.ExplicitSwiftModuleMap = A->getValue(); + for (auto A : Args.getAllArgValues(options::OPT_swift_module_file)) { + if (validateSwiftModuleFileArgumentAndAdd(A, Diags, + Opts.ExplicitSwiftModuleInputs)) + return true; + } for (auto A: Args.filtered(OPT_candidate_module_file)) { Opts.CandidateCompiledModules.push_back(resolveSearchPath(A->getValue())); } diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index c83b6986a9d..e15e81b133a 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -566,10 +566,12 @@ bool CompilerInstance::setUpModuleLoaders() { bool ExplicitModuleBuild = Invocation.getFrontendOptions().DisableImplicitModules; if (ExplicitModuleBuild || - !Invocation.getSearchPathOptions().ExplicitSwiftModuleMap.empty()) { + !Invocation.getSearchPathOptions().ExplicitSwiftModuleMap.empty() || + !Invocation.getSearchPathOptions().ExplicitSwiftModuleInputs.empty()) { ESML = ExplicitSwiftModuleLoader::create( *Context, getDependencyTracker(), MLM, Invocation.getSearchPathOptions().ExplicitSwiftModuleMap, + Invocation.getSearchPathOptions().ExplicitSwiftModuleInputs, IgnoreSourceInfoFile); } diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index e1ca8adfc76..977098482f7 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1897,6 +1897,16 @@ struct ExplicitSwiftModuleLoader::Implementation { } } } + + void addCommandLineExplicitInputs( + const std::vector> + &commandLineExplicitInputs) { + for (const auto &moduleInput : commandLineExplicitInputs) { + ExplicitModuleInfo entry; + entry.modulePath = moduleInput.second; + ExplicitModuleMap.try_emplace(moduleInput.first, std::move(entry)); + } + } }; ExplicitSwiftModuleLoader::ExplicitSwiftModuleLoader( @@ -2057,6 +2067,7 @@ std::unique_ptr ExplicitSwiftModuleLoader::create(ASTContext &ctx, DependencyTracker *tracker, ModuleLoadingMode loadMode, StringRef ExplicitSwiftModuleMap, + const std::vector> &ExplicitSwiftModuleInputs, bool IgnoreSwiftSourceInfoFile) { auto result = std::unique_ptr( new ExplicitSwiftModuleLoader(ctx, tracker, loadMode, @@ -2067,6 +2078,11 @@ ExplicitSwiftModuleLoader::create(ASTContext &ctx, // Parse a JSON file to collect explicitly built modules. Impl.parseSwiftExplicitModuleMap(ExplicitSwiftModuleMap); } + // If some modules are provided with explicit + // '-swift-module-file' options, add those as well. + if (!ExplicitSwiftModuleInputs.empty()) { + Impl.addCommandLineExplicitInputs(ExplicitSwiftModuleInputs); + } return result; } diff --git a/lib/Serialization/ModuleDependencyScanner.cpp b/lib/Serialization/ModuleDependencyScanner.cpp index a89c29b16f4..3197e41920e 100644 --- a/lib/Serialization/ModuleDependencyScanner.cpp +++ b/lib/Serialization/ModuleDependencyScanner.cpp @@ -112,21 +112,38 @@ ErrorOr ModuleDependencyScanner::scanInterfaceFile( StringRef(), SourceLoc(), [&](ASTContext &Ctx, ModuleDecl *mainMod, - ArrayRef Args, + ArrayRef BaseArgs, ArrayRef PCMArgs, StringRef Hash) { assert(mainMod); std::string InPath = moduleInterfacePath.str(); auto compiledCandidates = getCompiledCandidates(Ctx, realModuleName.str(), InPath); + std::vector Args(BaseArgs.begin(), BaseArgs.end()); + // Add explicit Swift dependency compilation flags + Args.push_back("-explicit-interface-module-build"); + Args.push_back("-disable-implicit-swift-modules"); + Args.push_back("-Xcc"); Args.push_back("-fno-implicit-modules"); + Args.push_back("-Xcc"); Args.push_back("-fno-implicit-module-maps"); + for (const auto &candidate : compiledCandidates) { + Args.push_back("-candidate-module-file"); + Args.push_back(candidate); + } + + // Compute the output path and add it to the command line SmallString<128> outputPathBase(moduleCachePath); llvm::sys::path::append( outputPathBase, moduleName.str() + "-" + Hash + "." + file_types::getExtension(file_types::TY_SwiftModuleFile)); + Args.push_back("-o"); + Args.push_back(outputPathBase.str().str()); + + std::vector ArgsRefs(Args.begin(), Args.end()); Result = ModuleDependencyInfo::forSwiftInterfaceModule( - outputPathBase.str().str(), InPath, compiledCandidates, Args, PCMArgs, + outputPathBase.str().str(), InPath, compiledCandidates, ArgsRefs, PCMArgs, Hash, isFramework); + // Open the interface file. auto &fs = *Ctx.SourceMgr.getFileSystem(); auto interfaceBuf = fs.getBufferForFile(moduleInterfacePath); diff --git a/test/ScanDependencies/explicit-swift-dependencies.swift b/test/ScanDependencies/explicit-swift-dependencies.swift new file mode 100644 index 00000000000..185a20750a9 --- /dev/null +++ b/test/ScanDependencies/explicit-swift-dependencies.swift @@ -0,0 +1,55 @@ +// RUN: %empty-directory(%t) +// RUN: mkdir -p %t/clang-module-cache + +// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 +// Check the contents of the JSON output +// RUN: %FileCheck %s < %t/deps.json + +// REQUIRES: executable_test +// REQUIRES: objc_interop + + +import F + +// CHECK: "mainModuleName": "deps" + +/// --------Main module +// CHECK-LABEL: "modulePath": "deps.swiftmodule", +// CHECK-NEXT: sourceFiles +// CHECK-NEXT: explicit-swift-dependencies.swift +// CHECK-NEXT: ], +// CHECK-NEXT: "directDependencies": [ +// CHECK-DAG: "swift": "F" +// CHECK-DAG: "swift": "Swift" +// CHECK-DAG: "swift": "SwiftOnoneSupport" +// CHECK-DAG: "swift": "_Concurrency" +// CHECK-DAG: "clang": "_SwiftConcurrencyShims" +// CHECK-DAG: "swift": "_StringProcessing" +// CHECK: ], + +/// --------Swift module F +// CHECK: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.swiftmodule", +// CHECK: directDependencies +// CHECK-NEXT: { +// CHECK-DAG: "clang": "F" +// CHECK-DAG: "swift": "Swift" +// CHECK-DAG: "swift": "SwiftOnoneSupport" + + +// CHECK: "commandLine": [ +// CHECK-NEXT: "-frontend", +// CHECK-NEXT: "-compile-module-from-interface", +// CHECK-NEXT: "-target", +// ... +// CHECK: "-explicit-interface-module-build", +// CHECK-NEXT: "-disable-implicit-swift-modules", +// CHECK-NEXT: "-Xcc", +// CHECK-NEXT: "-fno-implicit-modules", +// CHECK-NEXT: "-Xcc", +// CHECK-NEXT: "-fno-implicit-module-maps", +// CHECK-NEXT: "-o", +// CHECK-NEXT: "{{.*}}{{/|\\}}F-{{.*}}.swiftmodule" +// CHECK-DAG: "-swift-module-file=Swift={{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule" +// CHECK-DAG: "-swift-module-file=SwiftOnoneSupport={{.*}}{{/|\\}}SwiftOnoneSupport-{{.*}}.swiftmodule" +// CHECK-DAG: "-fmodule-file=F={{.*}}{{/|\\}}F-{{.*}}.pcm", +// CHECK-DAG: "-fmodule-file=SwiftShims={{.*}}{{/|\\}}SwiftShims-{{.*}}.pcm", diff --git a/test/ScanDependencies/module_deps_cache_reuse.swift b/test/ScanDependencies/module_deps_cache_reuse.swift index 41eda3dae6a..d683fb18c24 100644 --- a/test/ScanDependencies/module_deps_cache_reuse.swift +++ b/test/ScanDependencies/module_deps_cache_reuse.swift @@ -62,40 +62,24 @@ import SubE // CHECK-NEXT: "F" // CHECK-NEXT: ] -/// --------Clang module C -// CHECK-LABEL: "modulePath": "{{.*}}/C-{{.*}}.pcm", - -// CHECK: "sourceFiles": [ -// CHECK-DAG: module.modulemap -// CHECK-DAG: C.h +/// --------Swift module A +// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}A-{{.*}}.swiftmodule", // CHECK: directDependencies // CHECK-NEXT: { -// CHECK-NEXT: "clang": "B" +// CHECK-DAG: "clang": "A" +// CHECK-DAG: "swift": "Swift" -// CHECK: "moduleMapPath" -// CHECK-SAME: module.modulemap - -// CHECK: "contextHash" -// CHECK-SAME: "{{.*}}" - -// CHECK: "commandLine": [ -// CHECK-NEXT: "-frontend" -// CHECK-NEXT: "-only-use-extra-clang-opts -// CHECK-NOT: "BUILD_DIR/bin/clang" -// CHECK: "-emit-pcm", -// CHECK: "-module-name", -// CHECK-NEXT: "C" - -/// --------Swift module E -// CHECK: "swift": "E" -// CHECK-LABEL: modulePath": "{{.*}}{{/|\\}}E-{{.*}}.swiftmodule" -// CHECK: "directDependencies" -// CHECK-NEXT: { -// CHECK-NEXT: "swift": "Swift" - -// CHECK: "moduleInterfacePath" -// CHECK-SAME: E.swiftinterface +/// --------Swift module F +// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.swiftmodule", +// CHECK-NEXT: "sourceFiles": [ +// CHECK-NEXT: ], +// CHECK-NEXT: "directDependencies": [ +// CHECK-NEXT: { +// CHECK-DAG: "clang": "F" +// CHECK-DAG: "swift": "Swift" +// CHECK-DAG: "swift": "SwiftOnoneSupport" +// CHECK: ], /// --------Swift module G // CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}G-{{.*}}.swiftmodule" @@ -121,6 +105,16 @@ import SubE // CHECK" "-fapinotes-swift-version=5" // CHECK" ] +/// --------Swift module E +// CHECK: "swift": "E" +// CHECK-LABEL: modulePath": "{{.*}}{{/|\\}}E-{{.*}}.swiftmodule" +// CHECK: "directDependencies" +// CHECK-NEXT: { +// CHECK-NEXT: "swift": "Swift" + +// CHECK: "moduleInterfacePath" +// CHECK-SAME: E.swiftinterface + /// --------Swift module Swift // CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule", @@ -128,24 +122,34 @@ import SubE // CHECK-NEXT: { // CHECK-NEXT: "clang": "SwiftShims" -/// --------Swift module F -// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}F-{{.*}}.swiftmodule", -// CHECK-NEXT: "sourceFiles": [ -// CHECK-NEXT: ], -// CHECK-NEXT: "directDependencies": [ -// CHECK-NEXT: { -// CHECK-DAG: "clang": "F" -// CHECK-DAG: "swift": "Swift" -// CHECK-DAG: "swift": "SwiftOnoneSupport" -// CHECK: ], -/// --------Swift module A -// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}A-{{.*}}.swiftmodule", +/// --------Clang module SwiftShims +// CHECK-LABEL: "modulePath": "{{.*}}/SwiftShims-{{.*}}.pcm", + +/// --------Clang module C +// CHECK-LABEL: "modulePath": "{{.*}}/C-{{.*}}.pcm", + +// CHECK: "sourceFiles": [ +// CHECK-DAG: module.modulemap +// CHECK-DAG: C.h // CHECK: directDependencies // CHECK-NEXT: { -// CHECK-DAG: "clang": "A" -// CHECK-DAG: "swift": "Swift" +// CHECK-NEXT: "clang": "B" + +// CHECK: "moduleMapPath" +// CHECK-SAME: module.modulemap + +// CHECK: "contextHash" +// CHECK-SAME: "{{.*}}" + +// CHECK: "commandLine": [ +// CHECK-NEXT: "-frontend" +// CHECK-NOT: "BUILD_DIR/bin/clang" +// CHECK: "-emit-pcm", +// CHECK: "-module-name", +// CHECK-NEXT: "C" +// CHECK-NEXT: "-only-use-extra-clang-opts /// --------Clang module B // CHECK-LABEL: "modulePath": "{{.*}}/B-{{.*}}.pcm", @@ -158,7 +162,3 @@ import SubE // CHECK-NEXT: { // CHECK-NEXT: "clang": "A" // CHECK-NEXT: } - -/// --------Clang module SwiftShims -// CHECK-LABEL: "modulePath": "{{.*}}/SwiftShims-{{.*}}.pcm", - diff --git a/test/ScanDependencies/module_deps_external.swift b/test/ScanDependencies/module_deps_external.swift index 561dbe30d14..bbf302d94fb 100644 --- a/test/ScanDependencies/module_deps_external.swift +++ b/test/ScanDependencies/module_deps_external.swift @@ -71,13 +71,6 @@ import SomeExternalModule // CHECK-NEXT: "F" // CHECK-NEXT: ] -/// --------Swift external module SomeExternalModule -// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}SomeExternalModule.swiftmodule", -// CHECK-NEXT: "details": { -// CHECK-NEXT: "swiftPlaceholder": { -// CHECK-NEXT: "moduleDocPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftdoc", -// CHECK-NEXT: "moduleSourceInfoPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftsourceinfo" - /// --------Swift module Swift // CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}Swift-{{.*}}.swiftmodule", @@ -93,3 +86,10 @@ import SomeExternalModule // CHECK-MAKE-DEPS-SAME: Bridging.h // CHECK-MAKE-DEPS-SAME: BridgingOther.h // CHECK-MAKE-DEPS-SAME: module.modulemap + +/// --------Swift external module SomeExternalModule +// CHECK-LABEL: "modulePath": "{{.*}}{{/|\\}}SomeExternalModule.swiftmodule", +// CHECK-NEXT: "details": { +// CHECK-NEXT: "swiftPlaceholder": { +// CHECK-NEXT: "moduleDocPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftdoc", +// CHECK-NEXT: "moduleSourceInfoPath": "BUILD_DIR/{{.*}}/ScanDependencies/Output/module_deps_external.swift.tmp/inputs/SomeExternalModule.swiftsourceinfo"