2021-04-20 21:06:35 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, coreutils, ocaml-ng, zlib, pcre, neko, mbedtls, Security }:
|
2009-11-30 01:05:04 +00:00
|
|
|
|
2017-05-20 21:14:08 +00:00
|
|
|
let
|
2021-03-19 14:25:23 +00:00
|
|
|
ocamlDependencies = version:
|
2021-04-20 03:46:16 +00:00
|
|
|
if lib.versionAtLeast version "4.2"
|
2021-03-19 14:25:23 +00:00
|
|
|
then with ocaml-ng.ocamlPackages; [
|
|
|
|
ocaml
|
|
|
|
findlib
|
|
|
|
sedlex_2
|
|
|
|
xml-light
|
|
|
|
ptmap
|
|
|
|
camlp5
|
|
|
|
sha
|
|
|
|
dune_2
|
|
|
|
luv
|
2021-04-20 03:46:16 +00:00
|
|
|
ocaml_extlib
|
|
|
|
] else if lib.versionAtLeast version "4.0"
|
|
|
|
then with ocaml-ng.ocamlPackages_4_10; [
|
|
|
|
ocaml
|
|
|
|
findlib
|
|
|
|
sedlex_2
|
|
|
|
xml-light
|
|
|
|
ptmap
|
|
|
|
camlp5
|
|
|
|
sha
|
|
|
|
dune_2
|
|
|
|
luv
|
|
|
|
ocaml_extlib-1-7-7
|
2021-03-19 14:25:23 +00:00
|
|
|
] else with ocaml-ng.ocamlPackages_4_05; [
|
|
|
|
ocaml
|
|
|
|
camlp4
|
|
|
|
];
|
|
|
|
|
|
|
|
defaultPatch = ''
|
|
|
|
substituteInPlace extra/haxelib_src/src/haxelib/client/Main.hx \
|
|
|
|
--replace '"neko"' '"${neko}/bin/neko"'
|
|
|
|
'';
|
|
|
|
|
|
|
|
generic = { sha256, version, prePatch ? defaultPatch }:
|
2019-08-13 21:52:01 +00:00
|
|
|
stdenv.mkDerivation {
|
2019-08-13 21:52:01 +00:00
|
|
|
pname = "haxe";
|
|
|
|
inherit version;
|
2009-12-11 13:58:23 +00:00
|
|
|
|
2021-03-19 14:25:23 +00:00
|
|
|
buildInputs = [ zlib pcre neko ]
|
2021-04-20 21:06:35 +00:00
|
|
|
++ lib.optional (lib.versionAtLeast version "4.1") mbedtls
|
|
|
|
++ lib.optional (lib.versionAtLeast version "4.1" && stdenv.isDarwin) Security
|
2021-03-19 14:25:23 +00:00
|
|
|
++ ocamlDependencies version;
|
2009-12-11 13:58:23 +00:00
|
|
|
|
2021-03-19 14:25:23 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "HaxeFoundation";
|
|
|
|
repo = "haxe";
|
|
|
|
rev = version;
|
2017-05-20 21:14:08 +00:00
|
|
|
fetchSubmodules = true;
|
2021-03-19 14:25:23 +00:00
|
|
|
inherit sha256;
|
2017-05-20 21:14:08 +00:00
|
|
|
};
|
2014-06-01 13:13:04 +00:00
|
|
|
|
2017-05-20 21:14:08 +00:00
|
|
|
inherit prePatch;
|
|
|
|
|
|
|
|
buildFlags = [ "all" "tools" ];
|
2010-03-16 23:34:56 +00:00
|
|
|
|
2017-05-20 21:14:08 +00:00
|
|
|
installPhase = ''
|
|
|
|
install -vd "$out/bin" "$out/lib/haxe/std"
|
|
|
|
cp -vr haxe haxelib std "$out/lib/haxe"
|
2012-10-07 09:24:51 +00:00
|
|
|
|
2017-05-20 21:14:08 +00: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 16:33:48 +00:00
|
|
|
|
2017-05-20 21:14:08 +00:00
|
|
|
if [[ "\$HAXELIB_PATH" =~ : ]]; then
|
|
|
|
NEW_HAXELIB_PATH="\$(${coreutils}/bin/mktemp -d)"
|
2012-10-07 09:24:51 +00:00
|
|
|
|
2017-05-20 21:14:08 +00: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 21:14:08 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
2012-10-07 09:24:51 +00:00
|
|
|
|
2017-05-20 21:14:08 +00:00
|
|
|
dontStrip = true;
|
|
|
|
|
2018-04-17 11:52:29 +00: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
|
|
|
|
'';
|
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2017-05-20 21:14:08 +00:00
|
|
|
description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://haxe.org";
|
2021-03-20 00:25:24 +00:00
|
|
|
license = with licenses; [ gpl2Plus mit ]; # based on upstream opam file
|
2021-03-19 14:25:23 +00:00
|
|
|
maintainers = [ maintainers.marcweber maintainers.locallycompact ];
|
2017-05-20 21:14:08 +00:00
|
|
|
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
|
2021-03-19 14:25:23 +00:00
|
|
|
substituteInPlace extra/haxelib_src/src/tools/haxelib/Main.hx \
|
|
|
|
--replace '"neko"' '"${neko}/bin/neko"'
|
2017-05-20 21:14:08 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
haxe_3_4 = generic {
|
2018-02-18 22:54:21 +00:00
|
|
|
version = "3.4.6";
|
|
|
|
sha256 = "1myc4b8fwp0f9vky17wv45n34a583f5sjvajsc93f5gm1wanp4if";
|
2017-05-20 21:14:08 +00:00
|
|
|
prePatch = ''
|
2021-03-19 14:25:23 +00:00
|
|
|
${defaultPatch}
|
2018-04-17 11:52:29 +00:00
|
|
|
sed -i -re 's!(let +prefix_path += +).*( +in)!\1"'"$out/"'"\2!' src/main.ml
|
2017-05-20 21:14:08 +00:00
|
|
|
'';
|
2012-10-07 09:24:51 +00:00
|
|
|
};
|
2021-03-30 22:13:25 +00:00
|
|
|
haxe_4_0 = generic {
|
|
|
|
version = "4.0.5";
|
|
|
|
sha256 = "0f534pchdx0m057ixnk07ab4s518ica958pvpd0vfjsrxg5yjkqa";
|
|
|
|
};
|
2021-03-30 21:59:25 +00:00
|
|
|
haxe_4_1 = generic {
|
|
|
|
version = "4.1.5";
|
|
|
|
sha256 = "0rns6d28qzkbai6yyws08yzbyvxfn848nj0fsji7chdi0y7pzzj0";
|
|
|
|
};
|
2021-03-19 14:25:23 +00:00
|
|
|
haxe_4_2 = generic {
|
|
|
|
version = "4.2.1";
|
|
|
|
sha256 = "sha256-0j6M21dh8DB1gC/bPYNJrVuDbJyqQbP+61ItO5RBUcA=";
|
|
|
|
};
|
2009-11-30 01:05:04 +00:00
|
|
|
}
|