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.
This commit is contained in:
parent
9456522528
commit
90835bc666
@ -1,34 +1,35 @@
|
|||||||
{ stdenv, makeStaticLibraries,
|
{ pkgs, gccStdenv, lib, coreutils, # makeStaticLibraries,
|
||||||
coreutils, rsync, bash,
|
|
||||||
openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
|
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 {
|
stdenv.mkDerivation rec {
|
||||||
pname = "gerbil";
|
pname = "gerbil";
|
||||||
inherit version;
|
inherit version;
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
# Use makeStaticLibraries to enable creation of statically linked binaries
|
|
||||||
buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
|
buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
|
||||||
buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
|
|
||||||
|
|
||||||
buildInputs = [ gambit rsync bash ]
|
# TODO: either fix all of Gerbil's dependencies to provide static libraries,
|
||||||
++ buildInputs_libraries ++ buildInputs_staticLibraries;
|
# 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";
|
NIX_CFLAGS_COMPILE = "-I${libmysqlclient}/include/mysql -L${libmysqlclient}/lib/mysql";
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm
|
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm ;
|
||||||
|
patchShebangs . ;
|
||||||
patchShebangs .
|
|
||||||
|
|
||||||
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
|
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
|
||||||
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
|
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
|
||||||
done
|
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\""
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
## TODO: make static compilation work.
|
## TODO: make static compilation work.
|
||||||
@ -47,22 +48,20 @@ stdenv.mkDerivation rec {
|
|||||||
# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
|
# LEVELDB=${makeStaticLibraries leveldb}/lib/libleveldb.a
|
||||||
# EOF
|
# EOF
|
||||||
|
|
||||||
|
inherit configurePhase installPhase;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
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
|
# 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
|
# Build, replacing make by build.sh
|
||||||
( cd src && sh build.sh )
|
( cd src && sh build.sh )
|
||||||
@ -70,33 +69,15 @@ stdenv.mkDerivation rec {
|
|||||||
runHook postBuild
|
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;
|
dontStrip = true;
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Gerbil Scheme";
|
description = "Gerbil Scheme";
|
||||||
homepage = "https://github.com/vyzo/gerbil";
|
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.
|
# NB regarding platforms: regularly tested on Linux, only occasionally on macOS.
|
||||||
# Please report success and/or failure to fare.
|
# Please report success and/or failure to fare.
|
||||||
platforms = stdenv.lib.platforms.unix;
|
platforms = lib.platforms.unix;
|
||||||
maintainers = with stdenv.lib.maintainers; [ fare ];
|
maintainers = with lib.maintainers; [ fare ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,50 @@
|
|||||||
{ stdenv, callPackage, fetchFromGitHub, gambit }:
|
{ callPackage, fetchFromGitHub, gambit, bash }:
|
||||||
|
|
||||||
callPackage ./build.nix rec {
|
callPackage ./build.nix rec {
|
||||||
version = "0.15.1";
|
version = "0.15.1";
|
||||||
git-version = "0.15.1";
|
git-version = "0.15.1";
|
||||||
inherit gambit;
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "vyzo";
|
owner = "vyzo";
|
||||||
repo = "gerbil";
|
repo = "gerbil";
|
||||||
rev = "v${version}";
|
rev = "v${version}";
|
||||||
sha256 = "0qpqms66hz41wwhxb1z0fnzj96ivkm7qi9h9d7lhlr3fsxm1kp1n";
|
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
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
63
pkgs/development/compilers/gerbil/gerbil-support.nix
Normal file
63
pkgs/development/compilers/gerbil/gerbil-support.nix
Normal file
@ -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;
|
||||||
|
};
|
||||||
|
}
|
@ -1,15 +1,34 @@
|
|||||||
{ stdenv, callPackage, fetchFromGitHub, gambit, gambit-unstable }:
|
{ callPackage, fetchFromGitHub, gambit-unstable, gambit-support, coreutils, bash }:
|
||||||
|
|
||||||
callPackage ./build.nix {
|
callPackage ./build.nix {
|
||||||
version = "unstable-2020-02-27";
|
version = "unstable-2020-02-27";
|
||||||
git-version = "0.16-DEV-493-g1ffb74db";
|
git-version = "0.16-DEV-493-g1ffb74db";
|
||||||
#gambit = gambit-unstable;
|
|
||||||
gambit = gambit;
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "vyzo";
|
owner = "vyzo";
|
||||||
repo = "gerbil";
|
repo = "gerbil";
|
||||||
rev = "1ffb74db5ffd49b4bad751586cef5e619c891d41";
|
rev = "1ffb74db5ffd49b4bad751586cef5e619c891d41";
|
||||||
sha256 = "1szmdp8lvy5gpcwn5bpa7x383m6vywl35xa7hz9a5vs1rq4w2097";
|
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
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
@ -8202,11 +8202,13 @@ in
|
|||||||
|
|
||||||
fpc = callPackage ../development/compilers/fpc { };
|
fpc = callPackage ../development/compilers/fpc { };
|
||||||
|
|
||||||
gambit = callPackage ../development/compilers/gambit { stdenv = gccStdenv; };
|
gambit = callPackage ../development/compilers/gambit { };
|
||||||
gambit-unstable = callPackage ../development/compilers/gambit/unstable.nix { };
|
gambit-unstable = callPackage ../development/compilers/gambit/unstable.nix { };
|
||||||
gambit-support = callPackage ../development/compilers/gambit/gambit-support.nix { };
|
gambit-support = callPackage ../development/compilers/gambit/gambit-support.nix { };
|
||||||
gerbil = callPackage ../development/compilers/gerbil { stdenv = gccStdenv; };
|
gerbil = callPackage ../development/compilers/gerbil { };
|
||||||
gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { stdenv = gccStdenv; };
|
gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { };
|
||||||
|
gerbil-support = callPackage ../development/compilers/gerbil/gerbil-support.nix { };
|
||||||
|
gerbilPackages-unstable = gerbil-support.gerbilPackages-unstable; # NB: don't recurseIntoAttrs for (unstable!) libraries
|
||||||
|
|
||||||
gccFun = callPackage (if stdenv.targetPlatform.isVc4 then ../development/compilers/gcc/6 else ../development/compilers/gcc/9);
|
gccFun = callPackage (if stdenv.targetPlatform.isVc4 then ../development/compilers/gcc/6 else ../development/compilers/gcc/9);
|
||||||
gcc = if stdenv.targetPlatform.isVc4 then gcc6 else gcc9;
|
gcc = if stdenv.targetPlatform.isVc4 then gcc6 else gcc9;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user