Skip to content

Improve search paths for XCFrameworks #5724

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
Nov 2, 2022
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
8 changes: 4 additions & 4 deletions Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2272,8 +2272,8 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
if case .xcframework = target.kind {
let libraries = try self.parseXCFramework(for: target)
for library in libraries {
if let headersPath = library.headersPath {
clangTarget.additionalFlags += ["-I", headersPath.pathString]
library.headersPaths.forEach {
clangTarget.additionalFlags += ["-I", $0.pathString]
}
clangTarget.libraryBinaryPaths.insert(library.libraryPath)
}
Expand Down Expand Up @@ -2309,8 +2309,8 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
if case .xcframework = target.kind {
let libraries = try self.parseXCFramework(for: target)
for library in libraries {
if let headersPath = library.headersPath {
swiftTarget.additionalFlags += ["-Xcc", "-I", "-Xcc", headersPath.pathString]
library.headersPaths.forEach {
swiftTarget.additionalFlags += ["-I", $0.pathString, "-Xcc", "-I", "-Xcc", $0.pathString]
}
swiftTarget.libraryBinaryPaths.insert(library.libraryPath)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SPMBuildCore/BinaryTarget+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public struct LibraryInfo: Equatable {
/// The path to the binary.
public let libraryPath: AbsolutePath

/// The path to the headers directory, if one exists.
public let headersPath: AbsolutePath?
/// The paths to the headers directories.
public let headersPaths: [AbsolutePath]
}


Expand Down Expand Up @@ -54,8 +54,8 @@ extension BinaryTarget {
// Construct a LibraryInfo for the library.
let libraryDir = self.artifactPath.appending(component: library.libraryIdentifier)
let libraryFile = try AbsolutePath(validating: library.libraryPath, relativeTo: libraryDir)
let headersDir = try library.headersPath.map { try AbsolutePath(validating: $0, relativeTo: libraryDir) }
return [LibraryInfo(libraryPath: libraryFile, headersPath: headersDir)]
let headersDirs = try library.headersPath.map({ [try AbsolutePath(validating: $0, relativeTo: libraryDir)] }) ?? [] + [libraryDir]
return [LibraryInfo(libraryPath: libraryFile, headersPaths: headersDirs)]
}

public func parseArtifactArchives(for triple: Triple, fileSystem: FileSystem) throws -> [ExecutableInfo] {
Expand Down
1 change: 1 addition & 0 deletions Tests/BuildTests/BuildPlanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,7 @@ final class BuildPlanTests: XCTestCase {

let exeCompileArguments = try result.target(for: "exe").swiftTarget().compileArguments()
XCTAssertMatch(exeCompileArguments, [.anySequence, "-F", "\(buildPath)", .anySequence])
XCTAssertMatch(exeCompileArguments, [.anySequence, "-I", "\(Pkg.appending(components: "Framework.xcframework", "\(platform)-\(arch)"))", .anySequence])

let exeLinkArguments = try result.buildProduct(for: "exe").linkArguments()
XCTAssertMatch(exeLinkArguments, [.anySequence, "-F", "\(buildPath)", .anySequence])
Expand Down