diff --git a/.gitignore b/.gitignore index 6efd9a0..577adac 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ testvenv +compile-test diff --git a/Dockerfile.test b/Dockerfile.test index 0b471e4..9825330 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,5 +1,5 @@ -ARG SCHEME=chibi -FROM docker.io/schemers/${SCHEME}:head +ARG IMG=chibi +FROM docker.io/schemers/${IMG} RUN apt-get update && apt-get install -y \ build-essential git wget ca-certificates guile-3.0 guile-3.0-dev libcurl4 \ xz-utils @@ -19,8 +19,11 @@ WORKDIR /workdir RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm ENV PATH=/root/.local/bin:${PATH} ENV LD_LIBRARY_PATH=/root/.local/lib -COPY Makefile Makefile -COPY test.scm test.scm -COPY scheme-venv scheme-venv +COPY Makefile . +COPY test.scm . +COPY test.sps . +COPY compile-test.scm . +COPY compile-test.sps . +COPY scheme-venv . diff --git a/Jenkinsfile b/Jenkinsfile index b84ac7f..89574c3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,8 @@ pipeline { } parameters { - string(name: 'R6RS_SCHEMES', defaultValue: 'chezscheme', description: '') - string(name: 'R7RS_SCHEMES', defaultValue: 'chibi gauche', description: '') + string(name: 'R6RS_SCHEMES', defaultValue: 'capyscheme chezscheme guile ikarus ironscheme larceny loko mosh racket sagittarius ypsilon', description: '') + string(name: 'R7RS_SCHEMES', defaultValue: 'capyscheme chibi chicken cyclone foment gambit gauche guile kawa larceny loko meevax mosh mit-scheme racket sagittarius skint stklos tr7 ypsilon', description: '') } stages { @@ -30,7 +30,7 @@ pipeline { params.R6RS_SCHEMES.split().each { SCHEME -> stage("${SCHEME}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh "timeout 60 make SCHEME=${SCHEME} RNRS=r6rs test-docker" + sh "make SCHEME=${SCHEME} RNRS=r6rs test-docker" } } } @@ -43,7 +43,7 @@ pipeline { params.R7RS_SCHEMES.split().each { SCHEME -> stage("${SCHEME}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh "timeout 60 make SCHEME=${SCHEME} RNRS=r7rs test-docker" + sh "make SCHEME=${SCHEME} RNRS=r7rs test-docker" } } } diff --git a/Makefile b/Makefile index b1dcc9b..20523f1 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,46 @@ PREFIX=/usr/local SCHEME=chibi -RNRS=r7rs all: build build: @echo "No build step, just install" -test: - rm -rf testvenv/ \ - && ./scheme-venv ${SCHEME} ${RNRS} testvenv \ - && ./testvenv/bin/snow-chibi install retropikzel.hello \ +test-r6rs: + @echo "Starting test Scheme: ${SCHEME}, RNRS: R6RS" + @rm -rf testvenv/ \ + && ./scheme-venv ${SCHEME} r6rs testvenv \ + && ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello \ && ./testvenv/bin/akku install akku-r7rs \ - && ./testvenv/bin/scheme-script test.scm + && SCHEME_VENV_DEBUG=1 ./testvenv/bin/scheme-script test.sps \ + && SCHEME_VENV_DEBUG=1 ./testvenv/bin/scheme-compile compile-test.sps \ + && ./compile-test -test-docker: - docker build --build-arg SCHEME=${SCHEME} -f Dockerfile.test --tag=scheme-venv-test-${SCHEME} . - docker run -t scheme-venv-test-${SCHEME} bash -c "make SCHEME=${SCHEME} RNRS=${RNRS} test" +test-r7rs: + @echo "Starting test Scheme: ${SCHEME}, RNRS: R7RS" + @rm -rf testvenv/ \ + && ./scheme-venv ${SCHEME} r7rs testvenv \ + && ./testvenv/bin/snow-chibi install --always-yes retropikzel.hello srfi.64 \ + && SCHEME_VENV_DEBUG=1 ./testvenv/bin/scheme-script test.scm \ + && SCHEME_VENV_DEBUG=1 ./testvenv/bin/scheme-compile compile-test.scm \ + && ./compile-test + +build-test-docker-image: + @if [ "${SCHEME}" = "chicken" ]; then \ + docker build --build-arg IMG=${SCHEME}:5 -f Dockerfile.test --tag=scheme-venv-test-${SCHEME} . ; \ + else \ + docker build --build-arg IMG=${SCHEME}:head -f Dockerfile.test --tag=scheme-venv-test-${SCHEME} . ; \ + fi + +test-r6rs-docker: build-test-docker-image + @docker run -it scheme-venv-test-${SCHEME} bash -c "make SCHEME=${SCHEME} test-r6rs" + +test-r7rs-docker: build-test-docker-image + @docker run -it scheme-venv-test-${SCHEME} bash -c "make SCHEME=${SCHEME} test-r7rs" install: - mkdir -p ${PREFIX}/bin - install scheme-venv ${PREFIX}/bin/scheme-venv + @mkdir -p ${PREFIX}/bin + @install scheme-venv ${PREFIX}/bin/scheme-venv uninstall: - -rm ${PREFIX}/bin/scheme-venv + @-rm ${PREFIX}/bin/scheme-venv diff --git a/compile-test.scm b/compile-test.scm new file mode 100644 index 0000000..b357b6e --- /dev/null +++ b/compile-test.scm @@ -0,0 +1,9 @@ +(import (scheme base) + (scheme write) + (scheme process-context) + (retropikzel hello) + (srfi 64)) + +(display "Compile test: ") +(hello) +(exit 0) diff --git a/compile-test.sps b/compile-test.sps new file mode 100644 index 0000000..9a38099 --- /dev/null +++ b/compile-test.sps @@ -0,0 +1,9 @@ +(import (scheme base) + (scheme write) + (scheme process-context) + (retropikzel hello) + (srfi :64)) + +(display "Interpreter test: ") +(hello) +(exit 0) diff --git a/scheme-venv b/scheme-venv index 474cfce..0ff6192 100755 --- a/scheme-venv +++ b/scheme-venv @@ -1,26 +1,13 @@ #!/bin/sh -# TODO: -# Capyscheme -# Cyclone -# Ikarus -# Ironscheme -# Larceny -# Meevax -# MIT-Scheme -# Mosh -# Sagittarius -# Skint -# Vicare -# Ypsilon - # vi: ft=bash stringContain() { case $2 in *$1* ) return 0;; *) return 1;; esac ;} supported_rnrs="r6rs r7rs" -supported_implementations="chezscheme chibi chicken foment gambit gauche kawa \ - loko mit-scheme racket stklos tr7" +supported_implementations="capyscheme chezscheme chibi chicken cyclone foment \ + gambit gauche guile ikarus ironscheme kawa larceny loko meevax mosh \ + mit-scheme racket sagittarius skint stklos tr7 ypsilon" ## Make sure all arguments are right if [ "${1}" = "" ]; then @@ -163,6 +150,7 @@ export SCHEME_VENV_OLD_PATH="\${PATH}" export PATH="${venvpath}/bin:\${PATH}" hash -r 2> /dev/null echo "${implementation} ${rnrs}" +echo "if [ "${rnrs}" = "r6rs" ]; then . ${venvpath}/lib/.akku/bin/activate; fi" EOF } > "${venvpath}/bin/activate" chmod +x "${venvpath}/bin/activate" @@ -172,6 +160,9 @@ chmod +x "${venvpath}/bin/activate" if [ "${rnrs}" = "r6rs" ]; then ## R6RS case "${implementation}" in + "capyscheme") + scheme_cmd="capy --r6rs -L \"${venvpath}/lib\" --script=\"\${IF}\"" + ;; "chezscheme") if command -v chezscheme >/dev/null 2>&1 then @@ -180,12 +171,33 @@ if [ "${rnrs}" = "r6rs" ]; then scheme_cmd="scheme --libdirs \"${venvpath}/lib/.akku/lib\" --program \"\${IF}\"" fi ;; + "guile") + scheme_cmd="guile --r6rs -L \"${venvpath}/lib/.akku/lib\" \"\${IF}\"" + ;; + "ikarus") + scheme_cmd="IKARUS_LIBRARY_PATH=\"${venvpath}/lib/.akku/lib\" ikarus --r6rs-script \"\${IF}\"" + ;; + "ironscheme") + scheme_cmd="ironscheme -I \"${venvpath}/lib/.akku/lib\" \"\${IF}\"" + ;; + "larceny") + scheme_cmd="larceny -nobanner -quiet -utf8 -r6 -I \"${venvpath}/lib/.akku/lib\" \"\${IF}\"" + ;; "loko") - scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs --program \"\${IF}\"" - scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r6rs -o \"\${OF}\" --compile \"\${IF}\"" + scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib/.akku/lib\" loko --program \"\${IF}\"" + scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib/.akku/lib\" loko -o \"\${OF}\" --compile \"\${IF}\"" + ;; + "mosh") + scheme_cmd="mosh --loadpath=\"${venvpath}/lib/.akku/lib\" \"\${IF}\"" ;; "racket") - scheme_cmd="racket -I scheme/init -l r6rs/run.rkt -S \"${venvpath}/lib\" \"\${IF}\"" + scheme_cmd="racket -I scheme/init -l r6rs/run.rkt -S \"${venvpath}/lib/.akku/lib\" \"\${IF}\"" + ;; + "sagittarius") + scheme_cmd="sash -r6 -L \"${venvpath}/lib\" \"\${IF}\"" + ;; + "ypsilon") + scheme_cmd="ypsilon --r6rs --sitelib \"${venvpath}/lib\" --top-level-program \"\${IF}\"" ;; *) >&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}" @@ -196,6 +208,9 @@ if [ "${rnrs}" = "r6rs" ]; then else ## R7RS case "${implementation}" in + "capyscheme") + scheme_cmd="capy --r7rs -L \"${venvpath}/lib\" --script=\"\${IF}\"" + ;; "chibi") scheme_cmd="chibi-scheme -I \"${venvpath}/lib\" \"\${IF}\"" ;; @@ -203,6 +218,10 @@ else scheme_cmd="echo \"Chicken scripts not yet supported\" && exit 1" scheme_compile_cmd="csc -static -X r7rs -R r7rs -o \"\${OF}\" \"\${IF}\"" ;; + "cyclone") + scheme_cmd="icyc -I \"${venvpath}/lib\" \"\${IF}\"" + scheme_compile_cmd="cyclone -I \"${venvpath}/lib\" \"\${IF}\"" + ;; "foment") scheme_cmd="foment -I \"${venvpath}/lib\" \"\${IF}\"" ;; @@ -214,25 +233,46 @@ else "gauche") scheme_cmd="gosh -r7 -I \"${venvpath}/lib\" \"\${IF}\"" ;; + "guile") + scheme_cmd="guile --r7rs -C \"${venvpath}/lib\" -L \"${venvpath}/lib\" \"\${IF}\"" + ;; "kawa") scheme_cmd="kawa --r7rs --full-tailcalls -Dkawa.import.path=\"${venvpath}/lib/*.sld\" \"\${IF}\"" ;; + "larceny") + scheme_cmd="larceny -nobanner -quiet -utf8 -r7 -I \"${venvpath}/lib\" \"\${IF}\"" + ;; "loko") scheme_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs --program \"\${IF}\"" scheme_compile_cmd="LOKO_LIBRARY_PATH=\"${venvpath}/lib\" loko -std=r7rs -o \"\${OF}\" --compile \"\${IF}\"" ;; + "meevax") + scheme_cmd="meevax -I \"${venvpath}/lib\" \"\${IF}\"" + ;; "mit-scheme") scheme_cmd="mit-scheme --prepend-library ${venvpath}/lib --batch-mode --load \"\${IF}\" --eval \"(exit 0)\" --args" ;; + "mosh") + scheme_cmd="mosh --loadpath=\"${venvpath}/lib\" \"\${IF}\"" + ;; "racket") scheme_cmd="racket -I r7rs -S \"${venvpath}/lib\" --script \"\${IF}\"" ;; + "sagittarius") + scheme_cmd="sash -r7 -L \"${venvpath}/lib\" \"\${IF}\"" + ;; + "skint") + scheme_cmd="skint -I \"${venvpath}/lib\" \"\${IF}\"" + ;; "stklos") scheme_cmd="stklos -I \"${venvpath}/lib\" \"\${IF}\"" ;; "tr7") scheme_cmd="TR7_LIB_PATH=\"${venvpath}/lib\" tr7i -1 \"\${IF}\"" ;; + "ypsilon") + scheme_cmd="ypsilon --r7rs --sitelib \"${venvpath}/lib\" --top-level-program \"\${IF}\"" + ;; *) >&2 echo "Unsupported implementation RnRS combination: ${implementation} ${rnrs}" exit 1 @@ -256,16 +296,20 @@ chmod +x "${venvpath}/bin/scheme-script" 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}\"" + echo "if [ \"\${SCHEME_VENV_DEBUG}\" = "1" ]; then set -x; fi" + echo "IF=\"\$(realpath \"\${1}\")\"" + echo "if [ "${rnrs}" = "r6rs" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi" + echo "printf \"\n#|\nexec ${venvpath}/bin/scheme-script \\\"\\\${0}\\\" \\\"\\\$@\\\"\n|#\n\" > \"\${OF}\"" + echo "cat \"\${IF}\" >> \"\${OF}\"" + echo "chmod +x \"\${OF}\"" } > "${venvpath}/bin/scheme-compile" chmod +x "${venvpath}/bin/scheme-compile" else { echo "#!/bin/sh" + echo "if [ \"\${SCHEME_VENV_DEBUG}\" = "1" ]; then set -x; fi" echo "IF=\$(realpath \"\${1}\")" - echo "OF=\${IF%.scm}" + echo "if [ "${rnrs}" = "r6rs" ]; then OF=\"\${IF%.sps}\"; else OF=\"\${IF%.scm}\"; fi" echo "cd ${venvpath}/lib" echo "${scheme_compile_cmd}" } > "${venvpath}/bin/scheme-compile" diff --git a/test.scm b/test.scm index 1083af6..a4bafce 100644 --- a/test.scm +++ b/test.scm @@ -1,7 +1,9 @@ (import (scheme base) (scheme write) (scheme process-context) - (retropikzel hello)) + (retropikzel hello) + (srfi 64)) +(display "Interpreter test: ") (hello) -(exit) +(exit 0) diff --git a/test.sps b/test.sps new file mode 100644 index 0000000..9a38099 --- /dev/null +++ b/test.sps @@ -0,0 +1,9 @@ +(import (scheme base) + (scheme write) + (scheme process-context) + (retropikzel hello) + (srfi :64)) + +(display "Interpreter test: ") +(hello) +(exit 0)