about summary refs log tree commit diff
path: root/pkgs/by-name/jo/jogl/package.nix
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2024-02-10 22:18:16 +0100
committerWeijia Wang <9713184+wegank@users.noreply.github.com>2024-02-10 22:18:16 +0100
commitc9328750fa7c1a343b11727cf0bcf3509043048c (patch)
tree915be21849fa60362a842167bf8d814258fa96b5 /pkgs/by-name/jo/jogl/package.nix
parentc00ace12ae50ead6c5ae4e21146336277827910b (diff)
jogl: refactor
Diffstat (limited to 'pkgs/by-name/jo/jogl/package.nix')
-rw-r--r--pkgs/by-name/jo/jogl/package.nix73
1 files changed, 43 insertions, 30 deletions
diff --git a/pkgs/by-name/jo/jogl/package.nix b/pkgs/by-name/jo/jogl/package.nix
index 611b85acd42e0..3919ee1e0e0f0 100644
--- a/pkgs/by-name/jo/jogl/package.nix
+++ b/pkgs/by-name/jo/jogl/package.nix
@@ -38,7 +38,31 @@ stdenv.mkDerivation {
 
   unpackCmd = "cp -r $curSrc \${curSrc##*-}";
 
-  postPatch = lib.optionalString stdenv.isDarwin ''
+  postPatch = ''
+    substituteInPlace gluegen/src/java/com/jogamp/common/util/IOUtil.java \
+      --replace-fail '#!/bin/true' '#!${coreutils}/bin/true'
+  ''
+  # set timestamp of files in jar to a fixed point in time
+  + ''
+    xmlstarlet ed --inplace \
+      --append //jar --type attr -n modificationtime --value 1980-01-01T00:00Z \
+      gluegen/make/{build.xml,gluegen-cpptasks-base.xml} \
+      jogl/make/{build.xml,build-nativewindow.xml,build-jogl.xml}
+  ''
+  # prevent looking for native libraries in /usr/lib
+  + ''
+    substituteInPlace jogl/make/build-*.xml \
+      --replace-warn 'dir="''${TARGET_PLATFORM_USRLIBS}"' ""
+  ''
+  # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
+  # if arm/aarch64 support will be added, this block might be commented out on those platforms
+  # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
+  + ''
+    xmlstarlet ed --inplace \
+      --delete '//*[@if="setup.addNativeBroadcom"]' \
+      jogl/make/build-newt.xml
+  ''
+  + lib.optionalString stdenv.isDarwin ''
     sed -i '/if="use.macos/d' gluegen/make/gluegen-cpptasks-base.xml
     rm -r jogl/oculusvr-sdk
   '';
@@ -67,46 +91,35 @@ stdenv.mkDerivation {
     darwin.apple_sdk_11_0.frameworks.Cocoa
   ];
 
-  # Workaround build failure on -fno-common toolchains:
-  #   ld: ../obj/Bindingtest1p1Impl_JNI.o:(.bss+0x8): multiple definition of
-  #     `unsigned_size_t_1'; ../obj/TK_Surface_JNI.o:(.bss+0x8): first defined here
-  NIX_CFLAGS_COMPILE = "-fcommon"; # copied from 2.3.2, is this still needed?
+  env = {
+    SOURCE_LEVEL = "1.8";
+    TARGET_LEVEL = "1.8";
+    TARGET_RT_JAR = "null.jar";
+    # error: incompatible pointer to integer conversion returning 'GLhandleARB' (aka 'void *') from a function with result type 'jlong' (aka 'long long')
+    NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-int-conversion";
+  };
 
   buildPhase = ''
-    ( cd gluegen/make
-      substituteInPlace ../src/java/com/jogamp/common/util/IOUtil.java --replace '#!/bin/true' '#!${coreutils}/bin/true'
-
-      # set timestamp of files in jar to a fixed point in time
-      xmlstarlet ed --inplace \
-         --append //jar --type attr -n modificationtime --value 1980-01-01T00:00Z \
-         build.xml gluegen-cpptasks-base.xml
-
-      ant -Dtarget.sourcelevel=8 -Dtarget.targetlevel=8 -Dtarget.rt.jar='null.jar' )
-
-    ( cd jogl/make
+    runHook preBuild
 
-      # prevent looking for native libraries in /usr/lib
-      substituteInPlace build-*.xml \
-        --replace 'dir="''${TARGET_PLATFORM_USRLIBS}"' ""
+    for f in gluegen jogl; do
+      pushd $f/make
+      ant
+      popd
+    done
 
-      # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
-      # if arm/aarch64 support will be added, this block might be commented out on those platforms
-      # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
-      xmlstarlet ed --inplace --delete '//*[@if="setup.addNativeBroadcom"]' build-newt.xml
-
-      # set timestamp of files in jar to a fixed point in time
-      xmlstarlet ed --inplace \
-         --append //jar --type attr -n modificationtime --value 1980-01-01T00:00Z \
-         build.xml build-nativewindow.xml build-jogl.xml
-
-      ant -Dtarget.sourcelevel=8 -Dtarget.targetlevel=8 -Dtarget.rt.jar='null.jar' )
+    runHook postBuild
   '';
 
   installPhase = ''
+    runHook preInstall
+
     mkdir -p $out/share/java
     cp -v $NIX_BUILD_TOP/gluegen/build/gluegen-rt{,-natives-linux-*}.jar $out/share/java/
     cp -v $NIX_BUILD_TOP/jogl/build/jar/jogl-all{,-natives-linux-*}.jar  $out/share/java/
     cp -v $NIX_BUILD_TOP/jogl/build/nativewindow/nativewindow{,-awt,-natives-linux-*,-os-drm,-os-x11}.jar  $out/share/java/
+
+    runHook postInstall
   '';
 
   meta = with lib; {