haxe: Fix path to stdlib and add small test

The version bump in c727e7e7d6 (pull
request #35153) didn't actually take into account that Haxe has changed
the way they search for the stdlib. Instead of a hardcoded list of paths
it now searches based on a common prefix.

So when running Haxe, it errored out because it couldn't find its own
standard library. This is now fixed by changing the sed expression
accordingly.

Apart from fixing the actual issue, I've added a small test in
installCheckPhase to make sure something like this won't happen again in
future updates.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @volth, @joachifm
This commit is contained in:
aszlig 2018-04-17 13:52:29 +02:00
parent f21e931c98
commit 683e2067d7
No known key found for this signature in database
GPG Key ID: 684089CE67EBB691

View File

@ -53,6 +53,24 @@ let
dontStrip = true;
# 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
'';
meta = with stdenv.lib; {
description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
homepage = https://haxe.org;
@ -75,7 +93,7 @@ in {
version = "3.4.6";
sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if";
prePatch = ''
sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml
sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml
sed -i -e 's|"neko"|"${neko}/bin/neko"|g' extra/haxelib_src/src/haxelib/client/Main.hx
'';
};