Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359125
D3865.id12015.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D3865.id12015.diff
View Options
diff --git a/nix/cmake-install-path.patch b/nix/cmake-install-path.patch
new file mode 100644
--- /dev/null
+++ b/nix/cmake-install-path.patch
@@ -0,0 +1,32 @@
+diff --git a/cmake/install.cmake b/cmake/install.cmake
+index 9dd6e77..3c2e769 100644
+--- a/cmake/install.cmake
++++ b/cmake/install.cmake
+@@ -127,24 +127,20 @@ configure_file(protobuf-options.cmake
+ if (protobuf_BUILD_PROTOC_BINARIES)
+ export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
+ NAMESPACE protobuf::
+- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
++ FILE ${CMAKE_CURRENT_BINARY_DIR}/protobuf-targets.cmake
+ )
+ else (protobuf_BUILD_PROTOC_BINARIES)
+ export(TARGETS libprotobuf-lite libprotobuf
+ NAMESPACE protobuf::
+- FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
++ FILE ${CMAKE_CURRENT_BINARY_DIR}/protobuf-targets.cmake
+ )
+ endif (protobuf_BUILD_PROTOC_BINARIES)
+
+ install(EXPORT protobuf-targets
+ DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
++ FILE protobuf-targets.cmake
+ NAMESPACE protobuf::
+- COMPONENT protobuf-export)
+-
+-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
+- DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
+ COMPONENT protobuf-export
+- PATTERN protobuf-targets.cmake EXCLUDE
+ )
+
+ option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF)
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -13,5 +13,7 @@
# add packages meant for just this repository
amqp-cpp = prev.callPackage ./amqp-cpp.nix { };
+ protobuf_3_15_cmake = prev.callPackage ./protobuf_3_15.nix { };
+
devShell = final.callPackage ./dev-shell.nix { };
}
diff --git a/nix/protobuf_3_15.nix b/nix/protobuf_3_15.nix
new file mode 100644
--- /dev/null
+++ b/nix/protobuf_3_15.nix
@@ -0,0 +1,87 @@
+# 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
+, buildPackages
+, cmake
+, fetchFromGitHub
+, fetchpatch
+, gtest
+, zlib
+}:
+
+let
+ mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation rec {
+ pname = "protobuf";
+ version = "3.15.8";
+
+ src = fetchFromGitHub {
+ owner = "protocolbuffers";
+ repo = "protobuf";
+ rev = "v${version}";
+ sha256 = "sha256-G+fU6YWfpkRDJ9Xf+/zLmd52/1vTtPoZdugZDLtCc+A=";
+ };
+
+ # re-create git submodules
+ postPatch = ''
+ rm -rf gmock
+ cp -r ${gtest.src}/googlemock third_party/gmock
+ cp -r ${gtest.src}/googletest third_party/
+
+ chmod -R a+w third_party/
+ ln -s ../googletest third_party/gmock/gtest
+ ln -s ../gmock third_party/googletest/googlemock
+ ln -s $(pwd)/third_party/googletest third_party/googletest/googletest
+ '' + lib.optionalString stdenv.isDarwin ''
+ substituteInPlace src/google/protobuf/testing/googletest.cc \
+ --replace 'tmpnam(b)' '"'$TMPDIR'/foo"'
+ '';
+
+ patches = [
+ # This is an adjusted patch for https://github.com/protocolbuffers/protobuf/pull/9822
+ ./cmake-install-path.patch
+ ];
+
+ # There's a top-level BUILD file which doesn't allow for APFS to create a directory named "build"
+ dontUseCmakeBuildDir = true;
+ # Point cmake setup hook to cmake/CMakeLists.txt
+ cmakeDir = "cmake";
+
+ nativeBuildInputs = [
+ cmake
+ # buildPackages ensure that the package is compatible by the machine building it
+ buildPackages.which
+ buildPackages.stdenv.cc
+ buildProtobuf
+ ];
+
+ buildInputs = [
+ zlib
+ ];
+
+ cmakeFlags = lib.optionals (!stdenv.targetPlatform.isStatic) [
+ "-Dprotobuf_BUILD_SHARED_LIBS=ON"
+ ];
+
+ enableParallelBuilding = true;
+
+ # unfortunately the shared libraries have yet to been patched by nix, thus tests will fail
+ doCheck = false;
+
+ 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.unix;
+ homepage = "https://developers.google.com/protocol-buffers/";
+ };
+ };
+in
+ # this is meant to handle cross compilation logic
+ mkProtobufDerivation(if (stdenv.buildPlatform != stdenv.hostPlatform)
+ then (mkProtobufDerivation null buildPackages.stdenv)
+ else null) stdenv
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:25 AM (21 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578910
Default Alt Text
D3865.id12015.diff (4 KB)
Attached To
Mode
D3865: Add protobuf with corrected cmake build
Attached
Detach File
Event Timeline
Log In to Comment