Merge pull request #208389 from sternenseemann/cbqn-lib

cbqn: install headers and shared library
This commit is contained in:
Anderson Torres 2022-12-30 17:02:27 -03:00 committed by GitHub
commit 52f11dd920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,8 @@
, bqn-path ? null
, mbqn-source ? null
, enableReplxx ? false
# No support for macOS' .dylib on the CBQN side
, enableLibcbqn ? stdenv.hostPlatform.isLinux
, libffi
, pkg-config
}:
@ -43,7 +45,6 @@ stdenv.mkDerivation rec {
pkg-config
];
# TODO(@sternenseemann): allow building against dzaima's replxx fork
buildInputs = [
libffi
];
@ -59,6 +60,14 @@ stdenv.mkDerivation rec {
]
++ lib.optional enableReplxx "REPLXX=1";
buildFlags = [
# interpreter binary
"o3"
] ++ lib.optionals enableLibcbqn [
# embeddable interpreter as a shared lib
"shared-o3"
];
preBuild = ''
# Purity: avoids git downloading bytecode files
mkdir -p build/bytecodeLocal/gen
@ -69,13 +78,14 @@ stdenv.mkDerivation rec {
'')
+ lib.optionalString enableReplxx ''
cp -r ${replxx-submodule} build/replxxLocal/
''
# Need to adjust ld flags for darwin manually
# https://github.com/dzaima/CBQN/issues/26
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
makeFlagsArray+=(LD_LIBS="-ldl -lffi")
'';
outputs = [
"out"
"lib"
"dev"
];
installPhase = ''
runHook preInstall
@ -84,7 +94,12 @@ stdenv.mkDerivation rec {
# note guard condition for case-insensitive filesystems
[ -e $out/bin/bqn ] || ln -s $out/bin/BQN $out/bin/bqn
[ -e $out/bin/cbqn ] || ln -s $out/bin/BQN $out/bin/cbqn
''
+ lib.optionalString enableLibcbqn ''
install -Dm644 include/bqnffi.h -t "$dev/include"
install -Dm755 libcbqn${stdenv.hostPlatform.extensions.sharedLibrary} -t "$lib/lib"
''
+ ''
runHook postInstall
'';