Skip to content

Commit fa2b3ad

Browse files
authored
Add environment variable to specify include path for dispatch (swiftlang#5025)
1 parent 20967d3 commit fa2b3ad

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)),
@@ -30,8 +43,7 @@ let coreFoundationBuildSettings: [CSetting] = [
3043
"\(Context.packageDirectory)/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h",
3144
// /EHsc for Windows
3245
]),
33-
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
34-
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
46+
dispatchIncludeFlags
3547
]
3648

3749
// For _CFURLSessionInterface, _CFXMLInterface
@@ -59,8 +71,7 @@ let interfaceBuildSettings: [CSetting] = [
5971
"-fcf-runtime-abi=swift"
6072
// /EHsc for Windows
6173
]),
62-
.unsafeFlags(["-I/usr/lib/swift"], .when(platforms: [.linux, .android])), // dispatch
63-
.unsafeFlags(["-I/usr/lib/swift/Block"], .when(platforms: [.linux, .android])) // Block.h
74+
dispatchIncludeFlags
6475
]
6576

6677
let swiftBuildSettings: [SwiftSetting] = [

0 commit comments

Comments
 (0)