diff --git a/Dockerfile.test b/Dockerfile.test index b79be3a..ee6029a 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,22 +1,24 @@ ARG SCHEME=chibi ARG IMAGE=chibi:head -FROM docker.io/debian:trixie-slim AS local-chibi -RUN apt-get update && apt-get install -y git ca-certificates make gcc libc-dev -#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 --depth=1 -RUN cd chibi-scheme && make DESTDIR=/opt/chibi -j16 && make DESTDIR=/opt/chibi -j16 install +FROM schemers/${IMAGE} +FROM debian:trixie AS build +WORKDIR /debs +RUN apt-get update && apt-get install \ + -y \ + --no-install-recommends \ + --no-install-suggests \ + --download-only \ + gcc libffi-dev libc-dev cmark make linux-libc-dev ARG SCHEME=chibi ARG IMAGE=chibi:head -FROM docker.io/schemers/${IMAGE} -RUN apt-get update && apt-get install -y make gcc markdown libffi-dev -COPY --from=local-chibi /opt/chibi /opt/chibi -COPY --from=docker.io/retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs +FROM schemers/${IMAGE} +COPY --from=build /var/cache/apt/archives/*.deb /debs/ +RUN dpkg -i /debs/*.deb +COPY --from=retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs +ENV PATH=${PATH}:/opt/compile-r7rs/bin:/build/usr/bin ARG SCHEME=chibi ENV COMPILE_R7RS=${SCHEME} ENV GUILE_AUTO_COMPILE=0 RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm -ENV CHIBI_MODULE_PATH=/opt/chibi/usr/local/share/chibi:/opt/chibi/usr/local/lib/chibi -ENV LD_LIBRARY_PATH=/opt/chibi/usr/local/lib:/opt/chibi/usr/local/lib/chibi -ENV PATH=/opt/compile-r7rs/bin:/opt/chibi/usr/local/bin:${PATH} diff --git a/Jenkinsfile b/Jenkinsfile index 219b153..12d4ee6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ def tests = ['primitives', 'array', 'struct', 'addressof', 'callback'] pipeline { agent { - label 'linux' + label 'docker-x86_64' } options { @@ -11,6 +11,11 @@ pipeline { } stages { + + stage('Cache warmup') { + sh "docker build --build-arg IMAGE=chibi:head --build-arg SCHEME=chibi --tag=foreign-c-test-chibi -f Dockerfile.test ." + } + stage('Tests') { steps { script { diff --git a/Makefile b/Makefile index 99f003c..edabbe0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ .PHONY: libtest.o tests/libtest.so libtest.a documentation README.html foreign-c.pdf PDFENGINE=weasyprint -CC=gcc VERSION=0.10.6 TEST=primitives SCHEME=chibi TMPDIR=tmp/${SCHEME} SNOW_CHIBI_ARGS="" DOCKERIMG=${SCHEME}:head +CC=gcc + ifeq "${SCHEME}" "chicken" DOCKERIMG="chicken:5" endif @@ -42,32 +43,34 @@ test: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest. COMPILE_R7RS_CHICKEN="-L -ltest -I. -L." \ COMPILE_R7RS=${SCHEME} \ compile-r7rs -o ${TEST} ${TEST}.scm - cd ${TMPDIR}/test \ && timeout 60 printf "\n" | LD_LIBRARY_PATH=. ./${TEST} + cd ${TMPDIR}/test \ && printf "\n" | LD_LIBRARY_PATH=. ./${TEST} test-docker: docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f Dockerfile.test . - docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh -c "make SCHEME=${SCHEME} TEST=${TEST} SNOW_CHIBI_ARGS=--always-yes install test" + docker run -it -v "${PWD}:/workdir" -w /workdir -t foreign-c-test-${SCHEME} sh -c \ + "timeout 120 make SCHEME=${SCHEME} TEST=${TEST} SNOW_CHIBI_ARGS=--always-yes install test" ${TMPDIR}/test/libtest.o: tests/c-src/libtest.c mkdir -p ${TMPDIR}/test - ${CC} -o ${TMPDIR}/test/libtest.o -fPIC -c tests/c-src/libtest.c -I./include + ${CC} ${CFLAGS} -o ${TMPDIR}/test/libtest.o -fPIC -c tests/c-src/libtest.c -I./include ${LDFLAGS} ${TMPDIR}/test/libtest.so: tests/c-src/libtest.c mkdir -p ${TMPDIR}/test - ${CC} -o ${TMPDIR}/test/libtest.so -shared -fPIC tests/c-src/libtest.c -I./include + ${CC} ${CFLAGS} -o ${TMPDIR}/test/libtest.so -shared -fPIC tests/c-src/libtest.c -I./include ${LDFLAGS} ${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 ${LDFLAGS} ${TMPDIR}: mkdir -p ${TMPDIR} README.html: README.md - markdown README.md > README.html + cmark README.md > README.html chibi: foreign/c/primitives/chibi/foreign-c.stub chibi-ffi foreign/c/primitives/chibi/foreign-c.stub ${CC} \ + ${CFLAGS} \ -g3 \ -o foreign/c/primitives/chibi/foreign-c.so \ foreign/c/primitives/chibi/foreign-c.c \ @@ -79,7 +82,7 @@ gauche: gauche-package compile \ --srcdir=foreign/c/primitives/gauche \ --cc=${CC} \ - --cflags="-I.foreign/c/primitives/gauche" \ + --cflags="${CFLAGS} -I.foreign/c/primitives/gauche" \ --libs=-lffi \ foreign-c-primitives-gauche foreign-c-primitives-gauche.c gauchelib.scm mkdir -p foreign/c/lib diff --git a/README.md b/README.md index b992103..2a86ad2 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ library directory. Example for how to install for Gauche: + apt-get install libffi-dev git clone https://git.sr.ht/~retropikzel/foreign-c cd foreign-c make SCHEME=gauche