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";
version = "1.3.13";
src = fetchFromGitHub {
owner = "jnr";
repo = "jffi";
rev = "jffi-${version}";
sha256 = "sha256-aBQkkZyXZkaJc4sr/jHnIRaJYP116u4Jqsr9XXzfOBA=";
rev = "jffi-${finalAttrs.version}";
hash = "sha256-aBQkkZyXZkaJc4sr/jHnIRaJYP116u4Jqsr9XXzfOBA=";
};
nativeBuildInputs = [ jdk ant texinfo pkg-config ];
buildInputs = [ libffi ] ;
nativeBuildInputs = [
ant
jdk
pkg-config
texinfo
stripJavaArchivesHook
];
buildInputs = [ libffi ];
# The pkg-config script in the build.xml doesn't work propery
# set the lib path manually to work around this.
env.LIBFFI_LIBS = "${libffi}/lib/libffi${stdenv.hostPlatform.extensions.sharedLibrary}";
env.ANT_ARGS = "-Duse.system.libffi=1";
buildPhase = ''
# 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 jar
ant -Duse.system.libffi=1 archive-platform-jar
'';
installPhase = ''
mkdir -p $out/share/java
cp -r dist/* $out/share/java
runHook preBuild
ant jar
ant archive-platform-jar
runHook postBuild
'';
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; {
@ -45,4 +71,4 @@ stdenv.mkDerivation rec {
license = licenses.asl20;
maintainers = with maintainers; [ bachp ];
};
}
})