Skip to content

Use host triple in createIndexStoreAPI #2780

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jun 15, 2020
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
2 changes: 1 addition & 1 deletion Sources/Build/BuildDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public final class BuildExecutionContext {
private var indexStoreAPICache = LazyCache(createIndexStoreAPI)
private func createIndexStoreAPI() -> Result<IndexStoreAPI, Error> {
Result {
let ext = buildParameters.triple.dynamicLibraryExtension
let ext = buildParameters.hostTriple.dynamicLibraryExtension
let indexStoreLib = buildParameters.toolchain.toolchainLibDir.appending(component: "libIndexStore" + ext)
return try IndexStoreAPI(dylib: indexStoreLib)
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/SPMBuildCore/BuildParameters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public struct BuildParameters: Encodable {
public var toolchain: Toolchain { _toolchain.toolchain }
private let _toolchain: _Toolchain

/// Host triple.
public var hostTriple: Triple

/// Destination triple.
public var triple: Triple

Expand Down Expand Up @@ -120,6 +123,7 @@ public struct BuildParameters: Encodable {
dataPath: AbsolutePath,
configuration: BuildConfiguration,
toolchain: Toolchain,
hostTriple: Triple? = nil,
destinationTriple: Triple? = nil,
flags: BuildFlags,
xcbuildFlags: [String] = [],
Expand All @@ -140,6 +144,7 @@ public struct BuildParameters: Encodable {
self.dataPath = dataPath
self.configuration = configuration
self._toolchain = _Toolchain(toolchain: toolchain)
self.hostTriple = hostTriple ?? .getHostTriple(usingSwiftCompiler: toolchain.swiftCompiler)
self.triple = destinationTriple ?? .getHostTriple(usingSwiftCompiler: toolchain.swiftCompiler)
self.flags = flags
self.xcbuildFlags = xcbuildFlags
Expand Down
1 change: 1 addition & 0 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ final class BuildPlanTests: XCTestCase {
dataPath: buildPath,
configuration: config,
toolchain: MockToolchain(),
hostTriple: hostTriple,
destinationTriple: destinationTriple,
flags: flags,
jobs: 3,
Expand Down