haxe: fix hxcpp, introduce haxePackage with hxjava and hxcs
This commit is contained in:
parent
dc7cc77111
commit
37ef9e3b60
@ -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
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
addHaxeLibPath() {
|
||||
if [ ! -d "$1/lib/haxe/std" ]; then
|
||||
addToSearchPath HAXELIB_PATH "$1/lib/haxe"
|
||||
fi
|
||||
}
|
||||
|
||||
envHooks+=(addHaxeLibPath)
|
||||
|
@ -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 =
|
||||
|
@ -5473,9 +5473,10 @@ with pkgs;
|
||||
psc-package = haskell.lib.justStaticExecutables
|
||||
(haskellPackages.callPackage ../development/compilers/purescript/psc-package { });
|
||||
|
||||
inherit (ocamlPackages) haxe;
|
||||
|
||||
hxcpp = callPackage ../development/compilers/haxe/hxcpp.nix { };
|
||||
inherit (ocamlPackages.haxe) haxe_3_2 haxe_3_4;
|
||||
haxe = haxe_3_4;
|
||||
haxePackages = recurseIntoAttrs (callPackage ./haxe-packages.nix { });
|
||||
inherit (haxePackages) hxcpp;
|
||||
|
||||
hhvm = callPackage ../development/compilers/hhvm {
|
||||
boost = boost160;
|
||||
|
120
pkgs/top-level/haxe-packages.nix
Normal file
120
pkgs/top-level/haxe-packages.nix
Normal file
@ -0,0 +1,120 @@
|
||||
{ stdenv, fetchzip, fetchFromGitHub, newScope, haxe, neko, nodejs, wine, php, python3, jdk, mono, haskellPackages, fetchpatch }:
|
||||
|
||||
let
|
||||
self = haxePackages;
|
||||
callPackage = newScope self;
|
||||
haxePackages = with self; {
|
||||
|
||||
withCommas = stdenv.lib.replaceChars ["."] [","];
|
||||
|
||||
# simulate "haxelib dev $libname ."
|
||||
simulateHaxelibDev = libname: ''
|
||||
devrepo=$(mktemp -d)
|
||||
mkdir -p "$devrepo/${withCommas libname}"
|
||||
echo $(pwd) > "$devrepo/${withCommas libname}/.dev"
|
||||
export HAXELIB_PATH="$HAXELIB_PATH:$devrepo"
|
||||
'';
|
||||
|
||||
installLibHaxe = { libname, version, files ? "*" }: ''
|
||||
mkdir -p "$out/lib/haxe/${withCommas libname}/${withCommas version}"
|
||||
echo -n "${version}" > $out/lib/haxe/${withCommas libname}/.current
|
||||
cp -dpR ${files} "$out/lib/haxe/${withCommas libname}/${withCommas version}/"
|
||||
'';
|
||||
|
||||
buildHaxeLib = {
|
||||
libname,
|
||||
version,
|
||||
sha256,
|
||||
meta,
|
||||
...
|
||||
} @ attrs:
|
||||
stdenv.mkDerivation (attrs // {
|
||||
name = "${libname}-${version}";
|
||||
|
||||
buildInputs = (attrs.buildInputs or []) ++ [ haxe neko ]; # for setup-hook.sh to work
|
||||
src = fetchzip rec {
|
||||
name = "${libname}-${version}";
|
||||
url = "http://lib.haxe.org/files/3.0/${withCommas name}.zip";
|
||||
inherit sha256;
|
||||
stripRoot = false;
|
||||
};
|
||||
|
||||
installPhase = attrs.installPhase or ''
|
||||
runHook preInstall
|
||||
(
|
||||
if [ $(ls $src | wc -l) == 1 ]; then
|
||||
cd $src/* || cd $src
|
||||
else
|
||||
cd $src
|
||||
fi
|
||||
${installLibHaxe { inherit libname version; }}
|
||||
)
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
homepage = "http://lib.haxe.org/p/${libname}";
|
||||
license = stdenv.lib.licenses.bsd2;
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
description = throw "please write meta.description";
|
||||
} // attrs.meta;
|
||||
});
|
||||
|
||||
hxcpp = buildHaxeLib rec {
|
||||
libname = "hxcpp";
|
||||
version = "3.4.64";
|
||||
sha256 = "04gyjm6wqmsm0ifcfkxmq1yv8xrfzys3z5ajqnvvjrnks807mw8q";
|
||||
postFixup = ''
|
||||
for f in $out/lib/haxe/${withCommas libname}/${withCommas version}/{,project/libs/nekoapi/}bin/Linux{,64}/*; do
|
||||
chmod +w "$f"
|
||||
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) "$f" || true
|
||||
patchelf --set-rpath ${ stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] } "$f" || true
|
||||
done
|
||||
'';
|
||||
meta.description = "Runtime support library for the Haxe C++ backend";
|
||||
};
|
||||
|
||||
hxjava = buildHaxeLib {
|
||||
libname = "hxjava";
|
||||
version = "3.2.0";
|
||||
sha256 = "1vgd7qvsdxlscl3wmrrfi5ipldmr4xlsiwnj46jz7n6izff5261z";
|
||||
meta.description = "Support library for the Java backend of the Haxe compiler";
|
||||
propagatedBuildInputs = [ jdk ];
|
||||
};
|
||||
|
||||
hxcs = buildHaxeLib {
|
||||
libname = "hxcs";
|
||||
version = "3.4.0";
|
||||
sha256 = "0f5vgp2kqnpsbbkn2wdxmjf7xkl0qhk9lgl9kb8d5wdy89nac6q6";
|
||||
meta.description = "Support library for the C# backend of the Haxe compiler";
|
||||
propagatedBuildInputs = [ mono ];
|
||||
};
|
||||
|
||||
hxnodejs_4 = buildHaxeLib {
|
||||
libname = "hxnodejs";
|
||||
version = "4.0.9";
|
||||
sha256 = "0b7ck48nsxs88sy4fhhr0x1bc8h2ja732zzgdaqzxnh3nir0bajm";
|
||||
meta.description = "Extern definitions for node.js 4.x";
|
||||
};
|
||||
|
||||
hxnodejs_6 = let
|
||||
libname = "hxnodejs";
|
||||
version = "6.9.0";
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "${libname}-${version}";
|
||||
src = fetchFromGitHub {
|
||||
owner = "HaxeFoundation";
|
||||
repo = "hxnodejs";
|
||||
rev = "cf80c6a";
|
||||
sha256 = "0mdiacr5b2m8jrlgyd2d3vp1fha69lcfb67x4ix7l7zfi8g460gs";
|
||||
};
|
||||
installPhase = installLibHaxe { inherit libname version; };
|
||||
meta = {
|
||||
homepage = "http://lib.haxe.org/p/${libname}";
|
||||
license = stdenv.lib.licenses.bsd2;
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
description = "Extern definitions for node.js 6.9";
|
||||
};
|
||||
};
|
||||
};
|
||||
in self
|
Loading…
Reference in New Issue
Block a user