Commit b76ff913 authored by Doron Behar's avatar Doron Behar
Browse files

swt: 4.5 -> 4.33

Fixes #219771. Previous attempt: #75609
parent dd12b437
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
--- a/make_linux.mak
+++ b/make_linux.mak
@@ -63,4 +63,4 @@

 AWT_LFLAGS = -shared ${SWT_LFLAGS}
-AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt
+AWT_LIBS = `pkg-config --libs x11` -L$(AWT_LIB_PATH) -ljawt
+0 −14
Original line number Diff line number Diff line
--- a/make_linux.mak
+++ b/make_linux.mak
@@ -53,9 +53,4 @@

-# Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
-GTKCFLAGS = `pkg-config --cflags gtk+-$(GTK_VERSION) gtk+-unix-print-$(GTK_VERSION)`
+GTKCFLAGS = `pkg-config --cflags gtk+-$(GTK_VERSION) gthread-2.0 gtk+-unix-print-$(GTK_VERSION) x11 xtst`
+GTKLIBS = `pkg-config --libs gtk+-$(GTK_VERSION) gthread-2.0 gtk+-unix-print-$(GTK_VERSION) x11 xtst`
-ifeq ($(GTK_VERSION), 3.0)
-GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-3 -lgdk-3 -lcairo -lgthread-2.0 -lXtst
-else
-GTKLIBS = `pkg-config --libs-only-L gtk+-$(GTK_VERSION) gthread-2.0` $(XLIB64) -L/usr/X11R6/lib -lgtk-x11-$(GTK_VERSION) -lgthread-2.0 -lXtst
-endif
+30 −75
Original line number Diff line number Diff line
{
  atk,
  fetchzip,
  gtk2,
  gtk3,
  jdk,
  lib,
  libGL,
  libGLU,
  libXt,
  libXtst,
  pkg-config,
  stdenv,
  stripJavaArchivesHook,
@@ -15,18 +11,16 @@

stdenv.mkDerivation (finalAttrs: {
  pname = "swt";
  version = "4.5";
  fullVersion = "${finalAttrs.version}-201506032000";
  version = "4.33";
  fullVersion = "${finalAttrs.version}-202409030240";

  hardeningDisable = [ "format" ];

  passthru.srcMetadataByPlatform = {
    x86_64-linux.platform = "gtk-linux-x86_64";
    x86_64-linux.hash = "sha256-JhzRCrVzsM2NBf65l6CDZdgchlbECHGUg0J0bQVT2Z0=";
    i686-linux.platform = "gtk-linux-x86";
    i686-linux.hash = "sha256-C7H1CUFkl7GPpqDFSzYnlLWa1XcawI2hbtsn9fIJio0=";
    x86_64-linux.hash = "sha256-0OUr+jpwTx5/eoA6Uo2E9/SBAtf+IMMiSVRhOfaWFhE=";
    x86_64-darwin.platform = "cocoa-macosx-x86_64";
    x86_64-darwin.hash = "sha256-CrSFkrlnSP2uQzRrRzv8F0lXEA7TNK9RFe2neDjtXnI=";
    x86_64-darwin.hash = "sha256-n948C/YPF55WPYvub3re/wARLP1Wk+XhJiIuI0YQH5c=";
  };
  passthru.srcMetadata =
    finalAttrs.passthru.srcMetadataByPlatform.${stdenv.hostPlatform.system} or null;
@@ -56,84 +50,39 @@ stdenv.mkDerivation (finalAttrs: {
    };

  nativeBuildInputs = [
    jdk
    stripJavaArchivesHook
    pkg-config
  ];
  buildInputs = [
    atk
    gtk2
    jdk
    libGL
    gtk3
    libGLU
    libXtst
  ] ++ lib.optionals (lib.hasPrefix "8u" jdk.version) [ libXt ];

  patches = [
    ./awt-libs.patch
    ./gtk-libs.patch
  ];

  prePatch = ''
    # clear whitespace from makefiles (since we match on EOL later)
    sed -i 's/ \+$//' ./*.mak
  '';

  postPatch =
    let
      makefile-sed = builtins.toFile "swt-makefile.sed" ''
        # fix pkg-config invocations in CFLAGS/LIBS pairs.
        #
        # change:
        #     FOOCFLAGS = `pkg-config --cflags `foo bar`
        #     FOOLIBS = `pkg-config --libs-only-L foo` -lbaz
        # into:
        #     FOOCFLAGS = `pkg-config --cflags foo bar`
        #     FOOLIBS = `pkg-config --libs foo bar`
        #
        # the latter works more consistently.
        /^[A-Z0-9_]\+CFLAGS = `pkg-config --cflags [^`]\+`$/ {
          N
          s/${''
            ^\([A-Z0-9_]\+\)CFLAGS = `pkg-config --cflags \(.\+\)`\
            \1LIBS = `pkg-config --libs-only-L .\+$''}/${''
            \1CFLAGS = `pkg-config --cflags \2`\
            \1LIBS = `pkg-config --libs \2`''}/
        }
        # fix WebKit libs not being there
        s/\$(WEBKIT_LIB) \$(WEBKIT_OBJECTS)$/\0 `pkg-config --libs glib-2.0`/g
      '';
    in
    ''
      declare -a makefiles=(./*.mak)
      sed -i -f ${makefile-sed} "''${makefiles[@]}"
      # assign Makefile variables eagerly & change backticks to `$(shell …)`
      sed -i -e 's/ = `\([^`]\+\)`/ := $(shell \1)/' \
        -e 's/`\([^`]\+\)`/$(shell \1)/' \
        "''${makefiles[@]}"
  SWT_JAVA_HOME = jdk;
  AWT_LIB_PATH = "${jdk}/lib/openjdk/lib";
  # Used by the makefile which is responsible for the shared objects only
  OUTPUT_DIR = "${placeholder "out"}/lib";
  # GTK4 is not supported yet. Waiting for:
  # https://github.com/eclipse-platform/eclipse.platform.swt/pull/1482
  makeFlags = "gtk3";
  preBuild = ''
    cd library
    mkdir -p ${finalAttrs.OUTPUT_DIR}
  '';

  buildPhase = ''
    runHook preBuild

    export JAVA_HOME=${jdk}

    ./build.sh

  # Build the jar
  postBuild = ''
    cd ../
    mkdir out
    find org/ -name '*.java' -type f -exec javac -d out/ {} +

    runHook postBuild
  '';

  # The makefile doesn't have an install target, the installation of the shared
  # objects is part of the `all` target.
  installPhase = ''
    runHook preInstall

    if [[ -n "$prefix" ]]; then
      install -d -- "$prefix"
    fi

    install -Dm 644 -t "$out/lib" -- *.so

    install -d -- "$out/jars"
    install -m 644 -t out -- version.txt
    (cd out && jar -c *) > "$out/jars/swt.jar"
@@ -147,8 +96,14 @@ stdenv.mkDerivation (finalAttrs: {
      A widget toolkit for Java to access the user-interface facilities of
      the operating systems on which it is implemented.
    '';
    license = lib.licenses.epl10;
    license = with lib.licenses; [
      # All of these are located in the about_files directory of the source
      ijg
      lgpl21
      mpl11
      mpl20
    ];
    maintainers = [ ];
    platforms = lib.platforms.linux;
    platforms = lib.attrNames finalAttrs.passthru.srcMetadataByPlatform;
  };
})