Merge pull request #298989 from TomaSajt/jffi

jffi: clean up and make deterministic
This commit is contained in:
Pascal Bach 2024-03-25 22:24:36 +01:00 committed by GitHub
commit 50d5c2ee68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,40 +1,66 @@
{ lib, stdenv, fetchFromGitHub, jdk, jre, ant, libffi, texinfo, pkg-config }: { lib
, stdenv
, fetchFromGitHub
, ant
, jdk
, libffi
, pkg-config
, texinfo
, stripJavaArchivesHook
}:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "jffi"; pname = "jffi";
version = "1.3.13"; version = "1.3.13";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "jnr"; owner = "jnr";
repo = "jffi"; repo = "jffi";
rev = "jffi-${version}"; rev = "jffi-${finalAttrs.version}";
sha256 = "sha256-aBQkkZyXZkaJc4sr/jHnIRaJYP116u4Jqsr9XXzfOBA="; hash = "sha256-aBQkkZyXZkaJc4sr/jHnIRaJYP116u4Jqsr9XXzfOBA=";
}; };
nativeBuildInputs = [ jdk ant texinfo pkg-config ]; nativeBuildInputs = [
buildInputs = [ libffi ] ; ant
jdk
pkg-config
texinfo
stripJavaArchivesHook
];
buildInputs = [ libffi ];
buildPhase = ''
# The pkg-config script in the build.xml doesn't work propery # The pkg-config script in the build.xml doesn't work propery
# set the lib path manually to work around this. # set the lib path manually to work around this.
export LIBFFI_LIBS="${libffi}/lib/libffi.so" env.LIBFFI_LIBS = "${libffi}/lib/libffi${stdenv.hostPlatform.extensions.sharedLibrary}";
env.ANT_ARGS = "-Duse.system.libffi=1";
ant -Duse.system.libffi=1 jar buildPhase = ''
ant -Duse.system.libffi=1 archive-platform-jar runHook preBuild
''; ant jar
ant archive-platform-jar
installPhase = '' runHook postBuild
mkdir -p $out/share/java
cp -r dist/* $out/share/java
''; '';
doCheck = true; doCheck = true;
checkPhase = ''
# The pkg-config script in the build.xml doesn't work propery
# set the lib path manually to work around this.
export LIBFFI_LIBS="${libffi}/lib/libffi.so"
ant -Duse.system.libffi=1 test checkPhase = ''
runHook preCheck
ant test
runHook postCheck
'';
installPhase = ''
runHook preInstall
install -Dm644 dist/*.jar -t $out/share/java
runHook postInstall
'';
# nix can't detect libffi as a dependency inside the jar file, so we create
# a dummy file with the path to libffi, to make sure that nix knows about it
postFixup = ''
mkdir -p $out/nix-support
echo ${libffi} > $out/nix-support/depends
''; '';
meta = with lib; { meta = with lib; {
@ -45,4 +71,4 @@ stdenv.mkDerivation rec {
license = licenses.asl20; license = licenses.asl20;
maintainers = with maintainers; [ bachp ]; maintainers = with maintainers; [ bachp ];
}; };
} })