nixpkgs/pkgs/development/libraries/google-cloud-cpp/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

137 lines
4.1 KiB
Nix
Raw Normal View History

{ lib
, stdenv
2021-10-29 18:24:58 +02:00
, fetchFromGitHub
, c-ares
, cmake
2021-10-29 18:24:58 +02:00
, crc32c
, curl
, gbenchmark
2021-10-29 18:24:58 +02:00
, grpc
2021-10-29 18:24:58 +02:00
, gtest
, ninja
, nlohmann_json
, openssl
, pkg-config
, protobuf
2021-10-29 18:24:58 +02:00
# default list of APIs: https://github.com/googleapis/google-cloud-cpp/blob/v1.32.1/CMakeLists.txt#L173
, apis ? [ "*" ]
2021-10-29 18:24:58 +02:00
, staticOnly ? stdenv.hostPlatform.isStatic
}:
2019-07-31 21:51:48 +02:00
let
googleapisRev = "d4f3468ef85278428005ed555b3a85db91551ee6";
googleapis = fetchFromGitHub {
owner = "googleapis";
repo = "googleapis";
2021-10-29 18:24:58 +02:00
rev = googleapisRev;
hash = "sha256-sIQVFQhE3Ae6ia45apzdgtwzglMM4hFZ8efNAhMO5ZY=";
2019-07-31 21:51:48 +02:00
};
2021-10-29 18:24:58 +02:00
excludedTests = builtins.fromTOML (builtins.readFile ./skipped_tests.toml);
2021-10-29 18:24:58 +02:00
in
stdenv.mkDerivation rec {
2019-07-31 21:51:48 +02:00
pname = "google-cloud-cpp";
version = "1.38.0";
2019-07-31 21:51:48 +02:00
src = fetchFromGitHub {
owner = "googleapis";
repo = "google-cloud-cpp";
rev = "v${version}";
sha256 = "sha256-kobOkohWIDTQaaihhoh/25tZUNv+CjKFwj2xQqO52bA=";
2019-07-31 21:51:48 +02:00
};
postPatch = ''
2021-10-29 18:24:58 +02:00
substituteInPlace external/googleapis/CMakeLists.txt \
--replace "https://github.com/googleapis/googleapis/archive/\''${GOOGLE_CLOUD_CPP_GOOGLEAPIS_COMMIT_SHA}.tar.gz" "file://${googleapis}"
# https://github.com/googleapis/google-cloud-cpp/issues/8992
for file in external/googleapis/config.pc.in google/cloud/{,*/}config.pc.in; do
substituteInPlace "$file" \
--replace '$'{prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
--replace '$'{prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@ \
--replace '$'{prefix}/@CMAKE_INSTALL_BINDIR@ @CMAKE_INSTALL_FULL_BINDIR@
done
2019-07-31 21:51:48 +02:00
'';
2021-10-29 18:24:58 +02:00
nativeBuildInputs = [
cmake
ninja
pkg-config
2021-10-29 18:24:58 +02:00
] ++ lib.optionals (!doInstallCheck) [
# enable these dependencies when doInstallCheck is false because we're
# unconditionally building tests and benchmarks
#
# when doInstallCheck is true, these deps are added to installCheckInputs
2021-10-29 18:24:58 +02:00
gbenchmark
gtest
2021-10-29 18:24:58 +02:00
];
buildInputs = [
c-ares
crc32c
2022-07-04 01:48:24 +02:00
(curl.override { inherit openssl; })
2021-10-29 18:24:58 +02:00
grpc
nlohmann_json
openssl
2021-10-29 18:24:58 +02:00
protobuf
];
2021-10-29 18:24:58 +02:00
doInstallCheck = true;
preInstallCheck =
let
# These paths are added to (DY)LD_LIBRARY_PATH because they contain
# testing-only shared libraries that do not need to be installed, but
# need to be loadable by the test executables.
#
# Setting (DY)LD_LIBRARY_PATH is only necessary when building shared libraries.
additionalLibraryPaths = [
"$PWD/google/cloud/bigtable"
"$PWD/google/cloud/bigtable/benchmarks"
"$PWD/google/cloud/pubsub"
"$PWD/google/cloud/spanner"
"$PWD/google/cloud/spanner/benchmarks"
"$PWD/google/cloud/storage"
"$PWD/google/cloud/storage/benchmarks"
"$PWD/google/cloud/testing_util"
];
ldLibraryPathName = "${lib.optionalString stdenv.isDarwin "DY"}LD_LIBRARY_PATH";
in
lib.optionalString doInstallCheck (
lib.optionalString (!staticOnly) ''
export ${ldLibraryPathName}=${lib.concatStringsSep ":" additionalLibraryPaths}
'' + ''
export GTEST_FILTER="-${lib.concatStringsSep ":" excludedTests.cases}"
''
);
installCheckPhase = lib.optionalString doInstallCheck ''
runHook preInstallCheck
# disable tests that contact the internet
ctest --exclude-regex '^(${lib.concatStringsSep "|" excludedTests.whole})'
runHook postInstallCheck
'';
installCheckInputs = lib.optionals doInstallCheck [
gbenchmark
gtest
];
2019-07-31 21:51:48 +02:00
cmakeFlags = [
2021-10-29 18:24:58 +02:00
"-DBUILD_SHARED_LIBS:BOOL=${if staticOnly then "OFF" else "ON"}"
# unconditionally build tests to catch linker errors as early as possible
# this adds a good chunk of time to the build
2021-10-29 18:24:58 +02:00
"-DBUILD_TESTING:BOOL=ON"
"-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES:BOOL=OFF"
] ++ lib.optionals (apis != [ "*" ]) [
"-DGOOGLE_CLOUD_CPP_ENABLE=${lib.concatStringsSep ";" apis}"
2019-07-31 21:51:48 +02:00
];
meta = with lib; {
2019-07-31 21:51:48 +02:00
license = with licenses; [ asl20 ];
homepage = "https://github.com/googleapis/google-cloud-cpp";
2019-07-31 21:51:48 +02:00
description = "C++ Idiomatic Clients for Google Cloud Platform services";
2021-10-29 18:24:58 +02:00
maintainers = with maintainers; [ cpcloud ];
2019-07-31 21:51:48 +02:00
};
}