From 7414ec1fa0e6d41d7fcfc2ffb9405455b4239edc Mon Sep 17 00:00:00 2001 From: ryan4729 Date: Mon, 15 Oct 2018 00:22:24 -0700 Subject: [PATCH] protobuf3: support cross compilation PR #48450 --- pkgs/development/libraries/protobuf/generic-v3.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/protobuf/generic-v3.nix b/pkgs/development/libraries/protobuf/generic-v3.nix index 79e4c387cdf..883dff56f2e 100644 --- a/pkgs/development/libraries/protobuf/generic-v3.nix +++ b/pkgs/development/libraries/protobuf/generic-v3.nix @@ -1,11 +1,12 @@ { stdenv , fetchFromGitHub -, autoreconfHook, zlib, gmock +, autoreconfHook, zlib, gmock, which, buildPackages , version, sha256 , ... }: -stdenv.mkDerivation rec { +let +mkProtobufDerivation = buildProtobuf: stdenv: stdenv.mkDerivation rec { name = "protobuf-${version}"; # make sure you test also -A pythonPackages.protobuf @@ -28,8 +29,10 @@ stdenv.mkDerivation rec { --replace 'tmpnam(b)' '"'$TMPDIR'/foo"' ''; - nativeBuildInputs = [ autoreconfHook ]; + nativeBuildInputs = [ autoreconfHook buildPackages.which buildPackages.stdenv.cc buildProtobuf ]; + buildInputs = [ zlib ]; + configureFlags = if buildProtobuf == null then [] else [ "--with-protoc=${buildProtobuf}/bin/protoc" ]; enableParallelBuilding = true; @@ -54,4 +57,7 @@ stdenv.mkDerivation rec { }; passthru.version = version; -} +}; +in mkProtobufDerivation(if (stdenv.buildPlatform != stdenv.hostPlatform) + then (mkProtobufDerivation null buildPackages.stdenv) + else null) stdenv