haxe: fix hxcpp, introduce haxePackage with hxjava and hxcs

This commit is contained in:
Volth
2017-05-20 21:14:08 +00:00
parent dc7cc77111
commit 37ef9e3b60
6 changed files with 207 additions and 88 deletions

View File

@@ -1,40 +1,82 @@
{ stdenv, fetchgit, ocaml, zlib, pcre, neko, camlp4 }:
{ stdenv, fetchgit, bash, coreutils, ocaml, zlib, pcre, neko, camlp4 }:
stdenv.mkDerivation {
name = "haxe-3.4.2";
let
generic = { version, sha256, prePatch }:
stdenv.mkDerivation rec {
name = "haxe-${version}";
buildInputs = [ocaml zlib pcre neko camlp4];
buildInputs = [ocaml zlib pcre neko camlp4];
src = fetchgit {
url = "https://github.com/HaxeFoundation/haxe.git";
sha256 = "1m5fp183agqv8h3ynhxw4kndkpq2d6arysmirv3zl3vz5crmpwqd";
fetchSubmodules = true;
src = fetchgit {
url = https://github.com/HaxeFoundation/haxe.git;
inherit sha256;
fetchSubmodules = true;
rev = "refs/tags/${version}";
};
# Tag 3.4.2
rev = "890f8c70cf23ce6f9fe0fdd0ee514a9699433ca7";
inherit prePatch;
buildFlags = [ "all" "tools" ];
installPhase = ''
install -vd "$out/bin" "$out/lib/haxe/std"
cp -vr haxe haxelib std "$out/lib/haxe"
# make wrappers which provide a temporary HAXELIB_PATH with symlinks to multiple repositories HAXELIB_PATH may point to
for name in haxe haxelib; do
cat > $out/bin/$name <<EOF
#!{bash}/bin/bash
if [[ "\$HAXELIB_PATH" =~ : ]]; then
NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)"
IFS=':' read -ra libs <<< "\$HAXELIB_PATH"
for libdir in "\''${libs[@]}"; do
for lib in "\$libdir"/*; do
if [ ! -e "\$NEW_HAXELIB_PATH/\$(${coreutils}/bin/basename "\$lib")" ]; then
${coreutils}/bin/ln -s "--target-directory=\$NEW_HAXELIB_PATH" "\$lib"
fi
done
done
export HAXELIB_PATH="\$NEW_HAXELIB_PATH"
$out/lib/haxe/$name "\$@"
rm -rf "\$NEW_HAXELIB_PATH"
else
exec $out/lib/haxe/$name "\$@"
fi
EOF
chmod +x $out/bin/$name
done
'';
setupHook = ./setup-hook.sh;
dontStrip = true;
meta = with stdenv.lib; {
description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
homepage = https://haxe.org;
license = with licenses; [ gpl2 bsd2 /*?*/ ]; # -> docs/license.txt
maintainers = [ maintainers.marcweber ];
platforms = platforms.linux ++ platforms.darwin;
};
};
in {
# this old version is required to compile some libraries
haxe_3_2 = generic {
version = "3.2.1";
sha256 = "1x9ay5a2llq46fww3k07jxx8h1vfpyxb522snc6702a050ki5vz3";
prePatch = ''
sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' main.ml
sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/tools/haxelib/Main.hx
'';
};
prePatch = ''
sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
'';
buildFlags = [ "all" "tools" ];
installPhase = ''
install -vd "$out/bin" "$out/lib/haxe/std"
install -vt "$out/bin" haxe haxelib
cp -vr std "$out/lib/haxe"
'';
setupHook = ./setup-hook.sh;
dontStrip = true;
meta = with stdenv.lib; {
description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
homepage = https://haxe.org;
license = with licenses; [ gpl2 bsd2 /*?*/ ]; # -> docs/license.txt
maintainers = [ maintainers.marcweber ];
platforms = platforms.linux ++ platforms.darwin;
haxe_3_4 = generic {
version = "3.4.2";
sha256 = "1m5fp183agqv8h3ynhxw4kndkpq2d6arysmirv3zl3vz5crmpwqd";
prePatch = ''
sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
'';
};
}

View File

@@ -1,52 +0,0 @@
{ stdenv, fetchzip, haxe, neko, pcre, sqlite, zlib }:
stdenv.mkDerivation rec {
name = "hxcpp-3.2.27";
src = let
zipFile = stdenv.lib.replaceChars ["."] [","] name;
in fetchzip {
inherit name;
url = "http://lib.haxe.org/files/3.0/${zipFile}.zip";
sha256 = "1hw4kr1f8q7f4fkzis7kvkm7h1cxhv6cf5v1iq7rvxs2fxiys7fr";
};
NIX_LDFLAGS = "-lpcre -lz -lsqlite3";
outputs = [ "out" "lib" ];
patchPhase = ''
rm -rf bin lib project/thirdparty project/libs/sqlite/sqlite3.[ch]
find . -name '*.n' -delete
sed -i -re '/(PCRE|ZLIB)_DIR|\<sqlite3\.c\>/d' project/Build.xml
sed -i -e 's/mFromFile = "@";/mFromFile = "";/' tools/hxcpp/Linker.hx
sed -i -e '/dll_ext/s,HX_CSTRING("./"),HX_CSTRING("'"$lib"'/"),' \
src/hx/Lib.cpp
'';
buildInputs = [ haxe neko pcre sqlite zlib ];
targetArch = "linux-m${if stdenv.is64bit then "64" else "32"}";
buildPhase = ''
haxe -neko project/build.n -cp tools/build -main Build
haxe -neko run.n -cp tools/run -main RunMain
haxe -neko hxcpp.n -cp tools/hxcpp -main BuildTool
(cd project && neko build.n "ndll-$targetArch")
'';
installPhase = ''
for i in bin/Linux*/*.dso; do
install -vD "$i" "$lib/$(basename "$i")"
done
find *.n toolchain/*.xml build-tool/BuildCommon.xml src include \
-type f -exec install -vD -m 0644 {} "$out/lib/haxe/hxcpp/{}" \;
'';
meta = {
homepage = "http://lib.haxe.org/p/hxcpp";
description = "Runtime support library for the Haxe C++ backend";
license = stdenv.lib.licenses.bsd2;
platforms = stdenv.lib.platforms.linux;
};
}

View File

@@ -1,5 +1,7 @@
addHaxeLibPath() {
if [ ! -d "$1/lib/haxe/std" ]; then
addToSearchPath HAXELIB_PATH "$1/lib/haxe"
fi
}
envHooks+=(addHaxeLibPath)

View File

@@ -24,6 +24,12 @@ stdenv.mkDerivation rec {
+ "fe87462d9c7a6ee27e28f5be5e4fc0ac87b34574.patch";
sha256 = "1jbmq6j32vg3qv20dbh82cp54886lgrh7gkcqins8a2y4l4dl3sc";
})
# https://github.com/HaxeFoundation/neko/pull/165
(fetchpatch {
url = "https://github.com/HaxeFoundation/neko/commit/"
+ "c6d9c6d796200990b3b6a53a4dc716c9192398e6.patch";
sha256 = "1pq0qhhb9gbhc3zbgylwp0amhwsz0q0ggpj6v2xgv0hfy7d63rcd";
})
];
buildInputs =