From 8a6a09f620087fb3db9f4a8cd2de7de45de1c8f4 Mon Sep 17 00:00:00 2001 From: SharzyL Date: Sun, 2 Jul 2023 20:51:36 +0800 Subject: [PATCH] jextract: init at unstable-2023-04-14 --- .../tools/java/jextract/default.nix | 99 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 101 insertions(+) create mode 100644 pkgs/development/tools/java/jextract/default.nix diff --git a/pkgs/development/tools/java/jextract/default.nix b/pkgs/development/tools/java/jextract/default.nix new file mode 100644 index 000000000000..8302e02726e8 --- /dev/null +++ b/pkgs/development/tools/java/jextract/default.nix @@ -0,0 +1,99 @@ +{ lib +, stdenv +, fetchFromGitHub +, emptyDirectory +, writeText +, makeWrapper +, gradle +, jdk20 +, 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"; + version = "unstable-2023-04-14"; + + src = fetchFromGitHub { + owner = "openjdk"; + repo = "jextract"; + rev = "cf3afe9ca71592c8ebb32f219707285dd1d5b28a"; + hash = "sha256-8qRD1Xg39vxtFAdguD8XvkQ8u7YzFU55MhyyJozVffo="; + }; + + nativeBuildInputs = [ + gradle + makeWrapper + ]; + + env = { + ORG_GRADLE_PROJECT_llvm_home = llvmPackages.libclang.lib; + ORG_GRADLE_PROJECT_jdk20_home = jdk20; + }; + + 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 + + install -D --mode=0444 --target-directory="$out/share/java" \ + ./build/libs/org.openjdk.jextract-unspecified.jar + + runHook postInstall + ''; + + postFixup = '' + makeWrapper "${jdk20}/bin/java" "$out/bin/jextract" \ + --add-flags "--enable-preview" \ + --add-flags "--class-path $out/share/java/org.openjdk.jextract-unspecified.jar" \ + --add-flags "org.openjdk.jextract.JextractTool" + ''; + + meta = with lib; { + description = "A tool which mechanically generates Java bindings from a native library headers"; + homepage = "https://github.com/openjdk/jextract"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ sharzy ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4cac45c1deba..b867106b9103 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25215,6 +25215,8 @@ with pkgs; fastjar = callPackage ../development/tools/java/fastjar { }; + jextract = callPackage ../development/tools/java/jextract { }; + httpunit = callPackage ../development/libraries/java/httpunit { }; javaCup = callPackage ../development/libraries/java/cup {