Compare commits
3 Commits
afb9603b9e
...
b8e5cceb5f
| Author | SHA1 | Date |
|---|---|---|
|
|
b8e5cceb5f | |
|
|
63dc7d53a7 | |
|
|
d7a9578aad |
|
|
@ -0,0 +1,15 @@
|
||||||
|
Tool to create Scheme virtual environments
|
||||||
|
|
||||||
|
|
||||||
|
## scheme-compile
|
||||||
|
|
||||||
|
|
||||||
|
## Chicken
|
||||||
|
|
||||||
|
- Before compilation the directory is changed to be venv/lib so libraries will be found
|
||||||
|
- venv/include
|
||||||
|
- added into include paths
|
||||||
|
- venv/lib
|
||||||
|
- added into library paths
|
||||||
|
- venv/scheme-compile
|
||||||
|
- Environment variable VENV\_CSC\_ARGS is added to csc arguments
|
||||||
56
scheme-venv
56
scheme-venv
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# vi: ft=bash
|
# vi: ft=bash
|
||||||
|
|
||||||
|
VERSION=1.0.0
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
|
stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;}
|
||||||
|
|
@ -71,6 +73,7 @@ echo "scheme-venv version 1.0.0, scheme: ${implementation}, rnrs: ${rnrs}"
|
||||||
## Create venv directories
|
## Create venv directories
|
||||||
mkdir -p "${venvpath}"
|
mkdir -p "${venvpath}"
|
||||||
mkdir -p "${venvpath}/bin"
|
mkdir -p "${venvpath}/bin"
|
||||||
|
mkdir -p "${venvpath}/include"
|
||||||
if [ -d "${venvpath}/lib" ]; then
|
if [ -d "${venvpath}/lib" ]; then
|
||||||
rm -rf "${venvpath}/lib"
|
rm -rf "${venvpath}/lib"
|
||||||
fi
|
fi
|
||||||
|
|
@ -86,6 +89,7 @@ esac
|
||||||
## bin/activate
|
## bin/activate
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
if [ ! "\${VENV_DEBUG}" = "" ]; then set -x; fi
|
||||||
deactivate () {
|
deactivate () {
|
||||||
unset SCHEME
|
unset SCHEME
|
||||||
unset COMPILE_R7RS
|
unset COMPILE_R7RS
|
||||||
|
|
@ -117,44 +121,13 @@ echo "if [ "${rnrs}" = "r6rs" ]; then . ${venvpath}/lib/.akku/bin/activate; fi"
|
||||||
EOF
|
EOF
|
||||||
} > "${venvpath}/bin/activate"
|
} > "${venvpath}/bin/activate"
|
||||||
|
|
||||||
## /etc/Dockerfile
|
|
||||||
{
|
|
||||||
cat << EOF
|
|
||||||
FROM docker.io/schemers/${implementation}:head
|
|
||||||
RUN apt-get update && apt-get install -y make gcc libffi-dev git ca-certificates curl xz-utils
|
|
||||||
WORKDIR /build
|
|
||||||
RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
|
|
||||||
WORKDIR /build/chibi-scheme
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
WORKDIR /build
|
|
||||||
RUN curl -o akku.tar.xz https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz
|
|
||||||
RUN mkdir akku && tar -C akku --strip-components 1 -xf akku.tar.xz
|
|
||||||
WORKDIR /build/akku
|
|
||||||
RUN ./install.sh
|
|
||||||
WORKDIR /workdir
|
|
||||||
RUN ln -s ${venvpath}/bin/* /usr/local/bin/
|
|
||||||
#CMD ["bash", "--rcfile", "${venvpath}/bin/activate"]
|
|
||||||
CMD ["bash"]
|
|
||||||
EOF
|
|
||||||
} > "${venvpath}/etc/Dockerfile"
|
|
||||||
|
|
||||||
## /bin/docker
|
|
||||||
{
|
|
||||||
cat << EOF
|
|
||||||
docker build -f "${venvpath}/etc/Dockerfile" --tag="${docker_tag}"
|
|
||||||
docker run -v "${venvpath}":"${venvpath}" -it "${docker_tag}"
|
|
||||||
EOF
|
|
||||||
} > "${venvpath}/bin/docker"
|
|
||||||
chmod +x "${venvpath}/bin/docker"
|
|
||||||
|
|
||||||
## Set scheme commands
|
## Set scheme commands
|
||||||
|
|
||||||
if [ "${rnrs}" = "r6rs" ]; then
|
if [ "${rnrs}" = "r6rs" ]; then
|
||||||
## R6RS
|
## R6RS
|
||||||
case "${implementation}" in
|
case "${implementation}" in
|
||||||
"capyscheme")
|
"capyscheme")
|
||||||
scheme_cmd="capy --r6rs -L \"${venvpath}/lib\" --script \"\${IF}\""
|
scheme_cmd="capy --r6rs -L \"${venvpath}/lib\" VENV_CAPYSCHEME_ARGS --script \"\${IF}\""
|
||||||
scheme_repl_cmd="capy --r6rs -L \"${venvpath}/lib\""
|
scheme_repl_cmd="capy --r6rs -L \"${venvpath}/lib\""
|
||||||
;;
|
;;
|
||||||
"chezscheme")
|
"chezscheme")
|
||||||
|
|
@ -226,12 +199,12 @@ else
|
||||||
#scheme_cmd="LD_LIBRARY_PATH=\"${venvpath}/lib\" csi -R r7rs -I \"${venvpath}/lib\" -script \"\${IF}\""
|
#scheme_cmd="LD_LIBRARY_PATH=\"${venvpath}/lib\" csi -R r7rs -I \"${venvpath}/lib\" -script \"\${IF}\""
|
||||||
scheme_cmd="echo \"Chicken script not supported\" && exit 1"
|
scheme_cmd="echo \"Chicken script not supported\" && exit 1"
|
||||||
scheme_repl_cmd="echo \"Chicken repl not supported\" && exit 1"
|
scheme_repl_cmd="echo \"Chicken repl not supported\" && exit 1"
|
||||||
scheme_compile_cmd="csc -static -X r7rs -R r7rs -o \"\${OF}\" \"\${IF}\""
|
scheme_compile_cmd="cd \"${venvpath}/lib\" && csc -static -X r7rs -R r7rs \${VENV_CSC_ARGS:-} -I${venvpath}/include -L${venvpath}/lib -o \"\${OF}\" \"\${IF}\""
|
||||||
else
|
else
|
||||||
#scheme_cmd="LD_LIBRARY_PATH=\"${venvpath}/lib\" csi -I \"${venvpath}/lib\" -script \"\${IF}\""
|
#scheme_cmd="LD_LIBRARY_PATH=\"${venvpath}/lib\" csi -I \"${venvpath}/lib\" -script \"\${IF}\""
|
||||||
scheme_cmd="echo \"Chicken script not supported\" && exit 1"
|
scheme_cmd="echo \"Chicken script not supported\" && exit 1"
|
||||||
scheme_repl_cmd="echo \"Chicken repl not supported\" && exit 1"
|
scheme_repl_cmd="echo \"Chicken repl not supported\" && exit 1"
|
||||||
scheme_compile_cmd="csc -static -o \"\${OF}\" \"\${IF}\""
|
scheme_compile_cmd="cd \"${venvpath}/lib\" && csc -static \${VENV_CSC_ARGS:-} -I${venvpath}/include -L${venvpath}/lib -o \"\${OF}\" \"\${IF}\""
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"cyclone")
|
"cyclone")
|
||||||
|
|
@ -318,6 +291,7 @@ fi
|
||||||
## bin/scheme-script
|
## bin/scheme-script
|
||||||
{
|
{
|
||||||
echo "#!/bin/sh"
|
echo "#!/bin/sh"
|
||||||
|
echo "if [ ! \"\${VENV_DEBUG}\" = \"\" ]; then set -x; fi"
|
||||||
echo "if [ \"\${1}\" = \"\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
|
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 "if [ \"\${1}\" = \"--help\" ]; then echo 'scheme-venv (${implementation} ${rnrs}) Give script file as argument' && exit 1; fi"
|
||||||
echo "IF=\"\${1}\""
|
echo "IF=\"\${1}\""
|
||||||
|
|
@ -329,6 +303,7 @@ chmod +x "${venvpath}/bin/scheme-script"
|
||||||
## bin/scheme-repl
|
## bin/scheme-repl
|
||||||
{
|
{
|
||||||
echo "#!/bin/sh"
|
echo "#!/bin/sh"
|
||||||
|
echo "if [ ! \"\${VENV_DEBUG}\" = \"\" ]; then set -x; fi"
|
||||||
echo "${scheme_repl_cmd} \"\$@\""
|
echo "${scheme_repl_cmd} \"\$@\""
|
||||||
} > "${venvpath}/bin/scheme-repl"
|
} > "${venvpath}/bin/scheme-repl"
|
||||||
chmod +x "${venvpath}/bin/scheme-repl"
|
chmod +x "${venvpath}/bin/scheme-repl"
|
||||||
|
|
@ -337,6 +312,7 @@ chmod +x "${venvpath}/bin/scheme-repl"
|
||||||
if [ "${scheme_type}" = "interpreter" ]; then
|
if [ "${scheme_type}" = "interpreter" ]; then
|
||||||
{
|
{
|
||||||
echo "#!/bin/sh"
|
echo "#!/bin/sh"
|
||||||
|
echo "if [ ! \"${VENV_DEBUG}\" = \"\" ]; then set -x; fi"
|
||||||
echo "IF=\"\$(realpath \"\${1}\")\""
|
echo "IF=\"\$(realpath \"\${1}\")\""
|
||||||
echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
|
echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
|
||||||
# shellcheck disable=SC2028
|
# shellcheck disable=SC2028
|
||||||
|
|
@ -348,24 +324,30 @@ if [ "${scheme_type}" = "interpreter" ]; then
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo "#!/bin/sh"
|
echo "#!/bin/sh"
|
||||||
|
echo "if [ ! \"\${VENV_DEBUG}\" = \"\" ]; then set -x; fi"
|
||||||
echo "IF=\$(realpath \"\${1}\")"
|
echo "IF=\$(realpath \"\${1}\")"
|
||||||
echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
|
echo "if [ \"${rnrs}\" = \"r6rs\" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi"
|
||||||
echo "cd ${venvpath}/lib"
|
#echo "cd ${venvpath}/lib"
|
||||||
echo "${scheme_compile_cmd}"
|
echo "${scheme_compile_cmd}"
|
||||||
} > "${venvpath}/bin/scheme-compile"
|
} > "${venvpath}/bin/scheme-compile"
|
||||||
chmod +x "${venvpath}/bin/scheme-compile"
|
chmod +x "${venvpath}/bin/scheme-compile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
impls="${implementation}"
|
||||||
|
if [ "${RNRS}" = "" ]; then
|
||||||
|
impls=generic
|
||||||
|
fi
|
||||||
|
|
||||||
## bin/snow-chibi
|
## bin/snow-chibi
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
if [ ! "\${VENV_DEBUG}" = "" ]; then set -x; fi
|
||||||
if [ "\${1}" = "install" ]; then
|
if [ "\${1}" = "install" ]; then
|
||||||
shift
|
shift
|
||||||
snow-chibi \
|
snow-chibi \
|
||||||
install \
|
install \
|
||||||
--impls=${implementation} \
|
--impls=${impls} \
|
||||||
--install-source-dir=${venvpath}/lib \
|
--install-source-dir=${venvpath}/lib \
|
||||||
--install-library-dir=${venvpath}/lib \
|
--install-library-dir=${venvpath}/lib \
|
||||||
--install-data-dir=${venvpath}/lib \
|
--install-data-dir=${venvpath}/lib \
|
||||||
|
|
@ -382,6 +364,7 @@ chmod +x "${venvpath}/bin/snow-chibi"
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
if [ ! "\${VENV_DEBUG}" = "" ]; then set -x; fi
|
||||||
cd "${venvpath}/lib"
|
cd "${venvpath}/lib"
|
||||||
akku \$@
|
akku \$@
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -393,6 +376,7 @@ chmod +x "${venvpath}/bin/akku"
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
if [ ! "\${VENV_DEBUG}" = "" ]; then set -x; fi
|
||||||
echo "Scheme: ${implementation}"
|
echo "Scheme: ${implementation}"
|
||||||
echo "RNRS: ${rnrs}"
|
echo "RNRS: ${rnrs}"
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue