From 37ef9e3b606defb7b7c9f2bfd661ab160caf2198 Mon Sep 17 00:00:00 2001 From: Volth Date: Sat, 20 May 2017 21:14:08 +0000 Subject: haxe: fix hxcpp, introduce haxePackage with hxjava and hxcs --- pkgs/development/compilers/haxe/default.nix | 98 +++++++++++++++------ pkgs/development/compilers/haxe/hxcpp.nix | 52 ----------- pkgs/development/compilers/haxe/setup-hook.sh | 2 + pkgs/development/compilers/neko/default.nix | 6 ++ pkgs/top-level/all-packages.nix | 7 +- pkgs/top-level/haxe-packages.nix | 120 ++++++++++++++++++++++++++ 6 files changed, 202 insertions(+), 83 deletions(-) delete mode 100644 pkgs/development/compilers/haxe/hxcpp.nix create mode 100644 pkgs/top-level/haxe-packages.nix (limited to 'pkgs') diff --git a/pkgs/development/compilers/haxe/default.nix b/pkgs/development/compilers/haxe/default.nix index 684c6d25daad..ca41545eb451 100644 --- a/pkgs/development/compilers/haxe/default.nix +++ b/pkgs/development/compilers/haxe/default.nix @@ -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" ]; - prePatch = '' - sed -i -e 's|"/usr/lib/haxe/std/";|"'"$out/lib/haxe/std/"'";\n&|g' src/main.ml - ''; + installPhase = '' + install -vd "$out/bin" "$out/lib/haxe/std" + cp -vr haxe haxelib std "$out/lib/haxe" - buildFlags = [ "all" "tools" ]; + # 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 < docs/license.txt - maintainers = [ maintainers.marcweber ]; - platforms = platforms.linux ++ platforms.darwin; + 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 + ''; + }; + 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 + ''; }; } diff --git a/pkgs/development/compilers/haxe/hxcpp.nix b/pkgs/development/compilers/haxe/hxcpp.nix deleted file mode 100644 index 56b43fc128ef..000000000000 --- a/pkgs/development/compilers/haxe/hxcpp.nix +++ /dev/null @@ -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|\/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; - }; -} diff --git a/pkgs/development/compilers/haxe/setup-hook.sh b/pkgs/development/compilers/haxe/setup-hook.sh index a29e04a989b6..21cc0206859f 100644 --- a/pkgs/development/compilers/haxe/setup-hook.sh +++ b/pkgs/development/compilers/haxe/setup-hook.sh @@ -1,5 +1,7 @@ addHaxeLibPath() { + if [ ! -d "$1/lib/haxe/std" ]; then addToSearchPath HAXELIB_PATH "$1/lib/haxe" + fi } envHooks+=(addHaxeLibPath) diff --git a/pkgs/development/compilers/neko/default.nix b/pkgs/development/compilers/neko/default.nix index 493748d369b7..e90f3af704df 100644 --- a/pkgs/development/compilers/neko/default.nix +++ b/pkgs/development/compilers/neko/default.nix @@ -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 = diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b9a55eb84cf5..79ce43bddaed 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; diff --git a/pkgs/top-level/haxe-packages.nix b/pkgs/top-level/haxe-packages.nix new file mode 100644 index 000000000000..5a85dc3433ba --- /dev/null +++ b/pkgs/top-level/haxe-packages.nix @@ -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 -- cgit v1.2.3