about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/protobuf
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/protobuf')
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/3.19.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/3.20.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/3.21.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/3.23.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/3.24.nix6
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/generic-v3-cmake.nix112
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/generic-v3.nix59
-rw-r--r--nixpkgs/pkgs/development/libraries/protobuf/static-executables-have-no-rpath.patch18
8 files changed, 219 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/3.19.nix b/nixpkgs/pkgs/development/libraries/protobuf/3.19.nix
new file mode 100644
index 000000000000..7ee378d8ed3b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/3.19.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic-v3.nix ({
+  version = "3.19.6";
+  sha256 = "sha256-+ul9F8tyrwk2p25Dd9ragqwpYzdxdeGjpXhLAwKYWfM=";
+} // args)
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/3.20.nix b/nixpkgs/pkgs/development/libraries/protobuf/3.20.nix
new file mode 100644
index 000000000000..bae3550f8f05
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/3.20.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic-v3.nix ({
+  version = "3.20.3";
+  sha256 = "sha256-u/1Yb8+mnDzc3OwirpGESuhjkuKPgqDAvlgo3uuzbbk=";
+} // args)
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/3.21.nix b/nixpkgs/pkgs/development/libraries/protobuf/3.21.nix
new file mode 100644
index 000000000000..fe85be8cf022
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/3.21.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic-v3-cmake.nix ({
+  version = "3.21.12";
+  sha256 = "sha256-VZQEFHq17UsTH5CZZOcJBKiScGV2xPJ/e6gkkVliRCU=";
+} // args)
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/3.23.nix b/nixpkgs/pkgs/development/libraries/protobuf/3.23.nix
new file mode 100644
index 000000000000..2d658d57419b
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/3.23.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic-v3-cmake.nix ({
+  version = "3.23.4";
+  sha256 = "sha256-eI+mrsZAOLEsdyTC3B+K+GjD3r16CmPx1KJ2KhCwFdg=";
+} // args)
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/3.24.nix b/nixpkgs/pkgs/development/libraries/protobuf/3.24.nix
new file mode 100644
index 000000000000..60ad747194df
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/3.24.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic-v3-cmake.nix ({
+  version = "3.24.3";
+  sha256 = "sha256-wXGQW/o674DeLXX2IlyZskl5OrBcSRptOMoJqLQGm94=";
+} // args)
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/generic-v3-cmake.nix b/nixpkgs/pkgs/development/libraries/protobuf/generic-v3-cmake.nix
new file mode 100644
index 000000000000..5b5ab87bfcd5
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/generic-v3-cmake.nix
@@ -0,0 +1,112 @@
+# The cmake version of this build is meant to enable both cmake and .pc being exported
+# this is important because grpc exports a .cmake file which also expects for protobuf
+# to have been exported through cmake as well.
+{ lib
+, stdenv
+, abseil-cpp
+, buildPackages
+, cmake
+, fetchFromGitHub
+, fetchpatch
+, gtest
+, zlib
+, version
+, sha256
+
+  # downstream dependencies
+, python3
+, grpc
+
+, ...
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "protobuf";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "protocolbuffers";
+    repo = "protobuf";
+    rev = "v${version}";
+    inherit sha256;
+  };
+
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace src/google/protobuf/testing/googletest.cc \
+      --replace 'tmpnam(b)' '"'$TMPDIR'/foo"'
+  '';
+
+  patches = lib.optionals (lib.versionOlder version "3.22") [
+    # fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
+    # https://github.com/protocolbuffers/protobuf/pull/10090
+    (fetchpatch {
+      url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
+      sha256 = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
+    })
+  ] ++ lib.optionals stdenv.hostPlatform.isStatic [
+    ./static-executables-have-no-rpath.patch
+  ];
+
+  nativeBuildInputs =
+    let
+      protobufVersion = "${lib.versions.major version}_${lib.versions.minor version}";
+    in
+    [
+      cmake
+    ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+      # protoc of the same version must be available for build. For non-cross builds, it's able to
+      # re-use the executable generated as part of the build
+      buildPackages."protobuf${protobufVersion}"
+    ];
+
+  buildInputs = [
+    gtest
+    zlib
+  ];
+
+  propagatedBuildInputs = [
+    abseil-cpp
+  ];
+
+  strictDeps = true;
+
+  cmakeDir = if lib.versionOlder version "3.22" then "../cmake" else null;
+  cmakeFlags = [
+    "-Dprotobuf_USE_EXTERNAL_GTEST=ON"
+    "-Dprotobuf_ABSL_PROVIDER=package"
+  ] ++ lib.optionals (!stdenv.targetPlatform.isStatic) [
+    "-Dprotobuf_BUILD_SHARED_LIBS=ON"
+  ]
+  # Tests fail to build on 32-bit platforms; fixed in 3.22
+  # https://github.com/protocolbuffers/protobuf/issues/10418
+  ++ lib.optionals (stdenv.targetPlatform.is32bit && lib.versionOlder version "3.22") [
+    "-Dprotobuf_BUILD_TESTS=OFF"
+  ];
+
+  doCheck = true;
+
+  passthru = {
+    tests = {
+      pythonProtobuf = python3.pkgs.protobuf.override (_: {
+        protobuf = finalAttrs.finalPackage;
+      });
+      inherit grpc;
+    };
+
+    inherit abseil-cpp;
+  };
+
+  meta = {
+    description = "Google's data interchange format";
+    longDescription = ''
+      Protocol Buffers are a way of encoding structured data in an efficient
+      yet extensible format. Google uses Protocol Buffers for almost all of
+      its internal RPC protocols and file formats.
+    '';
+    license = lib.licenses.bsd3;
+    platforms = lib.platforms.all;
+    homepage = "https://protobuf.dev/";
+    maintainers = with lib.maintainers; [ jonringer ];
+    mainProgram = "protoc";
+  };
+})
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/generic-v3.nix b/nixpkgs/pkgs/development/libraries/protobuf/generic-v3.nix
new file mode 100644
index 000000000000..9dc7f70c2fe2
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/generic-v3.nix
@@ -0,0 +1,59 @@
+{ lib, stdenv
+, fetchFromGitHub
+, autoreconfHook, zlib, gtest, buildPackages
+, version, sha256
+, ...
+}:
+
+let
+mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation {
+  pname = "protobuf";
+  inherit version;
+
+  # make sure you test also -A pythonPackages.protobuf
+  src = fetchFromGitHub {
+    owner = "protocolbuffers";
+    repo = "protobuf";
+    rev = "v${version}";
+    inherit sha256;
+  };
+
+  postPatch = ''
+    rm -rf gmock
+    cp -r ${gtest.src}/googlemock gmock
+    cp -r ${gtest.src}/googletest googletest
+    chmod -R a+w gmock
+    chmod -R a+w googletest
+    ln -s ../googletest gmock/gtest
+  '' + lib.optionalString stdenv.isDarwin ''
+    substituteInPlace src/google/protobuf/testing/googletest.cc \
+      --replace 'tmpnam(b)' '"'$TMPDIR'/foo"'
+  '';
+
+  nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc buildProtobuf ];
+
+  buildInputs = [ zlib ];
+  configureFlags = lib.optional (buildProtobuf != null) "--with-protoc=${buildProtobuf}/bin/protoc";
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  dontDisableStatic = true;
+
+  meta = {
+    description = "Google's data interchange format";
+    longDescription =
+      ''Protocol Buffers are a way of encoding structured data in an efficient
+        yet extensible format. Google uses Protocol Buffers for almost all of
+        its internal RPC protocols and file formats.
+      '';
+    homepage = "https://developers.google.com/protocol-buffers/";
+    license = lib.licenses.bsd3;
+    mainProgram = "protoc";
+    platforms = lib.platforms.unix;
+  };
+};
+in mkProtobufDerivation(if (stdenv.buildPlatform != stdenv.hostPlatform)
+                        then (mkProtobufDerivation null buildPackages.stdenv)
+                        else null) stdenv
diff --git a/nixpkgs/pkgs/development/libraries/protobuf/static-executables-have-no-rpath.patch b/nixpkgs/pkgs/development/libraries/protobuf/static-executables-have-no-rpath.patch
new file mode 100644
index 000000000000..cd2474e14590
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/protobuf/static-executables-have-no-rpath.patch
@@ -0,0 +1,18 @@
+diff --git a/cmake/install.cmake b/cmake/install.cmake
+index 26a55be8b..b6823c3f9 100644
+--- a/cmake/install.cmake
++++ b/cmake/install.cmake
+@@ -32,13 +32,6 @@ if (protobuf_BUILD_PROTOC_BINARIES)
+   install(TARGETS protoc EXPORT protobuf-targets
+     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc
+     BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
+-  if (UNIX AND NOT APPLE)
+-    set_property(TARGET protoc
+-      PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
+-  elseif (APPLE)
+-    set_property(TARGET protoc
+-      PROPERTY INSTALL_RPATH "@loader_path/../lib")
+-  endif()
+ endif (protobuf_BUILD_PROTOC_BINARIES)
+ 
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")