summary refs log tree commit diff
path: root/pkgs/development/libraries/java/swt/default.nix
blob: a93d77742915fe0060e0e7c8b5072eed1107ae4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ stdenv, lib, fetchurl, unzip, jdk, pkgconfig, gtk2
, libXt, libXtst, libXi, libGLU_combined, webkitgtk, libsoup, xorg
, pango, gdk-pixbuf, glib
}:

let
  platformMap = {
    x86_64-linux =
      { platform = "gtk-linux-x86_64";
        sha256 = "1qq0pjll6030v4ml0hifcaaik7sx3fl7ghybfdw95vsvxafwp2ff"; };
    i686-linux =
      { platform = "gtk-linux-x86";
        sha256 = "03mhzraikcs4fsz7d3h5af9pw1bbcfd6dglsvbk2ciwimy9zj30q"; };
    x86_64-darwin =
      { platform = "cocoa-macosx-x86_64";
        sha256 = "00k1mfbncvyh8klgmk0891w8jwnd5niqb16j1j8yacrm2smmlb05"; };
  };

  metadata = assert platformMap ? ${stdenv.hostPlatform.system}; platformMap.${stdenv.hostPlatform.system};

in stdenv.mkDerivation rec {
  version = "4.5";
  fullVersion = "${version}-201506032000";
  pname = "swt";

  hardeningDisable = [ "format" ];

  # Alas, the Eclipse Project apparently doesn't produce source-only
  # releases of SWT.  So we just grab a binary release and extract
  # "src.zip" from that.
  src = fetchurl {
    url = "http://archive.eclipse.org/eclipse/downloads/drops4/R-${fullVersion}/${pname}-${version}-${metadata.platform}.zip";
    sha256 = metadata.sha256;
  };

  sourceRoot = ".";

  nativeBuildInputs = [ unzip pkgconfig ];
  buildInputs = [ jdk gtk2 libXt libXtst libXi libGLU_combined webkitgtk libsoup ];

  NIX_LFLAGS = (map (x: "-L${lib.getLib x}/lib") [ xorg.libX11 pango gdk-pixbuf glib ]) ++
    [ "-lX11" "-lpango-1.0" "-lgdk_pixbuf-2.0" "-lglib-2.0" ];

  buildPhase = ''
    unzip src.zip -d src

    cd src
    sed -i "s#^LFLAGS =#LFLAGS = $NIX_LFLAGS #g"  *.mak
    export JAVA_HOME=${jdk}

    sh ./build.sh

    mkdir out
    javac -d out/ $(find org/ -name "*.java")
  '';

  installPhase = ''
    mkdir -p $out/lib
    cp *.so $out/lib

    mkdir -p $out/jars
    cp version.txt out/
    cd out && jar -c * > $out/jars/swt.jar
  '';

  meta = with stdenv.lib; {
    homepage = http://www.eclipse.org/swt/;
    description = "An widget toolkit for Java to access the user-interface facilities of the operating systems on which it is implemented";
    license = licenses.epl10;
    maintainers = with maintainers; [ pSub ];
    platforms = with platforms; linux;
  };
}