Skip to content

Allow custom dispatch include path in SwiftPM package build #5025

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
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
19 changes: 15 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@

import PackageDescription

var dispatchIncludeFlags: CSetting
if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] {
dispatchIncludeFlags = .unsafeFlags([
"-I\(environmentPath)",
"-I\(environmentPath)/Block"
])
} else {
dispatchIncludeFlags = .unsafeFlags([
"-I/usr/lib/swift",
"-I/usr/lib/swift/Block"
], .when(platforms: [.linux, .android]))
}

let coreFoundationBuildSettings: [CSetting] = [
.headerSearchPath("internalInclude"),
.define("DEBUG", .when(configuration: .debug)),
Expand Down Expand Up @@ -30,8 +43,7 @@ let coreFoundationBuildSettings: [CSetting] = [
"\(Context.packageDirectory)/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h",
// /EHsc for Windows
]),
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
dispatchIncludeFlags
]

// For _CFURLSessionInterface, _CFXMLInterface
Expand Down Expand Up @@ -59,8 +71,7 @@ let interfaceBuildSettings: [CSetting] = [
"-fcf-runtime-abi=swift"
// /EHsc for Windows
]),
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
dispatchIncludeFlags
]

let swiftBuildSettings: [SwiftSetting] = [
Expand Down