nixpkgs/pkgs/development/libraries/glog/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

75 lines
2.3 KiB
Nix

{ stdenv, lib, fetchFromGitHub, cmake, gflags, gtest, perl }:
stdenv.mkDerivation rec {
pname = "glog";
version = "0.6.0";
src = fetchFromGitHub {
owner = "google";
repo = "glog";
rev = "v${version}";
sha256 = "sha256-xqRp9vaauBkKz2CXbh/Z4TWqhaUtqfbsSlbYZR/kW9s=";
};
nativeBuildInputs = [ cmake ];
buildInputs = [ gtest ];
propagatedBuildInputs = [ gflags ];
cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
# glog's custom FindUnwind.cmake module detects LLVM's unwind in case
# stdenv.cc is clang. But the module doesn't get installed, causing
# consumers of the CMake config file to fail at the configuration step.
# Explicitly disabling unwind support sidesteps the issue.
"-DWITH_UNWIND=OFF"
];
doCheck = true;
# There are some non-thread safe tests that can fail
enableParallelChecking = false;
nativeCheckInputs = [ perl ];
env.GTEST_FILTER =
let
filteredTests = lib.optionals stdenv.hostPlatform.isMusl [
"Symbolize.SymbolizeStackConsumption"
"Symbolize.SymbolizeWithDemanglingStackConsumption"
] ++ lib.optionals stdenv.hostPlatform.isStatic [
"LogBacktraceAt.DoesBacktraceAtRightLineWhenEnabled"
] ++ lib.optionals stdenv.cc.isClang [
# Clang optimizes an expected allocation away.
# See https://github.com/google/glog/issues/937
"DeathNoAllocNewHook.logging"
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"LogBacktraceAt.DoesBacktraceAtRightLineWhenEnabled"
];
in
"-${builtins.concatStringsSep ":" filteredTests}";
checkPhase =
let
excludedTests = lib.optionals stdenv.hostPlatform.isDarwin [
"mock-log"
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
"logging" # works around segfaults on aarch64-darwin for now
];
excludedTestsRegex = lib.optionalString (excludedTests != [ ]) "(${lib.concatStringsSep "|" excludedTests})";
in
''
runHook preCheck
ctest -E "${excludedTestsRegex}" --output-on-failure
runHook postCheck
'';
meta = with lib; {
homepage = "https://github.com/google/glog";
license = licenses.bsd3;
description = "Library for application-level logging";
platforms = platforms.unix;
maintainers = with maintainers; [ nh2 r-burns ];
};
}