diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2022-12-19 05:28:41 +0100 |
---|---|---|
committer | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2022-12-19 05:29:26 +0100 |
commit | 39938dacb3bf66d3ec460337dc2700a21b8271a3 (patch) | |
tree | d22bcfd283ee214ca962f1569f539e7830738650 /pkgs/development/libraries/grpc | |
parent | 8b0e7e56896afca2ff8e2fca38c83c546c3b606c (diff) |
grpc: expose cxxStandard
Diffstat (limited to 'pkgs/development/libraries/grpc')
-rw-r--r-- | pkgs/development/libraries/grpc/default.nix | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/pkgs/development/libraries/grpc/default.nix b/pkgs/development/libraries/grpc/default.nix index b924f3f51d345..8a3a936b14533 100644 --- a/pkgs/development/libraries/grpc/default.nix +++ b/pkgs/development/libraries/grpc/default.nix @@ -54,28 +54,18 @@ stdenv.mkDerivation rec { buildInputs = [ openssl protobuf ] ++ lib.optionals stdenv.isLinux [ libnsl ]; - cmakeFlags = - let - # Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is - # only an issue with the useLLVM stdenv, not the darwin stdenv… - # https://github.com/grpc/grpc/issues/26473#issuecomment-860885484 - useLLVMAndOldCC = (stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0"; - # With GCC 9 (current aarch64-linux) it fails with c++17 but OK with c++14. - useOldGCC = !(stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "10"; - cxxStandard = if useLLVMAndOldCC then "11" else if useOldGCC then "14" else "17"; - in - [ - "-DgRPC_ZLIB_PROVIDER=package" - "-DgRPC_CARES_PROVIDER=package" - "-DgRPC_RE2_PROVIDER=package" - "-DgRPC_SSL_PROVIDER=package" - "-DgRPC_PROTOBUF_PROVIDER=package" - "-DgRPC_ABSL_PROVIDER=package" - "-DBUILD_SHARED_LIBS=ON" - "-DCMAKE_CXX_STANDARD=${cxxStandard}" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc" - ]; + cmakeFlags = [ + "-DgRPC_ZLIB_PROVIDER=package" + "-DgRPC_CARES_PROVIDER=package" + "-DgRPC_RE2_PROVIDER=package" + "-DgRPC_SSL_PROVIDER=package" + "-DgRPC_PROTOBUF_PROVIDER=package" + "-DgRPC_ABSL_PROVIDER=package" + "-DBUILD_SHARED_LIBS=ON" + "-DCMAKE_CXX_STANDARD=${passthru.cxxStandard}" + ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-D_gRPC_PROTOBUF_PROTOC_EXECUTABLE=${buildPackages.protobuf}/bin/protoc" + ]; # CMake creates a build directory by default, this conflicts with the # basel BUILD file on case-insensitive filesystems. @@ -97,6 +87,17 @@ stdenv.mkDerivation rec { enableParallelBuilds = true; + passthru.cxxStandard = + let + # Needs to be compiled with -std=c++11 for clang < 11. Interestingly this is + # only an issue with the useLLVM stdenv, not the darwin stdenv… + # https://github.com/grpc/grpc/issues/26473#issuecomment-860885484 + useLLVMAndOldCC = (stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "11.0"; + # With GCC 9 (current aarch64-linux) it fails with c++17 but OK with c++14. + useOldGCC = !(stdenv.hostPlatform.useLLVM or false) && lib.versionOlder stdenv.cc.cc.version "10"; + in + (if useLLVMAndOldCC then "11" else if useOldGCC then "14" else "17"); + passthru.tests = { inherit (python3.pkgs) grpcio-status grpcio-tools; inherit arrow-cpp; |