summary refs log tree commit diff
path: root/pkgs/os-specific/linux/chromium-os/libchrome/default.nix
blob: 3aae238e243941506b77252ec2a7432d5c7af70b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ common-mk, stdenv, lib, fetchFromGitiles, upstreamInfo
, glib, libevent, gmock, modp_b64, chromiumos-overlay
}:

let
  versionData = upstreamInfo.components."aosp/platform/external/libchrome";
in

common-mk rec {
  platformSubdir = "libchrome";
  inherit (versionData) version;

  src = fetchFromGitiles { inherit (versionData) name url rev sha256; };

  NIX_CFLAGS_COMPILE = [
    "-Wno-error=attributes"
    "-Wno-error=dangling-else"
    "-Wno-error=implicit-fallthrough"
    "-Wno-error=unused-function"
  ];

  buildInputs = [ glib libevent gmock modp_b64 ];

  patches = [
    ./0001-Don-t-leak-source-absolute-paths-to-subprocesses.patch
    "${chromiumos-overlay}/chromeos-base/libchrome/files/libchrome-462023-Introduce-ValueReferenceAdapter-for-gracef.patch"
    "${chromiumos-overlay}/chromeos-base/libchrome/files/libchrome-462023-libchrome-add-alias-from-base-Location-base-GetProgr.patch"
  ];

  postPatch = ''
    substituteInPlace libchrome/BUILD.gn \
        --replace '/usr/include/base-''${libbase_ver}' \
                  "$out/include/base-\''${libbase_ver}"
  '' + (if stdenv.cc.isClang then ''
    substituteInPlace libchrome/BUILD.gn \
        --replace '"-Xclang-only=-Wno-char-subscripts",' ""
  '' else ''
    substituteInPlace libchrome/BUILD.gn \
        --replace "-Xclang-only=" "" \
        --replace '"-Wno-deprecated-register",' ""
  '');

  installPhase = ''
    mkdir -p $out/lib/pkgconfig
    install lib/libbase*-$version.so $out/lib
    install obj/libchrome/libchrome*-$version.pc $out/lib/pkgconfig

    pushd ../../libchrome
    mkdir -p $out/include/base-$version
    find . -name '*.h' -print0 \
        | xargs -0 tar -c \
        | tar -C $out/include/base-$version -x
    popd
  '';

  meta = with lib; {
    description = "Chromium project utility library";
    license = licenses.bsd3;
    maintainers = with maintainers; [ qyliss ];
    platform = platforms.all;
  };
}