Improvements
This commit is contained in:
parent
b64a539cdb
commit
f4de1c4847
|
|
@ -1,3 +1,4 @@
|
||||||
testvenv
|
testvenv
|
||||||
compile-test
|
compile-test
|
||||||
*.link
|
*.link
|
||||||
|
test
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,3 @@
|
||||||
ARG SCHEME=chibi
|
ARG SCHEME=chibi
|
||||||
FROM docker.io/schemers/${SCHEME}:head
|
FROM docker.io/schemers/${SCHEME}:head
|
||||||
ARG SCHEME=chibi
|
|
||||||
ENV SCHEME=${SCHEME}
|
|
||||||
ARG RNRS=r7rs
|
|
||||||
ENV RNRS=${RNRS}
|
|
||||||
RUN apt-get update && apt-get install -y gcc curl make git xz-utils
|
RUN apt-get update && apt-get install -y gcc curl make git xz-utils
|
||||||
COPY Makefile .
|
|
||||||
COPY test.sps .
|
|
||||||
COPY test.scm .
|
|
||||||
COPY scheme-venv .
|
|
||||||
RUN ./scheme-venv ${SCHEME} ${RNRS} testvenv
|
|
||||||
|
|
|
||||||
20
Makefile
20
Makefile
|
|
@ -1,36 +1,36 @@
|
||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
SCHEME=chibi
|
SCHEME=chibi
|
||||||
RNRS=r7rs
|
RNRS=r7rs
|
||||||
DOCKER_IMG=scheme-venv-test-${SCHEME}
|
DOCKERTAG=scheme-venv-test-${SCHEME}
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@echo "No build step, just install"
|
@echo "No build step, just install"
|
||||||
|
|
||||||
testvenv:
|
init-testvenv:
|
||||||
./scheme-venv ${SCHEME} ${RNRS} testvenv
|
./scheme-venv ${SCHEME} ${RNRS} testvenv
|
||||||
|
|
||||||
test-script: testvenv
|
test-script: init-testvenv
|
||||||
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
|
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
|
||||||
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-script test.sps; fi
|
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-script test.sps; fi
|
||||||
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
|
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
|
||||||
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-script test.scm; fi
|
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-script test.scm; fi
|
||||||
|
|
||||||
test-compile: testvenv
|
test-compile: init-testvenv
|
||||||
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
|
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/akku install chez-srfi; fi
|
||||||
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-compile test.sps && ./test; fi
|
@if [ "${RNRS}" = "r6rs" ]; then ./testvenv/bin/scheme-compile test.sps && ./test; fi
|
||||||
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
|
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello; fi
|
||||||
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-compile test.scm && ./test; fi
|
@if [ "${RNRS}" = "r7rs" ]; then ./testvenv/bin/scheme-compile test.scm && ./test; fi
|
||||||
|
|
||||||
build-test-docker-image:
|
build-docker-image:
|
||||||
docker build --build-arg SCHEME=${SCHEME} --build-arg RNRS=${RNRS} -f Dockerfile.test --tag=${DOCKER_IMG} .
|
docker build -f Dockerfile.test --tag=${DOCKERTAG}
|
||||||
|
|
||||||
test-script-docker: build-test-docker-image
|
test-script-docker: build-docker-image
|
||||||
docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-script"
|
docker run -v ${PWD}:${PWD} -w ${PWD} ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-script"
|
||||||
|
|
||||||
test-compile-docker: build-test-docker-image
|
test-compile-docker: build-docker-image
|
||||||
@docker run ${DOCKER_IMG} bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-compile"
|
docker run -v ${PWD}:${PWD} -w ${PWD} ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} RNRS=${RNRS} test-compile"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@mkdir -p ${PREFIX}/bin
|
@mkdir -p ${PREFIX}/bin
|
||||||
|
|
|
||||||
112
scheme-venv
112
scheme-venv
|
|
@ -45,16 +45,22 @@ if [ "${3}" = "" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "${3}" ]; then
|
if [ -d "${3}" ]; then
|
||||||
echo "Path already exists"
|
if [ -f "${3}/bin/scheme-venv-info" ]; then
|
||||||
|
echo "Directory is already venv, reiniting..."
|
||||||
|
else
|
||||||
|
echo "Path already exists, and is not scheme-venv (no /bin/scheme-venv-info)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
## Build variables
|
## Build variables
|
||||||
implementation="${1}"
|
implementation="${1}"
|
||||||
rnrs="${2}"
|
rnrs="${2}"
|
||||||
venvpath=$(realpath "${3}")
|
venvpath=$(realpath "${3}")
|
||||||
|
venvname=$(basename "${venvpath}")
|
||||||
downloadpath="${venvpath}/downloads"
|
downloadpath="${venvpath}/downloads"
|
||||||
toolinstallprefix="${venvpath}/tools"
|
toolinstallprefix="${venvpath}/tools"
|
||||||
|
docker_tag="${venvname}-${implementation}-${rnrs}"
|
||||||
scheme_compile_cmd=""
|
scheme_compile_cmd=""
|
||||||
scheme_cmd=""
|
scheme_cmd=""
|
||||||
scheme_script_cmd=""
|
scheme_script_cmd=""
|
||||||
|
|
@ -63,9 +69,13 @@ scheme_type="interpreter"
|
||||||
echo "scheme-venv version 1.0.0, scheme: ${implementation}, rnrs: ${rnrs}"
|
echo "scheme-venv version 1.0.0, scheme: ${implementation}, rnrs: ${rnrs}"
|
||||||
|
|
||||||
## Create venv directories
|
## Create venv directories
|
||||||
mkdir "${venvpath}"
|
mkdir -p "${venvpath}"
|
||||||
mkdir "${venvpath}/bin"
|
mkdir -p "${venvpath}/bin"
|
||||||
mkdir "${venvpath}/lib"
|
if [ -d "${venvpath}/lib" ]; then
|
||||||
|
rm -rf "${venvpath}/lib"
|
||||||
|
fi
|
||||||
|
mkdir -p "${venvpath}/lib"
|
||||||
|
mkdir -p "${venvpath}/etc"
|
||||||
|
|
||||||
## Set scheme type if other than interpreter
|
## Set scheme type if other than interpreter
|
||||||
case "${implementation}" in
|
case "${implementation}" in
|
||||||
|
|
@ -94,7 +104,7 @@ export COMPILE_SCHEME=${implementation}
|
||||||
export TEST_SCHEME=${implementation}
|
export TEST_SCHEME=${implementation}
|
||||||
export SCHEME=${implementation}
|
export SCHEME=${implementation}
|
||||||
|
|
||||||
venvname=\$(basename "${venvpath}")
|
venvname="${venvname}"
|
||||||
|
|
||||||
export SCHEME_VENV_OLD_PS1="\${PS1}"
|
export SCHEME_VENV_OLD_PS1="\${PS1}"
|
||||||
export PS1="(\${venvname}) \${PS1:-}"
|
export PS1="(\${venvname}) \${PS1:-}"
|
||||||
|
|
@ -106,7 +116,37 @@ echo "${implementation} ${rnrs}"
|
||||||
echo "if [ "${rnrs}" = "r6rs" ]; then . ${venvpath}/lib/.akku/bin/activate; fi"
|
echo "if [ "${rnrs}" = "r6rs" ]; then . ${venvpath}/lib/.akku/bin/activate; fi"
|
||||||
EOF
|
EOF
|
||||||
} > "${venvpath}/bin/activate"
|
} > "${venvpath}/bin/activate"
|
||||||
chmod +x "${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
|
||||||
|
|
||||||
|
|
@ -280,25 +320,6 @@ else
|
||||||
chmod +x "${venvpath}/bin/scheme-compile"
|
chmod +x "${venvpath}/bin/scheme-compile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${rnrs}" = "r6rs" ];then
|
|
||||||
sleep 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
## Check if system has snow-chibi
|
|
||||||
if command -v snow-chibi >/dev/null 2>&1; then
|
|
||||||
echo "Found local snow-chibi at $(which snow-chibi)"
|
|
||||||
snow_chibi_path=$(which snow-chibi)
|
|
||||||
snow_chibi_prefix=""
|
|
||||||
else
|
|
||||||
echo "Did not found local snow-chibi, installing"
|
|
||||||
mkdir -p "${downloadpath}"
|
|
||||||
mkdir -p "${toolinstallprefix}"
|
|
||||||
git clone https://github.com/ashinn/chibi-scheme.git "${downloadpath}/chibi-scheme" --depth=1
|
|
||||||
make -C "${downloadpath}/chibi-scheme" PREFIX="${toolinstallprefix}"
|
|
||||||
make -C "${downloadpath}/chibi-scheme" PREFIX="${toolinstallprefix}" install
|
|
||||||
snow_chibi_path="${toolinstallprefix}/bin/snow-chibi"
|
|
||||||
snow_chibi_prefix="LD_LIBRARY_PATH=\"${toolinstallprefix}/lib\" PATH=\"${toolinstallprefix}/bin:${PATH}\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
## bin/snow-chibi
|
## bin/snow-chibi
|
||||||
impls=${implementation}
|
impls=${implementation}
|
||||||
|
|
@ -311,7 +332,8 @@ cat << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if [ "\${1}" = "install" ]; then
|
if [ "\${1}" = "install" ]; then
|
||||||
shift
|
shift
|
||||||
${snow_chibi_prefix} "${snow_chibi_path}" install \
|
snow-chibi \
|
||||||
|
install \
|
||||||
--impls=${impls} \
|
--impls=${impls} \
|
||||||
--install-source-dir=${venvpath}/lib \
|
--install-source-dir=${venvpath}/lib \
|
||||||
--install-library-dir=${venvpath}/lib \
|
--install-library-dir=${venvpath}/lib \
|
||||||
|
|
@ -319,41 +341,31 @@ if [ "\${1}" = "install" ]; then
|
||||||
--install-binary-dir=${venvpath}/bin \
|
--install-binary-dir=${venvpath}/bin \
|
||||||
"\$@"
|
"\$@"
|
||||||
else
|
else
|
||||||
${snow_chibi_prefix} "${snow_chibi_path}" "\$@"
|
snow-chibi "\$@"
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
} > "${venvpath}/bin/snow-chibi"
|
} > "${venvpath}/bin/snow-chibi"
|
||||||
chmod +x "${venvpath}/bin/snow-chibi"
|
chmod +x "${venvpath}/bin/snow-chibi"
|
||||||
|
|
||||||
if [ "${rnrs}" = "r6rs" ]; then
|
|
||||||
## Check if system has akku
|
|
||||||
if command -v akku >/dev/null 2>&1; then
|
|
||||||
echo "Found local akku at $(which akku)"
|
|
||||||
akku_path=$(which akku)
|
|
||||||
akku_prefix=""
|
|
||||||
else
|
|
||||||
echo "Did not found local akku, installing"
|
|
||||||
mkdir -p "${downloadpath}"
|
|
||||||
mkdir -p "${toolinstallprefix}/akku"
|
|
||||||
mkdir -p "${toolinstallprefix}/bin"
|
|
||||||
curl -o "${downloadpath}/akku.tar.xz" https://gitlab.com/-/project/6808260/uploads/094ce726ce3c6cf8c14560f1e31aaea0/akku-1.1.0.amd64-linux.tar.xz
|
|
||||||
tar -C "${toolinstallprefix}/akku" --strip-components 1 -xf "${downloadpath}/akku.tar.xz"
|
|
||||||
akku_install_path="${toolinstallprefix}/akku/lib/x86_64-linux-gnu/akku"
|
|
||||||
echo "exec \"${akku_install_path}/petite\" -b \"${akku_install_path}/petite.boot\" --program \"${akku_install_path}/akku\" \"\$@\"" > "${toolinstallprefix}/bin/akku"
|
|
||||||
chmod +x "${toolinstallprefix}/bin/akku"
|
|
||||||
akku_path="${toolinstallprefix}/bin/akku"
|
|
||||||
akku_prefix="PATH=\"${toolinstallprefix}/bin:${PATH}\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
## bin/akku
|
## bin/akku
|
||||||
{
|
{
|
||||||
cat << EOF
|
cat << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd "${venvpath}/lib"
|
cd "${venvpath}/lib"
|
||||||
"${akku_prefix}" "${akku_path}" update
|
akku \$@
|
||||||
${akku_prefix} "${akku_path}" "\$@"
|
|
||||||
EOF
|
EOF
|
||||||
} > "${venvpath}/bin/akku"
|
} > "${venvpath}/bin/akku"
|
||||||
chmod +x "${venvpath}/bin/akku"
|
chmod +x "${venvpath}/bin/akku"
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
## /bin/scheme-venv-info
|
||||||
|
{
|
||||||
|
cat << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
echo "Scheme: ${implementation}"
|
||||||
|
echo "RNRS: ${rnrs}"
|
||||||
|
EOF
|
||||||
|
} > "${venvpath}/bin/scheme-venv-info"
|
||||||
|
chmod +x "${venvpath}/bin/scheme-venv-info"
|
||||||
|
|
||||||
|
echo "Initialized scheme-venv ${venvpath}, with ${implementation} and ${rnrs}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue