git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #27101 from volth/haxe-essentials

haxe: fix hxcpp, introduce haxePackage with hxjava and hxcs

commitf873ba8cc8bb69b57913f2468f0dd78ddbeb427d authorJörg Thalheim <Mic92@users.noreply.github.com> dateTue 4 Jul 2017, 18:09 (9 years ago) parent240b63237ef9e3
6 files changed+202−83
pkgs/development/compilers/haxe/default.nix+70−28 pkgs/development/compilers/haxe/hxcpp.nix−52 pkgs/development/compilers/haxe/setup-hook.sh+2 pkgs/development/compilers/neko/default.nix+6 pkgs/top-level/all-packages.nix+4−3 pkgs/top-level/haxe-packages.nix+120
pkgs/development/compilers/haxe/default.nix+70−28
@@ -1,40 +1,82 @@
1−{ stdenv, fetchgit, ocaml, zlib, pcre, neko, camlp4 }:
1+{ stdenv, fetchgit, bash, coreutils, ocaml, zlib, pcre, neko, camlp4 }:
22
3−stdenv.mkDerivation {
4− name = "haxe-3.4.2";
3+let
4+ generic = { version, sha256, prePatch }:
5+ stdenv.mkDerivation rec {
6+ name = "haxe-${version}";
57
6− buildInputs = [ocaml zlib pcre neko camlp4];
8+ buildInputs = [ocaml zlib pcre neko camlp4];
79
8− src = fetchgit {
9− url = "https://github.com/HaxeFoundation/haxe.git";
10− sha256 = "1m5fp183agqv8h3ynhxw4kndkpq2d6arysmirv3zl3vz5crmpwqd";
11− fetchSubmodules = true;
10+ src = fetchgit {
11+ url = https://github.com/HaxeFoundation/haxe.git;
12+ inherit sha256;
13+ fetchSubmodules = true;
14+ rev = "refs/tags/${version}";
15+ };
1216
13− # Tag 3.4.2
14− rev = "890f8c70cf23ce6f9fe0fdd0ee514a9699433ca7";
15− };
17+ inherit prePatch;
18+
19+ buildFlags = [ "all" "tools" ];
1620
17− prePatch = ''
18− sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
19− '';
21+ installPhase = ''
22+ install -vd "$out/bin" "$out/lib/haxe/std"
23+ cp -vr haxe haxelib std "$out/lib/haxe"
2024
21− buildFlags = [ "all" "tools" ];
25+ # make wrappers which provide a temporary HAXELIB_PATH with symlinks to multiple repositories HAXELIB_PATH may point to
26+ for name in haxe haxelib; do
27+ cat > $out/bin/$name <<EOF
28+ #!{bash}/bin/bash
2229
23− installPhase = ''
24− install -vd "$out/bin" "$out/lib/haxe/std"
25− install -vt "$out/bin" haxe haxelib
26− cp -vr std "$out/lib/haxe"
27− '';
30+ if [[ "\$HAXELIB_PATH" =~ : ]]; then
31+ NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)"
2832
29− setupHook = ./setup-hook.sh;
33+ IFS=':' read -ra libs <<< "\$HAXELIB_PATH"
34+ for libdir in "\''${libs[@]}"; do
35+ for lib in "\$libdir"/*; do
36+ if [ ! -e "\$NEW_HAXELIB_PATH/\$(${coreutils}/bin/basename "\$lib")" ]; then
37+ ${coreutils}/bin/ln -s "--target-directory=\$NEW_HAXELIB_PATH" "\$lib"
38+ fi
39+ done
40+ done
41+ export HAXELIB_PATH="\$NEW_HAXELIB_PATH"
42+ $out/lib/haxe/$name "\$@"
43+ rm -rf "\$NEW_HAXELIB_PATH"
44+ else
45+ exec $out/lib/haxe/$name "\$@"
46+ fi
47+ EOF
48+ chmod +x $out/bin/$name
49+ done
50+ '';
3051
31− dontStrip = true;
52+ setupHook = ./setup-hook.sh;
3253
33− meta = with stdenv.lib; {
34− description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
35− homepage = https://haxe.org;
36− license = with licenses; [ gpl2 bsd2 /*?*/ ]; # -> docs/license.txt
37− maintainers = [ maintainers.marcweber ];
38− platforms = platforms.linux ++ platforms.darwin;
54+ dontStrip = true;
55+
56+ meta = with stdenv.lib; {
57+ description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
58+ homepage = https://haxe.org;
59+ license = with licenses; [ gpl2 bsd2 /*?*/ ]; # -> docs/license.txt
60+ maintainers = [ maintainers.marcweber ];
61+ platforms = platforms.linux ++ platforms.darwin;
62+ };
63+ };
64+in {
65+ # this old version is required to compile some libraries
66+ haxe_3_2 = generic {
67+ version = "3.2.1";
68+ sha256 = "1x9ay5a2llq46fww3k07jxx8h1vfpyxb522snc6702a050ki5vz3";
69+ prePatch = ''
70+ sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' main.ml
71+ sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/tools/haxelib/Main.hx
72+ '';
73+ };
74+ haxe_3_4 = generic {
75+ version = "3.4.2";
76+ sha256 = "1m5fp183agqv8h3ynhxw4kndkpq2d6arysmirv3zl3vz5crmpwqd";
77+ prePatch = ''
78+ sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
79+ sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
80+ '';
3981 };
4082}
pkgs/development/compilers/haxe/hxcpp.nixdeleted−52
@@ -1,52 +0,0 @@
1−{ stdenv, fetchzip, haxe, neko, pcre, sqlite, zlib }:
2−
3−stdenv.mkDerivation rec {
4− name = "hxcpp-3.2.27";
5−
6− src = let
7− zipFile = stdenv.lib.replaceChars ["."] [","] name;
8− in fetchzip {
9− inherit name;
10− url = "http://lib.haxe.org/files/3.0/${zipFile}.zip";
11− sha256 = "1hw4kr1f8q7f4fkzis7kvkm7h1cxhv6cf5v1iq7rvxs2fxiys7fr";
12− };
13−
14− NIX_LDFLAGS = "-lpcre -lz -lsqlite3";
15−
16− outputs = [ "out" "lib" ];
17−
18− patchPhase = ''
19− rm -rf bin lib project/thirdparty project/libs/sqlite/sqlite3.[ch]
20− find . -name '*.n' -delete
21− sed -i -re '/(PCRE|ZLIB)_DIR|\<sqlite3\.c\>/d' project/Build.xml
22− sed -i -e 's/mFromFile = "@";/mFromFile = "";/' tools/hxcpp/Linker.hx
23− sed -i -e '/dll_ext/s,HX_CSTRING("./"),HX_CSTRING("'"$lib"'/"),' \
24− src/hx/Lib.cpp
25− '';
26−
27− buildInputs = [ haxe neko pcre sqlite zlib ];
28−
29− targetArch = "linux-m${if stdenv.is64bit then "64" else "32"}";
30−
31− buildPhase = ''
32− haxe -neko project/build.n -cp tools/build -main Build
33− haxe -neko run.n -cp tools/run -main RunMain
34− haxe -neko hxcpp.n -cp tools/hxcpp -main BuildTool
35− (cd project && neko build.n "ndll-$targetArch")
36− '';
37−
38− installPhase = ''
39− for i in bin/Linux*/*.dso; do
40− install -vD "$i" "$lib/$(basename "$i")"
41− done
42− find *.n toolchain/*.xml build-tool/BuildCommon.xml src include \
43− -type f -exec install -vD -m 0644 {} "$out/lib/haxe/hxcpp/{}" \;
44− '';
45−
46− meta = {
47− homepage = "http://lib.haxe.org/p/hxcpp";
48− description = "Runtime support library for the Haxe C++ backend";
49− license = stdenv.lib.licenses.bsd2;
50− platforms = stdenv.lib.platforms.linux;
51− };
52−}
pkgs/development/compilers/haxe/setup-hook.sh+2
@@ -1,5 +1,7 @@
11addHaxeLibPath() {
2+ if [ ! -d "$1/lib/haxe/std" ]; then
23 addToSearchPath HAXELIB_PATH "$1/lib/haxe"
4+ fi
35}
46
57envHooks+=(addHaxeLibPath)
pkgs/development/compilers/neko/default.nix+6
@@ -24,6 +24,12 @@ stdenv.mkDerivation rec {
2424 + "fe87462d9c7a6ee27e28f5be5e4fc0ac87b34574.patch";
2525 sha256 = "1jbmq6j32vg3qv20dbh82cp54886lgrh7gkcqins8a2y4l4dl3sc";
2626 })
27+ # https://github.com/HaxeFoundation/neko/pull/165
28+ (fetchpatch {
29+ url = "https://github.com/HaxeFoundation/neko/commit/"
30+ + "c6d9c6d796200990b3b6a53a4dc716c9192398e6.patch";
31+ sha256 = "1pq0qhhb9gbhc3zbgylwp0amhwsz0q0ggpj6v2xgv0hfy7d63rcd";
32+ })
2733 ];
2834
2935 buildInputs =
pkgs/top-level/all-packages.nix+4−3
@@ -5476,9 +5476,10 @@ with pkgs;
54765476 psc-package = haskell.lib.justStaticExecutables
54775477 (haskellPackages.callPackage ../development/compilers/purescript/psc-package { });
54785478
5479− inherit (ocamlPackages) haxe;
5480−
5481− hxcpp = callPackage ../development/compilers/haxe/hxcpp.nix { };
5479+ inherit (ocamlPackages.haxe) haxe_3_2 haxe_3_4;
5480+ haxe = haxe_3_4;
5481+ haxePackages = recurseIntoAttrs (callPackage ./haxe-packages.nix { });
5482+ inherit (haxePackages) hxcpp;
54825483
54835484 hhvm = callPackage ../development/compilers/hhvm {
54845485 boost = boost160;
pkgs/top-level/haxe-packages.nixnew file+120
@@ -0,0 +1,120 @@
1+{ stdenv, fetchzip, fetchFromGitHub, newScope, haxe, neko, nodejs, wine, php, python3, jdk, mono, haskellPackages, fetchpatch }:
2+
3+let
4+ self = haxePackages;
5+ callPackage = newScope self;
6+ haxePackages = with self; {
7+
8+ withCommas = stdenv.lib.replaceChars ["."] [","];
9+
10+ # simulate "haxelib dev $libname ."
11+ simulateHaxelibDev = libname: ''
12+ devrepo=$(mktemp -d)
13+ mkdir -p "$devrepo/${withCommas libname}"
14+ echo $(pwd) > "$devrepo/${withCommas libname}/.dev"
15+ export HAXELIB_PATH="$HAXELIB_PATH:$devrepo"
16+ '';
17+
18+ installLibHaxe = { libname, version, files ? "*" }: ''
19+ mkdir -p "$out/lib/haxe/${withCommas libname}/${withCommas version}"
20+ echo -n "${version}" > $out/lib/haxe/${withCommas libname}/.current
21+ cp -dpR ${files} "$out/lib/haxe/${withCommas libname}/${withCommas version}/"
22+ '';
23+
24+ buildHaxeLib = {
25+ libname,
26+ version,
27+ sha256,
28+ meta,
29+ ...
30+ } @ attrs:
31+ stdenv.mkDerivation (attrs // {
32+ name = "${libname}-${version}";
33+
34+ buildInputs = (attrs.buildInputs or []) ++ [ haxe neko ]; # for setup-hook.sh to work
35+ src = fetchzip rec {
36+ name = "${libname}-${version}";
37+ url = "http://lib.haxe.org/files/3.0/${withCommas name}.zip";
38+ inherit sha256;
39+ stripRoot = false;
40+ };
41+
42+ installPhase = attrs.installPhase or ''
43+ runHook preInstall
44+ (
45+ if [ $(ls $src | wc -l) == 1 ]; then
46+ cd $src/* || cd $src
47+ else
48+ cd $src
49+ fi
50+ ${installLibHaxe { inherit libname version; }}
51+ )
52+ runHook postInstall
53+ '';
54+
55+ meta = {
56+ homepage = "http://lib.haxe.org/p/${libname}";
57+ license = stdenv.lib.licenses.bsd2;
58+ platforms = stdenv.lib.platforms.all;
59+ description = throw "please write meta.description";
60+ } // attrs.meta;
61+ });
62+
63+ hxcpp = buildHaxeLib rec {
64+ libname = "hxcpp";
65+ version = "3.4.64";
66+ sha256 = "04gyjm6wqmsm0ifcfkxmq1yv8xrfzys3z5ajqnvvjrnks807mw8q";
67+ postFixup = ''
68+ for f in $out/lib/haxe/${withCommas libname}/${withCommas version}/{,project/libs/nekoapi/}bin/Linux{,64}/*; do
69+ chmod +w "$f"
70+ patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) "$f" || true
71+ patchelf --set-rpath ${ stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] } "$f" || true
72+ done
73+ '';
74+ meta.description = "Runtime support library for the Haxe C++ backend";
75+ };
76+
77+ hxjava = buildHaxeLib {
78+ libname = "hxjava";
79+ version = "3.2.0";
80+ sha256 = "1vgd7qvsdxlscl3wmrrfi5ipldmr4xlsiwnj46jz7n6izff5261z";
81+ meta.description = "Support library for the Java backend of the Haxe compiler";
82+ propagatedBuildInputs = [ jdk ];
83+ };
84+
85+ hxcs = buildHaxeLib {
86+ libname = "hxcs";
87+ version = "3.4.0";
88+ sha256 = "0f5vgp2kqnpsbbkn2wdxmjf7xkl0qhk9lgl9kb8d5wdy89nac6q6";
89+ meta.description = "Support library for the C# backend of the Haxe compiler";
90+ propagatedBuildInputs = [ mono ];
91+ };
92+
93+ hxnodejs_4 = buildHaxeLib {
94+ libname = "hxnodejs";
95+ version = "4.0.9";
96+ sha256 = "0b7ck48nsxs88sy4fhhr0x1bc8h2ja732zzgdaqzxnh3nir0bajm";
97+ meta.description = "Extern definitions for node.js 4.x";
98+ };
99+
100+ hxnodejs_6 = let
101+ libname = "hxnodejs";
102+ version = "6.9.0";
103+ in stdenv.mkDerivation rec {
104+ name = "${libname}-${version}";
105+ src = fetchFromGitHub {
106+ owner = "HaxeFoundation";
107+ repo = "hxnodejs";
108+ rev = "cf80c6a";
109+ sha256 = "0mdiacr5b2m8jrlgyd2d3vp1fha69lcfb67x4ix7l7zfi8g460gs";
110+ };
111+ installPhase = installLibHaxe { inherit libname version; };
112+ meta = {
113+ homepage = "http://lib.haxe.org/p/${libname}";
114+ license = stdenv.lib.licenses.bsd2;
115+ platforms = stdenv.lib.platforms.all;
116+ description = "Extern definitions for node.js 6.9";
117+ };
118+ };
119+ };
120+in self