Add support for more implementations
This commit is contained in:
parent
51a50c0e85
commit
d82742183e
115
scheme-venv
115
scheme-venv
|
|
@ -5,11 +5,12 @@
|
|||
stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
|
||||
|
||||
supported_rnrs="r6rs r7rs"
|
||||
supported_implementations="chezscheme chibi"
|
||||
supported_implementations="chezscheme chibi chicken gambit gauche kawa loko"
|
||||
|
||||
## Make sure all arguments are right
|
||||
if [ "${1}" = "" ]; then
|
||||
echo "Give implementation name as first argument: ${supported_implementations}"
|
||||
echo "Give implementation name as first argument"
|
||||
echo "${supported_implementations}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -17,11 +18,13 @@ if stringContain "${1}" "${supported_implementations}"; then
|
|||
sleep 0
|
||||
else
|
||||
echo "Unsupported implementation: ${1}"
|
||||
echo "${supported_implementations}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${2}" = "" ]; then
|
||||
echo "Give the RnRS as the second argument: ${supported_rnrs}"
|
||||
echo "Give the RnRS as the second argument"
|
||||
echo "${supported_rnrs}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -29,6 +32,7 @@ if stringContain "${2}" "${supported_rnrs}"; then
|
|||
sleep 0
|
||||
else
|
||||
echo "Unsupported RnRS: ${2}"
|
||||
echo "${supported_rnrs}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -47,7 +51,6 @@ implementation="${1}"
|
|||
rnrs="${2}"
|
||||
venvpath=$(realpath "${3}")
|
||||
schemebinpath="${venvpath}/bin/scheme"
|
||||
scheme_path="${venvpath}/bin"
|
||||
scheme_compile_cmd=""
|
||||
scheme_cmd=""
|
||||
scheme_script_cmd=""
|
||||
|
|
@ -62,15 +65,37 @@ mkdir "${venvpath}/lib"
|
|||
case "${implementation}" in
|
||||
"chezscheme") scheme_type=interpreter ;;
|
||||
"chibi") scheme_type=interpreter ;;
|
||||
"chicken") scheme_type=compiler ;;
|
||||
"gambit") scheme_type=compiler ;;
|
||||
"gauche") scheme_type=interpreter;;
|
||||
esac
|
||||
|
||||
## bin/snow-chibi
|
||||
if [ "${rnrs}" = "r6rs" ]; then
|
||||
{
|
||||
cat << EOF
|
||||
#!/bin/sh
|
||||
if [ "\${1}" = "install" ]; then
|
||||
shift
|
||||
snow-chibi install \
|
||||
PATH="${PATH}" $(which snow-chibi) install \
|
||||
--impls=generic \
|
||||
--install-source-dir=${venvpath}/lib \
|
||||
--install-library-dir=${venvpath}/lib \
|
||||
--install-data-dir=${venvpath}/lib \
|
||||
"\$@"
|
||||
else
|
||||
snow-chibi "\$@"
|
||||
fi
|
||||
EOF
|
||||
} > "${venvpath}/bin/snow-chibi"
|
||||
chmod +x "${venvpath}/bin/snow-chibi"
|
||||
else
|
||||
{
|
||||
cat << EOF
|
||||
#!/bin/sh
|
||||
if [ "\${1}" = "install" ]; then
|
||||
shift
|
||||
PATH="${PATH}" $(which snow-chibi) install \
|
||||
--impls=${implementation} \
|
||||
--install-source-dir=${venvpath}/lib \
|
||||
--install-library-dir=${venvpath}/lib \
|
||||
|
|
@ -82,13 +107,15 @@ fi
|
|||
EOF
|
||||
} > "${venvpath}/bin/snow-chibi"
|
||||
chmod +x "${venvpath}/bin/snow-chibi"
|
||||
fi
|
||||
|
||||
## bin/akku
|
||||
{
|
||||
cat << EOF
|
||||
#!/bin/sh
|
||||
cd ${venvpath}
|
||||
exec akku \"\$@\"
|
||||
cd "${venvpath}/lib"
|
||||
$(which akku) update
|
||||
$(which akku) "\$@"
|
||||
EOF
|
||||
} > "${venvpath}/bin/akku"
|
||||
chmod +x "${venvpath}/bin/akku"
|
||||
|
|
@ -106,7 +133,7 @@ deactivate () {
|
|||
unset SCHEME_VENV_OLD_PS1
|
||||
export PATH="\${SCHEME_VENV_OLD_PATH}"
|
||||
unset SCHEME_VENV_OLD_PATH
|
||||
#hash -r 2> /dev/null
|
||||
hash -r 2> /dev/null
|
||||
}
|
||||
|
||||
export COMPILE_R7RS=${implementation}
|
||||
|
|
@ -121,7 +148,7 @@ export PS1="(\${venvname}) \${PS1:-}"
|
|||
|
||||
export SCHEME_VENV_OLD_PATH="\${PATH}"
|
||||
export PATH="${venvpath}/bin:\${PATH}"
|
||||
#hash -r 2> /dev/null
|
||||
hash -r 2> /dev/null
|
||||
echo "${implementation} ${rnrs}"
|
||||
EOF
|
||||
} > "${venvpath}/bin/activate"
|
||||
|
|
@ -135,16 +162,15 @@ if [ "${rnrs}" = "r6rs" ]; then
|
|||
"chezscheme")
|
||||
if command -v chezscheme >/dev/null 2>&1
|
||||
then
|
||||
scheme_path="${scheme_path}/chezscheme"
|
||||
scheme_cmd="exec chezscheme --libdirs \"${venvpath}/lib\" \"\$@\""
|
||||
scheme_script_cmd="exec chezscheme --libdirs ${venvpath}/lib --program \"\${1}\""
|
||||
scheme_cmd="chezscheme --libdirs ${venvpath}/lib/.akku/lib --program \"\${1}\""
|
||||
else
|
||||
scheme_path="${scheme_path}/scheme"
|
||||
scheme_cmd="exec scheme \"\$@\""
|
||||
scheme_cmd="exec scheme --libdirs \"${venvpath}/lib\" \"\$@\""
|
||||
scheme_script_cmd="exec scheme --libdirs ${venvpath}/lib --program \"\${1}\""
|
||||
scheme_cmd="scheme --libdirs \"${venvpath}/lib/.akku/lib\" --program \"\${1}\""
|
||||
fi
|
||||
;;
|
||||
"loko")
|
||||
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs --program \"\${1}\""
|
||||
scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs -o \"\${OF}\" --compile \"\${IF}\""
|
||||
;;
|
||||
*)
|
||||
>&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}"
|
||||
exit 1
|
||||
|
|
@ -155,9 +181,26 @@ else
|
|||
## R7RS
|
||||
case "${implementation}" in
|
||||
"chibi")
|
||||
scheme_path="${scheme_path}/chibi-scheme"
|
||||
scheme_cmd="exec chibi-scheme -I \"${venvpath}/lib\" \"\$@\""
|
||||
scheme_script_cmd="exec chibi-scheme -I \"${venvpath}/lib\" \"\${1}\""
|
||||
scheme_cmd="chibi-scheme -I \"${venvpath}/lib\" \"\${1}\""
|
||||
;;
|
||||
"chicken")
|
||||
scheme_cmd="echo \"Chicken scripts not yet supported\" && exit 1"
|
||||
scheme_compile_cmd="csc -static -X r7rs -R r7rs -o \"\${OF}\" \"\${IF}\""
|
||||
;;
|
||||
"gambit")
|
||||
scheme_cmd="gsi \"${venvpath}/lib/\" \"\${1}\""
|
||||
#scheme_compile_cmd="gsc -o \"\${OF}\" -exe -nopreload \"${venvpath}/lib/\" \"\${IF}\""
|
||||
scheme_compile_cmd="echo \"Gambit compiler not yet supported\" && exit 1"
|
||||
;;
|
||||
"gauche")
|
||||
scheme_cmd="gosh -r7 -I \"${venvpath}/lib\" \"\${1}\""
|
||||
;;
|
||||
"kawa")
|
||||
scheme_cmd="kawa --r7rs -Dkawa.import.path=\"${venvpath}/lib/*.sld\" \"\${1}\""
|
||||
;;
|
||||
"loko")
|
||||
scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs --program \"\${1}\""
|
||||
scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs -o \"\${OF}\" --compile \"\${IF}\""
|
||||
;;
|
||||
*)
|
||||
>&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}"
|
||||
|
|
@ -167,26 +210,32 @@ else
|
|||
echo "${scheme_script_cmd}" > "${venvpath}/bin/scheme-r7rs"
|
||||
fi
|
||||
|
||||
## bin/implementation script
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "${scheme_cmd}"
|
||||
} > "${scheme_path}"
|
||||
chmod +x "${scheme_path}"
|
||||
|
||||
## bin/scheme-script
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "if [ \"\${1}\" = \"\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
|
||||
echo "if [ \"\${1}\" = \"--help\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
|
||||
echo "${scheme_script_cmd}"
|
||||
echo "${scheme_cmd}"
|
||||
} > "${venvpath}/bin/scheme-script"
|
||||
chmod +x "${venvpath}/bin/scheme-script"
|
||||
|
||||
## bin/compile-r7rs
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "${scheme_compile_cmd}"
|
||||
} > "${venvpath}/bin/compile-r7rs"
|
||||
chmod +x "${venvpath}/bin/compile-r7rs"
|
||||
## bin/scheme-compile
|
||||
if [ "${scheme_type}" = "interpreter" ]; then
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "printf \"\n#|\nexec ${venvpath}/bin/scheme-script \\\"\\\${0}\\\" \\\"\\\$@\\\"\n|#\n\" > \"\${1%.scm}\""
|
||||
echo "cat \"\${1}\" >> \"\${1%.scm}\""
|
||||
echo "chmod +x \"\${1%.scm}\""
|
||||
} > "${venvpath}/bin/scheme-compile"
|
||||
chmod +x "${venvpath}/bin/scheme-compile"
|
||||
else
|
||||
{
|
||||
echo "#!/bin/sh"
|
||||
echo "IF=\$(realpath \"\${1}\")"
|
||||
echo "OF=\${IF%.scm}"
|
||||
echo "cd ${venvpath}/lib"
|
||||
echo "${scheme_compile_cmd}"
|
||||
} > "${venvpath}/bin/scheme-compile"
|
||||
chmod +x "${venvpath}/bin/scheme-compile"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue