Skip to content

Commit

Permalink
Add environment flag for BoringSSL/OpenSSL on MacOS (#341)
Browse files Browse the repository at this point in the history
* Add environment flag for BoringSSL/OpenSSL on MacOS

* Invert logic to make reading easier

* Move isLinux check first, move comment down to check.
  • Loading branch information
jgh- authored and MrMage committed Dec 10, 2018
1 parent bf20e93 commit 54659b8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/
import PackageDescription
import Foundation

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

var cGRPCDependencies: [Target.Dependency] = []

#if os(Linux)
let isLinux = true
#else
let isLinux = false
#endif

// On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
// See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
#else
cGRPCDependencies.append("BoringSSL")
#endif
// swift build doesn't pass -Xswiftc flags to dependencies, so here using an environment variable
// is easiest.
if isLinux || ProcessInfo.processInfo.environment.keys.contains("GRPC_USE_OPENSSL") {
packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
} else {
cGRPCDependencies.append("BoringSSL")
}

let package = Package(
name: "SwiftGRPC",
Expand Down

0 comments on commit 54659b8

Please sign in to comment.