Skip to content

Commit c0f7143

Browse files
authored
Merge pull request #39887 from keith/ks/allow-explicit-swift-module-map-file-without-full-explicit-module-build
Allow -explicit-swift-module-map-file without full explicit module build
2 parents 1b2ac8c + 73cfe34 commit c0f7143

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,17 @@ bool CompilerInstance::setUpModuleLoaders() {
546546
// If implicit modules are disabled, we need to install an explicit module
547547
// loader.
548548
bool ExplicitModuleBuild = Invocation.getFrontendOptions().DisableImplicitModules;
549-
if (ExplicitModuleBuild) {
549+
if (ExplicitModuleBuild || !Invocation.getSearchPathOptions().ExplicitSwiftModuleMap.empty()) {
550550
auto ESML = ExplicitSwiftModuleLoader::create(
551551
*Context,
552552
getDependencyTracker(), MLM,
553553
Invocation.getSearchPathOptions().ExplicitSwiftModuleMap,
554554
IgnoreSourceInfoFile);
555555
this->DefaultSerializedLoader = ESML.get();
556556
Context->addModuleLoader(std::move(ESML));
557-
} else {
557+
}
558+
559+
if (!ExplicitModuleBuild) {
558560
if (MLM != ModuleLoadingMode::OnlySerialized) {
559561
// We only need ModuleInterfaceLoader for implicit modules.
560562
auto PIML = ModuleInterfaceLoader::create(
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/clang-module-cache
3+
// RUN: mkdir -p %t/inputs
4+
// RUN: mkdir -p %t/barinputs
5+
// RUN: echo "public func foo() {}" >> %t/foo.swift
6+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/inputs/Foo.swiftmodule -emit-module-doc-path %t/inputs/Foo.swiftdoc -emit-module-source-info -emit-module-source-info-path %t/inputs/Foo.swiftsourceinfo -module-cache-path %t.module-cache %t/foo.swift -module-name Foo
7+
// RUN: echo "public func bar() {}" >> %t/bar.swift
8+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/barinputs/Bar.swiftmodule -emit-module-doc-path %t/barinputs/Bar.swiftdoc -emit-module-source-info -emit-module-source-info-path %t/barinputs/Bar.swiftsourceinfo -module-cache-path %t.module-cache %t/bar.swift -module-name Bar
9+
10+
// RUN: echo "[{" > %/t/inputs/map.json
11+
// RUN: echo "\"moduleName\": \"Foo\"," >> %/t/inputs/map.json
12+
// RUN: echo "\"modulePath\": \"%/t/inputs/Foo.swiftmodule\"," >> %/t/inputs/map.json
13+
// RUN: echo "\"docPath\": \"%/t/inputs/Foo.swiftdoc\"," >> %/t/inputs/map.json
14+
// RUN: echo "\"sourceInfoPath\": \"%/t/inputs/Foo.swiftsourceinfo\"," >> %/t/inputs/map.json
15+
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
16+
// RUN: echo "}]" >> %/t/inputs/map.json
17+
18+
// RUN: not %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -disable-implicit-swift-modules
19+
// RUN: %target-swift-frontend -typecheck %s -explicit-swift-module-map-file %t/inputs/map.json -I %t/barinputs
20+
import Foo
21+
import Bar

0 commit comments

Comments
 (0)