nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 130 lines 3.7 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, abseil-cpp 5, c-ares 6, cmake 7, crc32c 8, curl 9, gbenchmark 10, grpc 11, gtest 12, ninja 13, nlohmann_json 14, openssl 15, pkg-config 16, protobuf 17 # default list of APIs: https://github.com/googleapis/google-cloud-cpp/blob/v1.32.1/CMakeLists.txt#L173 18, apis ? [ "*" ] 19, staticOnly ? stdenv.hostPlatform.isStatic 20}: 21let 22 googleapisRev = "d4f3468ef85278428005ed555b3a85db91551ee6"; 23 googleapis = fetchFromGitHub { 24 owner = "googleapis"; 25 repo = "googleapis"; 26 rev = googleapisRev; 27 hash = "sha256-sIQVFQhE3Ae6ia45apzdgtwzglMM4hFZ8efNAhMO5ZY="; 28 }; 29 excludedTests = builtins.fromTOML (builtins.readFile ./skipped_tests.toml); 30in 31stdenv.mkDerivation rec { 32 pname = "google-cloud-cpp"; 33 version = "1.38.0"; 34 35 src = fetchFromGitHub { 36 owner = "googleapis"; 37 repo = "google-cloud-cpp"; 38 rev = "v${version}"; 39 sha256 = "sha256-kobOkohWIDTQaaihhoh/25tZUNv+CjKFwj2xQqO52bA="; 40 }; 41 42 postPatch = '' 43 substituteInPlace external/googleapis/CMakeLists.txt \ 44 --replace "https://github.com/googleapis/googleapis/archive/\''${GOOGLE_CLOUD_CPP_GOOGLEAPIS_COMMIT_SHA}.tar.gz" "file://${googleapis}" 45 ''; 46 47 nativeBuildInputs = [ 48 cmake 49 ninja 50 pkg-config 51 ] ++ lib.optionals (!doInstallCheck) [ 52 # enable these dependencies when doInstallCheck is false because we're 53 # unconditionally building tests and benchmarks 54 # 55 # when doInstallCheck is true, these deps are added to installCheckInputs 56 gbenchmark 57 gtest 58 ]; 59 60 buildInputs = [ 61 abseil-cpp 62 c-ares 63 crc32c 64 curl 65 grpc 66 nlohmann_json 67 openssl 68 protobuf 69 ]; 70 71 doInstallCheck = true; 72 73 preInstallCheck = 74 let 75 # These paths are added to (DY)LD_LIBRARY_PATH because they contain 76 # testing-only shared libraries that do not need to be installed, but 77 # need to be loadable by the test executables. 78 # 79 # Setting (DY)LD_LIBRARY_PATH is only necessary when building shared libraries. 80 additionalLibraryPaths = [ 81 "$PWD/google/cloud/bigtable" 82 "$PWD/google/cloud/bigtable/benchmarks" 83 "$PWD/google/cloud/pubsub" 84 "$PWD/google/cloud/spanner" 85 "$PWD/google/cloud/spanner/benchmarks" 86 "$PWD/google/cloud/storage" 87 "$PWD/google/cloud/storage/benchmarks" 88 "$PWD/google/cloud/testing_util" 89 ]; 90 ldLibraryPathName = "${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH"; 91 in 92 lib.optionalString doInstallCheck ( 93 lib.optionalString (!staticOnly) '' 94 export ${ldLibraryPathName}=${lib.concatStringsSep ":" additionalLibraryPaths} 95 '' + '' 96 export GTEST_FILTER="-${lib.concatStringsSep ":" excludedTests.cases}" 97 '' 98 ); 99 100 installCheckPhase = lib.optionalString doInstallCheck '' 101 runHook preInstallCheck 102 103 # disable tests that contact the internet 104 ctest --exclude-regex '^(${lib.concatStringsSep "|" excludedTests.whole})' 105 106 runHook postInstallCheck 107 ''; 108 109 installCheckInputs = lib.optionals doInstallCheck [ 110 gbenchmark 111 gtest 112 ]; 113 114 cmakeFlags = [ 115 "-DBUILD_SHARED_LIBS:BOOL=${if staticOnly then "OFF" else "ON"}" 116 # unconditionally build tests to catch linker errors as early as possible 117 # this adds a good chunk of time to the build 118 "-DBUILD_TESTING:BOOL=ON" 119 "-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES:BOOL=OFF" 120 ] ++ lib.optionals (apis != [ "*" ]) [ 121 "-DGOOGLE_CLOUD_CPP_ENABLE=${lib.concatStringsSep ";" apis}" 122 ]; 123 124 meta = with lib; { 125 license = with licenses; [ asl20 ]; 126 homepage = "https://github.com/googleapis/google-cloud-cpp"; 127 description = "C++ Idiomatic Clients for Google Cloud Platform services"; 128 maintainers = with maintainers; [ cpcloud ]; 129 }; 130}