Fix gauche installation

This commit is contained in:
retropikzel 2025-09-13 10:25:37 +03:00
parent fa39928d48
commit d95428691e
4 changed files with 30 additions and 124 deletions

2
Jenkinsfile vendored
View File

@ -32,7 +32,7 @@ pipeline {
DOCKERIMG="${implementation}:head" DOCKERIMG="${implementation}:head"
} }
sh "docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.snow-chibi-install-test ." sh "docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${implementation} --tag=foreign-c-test-${implementation} -f dockerfiles/Dockerfile.snow-chibi-install-test ."
sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t foreign-c-test-${implementation} sh -c \"timeout 120 make SCHEME=${implementation} clean force-install && cp tests/hello.scm /tmp/ && cd /tmp && COMPILE_R7RS=${implementation} printf \"\\n\" | timeout 120 compile-r7rs -o hello hello.scm && printf \"\\n\" | timeout 120 ./hello\"" sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t foreign-c-test-${implementation} sh -c \"timeout 120 make SCHEME=${implementation} SNOW_CHIBI_ARGS=\"--always-yes\" clean install && cp tests/hello.scm /tmp/ && cd /tmp && COMPILE_R7RS=${implementation} printf \"\\n\" | timeout 120 compile-r7rs -o hello hello.scm && printf \"\\n\" | timeout 120 ./hello\""
} }
} }
tests.each { test -> tests.each { test ->

132
Makefile
View File

@ -5,18 +5,20 @@ VERSION=0.10.5
TEST=primitives TEST=primitives
SCHEME=chibi SCHEME=chibi
TMPDIR=tmp/${SCHEME} TMPDIR=tmp/${SCHEME}
SNOW_CHIBI_ARGS=""
DOCKERIMG=${SCHEME}:head DOCKERIMG=${SCHEME}:head
ifeq "${SCHEME}" "chicken" ifeq "${SCHEME}" "chicken"
DOCKERIMG="chicken:5" DOCKERIMG="chicken:5"
endif endif
INCDIRS=-I . -I /usr/local/share/kawa/lib GAUCHE_LIB_DIR=""
ifeq "${SCHEME}" "ypsilon" ifeq "${SCHEME}" "gauche"
INCDIRS=-I . GAUCHE_LIB_DIR=$(shell gauche-config --sitelibdir)
endif endif
all: package
package: README.html package: README.html
make ${SCHEME}
snow-chibi package \ snow-chibi package \
--version=${VERSION} \ --version=${VERSION} \
--authors="Retropikzel" \ --authors="Retropikzel" \
@ -25,86 +27,32 @@ package: README.html
--description="Portable foreign function interface for R7RS Schemes" \ --description="Portable foreign function interface for R7RS Schemes" \
foreign/c.sld foreign/c.sld
install: install: package
if [ "${SCHEME}" = "gauche" ]; then \
cp -r foreign $(shell gauche-config --syslibdir)/; \
mkdir -p $(shell gauche-config --sysarchdir)/foreign/c/lib; \
cp -r foreign/c/lib/gauche.so $(shell gauche-config --sysarchdir)/foreign/c/lib/; \
else \
snow-chibi --impls=${SCHEME} install foreign-c-${VERSION}.tgz; \ snow-chibi --impls=${SCHEME} install foreign-c-${VERSION}.tgz; \
if [ "${SCHEME}" = "gauche" ]; then \
make gauche; \
cp foreign/c/primitives/gauche.scm ${GAUCHE_LIB_DIR}/foreign/c/primitives/;\
mkdir -p $(shell gauche-config --sitearchdir)/foreign/c/lib/; \
cp -r foreign/c/lib/gauche.so $(shell gauche-config --sitearchdir)/foreign/c/lib/; \
tree ${GAUCHE_LIB_DIR}/; \
fi fi
uninstall: uninstall:
snow-chibi --impls=${SCHEME} remove foreign.c snow-chibi --impls=${SCHEME} remove "(foreign c)"
force-install:
if [ "${SCHEME}" = "gauche" ]; then \
cp -r foreign $(shell gauche-config --sitelibdir)/; \
mkdir -p $(shell gauche-config --sysarchdir)/foreign/c/lib; \
cp -r foreign/c/lib/gauche.so $(shell gauche-config --sysarchdir)/foreign/c/lib/; \
else \
printf "\n" | snow-chibi --impls=${SCHEME} --always-yes install foreign-c-${VERSION}.tgz; \
fi
test-java: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a
mkdir -p ${TMPDIR}/test
cp kawa.jar ${TMPDIR}/test/
cp -r foreign ${TMPDIR}/test/
cp tests/*.scm ${TMPDIR}/test/
cp tests/c-include/libtest.h ${TMPDIR}/test/
cd ${TMPDIR}/test \
&& ${JAVA_HOME}/bin/java --add-exports java.base/jdk.internal.foreign.abi=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign.layout=ALL-UNNAMED --add-exports java.base/jdk.internal.foreign=ALL-UNNAMED --enable-native-access=ALL-UNNAMED --enable-preview -jar kawa.jar --r7rs --full-tailcalls -Dkawa.import.path=*.sld:./snow/*.sld:./snow/retropikzel/*.sld ${TEST}.scm
test-chibi: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a
make chibi
mkdir -p ${TMPDIR}/test
cp kawa.jar ${TMPDIR}/test/
cp -r foreign ${TMPDIR}/test/
cp tests/*.scm ${TMPDIR}/test/
cp tests/c-include/libtest.h ${TMPDIR}/test/
cd ${TMPDIR}/test && chibi-scheme -I . ${TEST}.scm
test: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a test: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a
make ${SCHEME}
cp -r foreign ${TMPDIR}/test/ cp -r foreign ${TMPDIR}/test/
cp tests/*.scm ${TMPDIR}/test/ cp tests/*.scm ${TMPDIR}/test/
cp tests/c-include/libtest.h ${TMPDIR}/test/ cp tests/c-include/libtest.h ${TMPDIR}/test/
cd ${TMPDIR}/test && \ cd ${TMPDIR}/test && \
COMPILE_R7RS_CHICKEN="-L -ltest -I. -L." \ COMPILE_R7RS_CHICKEN="-L -ltest -I. -L." \
COMPILE_R7RS_KAWA="-J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED -J--enable-native-access=ALL-UNNAMED -J--enable-preview" \
COMPILE_R7RS=${SCHEME} \ COMPILE_R7RS=${SCHEME} \
compile-r7rs ${INCDIRS} -o ${TEST} ${TEST}.scm compile-r7rs -o ${TEST} ${TEST}.scm
cd ${TMPDIR}/test \ cd ${TMPDIR}/test \ && timeout 60 printf "\n" | LD_LIBRARY_PATH=. ./${TEST}
&& export LD_LIBRARY_PATH=. \
&& export GUILE_AUTO_COMPILE=0 \
&& timeout 60 printf "\n" | ./${TEST}
test-compile-r7rs-snow: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a
cp tests/*.scm ${TMPDIR}/test/
cp tests/c-include/libtest.h ${TMPDIR}/test/
cd ${TMPDIR}/test && \
compile-r7rs -o hello hello.scm
cd ${TMPDIR}/test && ./hello
test-compile-r7rs-wine:
cp -r foreign ${TMPDIR}/test/
cp tests/*.scm ${TMPDIR}/test/
cp tests/c-include/libtest.h ${TMPDIR}/test/
cd ${TMPDIR}/test && \
wine "${HOME}/.wine/drive_c/Program Files (x86)/compile-r7rs/compile-r7rs.bat" -I . -o ${TEST} ${TEST}.scm
cd ${TMPDIR}/test && \
LD_LIBRARY_PATH=. \
wine ./${TEST}.bat
test-docker: test-docker:
docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f dockerfiles/Dockerfile.test . docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f dockerfiles/Dockerfile.test .
docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh \ docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh -c "make SCHEME=${SCHEME} TEST=${TEST} install test"
-c "make SCHEME=${SCHEME} TEST=${TEST} test"
test-install-docker:
docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f dockerfiles/Dockerfile.snow-chibi-install-test .
docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh \
-c "make SCHEME=${SCHEME} clean ${SCHEME} install && cp tests/hello.scm /tmp/ && cd /tmp && COMPILE_R7RS=${SCHEME} compile-r7rs -o hello hello.scm && ./hello"
${TMPDIR}/test/libtest.o: tests/c-src/libtest.c ${TMPDIR}/test/libtest.o: tests/c-src/libtest.c
mkdir -p ${TMPDIR}/test mkdir -p ${TMPDIR}/test
@ -117,7 +65,6 @@ ${TMPDIR}/test/libtest.so: tests/c-src/libtest.c
${TMPDIR}/test/libtest.a: ${TMPDIR}/test/libtest.o tests/c-src/libtest.c ${TMPDIR}/test/libtest.a: ${TMPDIR}/test/libtest.o tests/c-src/libtest.c
ar rcs ${TMPDIR}/test/libtest.a ${TMPDIR}/test/libtest.o ar rcs ${TMPDIR}/test/libtest.a ${TMPDIR}/test/libtest.o
${TMPDIR}: ${TMPDIR}:
mkdir -p ${TMPDIR} mkdir -p ${TMPDIR}
@ -137,18 +84,6 @@ chibi: foreign/c/primitives/chibi/foreign-c.stub
-lffi \ -lffi \
-shared -shared
chicken:
@echo "Nothing to build for Chicken"
cyclone:
@echo "Nothing to build for Cyclone"
foment:
@echo "Nothing to build for Foment"
gambit:
@echo "Nothing to build for Gambit"
gauche: gauche:
gauche-package compile \ gauche-package compile \
--srcdir=foreign/c/primitives/gauche \ --srcdir=foreign/c/primitives/gauche \
@ -160,39 +95,6 @@ gauche:
mv foreign-c-primitives-gauche.so foreign/c/lib/gauche.so mv foreign-c-primitives-gauche.so foreign/c/lib/gauche.so
mv foreign-c-primitives-gauche.o foreign/c/lib/gauche.o mv foreign-c-primitives-gauche.o foreign/c/lib/gauche.o
guile:
@echo "Nothing to build for Guile"
kawa:
@echo "Nothing to build for Kawa"
mit-scheme:
@echo "Nothing to build for Kawa"
larceny:
@echo "Nothing to build for Larceny"
mosh:
@echo "Nothing to build for Mosh"
racket:
@echo "Nothing to build for Racket"
sagittarius:
@echo "Nothing to build for Sagittarius"
skint:
@echo "Nothing to build for Skint"
stklos:
@echo "Nothing to build for Stklos"
tr7:
@echo "Nothing to build for tr7"
ypsilon:
@echo "Nothing to build for Ypsilon"
clean: clean:
rm -rf ${TMPDIR} rm -rf ${TMPDIR}

View File

@ -185,21 +185,20 @@ You can test that library is found by your implementation like this:
### Manual system wide ### Manual system wide
Manual system wide installation requires snow-chibi for other implementations Manual system wide installation requires snow-chibi.
than Gauche.
Either download the latest release from Either download the latest release from
[https://git.sr.ht/~retropikzel/foreign-c/refs](https://git.sr.ht/~retropikzel/foreign-c/refs) [https://git.sr.ht/~retropikzel/foreign-c/refs](https://git.sr.ht/~retropikzel/foreign-c/refs)
or git clone, tag, and copy the _foreign_ directory to your or git clone, tag, and copy the _foreign_ directory to your
library directory. library directory.
Example installation for Gauche: Example for how to install for Gauche:
git clone https://git.sr.ht/~retropikzel/foreign-c
cd foreign-c
make SCHEME=gauche make SCHEME=gauche
make SCHEME=gauche install make SCHEME=gauche install
With most implementations the make command does not compile anything. When that
is the case it will say "Nothing to build on SCHEME\_IMPLEMENTATION\_NAME."
### Manual for project ### Manual for project
Either download the latest release from Either download the latest release from

View File

@ -1,6 +1,6 @@
ARG SCHEME=chibi ARG SCHEME=chibi
ARG IMAGE=chibi:head ARG IMAGE=chibi:head
FROM schemers/${IMAGE} FROM docker.io/schemers/${IMAGE}
RUN apt-get update && apt-get install \ RUN apt-get update && apt-get install \
--no-install-suggests \ --no-install-suggests \
--no-install-recommends \ --no-install-recommends \
@ -11,9 +11,14 @@ RUN apt-get update && apt-get install \
libffi-dev \ libffi-dev \
pandoc \ pandoc \
libmbedtls-dev \ libmbedtls-dev \
tree tree \
git \
ca-certificates
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
COPY --from=retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs #RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1
RUN git clone https://github.com/Retropikzel/chibi-scheme.git --branch gauche-fixes
RUN cd chibi-scheme && make && make install
COPY --from=docker.io/retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs
ENV PATH=/opt/compile-r7rs/bin:${PATH} ENV PATH=/opt/compile-r7rs/bin:${PATH}
ARG SCHEME=chibi ARG SCHEME=chibi
ENV COMPILE_R7RS=${SCHEME} ENV COMPILE_R7RS=${SCHEME}