Skip to content

Commit 39d7157

Browse files
parkerajmschonfeld
andauthored
Add environment variable to specify include path for dispatch (#5025) (#5029)
(cherry picked from commit fa2b3ad) Co-authored-by: Jeremy Schonfeld <[email protected]>
1 parent 67d407f commit 39d7157

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Package.swift

+15-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33

44
import PackageDescription
55

6+
var dispatchIncludeFlags: CSetting
7+
if let environmentPath = Context.environment["DISPATCH_INCLUDE_PATH"] {
8+
dispatchIncludeFlags = .unsafeFlags([
9+
"-I\(environmentPath)",
10+
"-I\(environmentPath)/Block"
11+
])
12+
} else {
13+
dispatchIncludeFlags = .unsafeFlags([
14+
"-I/usr/lib/swift",
15+
"-I/usr/lib/swift/Block"
16+
], .when(platforms: [.linux, .android]))
17+
}
18+
619
let coreFoundationBuildSettings: [CSetting] = [
720
.headerSearchPath("internalInclude"),
821
.define("DEBUG", .when(configuration: .debug)),
@@ -31,8 +44,7 @@ let coreFoundationBuildSettings: [CSetting] = [
3144
"\(Context.packageDirectory)/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h",
3245
// /EHsc for Windows
3346
]),
34-
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
35-
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
47+
dispatchIncludeFlags
3648
]
3749

3850
// For _CFURLSessionInterface, _CFXMLInterface
@@ -60,8 +72,7 @@ let interfaceBuildSettings: [CSetting] = [
6072
"-fcf-runtime-abi=swift"
6173
// /EHsc for Windows
6274
]),
63-
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
64-
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
75+
dispatchIncludeFlags
6576
]
6677

6778
let swiftBuildSettings: [SwiftSetting] = [

0 commit comments

Comments
 (0)