mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-20 00:53:12 +03:00
3bb0e6df8a
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>
53 lines
1.6 KiB
Nix
53 lines
1.6 KiB
Nix
{ 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;
|
|
};
|
|
}
|