Skip to content

Add additional implicit framework search path for Darwin platforms #77991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions include/swift/AST/SearchPathOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,13 @@ class SearchPathOptions {
SmallString<128> systemFrameworksScratch(NewSDKPath);
llvm::sys::path::append(systemFrameworksScratch, "System", "Library",
"Frameworks");
SmallString<128> systemSubFrameworksScratch(NewSDKPath);
llvm::sys::path::append(systemSubFrameworksScratch, "System", "Library",
"SubFrameworks");
SmallString<128> frameworksScratch(NewSDKPath);
llvm::sys::path::append(frameworksScratch, "Library", "Frameworks");
DarwinImplicitFrameworkSearchPaths = {systemFrameworksScratch.str().str(),
systemSubFrameworksScratch.str().str(),
frameworksScratch.str().str()};

Lookup.searchPathsDidChange();
Expand Down
23 changes: 23 additions & 0 deletions test/ScanDependencies/subframework_implicit_search_path.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// REQUIRES: VENDOR=apple
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/module-cache)
// RUN: %empty-directory(%t/mock.sdk/System/Library)

// RUN: %empty-directory(%t/mock.sdk/System/Library/Frameworks)
// RUN: %empty-directory(%t/mock.sdk/System/Library/SubFrameworks)

// RUN: %empty-directory(%t/mock.sdk/System/Library/Frameworks/E.framework/Modules/E.swiftmodule)
// RUN: %empty-directory(%t/mock.sdk/System/Library/SubFrameworks/SubE.framework/Modules/SubE.swiftmodule)

// RUN: cp %S/Inputs/Swift/E.swiftinterface %t/mock.sdk/System/Library/Frameworks/E.framework/Modules/E.swiftmodule/%target-swiftinterface-name
// RUN: cp %S/Inputs/Swift/SubE.swiftinterface %t/mock.sdk/System/Library/SubFrameworks/SubE.framework/Modules/SubE.swiftmodule/%target-swiftinterface-name

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/module-cache %s -o %t/deps.json -sdk %t/mock.sdk
// RUN: %validate-json %t/deps.json | %FileCheck %s

import E
import SubE

// CHECK: "mainModuleName": "deps"
// CHECK: "swift": "E"
// CHECK: "swift": "SubE"
21 changes: 21 additions & 0 deletions test/Serialization/search-paths-sdk-auxiliary.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// REQUIRES: VENDOR=apple
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/System/Library/Frameworks/TestFramework.framework/Modules/TestFramework.swiftmodule)
// RUN: %empty-directory(%t/System/Library/SubRFrameworksLibrary/Frameworks/TestFramework2.framework/Modules/TestFramework2.swiftmodule)

// RUN: %target-build-swift -emit-module -o %t/System/Library/Frameworks/TestFramework.framework/Modules/TestFramework.swiftmodule/%target-swiftmodule-name -module-name TestFramework %s -DFRAMEWORK
// RUN: %target-build-swift -emit-module -o %t/System/Library/SubFrameworks/TestFramework2.framework/Modules/TestFramework2.swiftmodule/%target-swiftmodule-name -module-name TestFramework2 %s -DFRAMEWORK

// RUN: %target-swift-frontend -typecheck -sdk %t %s -diagnostic-style llvm -Rmodule-loading 2>&1 | %FileCheck %s

#if FRAMEWORK
public func foo() {}
#else

import TestFramework
import TestFramework2

#endif // FRAMEWORK

// CHECK: remark: loaded module 'TestFramework'
// CHECK: remark: loaded module 'TestFramework2'