at 24.05-pre 3.9 kB view raw
1{ lib 2, stdenv 3, canonicalize-jars-hook 4, fetchzip 5, pkg-config 6, atk 7, glib 8, gtk2 9, jdk 10, libGL 11, libGLU 12, libXt 13, libXtst 14, gnome2 15}: 16 17let 18 platformMap = { 19 x86_64-linux = 20 { platform = "gtk-linux-x86_64"; 21 sha256 = "17frac2nsx22hfa72264as31rn35hfh9gfgy0n6wvc3knl5d2716"; }; 22 i686-linux = 23 { platform = "gtk-linux-x86"; 24 sha256 = "13ca17rga9yvdshqvh0sfzarmdcl4wv4pid0ls7v35v4844zbc8b"; }; 25 x86_64-darwin = 26 { platform = "cocoa-macosx-x86_64"; 27 sha256 = "0wjyxlw7i9zd2m8syd6k1q85fj8pzhxlfsrl8fpgsj37p698bd0a"; }; 28 }; 29 30 metadata = assert platformMap ? ${stdenv.hostPlatform.system}; 31 platformMap.${stdenv.hostPlatform.system}; 32in stdenv.mkDerivation rec { 33 pname = "swt"; 34 version = "4.5"; 35 fullVersion = "${version}-201506032000"; 36 37 hardeningDisable = [ "format" ]; 38 39 # Alas, the Eclipse Project apparently doesn't produce source-only 40 # releases of SWT. So we just grab a binary release and extract 41 # "src.zip" from that. 42 src = fetchzip { 43 url = "https://archive.eclipse.org/eclipse/downloads/drops4/" + 44 "R-${fullVersion}/${pname}-${version}-${metadata.platform}.zip"; 45 inherit (metadata) sha256; 46 stripRoot = false; 47 postFetch = '' 48 mkdir "$unpackDir" 49 cd "$unpackDir" 50 51 renamed="$TMPDIR/src.zip" 52 mv "$out/src.zip" "$renamed" 53 unpackFile "$renamed" 54 rm -r "$out" 55 56 mv "$unpackDir" "$out" 57 ''; 58 }; 59 60 nativeBuildInputs = [ 61 canonicalize-jars-hook 62 pkg-config 63 ]; 64 buildInputs = [ 65 atk 66 gtk2 67 jdk 68 libGL 69 libGLU 70 libXtst 71 gnome2.gnome_vfs 72 gnome2.libgnome 73 gnome2.libgnomeui 74 ] ++ lib.optionals (lib.hasPrefix "8u" jdk.version) [ 75 libXt 76 ]; 77 78 patches = [ ./awt-libs.patch ./gtk-libs.patch ]; 79 80 prePatch = '' 81 # clear whitespace from makefiles (since we match on EOL later) 82 sed -i 's/ \+$//' ./*.mak 83 ''; 84 85 postPatch = let makefile-sed = builtins.toFile "swt-makefile.sed" ('' 86 # fix pkg-config invocations in CFLAGS/LIBS pairs. 87 # 88 # change: 89 # FOOCFLAGS = `pkg-config --cflags `foo bar` 90 # FOOLIBS = `pkg-config --libs-only-L foo` -lbaz 91 # into: 92 # FOOCFLAGS = `pkg-config --cflags foo bar` 93 # FOOLIBS = `pkg-config --libs foo bar` 94 # 95 # the latter works more consistently. 96 /^[A-Z0-9_]\+CFLAGS = `pkg-config --cflags [^`]\+`$/ { 97 N 98 s'' + 99 "/" + '' 100 ^\([A-Z0-9_]\+\)CFLAGS = `pkg-config --cflags \(.\+\)`\ 101 \1LIBS = `pkg-config --libs-only-L .\+$'' + 102 "/" + '' 103 \1CFLAGS = `pkg-config --cflags \2`\ 104 \1LIBS = `pkg-config --libs \2`'' + 105 "/\n" + '' 106 } 107 # fix WebKit libs not being there 108 s/\$(WEBKIT_LIB) \$(WEBKIT_OBJECTS)$/\0 `pkg-config --libs glib-2.0`/g 109 ''); in '' 110 declare -a makefiles=(./*.mak) 111 sed -i -f ${makefile-sed} "''${makefiles[@]}" 112 # assign Makefile variables eagerly & change backticks to `$(shell )` 113 sed -i -e 's/ = `\([^`]\+\)`/ := $(shell \1)/' \ 114 -e 's/`\([^`]\+\)`/$(shell \1)/' \ 115 "''${makefiles[@]}" 116 ''; 117 118 buildPhase = '' 119 runHook preBuild 120 121 export JAVA_HOME=${jdk} 122 123 ./build.sh 124 125 mkdir out 126 find org/ -name '*.java' -type f -exec javac -d out/ {} + 127 128 runHook postBuild 129 ''; 130 131 installPhase = '' 132 runHook preInstall 133 134 if [ -n "$prefix" ]; then 135 mkdir -p "$prefix" 136 fi 137 138 mkdir -p "$out/lib" 139 cp -t "$out/lib" ./*.so 140 141 mkdir -p "$out/jars" 142 cp -t out/ version.txt 143 (cd out && jar -c *) > "$out/jars/swt.jar" 144 145 runHook postInstall 146 ''; 147 148 meta = with lib; { 149 homepage = "https://www.eclipse.org/swt/"; 150 description = '' 151 A widget toolkit for Java to access the user-interface facilities of 152 the operating systems on which it is implemented. 153 ''; 154 license = licenses.epl10; 155 maintainers = with maintainers; [ bb010g ]; 156 platforms = platforms.linux; 157 }; 158}