Skip to content

Commit 9e60c4f

Browse files
authored
Merge pull request #77991 from artemcm/SubFrameworksImplicit
Add additional implicit framework search path for Darwin platforms
2 parents f7d1c59 + faf0b21 commit 9e60c4f

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

include/swift/AST/SearchPathOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,13 @@ class SearchPathOptions {
405405
SmallString<128> systemFrameworksScratch(NewSDKPath);
406406
llvm::sys::path::append(systemFrameworksScratch, "System", "Library",
407407
"Frameworks");
408+
SmallString<128> systemSubFrameworksScratch(NewSDKPath);
409+
llvm::sys::path::append(systemSubFrameworksScratch, "System", "Library",
410+
"SubFrameworks");
408411
SmallString<128> frameworksScratch(NewSDKPath);
409412
llvm::sys::path::append(frameworksScratch, "Library", "Frameworks");
410413
DarwinImplicitFrameworkSearchPaths = {systemFrameworksScratch.str().str(),
414+
systemSubFrameworksScratch.str().str(),
411415
frameworksScratch.str().str()};
412416

413417
Lookup.searchPathsDidChange();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t/module-cache)
4+
// RUN: %empty-directory(%t/mock.sdk/System/Library)
5+
6+
// RUN: %empty-directory(%t/mock.sdk/System/Library/Frameworks)
7+
// RUN: %empty-directory(%t/mock.sdk/System/Library/SubFrameworks)
8+
9+
// RUN: %empty-directory(%t/mock.sdk/System/Library/Frameworks/E.framework/Modules/E.swiftmodule)
10+
// RUN: %empty-directory(%t/mock.sdk/System/Library/SubFrameworks/SubE.framework/Modules/SubE.swiftmodule)
11+
12+
// RUN: cp %S/Inputs/Swift/E.swiftinterface %t/mock.sdk/System/Library/Frameworks/E.framework/Modules/E.swiftmodule/%target-swiftinterface-name
13+
// RUN: cp %S/Inputs/Swift/SubE.swiftinterface %t/mock.sdk/System/Library/SubFrameworks/SubE.framework/Modules/SubE.swiftmodule/%target-swiftinterface-name
14+
15+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %s -o %t/deps.json -sdk %t/mock.sdk
16+
// RUN: %validate-json %t/deps.json | %FileCheck %s
17+
18+
import E
19+
import SubE
20+
21+
// CHECK: "mainModuleName": "deps"
22+
// CHECK: "swift": "E"
23+
// CHECK: "swift": "SubE"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t/System/Library/Frameworks/TestFramework.framework/Modules/TestFramework.swiftmodule)
4+
// RUN: %empty-directory(%t/System/Library/SubRFrameworksLibrary/Frameworks/TestFramework2.framework/Modules/TestFramework2.swiftmodule)
5+
6+
// RUN: %target-build-swift -emit-module -o %t/System/Library/Frameworks/TestFramework.framework/Modules/TestFramework.swiftmodule/%target-swiftmodule-name -module-name TestFramework %s -DFRAMEWORK
7+
// RUN: %target-build-swift -emit-module -o %t/System/Library/SubFrameworks/TestFramework2.framework/Modules/TestFramework2.swiftmodule/%target-swiftmodule-name -module-name TestFramework2 %s -DFRAMEWORK
8+
9+
// RUN: %target-swift-frontend -typecheck -sdk %t %s -diagnostic-style llvm -Rmodule-loading 2>&1 | %FileCheck %s
10+
11+
#if FRAMEWORK
12+
public func foo() {}
13+
#else
14+
15+
import TestFramework
16+
import TestFramework2
17+
18+
#endif // FRAMEWORK
19+
20+
// CHECK: remark: loaded module 'TestFramework'
21+
// CHECK: remark: loaded module 'TestFramework2'

0 commit comments

Comments
 (0)