Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / lisp-modules-obsolete / clwrapper / cl-wrapper.sh
blobd6fec46b449ea44593a50874e75309b64d4e2b78
1 #!@bash@/bin/bash
2 # Part of NixPkgs package collection
3 # This script can be used at your option under the same license as NixPkgs or
4 # under MIT/X11 license
6 eval "$NIX_LISP_PREHOOK"
8 NIX_LISP_COMMAND="$1"
9 shift
11 if [ -z "$NIX_LISP" ]; then
12 while [ -h "${NIX_LISP_COMMAND}" ]; do
13 NIX_LISP_COMMAND="$(readlink -n "${NIX_LISP_COMMAND}")"
14 done
15 NIX_LISP="${NIX_LISP_COMMAND##*/}"
18 export NIX_LISP NIX_LISP_LOAD_FILE NIX_LISP_EXEC_CODE NIX_LISP_COMMAND NIX_LISP_FINAL_PARAMETERS
20 test -n "$NIX_LISP_LD_LIBRARY_PATH" &&
21 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$NIX_LISP_LD_LIBRARY_PATH"
23 declare -a NIX_LISP_FINAL_PARAMETERS;
25 case "$NIX_LISP" in
26 sbcl)
27 NIX_LISP_LOAD_FILE="--load"
28 NIX_LISP_EXEC_CODE="--eval"
29 NIX_LISP_QUIT="(quit)"
30 NIX_LISP_NODEBUG='--non-interactive'
31 NIX_LISP_FINAL_PARAMETERS=
32 NIX_LISP_FASL_TYPE="fasl"
34 ecl)
35 NIX_LISP_LOAD_FILE="-load"
36 NIX_LISP_EXEC_CODE="-eval"
37 NIX_LISP_QUIT="(quit)"
38 NIX_LISP_NODEBUG='--nodebug'
39 NIX_LISP_FINAL_PARAMETERS=
40 NIX_LISP_FASL_TYPE="fas"
42 clisp)
43 NIX_LISP_LOAD_FILE="-c -l"
44 NIX_LISP_EXEC_CODE="-x"
45 NIX_LISP_QUIT="(quit)"
46 NIX_LISP_NODEBUG='-on-error exit'
47 NIX_LISP_FINAL_PARAMETERS="-repl"
48 NIX_LISP_FASL_TYPE="fas"
50 lx86cl64)
51 NIX_LISP_LOAD_FILE="-l"
52 NIX_LISP_EXEC_CODE="-e"
53 NIX_LISP_QUIT="(quit)"
54 NIX_LISP_NODEBUG='-b'
55 NIX_LISP_FINAL_PARAMETERS=
56 NIX_LISP_FASL_TYPE="lx64fsl"
58 lx86cl)
59 NIX_LISP_LOAD_FILE="-l"
60 NIX_LISP_EXEC_CODE="-e"
61 NIX_LISP_QUIT="(quit)"
62 NIX_LISP_NODEBUG='-b'
63 NIX_LISP_FINAL_PARAMETERS=
64 NIX_LISP_FASL_TYPE="lx32fsl"
66 abcl)
67 NIX_LISP_LOAD_FILE="--load"
68 NIX_LISP_EXEC_CODE="--eval"
69 NIX_LISP_QUIT="(quit)"
70 NIX_LISP_NODEBUG=''
71 NIX_LISP_FINAL_PARAMETERS=
72 NIX_LISP_FASL_TYPE="abcl"
74 esac
76 NIX_LISP_ASDF_REGISTRY_CODE="
77 (progn
78 (setf asdf:*source-registry-parameter*
79 '(:source-registry
80 $(for p in $NIX_LISP_ASDF_PATHS; do
81 echo "(:tree \"$p\")"
82 done)
83 :inherit-configuration))
84 (asdf:initialize-source-registry)
88 NIX_LISP_ASDF="${NIX_LISP_ASDF:-@out@}"
90 nix_lisp_run_single_form(){
91 NIX_LISP_FINAL_PARAMETERS=("$NIX_LISP_EXEC_CODE" "$1"
92 "$NIX_LISP_EXEC_CODE" "$NIX_LISP_QUIT" $NIX_LISP_NODEBUG)
95 nix_lisp_build_system(){
96 NIX_LISP_FINAL_PARAMETERS=(
97 "$NIX_LISP_EXEC_CODE" "(progn
98 (asdf:load-system :$1)
99 (loop for s in (list $(for i in $3; do echo ":$i"; done)) do (asdf:load-system s)))"
100 "$NIX_LISP_EXEC_CODE" "(progn
101 (setf (asdf/system:component-entry-point (asdf:find-system :$1)) ${2:-nil})
102 #+cffi(setf cffi:*foreign-library-directories*
103 (cffi::explode-path-environment-variable \"NIX_LISP_LD_LIBRARY_PATH\"))
104 #+sbcl(loop
105 with libpath := (uiop:split-string (uiop:getenv \"NIX_LISP_LD_LIBRARY_PATH\")
106 :separator \":\")
107 for l in sb-alien::*shared-objects*
108 for ns := (sb-alien::shared-object-namestring l)
109 do (format *error-output* \"Searching alien object ~s in ~s~%\"
110 ns libpath)
111 do (and (> (length ns) 0) (not (equal (elt ns 0) \"/\"))
112 (let*
113 ((prefix (find-if (lambda (s) (probe-file (format nil \"~a/~a\" s ns))) libpath))
114 (fullpath (and prefix (format nil \"~a/~a\" prefix ns))))
115 (when fullpath
116 (format *error-output* \"Found: ~s~%\" fullpath)
117 (setf
118 (sb-alien::shared-object-namestring l) fullpath
119 (sb-alien::shared-object-pathname l) (probe-file fullpath)))))
122 (asdf:perform (quote asdf:program-op) :$1)
126 eval "$NIX_LISP_PRELAUNCH_HOOK"
128 if [ -z "$NIX_LISP_SKIP_CODE" ]; then
129 "$NIX_LISP_COMMAND" $NIX_LISP_EARLY_OPTIONS \
130 $NIX_LISP_EXEC_CODE "${NIX_LISP_ASDF_LOAD:-"(load \"$NIX_LISP_ASDF/lib/common-lisp/asdf/build/asdf.$NIX_LISP_FASL_TYPE\")"}" \
131 $NIX_LISP_EXEC_CODE "$NIX_LISP_ASDF_REGISTRY_CODE" \
132 ${NIX_LISP_FINAL_PARAMETERS[*]:+"${NIX_LISP_FINAL_PARAMETERS[@]}"} \
133 "$@"