2018-07-21 01:44:44 +01:00
|
|
|
{ stdenv, fetchgit, coreutils, ocaml, zlib, pcre, neko, camlp4 }:
|
2009-11-30 01:05:04 +00:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
let
|
|
|
|
generic = { version, sha256, prePatch }:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "haxe-${version}";
|
2009-12-11 13:58:23 +00:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
buildInputs = [ocaml zlib pcre neko camlp4];
|
2009-12-11 13:58:23 +00:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
src = fetchgit {
|
|
|
|
url = https://github.com/HaxeFoundation/haxe.git;
|
|
|
|
inherit sha256;
|
|
|
|
fetchSubmodules = true;
|
|
|
|
rev = "refs/tags/${version}";
|
|
|
|
};
|
2014-06-01 14:13:04 +01:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
inherit prePatch;
|
|
|
|
|
|
|
|
buildFlags = [ "all" "tools" ];
|
2010-03-16 23:34:56 +00:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
installPhase = ''
|
|
|
|
install -vd "$out/bin" "$out/lib/haxe/std"
|
|
|
|
cp -vr haxe haxelib std "$out/lib/haxe"
|
2012-10-07 10:24:51 +01:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
# 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
|
2013-05-25 17:33:48 +01:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
if [[ "\$HAXELIB_PATH" =~ : ]]; then
|
|
|
|
NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)"
|
2012-10-07 10:24:51 +01:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
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
|
|
|
|
'';
|
2015-03-20 07:32:52 +00:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
setupHook = ./setup-hook.sh;
|
2012-10-07 10:24:51 +01:00
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
dontStrip = true;
|
|
|
|
|
2018-04-17 12:52:29 +01:00
|
|
|
# While it might be a good idea to run the upstream test suite, let's at
|
|
|
|
# least make sure we can actually run the compiler.
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
# Get out of the source directory to make sure the stdlib from the
|
|
|
|
# sources doesn't interfere with the installed one.
|
|
|
|
mkdir installcheck
|
|
|
|
pushd installcheck > /dev/null
|
|
|
|
cat >> InstallCheck.hx <<EOF
|
|
|
|
class InstallCheck {
|
|
|
|
public static function main() trace("test");
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
"$out/bin/haxe" -js installcheck.js -main InstallCheck
|
|
|
|
grep -q 'console\.log.*test' installcheck.js
|
|
|
|
popd > /dev/null
|
|
|
|
'';
|
|
|
|
|
2017-05-20 22:14:08 +01:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
haxe_3_4 = generic {
|
2018-02-18 22:54:21 +00:00
|
|
|
version = "3.4.6";
|
|
|
|
sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if";
|
2017-05-20 22:14:08 +01:00
|
|
|
prePatch = ''
|
2018-04-17 12:52:29 +01:00
|
|
|
sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml
|
2017-05-20 22:14:08 +01:00
|
|
|
sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
|
|
|
|
'';
|
2012-10-07 10:24:51 +01:00
|
|
|
};
|
2009-11-30 01:05:04 +00:00
|
|
|
}
|