haxe: Add package for the hxcpp runtime library.

I'm not adding this to pkgs/development/libraries because it somewhat is
strongly tied to Haxe itself, because otherwise you can't compile to C++
and in the event that someone is going to create something like
"haxePackages" someday it is easier to notice when it's residing in the
Haxe folder.

In theory it would also work by using imperative haxelib, but you'll get
precompiled libraries which need to be patched on NixOS systems. That's
the main reason I was packaging this, among from the fact that even when
patching the libraries, it still leads to occasional library hell and
instabilities.

The package has two outputs: One with the library itself, needed for
compile time ($out) and another one ($lib) which is needed at runtime,
so after compiling, the $out path can be safely garbage collected.

Right now, I've set meta.platforms to Linux only, because that's where
I've tested it. In order to get it running on other platforms the
targetArch attribute has to be set accordingly.

We also build everything completely from scratch, even though there are
binaries within the source ZIP file. The main reason is to make smaller
library dependencies by avoiding bundled libraries and using the ones we
already ship with nixpkgs.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2015-03-20 08:47:11 +01:00
parent d68e9b855c
commit 3bb0e6df8a
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,52 @@
{ 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

@ -3650,6 +3650,7 @@ let
};
haxe = callPackage ../development/compilers/haxe { };
hxcpp = callPackage ../development/compilers/haxe/hxcpp.nix { };
hhvm = callPackage ../development/compilers/hhvm { };
hiphopvm = hhvm; /* Compatibility alias */