2023-08-10 07:59:29 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, emptyDirectory
|
|
|
|
, writeText
|
2024-04-21 15:54:59 +00:00
|
|
|
, makeBinaryWrapper
|
2023-08-10 07:59:29 +00:00
|
|
|
, gradle
|
2024-01-02 11:29:13 +00:00
|
|
|
, jdk21
|
2023-08-10 07:59:29 +00:00
|
|
|
, llvmPackages
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
gradleInit = writeText "init.gradle" ''
|
|
|
|
logger.lifecycle 'Replacing Maven repositories with empty directory...'
|
|
|
|
gradle.projectsLoaded {
|
|
|
|
rootProject.allprojects {
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
clear()
|
|
|
|
maven { url '${emptyDirectory}' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repositories {
|
|
|
|
clear()
|
|
|
|
maven { url '${emptyDirectory}' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
settingsEvaluated { settings ->
|
|
|
|
settings.pluginManagement {
|
|
|
|
repositories {
|
|
|
|
maven { url '${emptyDirectory}' }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
pname = "jextract";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "unstable-2023-11-27";
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "openjdk";
|
|
|
|
repo = "jextract";
|
2024-01-02 11:29:13 +00:00
|
|
|
rev = "8730fcf05c229d035b0db52ee6bd82622e9d03e9"; # Update jextract 21 with latest fixes
|
|
|
|
hash = "sha256-Wct/yx5C0EjDtDyXNYDH5LRmrfq7islXbPVIGBR6x5Y=";
|
2023-08-10 07:59:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
gradle
|
2024-04-21 15:54:59 +00:00
|
|
|
makeBinaryWrapper
|
2023-08-10 07:59:29 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
env = {
|
|
|
|
ORG_GRADLE_PROJECT_llvm_home = llvmPackages.libclang.lib;
|
2024-01-02 11:29:13 +00:00
|
|
|
ORG_GRADLE_PROJECT_jdk21_home = jdk21;
|
2023-08-10 07:59:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
|
|
gradle --console plain --init-script "${gradleInit}" assemble
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
gradle --console plain --init-script "${gradleInit}" verify
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/opt/
|
|
|
|
cp -r ./build/jextract $out/opt/jextract
|
2024-04-21 15:54:59 +00:00
|
|
|
makeBinaryWrapper "$out/opt/jextract/bin/jextract" "$out/bin/jextract"
|
2023-08-10 07:59:29 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Tool which mechanically generates Java bindings from a native library headers";
|
2024-04-21 15:54:59 +00:00
|
|
|
mainProgram = "jextract";
|
2023-08-10 07:59:29 +00:00
|
|
|
homepage = "https://github.com/openjdk/jextract";
|
2024-04-21 15:54:59 +00:00
|
|
|
platforms = jdk21.meta.platforms;
|
2023-08-10 07:59:29 +00:00
|
|
|
license = licenses.gpl2Only;
|
|
|
|
maintainers = with maintainers; [ sharzy ];
|
|
|
|
};
|
|
|
|
}
|