at 18.03-beta 60 lines 1.9 kB view raw
1{ stdenv, lib, version, src 2, autoreconfHook, zlib, gtest 3, ... 4}: 5 6stdenv.mkDerivation rec { 7 name = "protobuf-${version}"; 8 9 inherit src; 10 11 postPatch = '' 12 rm -rf gtest 13 cp -r ${gtest.src}/googletest gtest 14 chmod -R a+w gtest 15 '' + stdenv.lib.optionalString stdenv.isDarwin '' 16 substituteInPlace src/google/protobuf/testing/googletest.cc \ 17 --replace 'tmpnam(b)' '"'$TMPDIR'/foo"' 18 ''; 19 20 outputs = [ "out" "lib" ]; 21 22 nativeBuildInputs = [ autoreconfHook ]; 23 buildInputs = [ zlib ]; 24 25 # The generated C++ code uses static initializers which mutate a global data 26 # structure. This causes problems for an executable when: 27 # 28 # 1) it dynamically links to two libs, both of which contain generated C++ for 29 # the same proto file, and 30 # 2) the two aforementioned libs both dynamically link to libprotobuf. 31 # 32 # One solution is to statically link libprotobuf, that way the global 33 # variables are not shared; in fact, this is necessary for the python Mesos 34 # binding to not crash, as the python lib contains two C extensions which 35 # both refer to the same proto schema. 36 # 37 # See: https://github.com/NixOS/nixpkgs/pull/19064#issuecomment-255082684 38 # https://github.com/google/protobuf/issues/1489 39 dontDisableStatic = true; 40 configureFlags = [ 41 "CFLAGS=-fPIC" 42 "CXXFLAGS=-fPIC" 43 ]; 44 45 doCheck = true; 46 47 meta = { 48 description = "Protocol Buffers - Google's data interchange format"; 49 longDescription = 50 '' Protocol Buffers are a way of encoding structured data in an 51 efficient yet extensible format. Google uses Protocol Buffers for 52 almost all of its internal RPC protocols and file formats. 53 ''; 54 license = "mBSD"; 55 homepage = https://developers.google.com/protocol-buffers/; 56 platforms = stdenv.lib.platforms.unix; 57 }; 58 59 passthru.version = version; 60}