1{ lib
2, stdenv
3, fetchFromGitHub
4, buildPackages
5, cmake
6, gtest
7, jre
8, pkg-config
9, boost
10, icu
11, protobuf
12, Foundation
13}:
14
15stdenv.mkDerivation (finalAttrs: {
16 pname = "libphonenumber";
17 version = "8.13.40";
18
19 src = fetchFromGitHub {
20 owner = "google";
21 repo = "libphonenumber";
22 rev = "v${finalAttrs.version}";
23 hash = "sha256-3I+/oLJVbgOA+o8jHhOuHhD+0s7sgOghnW7DTMCllBU=";
24 };
25
26 patches = [
27 # An earlier version of this patch was submitted upstream but did not get
28 # any interest there - https://github.com/google/libphonenumber/pull/2921
29 ./build-reproducibility.patch
30 ];
31
32 nativeBuildInputs = [
33 cmake
34 gtest
35 jre
36 pkg-config
37 ];
38
39 buildInputs = [
40 boost
41 icu
42 protobuf
43 ] ++ lib.optionals stdenv.isDarwin [
44 Foundation
45 ];
46
47 cmakeDir = "../cpp";
48
49 doCheck = true;
50
51 checkTarget = "tests";
52
53 cmakeFlags = lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
54 (lib.cmakeFeature "CMAKE_CROSSCOMPILING_EMULATOR" (stdenv.hostPlatform.emulator buildPackages))
55 (lib.cmakeFeature "PROTOC_BIN" (lib.getExe buildPackages.protobuf))
56 ];
57
58 meta = with lib; {
59 changelog = "https://github.com/google/libphonenumber/blob/${finalAttrs.src.rev}/release_notes.txt";
60 description = "Google's i18n library for parsing and using phone numbers";
61 homepage = "https://github.com/google/libphonenumber";
62 license = licenses.asl20;
63 maintainers = with maintainers; [ illegalprime ];
64 };
65})