From 370afc7cced5e775055d694b8244dc8f3d801a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rolf=20Schr=C3=B6der?= Date: Thu, 11 Jan 2024 13:37:08 +0100 Subject: [PATCH 1/2] gdal: add java bindings --- pkgs/development/libraries/gdal/default.nix | 13 ++++++++++++- pkgs/development/libraries/gdal/tests.nix | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix index 6f0e062136268..3aad307aab570 100644 --- a/pkgs/development/libraries/gdal/default.nix +++ b/pkgs/development/libraries/gdal/default.nix @@ -14,7 +14,9 @@ , useHDF ? (!useMinimalFeatures) , useNetCDF ? (!useMinimalFeatures) , useArmadillo ? (!useMinimalFeatures) +, useJava ? (!useMinimalFeatures) +, ant , bison , cmake , gtest @@ -36,6 +38,7 @@ , libgeotiff , geos , giflib +, jdk , libheif , dav1d , libaom @@ -94,7 +97,7 @@ stdenv.mkDerivation (finalAttrs: { python3.pkgs.setuptools python3.pkgs.wrapPython swig - ]; + ] ++ lib.optionals useJava [ ant jdk ]; cmakeFlags = [ "-DGDAL_USE_INTERNAL_LIBS=OFF" @@ -110,6 +113,10 @@ stdenv.mkDerivation (finalAttrs: { "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON" ] ++ lib.optionals (!useTiledb) [ "-DGDAL_USE_TILEDB=OFF" + ] ++ lib.optionals (!useJava) [ + # This is not strictly needed as the Java bindings wouldn't build anyway if + # ant/jdk were not available. + "-DBUILD_JAVA_BINDINGS=OFF" ]; buildInputs = @@ -192,6 +199,10 @@ stdenv.mkDerivation (finalAttrs: { postInstall = '' wrapPythonPrograms + '' + lib.optionalString useJava '' + cd $out/lib + ln -s ./jni/libgdalalljni${stdenv.hostPlatform.extensions.sharedLibrary} + cd - ''; enableParallelBuilding = true; diff --git a/pkgs/development/libraries/gdal/tests.nix b/pkgs/development/libraries/gdal/tests.nix index b89bbd51ab201..87fbff2d5fa57 100644 --- a/pkgs/development/libraries/gdal/tests.nix +++ b/pkgs/development/libraries/gdal/tests.nix @@ -1,4 +1,4 @@ -{ runCommand, gdal }: +{ runCommand, gdal, jdk }: let inherit (gdal) pname version; @@ -40,5 +40,16 @@ runCommand "${pname}-tests" { meta.timeout = 60; } ${gdal}/bin/gdalinfo ./test.tif + # test java bindings + cat < main.java + import org.gdal.gdal.gdal; + class Main { + public static void main(String[] args) { + gdal.AllRegister(); + } + } + EOF + ${jdk}/bin/java -Djava.library.path=${gdal}/lib/ -cp ${gdal}/share/java/gdal-${version}.jar main.java + touch $out '' From e130791ad6e13934efeb8e70b71b16bfc2cdcd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rolf=20Schr=C3=B6der?= Date: Thu, 25 Jan 2024 12:15:27 +0100 Subject: [PATCH 2/2] gdal: apply `nixpkgs-fmt` --- pkgs/development/libraries/gdal/default.nix | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix index 3aad307aab570..fd1aaf9c2e928 100644 --- a/pkgs/development/libraries/gdal/default.nix +++ b/pkgs/development/libraries/gdal/default.nix @@ -151,7 +151,8 @@ stdenv.mkDerivation (finalAttrs: { openexr xercesc ] ++ arrowDeps); - in [ + in + [ c-blosc brunsli cfitsio @@ -185,17 +186,17 @@ stdenv.mkDerivation (finalAttrs: { python3 python3.pkgs.numpy ] ++ tileDbDeps - ++ libHeifDeps - ++ libJxlDeps - ++ mysqlDeps - ++ postgresDeps - ++ popplerDeps - ++ arrowDeps - ++ hdfDeps - ++ netCdfDeps - ++ armadilloDeps - ++ darwinDeps - ++ nonDarwinDeps; + ++ libHeifDeps + ++ libJxlDeps + ++ mysqlDeps + ++ postgresDeps + ++ popplerDeps + ++ arrowDeps + ++ hdfDeps + ++ netCdfDeps + ++ armadilloDeps + ++ darwinDeps + ++ nonDarwinDeps; postInstall = '' wrapPythonPrograms