protobuf3: support cross compilation

PR #48450
This commit is contained in:
ryan4729 2018-10-15 00:22:24 -07:00 committed by Linus Heckemann
parent 143884d456
commit 7414ec1fa0

View File

@ -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