diff options
author | Francois-Rene Rideau <fare@tunes.org> | 2020-03-21 00:53:33 -0400 |
---|---|---|
committer | Francois-Rene Rideau <fare@tunes.org> | 2020-05-17 15:48:13 -0400 |
commit | 90835bc666881cfc9d4f632379f58684dea4a590 (patch) | |
tree | 308ae587df6c3afce7d28cae2ac5cf818e290308 /pkgs/development/compilers/gerbil | |
parent | 9456522528a118d9eeb078a77064a4f85ae9b887 (diff) | |
download | nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar.gz nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar.bz2 nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar.lz nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar.xz nixlib-90835bc666881cfc9d4f632379f58684dea4a590.tar.zst nixlib-90835bc666881cfc9d4f632379f58684dea4a590.zip |
Refactor Gerbil support
- Use the new Gambit support. - Move files from $out to $out/gerbil. - Use new Gerbil configuration and installation scripts. - Move some fixups from preBuild to postPatch. - Give up on previous failed attempts at using static libraries. - Add support for compiling libraries written in Gerbil. - Build using NIX_BUILD_CORES. - Register all those things in all-packages.
Diffstat (limited to 'pkgs/development/compilers/gerbil')
-rw-r--r-- | pkgs/development/compilers/gerbil/build.nix | 81 | ||||
-rw-r--r-- | pkgs/development/compilers/gerbil/default.nix | 42 | ||||
-rw-r--r-- | pkgs/development/compilers/gerbil/gerbil-support.nix | 63 | ||||
-rw-r--r-- | pkgs/development/compilers/gerbil/unstable.nix | 27 |
4 files changed, 156 insertions, 57 deletions
diff --git a/pkgs/development/compilers/gerbil/build.nix b/pkgs/development/compilers/gerbil/build.nix index 21c2936fa0f8..0177e706af11 100644 --- a/pkgs/development/compilers/gerbil/build.nix +++ b/pkgs/development/compilers/gerbil/build.nix @@ -1,34 +1,35 @@ -{ stdenv, makeStaticLibraries, - coreutils, rsync, bash, +{ pkgs, gccStdenv, lib, coreutils, # makeStaticLibraries, openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql, - version, git-version, gambit, src }: + version, git-version, + gambit-support, + gambit ? pkgs.gambit, gambit-params ? pkgs.gambit-support.stable-params, + src, configurePhase, installPhase }: + +# We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix +let stdenv = gccStdenv; in stdenv.mkDerivation rec { pname = "gerbil"; inherit version; inherit src; - # Use makeStaticLibraries to enable creation of statically linked binaries buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ]; - buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries; - buildInputs = [ gambit rsync bash ] - ++ buildInputs_libraries ++ buildInputs_staticLibraries; + # TODO: either fix all of Gerbil's dependencies to provide static libraries, + # or give up and delete all tentative support for static libraries. + #buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries; + + buildInputs = [ gambit ] + ++ buildInputs_libraries; # ++ buildInputs_staticLibraries; NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql"; postPatch = '' - echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm - - patchShebangs . - + echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ; + patchShebangs . ; grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do - substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' - done - grep -Fl '"gsc"' `find . -type f -name '*.s*'` | while read f ; do - substituteInPlace "$f" --replace '"gsc"' '"${gambit}/bin/gsc"' - done - substituteInPlace "etc/gerbil.el" --replace '"gxc"' "\"$out/bin/gxc\"" + substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ; + done ; ''; ## TODO: make static compilation work. @@ -47,22 +48,20 @@ stdenv.mkDerivation rec { # LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a # EOF + inherit configurePhase installPhase; + buildPhase = '' runHook preBuild - # Enable all optional libraries - substituteInPlace "src/std/build-features.ss" --replace '#f' '#t' - - # Enable autodetection of a default GERBIL_HOME - for i in src/gerbil/boot/gx-init-exe.scm src/gerbil/boot/gx-init.scm ; do - substituteInPlace "$i" --replace '(getenv "GERBIL_HOME" #f)' "(getenv \"GERBIL_HOME\" \"$out\")" - done - for i in src/gerbil/boot/gxi-init.scm src/gerbil/compiler/driver.ss src/gerbil/runtime/gx-gambc.scm src/std/build.ss src/tools/build.ss ; do - substituteInPlace "$i" --replace '(getenv "GERBIL_HOME")' "(getenv \"GERBIL_HOME\" \"$out\")" - done - # gxprof testing uses $HOME/.cache/gerbil/gxc - export HOME=$$PWD + export HOME=$PWD + export GERBIL_BUILD_CORES=$NIX_BUILD_CORES + export GERBIL_GXC=$PWD/bin/gxc + export GERBIL_BASE=$PWD + export GERBIL_HOME=$PWD + export GERBIL_PATH=$PWD/lib + export PATH=$PWD/bin:$PATH + ${gambit-support.export-gambopt gambit-params} # Build, replacing make by build.sh ( cd src && sh build.sh ) @@ -70,33 +69,15 @@ stdenv.mkDerivation rec { runHook postBuild ''; - installPhase = '' - runHook preInstall - mkdir -p $out/ - cp -fa bin lib etc doc $out/ - - cat > $out/bin/gxi <<EOF -#!${bash}/bin/bash -e -export GERBIL_HOME=$out -case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac -if [[ \$# = 0 ]] ; then - exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - -else - exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@" -fi -EOF - runHook postInstall - ''; - dontStrip = true; meta = { description = "Gerbil Scheme"; homepage = "https://github.com/vyzo/gerbil"; - license = stdenv.lib.licenses.lgpl2; + license = lib.licenses.lgpl21; # also asl20, like Gambit # NB regarding platforms: regularly tested on Linux, only occasionally on macOS. # Please report success and/or failure to fare. - platforms = stdenv.lib.platforms.unix; - maintainers = with stdenv.lib.maintainers; [ fare ]; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ fare ]; }; } diff --git a/pkgs/development/compilers/gerbil/default.nix b/pkgs/development/compilers/gerbil/default.nix index 8c6b1a87cd37..d7b1fe3cf5e2 100644 --- a/pkgs/development/compilers/gerbil/default.nix +++ b/pkgs/development/compilers/gerbil/default.nix @@ -1,14 +1,50 @@ -{ stdenv, callPackage, fetchFromGitHub, gambit }: +{ callPackage, fetchFromGitHub, gambit, bash }: callPackage ./build.nix rec { version = "0.15.1"; git-version = "0.15.1"; - inherit gambit; src = fetchFromGitHub { owner = "vyzo"; repo = "gerbil"; rev = "v${version}"; sha256 = "0qpqms66hz41wwhxb1z0fnzj96ivkm7qi9h9d7lhlr3fsxm1kp1n"; }; - inherit stdenv; + configurePhase = '' + grep -Fl '"gsc"' `find . -type f -name '*.s*'` | while read f ; do + substituteInPlace "$f" --replace '"gsc"' '"${gambit}/bin/gsc"' ; + done ; + for f in etc/gerbil.el src/std/make.ss ; do + substituteInPlace "$f" --replace '"gxc"' "\"$out/bin/gxc\"" ; + done ; + + # Enable all optional libraries + substituteInPlace "src/std/build-features.ss" --replace '#f' '#t' ; + + # Enable autodetection of a default GERBIL_HOME + for i in src/gerbil/boot/gx-init-exe.scm src/gerbil/boot/gx-init.scm ; do + substituteInPlace "$i" --replace '(define default-gerbil-home #f)' "(define default-gerbil-home \"$out/gerbil\")" ; + substituteInPlace "$i" --replace '(getenv "GERBIL_HOME" #f)' "(getenv \"GERBIL_HOME\" \"$out/gerbil\")" ; + done ; + for i in src/gerbil/boot/gxi-init.scm src/gerbil/compiler/driver.ss src/gerbil/runtime/gx-gambc.scm src/std/build.ss src/tools/build.ss ; do + substituteInPlace "$i" --replace '(getenv "GERBIL_HOME")' "(getenv \"GERBIL_HOME\" \"$out/gerbil\")" ; + done + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/gerbil $out/bin + cp -fa bin lib etc doc $out/gerbil + cat > $out/gerbil/bin/gxi <<EOF +#!${bash}/bin/bash -e +GERBIL_GSI=${gambit}/bin/gsi +export GERBIL_HOME=$out/gerbil +case "\$1" in -:*) GSIOPTIONS="\$1" ; shift ;; esac +if [[ \$# = 0 ]] ; then + exec "\$GERBIL_GSI" \$GSIOPTIONS "\$GERBIL_HOME/lib/gxi-init" "\$GERBIL_HOME/lib/gxi-interactive" - +else + exec "\$GERBIL_GSI" \$GSIOPTIONS "\$GERBIL_HOME/lib/gxi-init" "\$@" +fi +EOF + (cd $out/bin ; ln -s ../gerbil/bin/* .) + runHook postInstall + ''; } diff --git a/pkgs/development/compilers/gerbil/gerbil-support.nix b/pkgs/development/compilers/gerbil/gerbil-support.nix new file mode 100644 index 000000000000..af83cfa4a600 --- /dev/null +++ b/pkgs/development/compilers/gerbil/gerbil-support.nix @@ -0,0 +1,63 @@ +{ pkgs, gccStdenv, callPackage, fetchFromGitHub }: +# See ../gambit/build.nix regarding gccStdenv + +rec { + # Gerbil libraries + gerbilPackages-unstable = { + }; + + # Use this function in any package that uses Gerbil libraries, to define the GERBIL_LOADPATH. + gerbilLoadPath = + gerbilInputs : builtins.concatStringsSep ":" (map (x : x + "/gerbil/lib") gerbilInputs); + + # Use this function to create a Gerbil library. See gerbil-utils as an example. + gerbilPackage = { + pname, version, src, meta, package, + git-version ? "", version-path ? "config/version.ss", + gerbil ? pkgs.gerbil-unstable, + gambit-params ? pkgs.gambit-support.stable-params, + gerbilInputs ? [], + buildInputs ? [], + softwareName ? "" } : + let buildInputs_ = buildInputs; in + gccStdenv.mkDerivation rec { + inherit src meta pname version; + buildInputs = [ gerbil ] ++ gerbilInputs ++ buildInputs_; + postPatch = '' + set -e ; + if [ -n "${version-path}" ] ; then + echo '(import :clan/utils/version)\n(register-software "${softwareName}" "${git-version}")\n' > "${version-path}" + fi + patchShebangs . ; + ''; + + postConfigure = '' + export GERBIL_BUILD_CORES=$NIX_BUILD_CORES + export GERBIL_PATH=$PWD/.build + export GERBIL_LOADPATH=${gerbilLoadPath gerbilInputs} + ${pkgs.gambit-support.export-gambopt gambit-params} + ''; + + buildPhase = '' + runHook preBuild + ./build.ss + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/gerbil/lib + cp -fa .build/lib $out/gerbil/ + bins=(.build/bin/*) + if [ 0 -lt ''${#bins} ] ; then + cp -fa .build/bin $out/gerbil/ + mkdir $out/bin + cd $out/bin + ln -s ../gerbil/bin/* . + fi + runHook postInstall + ''; + + dontFixup = true; + }; +} diff --git a/pkgs/development/compilers/gerbil/unstable.nix b/pkgs/development/compilers/gerbil/unstable.nix index eb78eed35ee9..d14b4f7d349b 100644 --- a/pkgs/development/compilers/gerbil/unstable.nix +++ b/pkgs/development/compilers/gerbil/unstable.nix @@ -1,15 +1,34 @@ -{ stdenv, callPackage, fetchFromGitHub, gambit, gambit-unstable }: +{ callPackage, fetchFromGitHub, gambit-unstable, gambit-support, coreutils, bash }: callPackage ./build.nix { version = "unstable-2020-02-27"; git-version = "0.16-DEV-493-g1ffb74db"; - #gambit = gambit-unstable; - gambit = gambit; src = fetchFromGitHub { owner = "vyzo"; repo = "gerbil"; rev = "1ffb74db5ffd49b4bad751586cef5e619c891d41"; sha256 = "1szmdp8lvy5gpcwn5bpa7x383m6vywl35xa7hz9a5vs1rq4w2097"; }; - inherit stdenv; + inherit gambit-support; + gambit = gambit-unstable; + gambit-params = gambit-support.unstable-params; + configurePhase = '' + (cd src && ./configure \ + --prefix=$out/gerbil \ + --with-gambit=${gambit}/gambit \ + --enable-libxml \ + --enable-libyaml \ + --enable-zlib \ + --enable-sqlite \ + --enable-mysql \ + --enable-lmdb \ + --enable-leveldb) + ''; + installPhase = '' + runHook preInstall + mkdir -p $out/gerbil $out/bin + (cd src; ./install) + (cd $out/bin ; ln -s ../gerbil/bin/* .) + runHook postInstall + ''; } |