2018-02-17 20:05:35 +00:00
|
|
|
#!@bash@/bin/bash
|
2013-10-13 06:45:07 +00:00
|
|
|
# Part of NixPkgs package collection
|
2017-04-09 23:10:39 +00:00
|
|
|
# This script can be used at your option under the same license as NixPkgs or
|
2013-10-13 06:45:07 +00:00
|
|
|
# under MIT/X11 license
|
|
|
|
|
|
|
|
eval "$NIX_LISP_PREHOOK"
|
|
|
|
|
|
|
|
NIX_LISP_COMMAND="$1"
|
|
|
|
shift
|
|
|
|
|
2019-07-24 16:21:04 +00:00
|
|
|
if [ -z "$NIX_LISP" ]; then
|
|
|
|
while [ -h "${NIX_LISP_COMMAND}" ]; do
|
|
|
|
NIX_LISP_COMMAND="$(readlink -n "${NIX_LISP_COMMAND}")"
|
|
|
|
done
|
|
|
|
NIX_LISP="${NIX_LISP_COMMAND##*/}"
|
|
|
|
fi
|
2013-10-13 06:45:07 +00:00
|
|
|
|
|
|
|
export NIX_LISP NIX_LISP_LOAD_FILE NIX_LISP_EXEC_CODE NIX_LISP_COMMAND NIX_LISP_FINAL_PARAMETERS
|
|
|
|
|
2014-11-13 08:11:16 +00:00
|
|
|
test -n "$NIX_LISP_LD_LIBRARY_PATH" &&
|
2021-11-14 02:54:33 +00:00
|
|
|
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$NIX_LISP_LD_LIBRARY_PATH"
|
2014-11-13 08:11:16 +00:00
|
|
|
|
2017-03-30 11:00:43 +00:00
|
|
|
declare -a NIX_LISP_FINAL_PARAMETERS;
|
|
|
|
|
2013-10-13 06:45:07 +00:00
|
|
|
case "$NIX_LISP" in
|
2021-11-14 02:54:33 +00:00
|
|
|
sbcl)
|
|
|
|
NIX_LISP_LOAD_FILE="--load"
|
|
|
|
NIX_LISP_EXEC_CODE="--eval"
|
2016-03-25 16:57:45 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
2017-03-30 11:00:43 +00:00
|
|
|
NIX_LISP_NODEBUG='--non-interactive'
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS=
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="fasl"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
|
|
|
ecl)
|
|
|
|
NIX_LISP_LOAD_FILE="-load"
|
|
|
|
NIX_LISP_EXEC_CODE="-eval"
|
2016-03-25 16:57:45 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
2017-03-30 11:00:43 +00:00
|
|
|
NIX_LISP_NODEBUG='--nodebug'
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS=
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="fas"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
|
|
|
clisp)
|
|
|
|
NIX_LISP_LOAD_FILE="-c -l"
|
|
|
|
NIX_LISP_EXEC_CODE="-x"
|
2016-03-25 16:57:45 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
2017-03-30 11:00:43 +00:00
|
|
|
NIX_LISP_NODEBUG='-on-error exit'
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS="-repl"
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="fas"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
|
|
|
lx86cl64)
|
|
|
|
NIX_LISP_LOAD_FILE="-l"
|
|
|
|
NIX_LISP_EXEC_CODE="-e"
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
|
|
|
NIX_LISP_NODEBUG='-b'
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS=
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="lx64fsl"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
|
|
|
lx86cl)
|
|
|
|
NIX_LISP_LOAD_FILE="-l"
|
|
|
|
NIX_LISP_EXEC_CODE="-e"
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
|
|
|
NIX_LISP_NODEBUG='-b'
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS=
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="lx32fsl"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
|
|
|
abcl)
|
|
|
|
NIX_LISP_LOAD_FILE="--load"
|
|
|
|
NIX_LISP_EXEC_CODE="--eval"
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_QUIT="(quit)"
|
|
|
|
NIX_LISP_NODEBUG=''
|
2021-11-14 02:54:33 +00:00
|
|
|
NIX_LISP_FINAL_PARAMETERS=
|
2017-04-09 23:10:39 +00:00
|
|
|
NIX_LISP_FASL_TYPE="abcl"
|
2021-11-14 02:54:33 +00:00
|
|
|
;;
|
2013-10-13 06:45:07 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
NIX_LISP_ASDF_REGISTRY_CODE="
|
|
|
|
(progn
|
2017-11-22 06:55:06 +00:00
|
|
|
(setf asdf:*source-registry-parameter*
|
|
|
|
'(:source-registry
|
|
|
|
$(for p in $NIX_LISP_ASDF_PATHS; do
|
|
|
|
echo "(:tree \"$p\")"
|
|
|
|
done)
|
|
|
|
:inherit-configuration))
|
2013-10-13 06:45:07 +00:00
|
|
|
(asdf:initialize-source-registry)
|
|
|
|
)
|
|
|
|
"
|
|
|
|
|
2017-04-06 16:43:42 +00:00
|
|
|
NIX_LISP_ASDF="${NIX_LISP_ASDF:-@out@}"
|
2015-04-14 08:51:19 +00:00
|
|
|
|
2017-03-30 11:00:43 +00:00
|
|
|
nix_lisp_run_single_form(){
|
|
|
|
NIX_LISP_FINAL_PARAMETERS=("$NIX_LISP_EXEC_CODE" "$1"
|
|
|
|
"$NIX_LISP_EXEC_CODE" "$NIX_LISP_QUIT" $NIX_LISP_NODEBUG)
|
|
|
|
}
|
|
|
|
|
2018-01-29 14:15:00 +00:00
|
|
|
nix_lisp_build_system(){
|
|
|
|
NIX_LISP_FINAL_PARAMETERS=(
|
|
|
|
"$NIX_LISP_EXEC_CODE" "(progn
|
2020-10-24 23:30:44 +00:00
|
|
|
(asdf:load-system :$1)
|
|
|
|
(loop for s in (list $(for i in $3; do echo ":$i"; done)) do (asdf:load-system s)))"
|
2018-01-29 14:15:00 +00:00
|
|
|
"$NIX_LISP_EXEC_CODE" "(progn
|
|
|
|
(setf (asdf/system:component-entry-point (asdf:find-system :$1)) ${2:-nil})
|
|
|
|
#+cffi(setf cffi:*foreign-library-directories*
|
|
|
|
(cffi::explode-path-environment-variable \"NIX_LISP_LD_LIBRARY_PATH\"))
|
|
|
|
#+sbcl(loop
|
|
|
|
with libpath := (uiop:split-string (uiop:getenv \"NIX_LISP_LD_LIBRARY_PATH\")
|
|
|
|
:separator \":\")
|
|
|
|
for l in sb-alien::*shared-objects*
|
|
|
|
for ns := (sb-alien::shared-object-namestring l)
|
2020-10-24 23:30:44 +00:00
|
|
|
do (format *error-output* \"Searching alien object ~s in ~s~%\"
|
|
|
|
ns libpath)
|
2018-02-01 20:32:21 +00:00
|
|
|
do (and (> (length ns) 0) (not (equal (elt ns 0) \"/\"))
|
2018-01-29 14:15:00 +00:00
|
|
|
(let*
|
|
|
|
((prefix (find-if (lambda (s) (probe-file (format nil \"~a/~a\" s ns))) libpath))
|
|
|
|
(fullpath (and prefix (format nil \"~a/~a\" prefix ns))))
|
|
|
|
(when fullpath
|
2020-10-24 23:30:44 +00:00
|
|
|
(format *error-output* \"Found: ~s~%\" fullpath)
|
2018-01-29 14:15:00 +00:00
|
|
|
(setf
|
|
|
|
(sb-alien::shared-object-namestring l) fullpath
|
|
|
|
(sb-alien::shared-object-pathname l) (probe-file fullpath)))))
|
|
|
|
)
|
2020-10-24 23:30:44 +00:00
|
|
|
$4
|
2018-01-29 14:15:00 +00:00
|
|
|
(asdf:perform (quote asdf:program-op) :$1)
|
|
|
|
)")
|
|
|
|
}
|
|
|
|
|
2017-03-30 11:00:43 +00:00
|
|
|
eval "$NIX_LISP_PRELAUNCH_HOOK"
|
|
|
|
|
2019-07-24 16:30:24 +00:00
|
|
|
if [ -z "$NIX_LISP_SKIP_CODE" ]; then
|
|
|
|
"$NIX_LISP_COMMAND" $NIX_LISP_EARLY_OPTIONS \
|
2021-11-14 02:54:33 +00:00
|
|
|
$NIX_LISP_EXEC_CODE "${NIX_LISP_ASDF_LOAD:-"(load \"$NIX_LISP_ASDF/lib/common-lisp/asdf/build/asdf.$NIX_LISP_FASL_TYPE\")"}" \
|
|
|
|
$NIX_LISP_EXEC_CODE "$NIX_LISP_ASDF_REGISTRY_CODE" \
|
|
|
|
${NIX_LISP_FINAL_PARAMETERS[*]:+"${NIX_LISP_FINAL_PARAMETERS[@]}"} \
|
|
|
|
"$@"
|
2019-07-24 16:30:24 +00:00
|
|
|
fi
|