Skip to content

Commit 591d24a

Browse files
committed
[Dependency Scanning] Query scanner whether discovered binary Swift modules are frameworks
Part of rdar://102824777
1 parent f0efe6c commit 591d24a

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

Sources/CSwiftScan/include/swiftscan_header.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ typedef struct {
130130
(*swiftscan_swift_binary_detail_get_module_doc_path)(swiftscan_module_details_t);
131131
swiftscan_string_ref_t
132132
(*swiftscan_swift_binary_detail_get_module_source_info_path)(swiftscan_module_details_t);
133+
bool
134+
(*swiftscan_swift_binary_detail_get_is_framework)(swiftscan_module_details_t);
133135

134136
//=== Swift Placeholder Module Details query APIs -------------------------===//
135137
swiftscan_string_ref_t

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyGraph.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public struct SwiftPrebuiltExternalModuleDetails: Codable {
141141
public init(compiledModulePath: TextualVirtualPath,
142142
moduleDocPath: TextualVirtualPath? = nil,
143143
moduleSourceInfoPath: TextualVirtualPath? = nil,
144-
isFramework: Bool = false) throws {
144+
isFramework: Bool) throws {
145145
self.compiledModulePath = compiledModulePath
146146
self.moduleDocPath = moduleDocPath
147147
self.moduleSourceInfoPath = moduleSourceInfoPath

Sources/SwiftDriver/SwiftScan/DependencyGraphBuilder.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,18 @@ private extension SwiftScan {
200200
let moduleSourceInfoPath =
201201
try getOptionalPathDetail(from: moduleDetailsRef,
202202
using: api.swiftscan_swift_binary_detail_get_module_source_info_path)
203+
204+
let isFramework: Bool
205+
if hasBinarySwiftModuleIsFramework {
206+
isFramework = api.swiftscan_swift_binary_detail_get_is_framework(moduleDetailsRef)
207+
} else {
208+
isFramework = false
209+
}
210+
203211
return try SwiftPrebuiltExternalModuleDetails(compiledModulePath: compiledModulePath,
204212
moduleDocPath: moduleDocPath,
205-
moduleSourceInfoPath: moduleSourceInfoPath)
213+
moduleSourceInfoPath: moduleSourceInfoPath,
214+
isFramework: isFramework)
206215
}
207216

208217
/// Construct a `SwiftPlaceholderModuleDetails` from a `swiftscan_module_details_t` reference

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ internal final class SwiftScan {
234234
return resultGraphMap
235235
}
236236

237+
@_spi(Testing) public var hasBinarySwiftModuleIsFramework : Bool {
238+
api.swiftscan_swift_binary_detail_get_is_framework != nil
239+
}
240+
237241
@_spi(Testing) public var canLoadStoreScannerCache : Bool {
238242
api.swiftscan_scanner_cache_load != nil &&
239243
api.swiftscan_scanner_cache_serialize != nil &&
@@ -370,6 +374,10 @@ private extension swiftscan_functions_t {
370374
self.swiftscan_diagnostics_set_dispose =
371375
try loadOptional("swiftscan_diagnostics_set_dispose")
372376

377+
// isFramework on binary module dependencies
378+
self.swiftscan_swift_binary_detail_get_is_framework =
379+
try loadOptional("swiftscan_swift_binary_detail_get_is_framework")
380+
373381
// MARK: Required Methods
374382
func loadRequired<T>(_ symbol: String) throws -> T {
375383
guard let sym: T = Loader.lookup(symbol: symbol, in: swiftscan) else {

0 commit comments

Comments
 (0)