Skip to content

Commit 54659b8

Browse files
jgh-MrMage
authored andcommitted
Add environment flag for BoringSSL/OpenSSL on MacOS (#341)
* Add environment flag for BoringSSL/OpenSSL on MacOS * Invert logic to make reading easier * Move isLinux check first, move comment down to check.
1 parent bf20e93 commit 54659b8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Package.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
import PackageDescription
18+
import Foundation
1819

1920
var packageDependencies: [Package.Dependency] = [
2021
.package(url: "https://github.com/apple/swift-protobuf.git", .upToNextMinor(from: "1.1.1")),
@@ -26,13 +27,22 @@ var packageDependencies: [Package.Dependency] = [
2627
]
2728

2829
var cGRPCDependencies: [Target.Dependency] = []
30+
2931
#if os(Linux)
32+
let isLinux = true
33+
#else
34+
let isLinux = false
35+
#endif
36+
3037
// On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
3138
// See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
32-
packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
33-
#else
34-
cGRPCDependencies.append("BoringSSL")
35-
#endif
39+
// swift build doesn't pass -Xswiftc flags to dependencies, so here using an environment variable
40+
// is easiest.
41+
if isLinux || ProcessInfo.processInfo.environment.keys.contains("GRPC_USE_OPENSSL") {
42+
packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
43+
} else {
44+
cGRPCDependencies.append("BoringSSL")
45+
}
3646

3747
let package = Package(
3848
name: "SwiftGRPC",

0 commit comments

Comments
 (0)