Skip to content

Commit e55c6cb

Browse files
authored
Merge pull request #170 from ikesyo/refactor-dwarfextractor
[Refactor] Move dwarfPath construction to DwarfExtractor and remove DebugSymbol type
2 parents b02e804 + 4ebc2cf commit e55c6cb

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

Sources/ScipioKit/Producer/Compiler.swift

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,36 @@ extension Compiler {
2222
var result = [SDK: [TSCAbsolutePath]]()
2323

2424
for sdk in sdks {
25-
let dsymPath = descriptionPackage.buildDebugSymbolPath(buildConfiguration: buildConfiguration, sdk: sdk, target: target)
26-
guard fileSystem.exists(dsymPath) else { continue }
27-
let debugSymbol = DebugSymbol(
28-
dSYMPath: dsymPath,
29-
target: target,
25+
let dsymPath = descriptionPackage.buildDebugSymbolPath(
26+
buildConfiguration: buildConfiguration,
3027
sdk: sdk,
31-
buildConfiguration: buildConfiguration
28+
target: target
3229
)
33-
let dumpedDSYMsMaps = try await extractor.dump(dwarfPath: debugSymbol.dwarfPath)
30+
guard fileSystem.exists(dsymPath) else { continue }
31+
32+
let dwarfPath = extractor.dwarfPath(for: target, dSYMPath: dsymPath)
33+
let dumpedDSYMsMaps = try await extractor.dump(dwarfPath: dwarfPath)
3434
let bcSymbolMapPaths: [TSCAbsolutePath] = dumpedDSYMsMaps.values.compactMap { uuid in
3535
let path = descriptionPackage.productsDirectory(
36-
buildConfiguration: debugSymbol.buildConfiguration,
37-
sdk: debugSymbol.sdk
36+
buildConfiguration: buildConfiguration,
37+
sdk: sdk
3838
)
3939
.appending(component: "\(uuid.uuidString).bcsymbolmap")
4040
guard fileSystem.exists(path) else { return nil }
4141
return path
4242
}
43-
result[sdk] = [debugSymbol.dSYMPath] + bcSymbolMapPaths
43+
result[sdk] = [dsymPath] + bcSymbolMapPaths
4444
}
4545
return result
4646
}
4747
}
4848

4949
extension DescriptionPackage {
50-
fileprivate func buildDebugSymbolPath(buildConfiguration: BuildConfiguration, sdk: SDK, target: ScipioResolvedModule) -> TSCAbsolutePath {
50+
fileprivate func buildDebugSymbolPath(
51+
buildConfiguration: BuildConfiguration,
52+
sdk: SDK,
53+
target: ScipioResolvedModule
54+
) -> TSCAbsolutePath {
5155
productsDirectory(buildConfiguration: buildConfiguration, sdk: sdk)
5256
.appending(component: "\(target.name).framework.dSYM")
5357
}

Sources/ScipioKit/Producer/DebugSymbol.swift renamed to Sources/ScipioKit/Producer/DwarfExtractor.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ import Foundation
22
import PackageGraph
33
import Basics
44

5-
struct DebugSymbol {
6-
var dSYMPath: TSCAbsolutePath
7-
var target: ScipioResolvedModule
8-
var sdk: SDK
9-
var buildConfiguration: BuildConfiguration
10-
11-
var dwarfPath: TSCAbsolutePath {
12-
dSYMPath.appending(components: "Contents", "Resources", "DWARF", target.name)
13-
}
14-
}
15-
165
struct DwarfExtractor<E: Executor> {
176
private let executor: E
187

@@ -22,6 +11,10 @@ struct DwarfExtractor<E: Executor> {
2211

2312
typealias Arch = String
2413

14+
func dwarfPath(for target: ScipioResolvedModule, dSYMPath: TSCAbsolutePath) -> TSCAbsolutePath {
15+
dSYMPath.appending(components: "Contents", "Resources", "DWARF", target.name)
16+
}
17+
2518
func dump(dwarfPath: TSCAbsolutePath) async throws -> [Arch: UUID] {
2619
let result = try await executor.execute("/usr/bin/xcrun", "dwarfdump", "--uuid", dwarfPath.pathString)
2720

0 commit comments

Comments
 (0)