1{ stdenv, fetchzip, haxe, neko, pcre, sqlite, zlib }:
2
3stdenv.mkDerivation rec {
4 name = "hxcpp-3.2.27";
5
6 src = let
7 zipFile = stdenv.lib.replaceChars ["."] [","] name;
8 in fetchzip {
9 inherit name;
10 url = "http://lib.haxe.org/files/3.0/${zipFile}.zip";
11 sha256 = "1hw4kr1f8q7f4fkzis7kvkm7h1cxhv6cf5v1iq7rvxs2fxiys7fr";
12 };
13
14 NIX_LDFLAGS = "-lpcre -lz -lsqlite3";
15
16 outputs = [ "out" "lib" ];
17
18 patchPhase = ''
19 rm -rf bin lib project/thirdparty project/libs/sqlite/sqlite3.[ch]
20 find . -name '*.n' -delete
21 sed -i -re '/(PCRE|ZLIB)_DIR|\<sqlite3\.c\>/d' project/Build.xml
22 sed -i -e 's/mFromFile = "@";/mFromFile = "";/' tools/hxcpp/Linker.hx
23 sed -i -e '/dll_ext/s,HX_CSTRING("./"),HX_CSTRING("'"$lib"'/"),' \
24 src/hx/Lib.cpp
25 '';
26
27 buildInputs = [ haxe neko pcre sqlite zlib ];
28
29 targetArch = "linux-m${if stdenv.is64bit then "64" else "32"}";
30
31 buildPhase = ''
32 haxe -neko project/build.n -cp tools/build -main Build
33 haxe -neko run.n -cp tools/run -main RunMain
34 haxe -neko hxcpp.n -cp tools/hxcpp -main BuildTool
35 (cd project && neko build.n "ndll-$targetArch")
36 '';
37
38 installPhase = ''
39 for i in bin/Linux*/*.dso; do
40 install -vD "$i" "$lib/$(basename "$i")"
41 done
42 find *.n toolchain/*.xml build-tool/BuildCommon.xml src include \
43 -type f -exec install -vD -m 0644 {} "$out/lib/haxe/hxcpp/{}" \;
44 '';
45
46 meta = {
47 homepage = "http://lib.haxe.org/p/hxcpp";
48 description = "Runtime support library for the Haxe C++ backend";
49 license = stdenv.lib.licenses.bsd2;
50 platforms = stdenv.lib.platforms.linux;
51 };
52}