From b0184ac4f7af9b02e0a2aefb2ede8e34b935ec53 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Sun, 21 Sep 2025 18:36:10 +0300 Subject: [PATCH] Backup --- .gitignore | 1 + Dockerfile.test | 15 ++++++++------- Makefile | 36 ++++++++++++++++++------------------ primitives | 2 ++ test.scm | 11 +++++++++++ 5 files changed, 40 insertions(+), 25 deletions(-) create mode 100755 primitives create mode 100644 test.scm diff --git a/.gitignore b/.gitignore index 2fce631..15732c5 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ README.html *.tar.gz foreign/c/primitives/chibi/foreign-c.c *.pdf +.* diff --git a/Dockerfile.test b/Dockerfile.test index ee6029a..5e46b7f 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -2,23 +2,24 @@ ARG SCHEME=chibi ARG IMAGE=chibi:head FROM schemers/${IMAGE} FROM debian:trixie AS build -WORKDIR /debs +WORKDIR /cache/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 + gcc libffi-dev libc-dev make linux-libc-dev +RUN cp -r /var/cache/apt/archives/*.deb . ARG SCHEME=chibi ARG IMAGE=chibi:head FROM schemers/${IMAGE} -COPY --from=build /var/cache/apt/archives/*.deb /debs/ -RUN dpkg -i /debs/*.deb +COPY --from=build /cache /cache +WORKDIR /cache/debs +RUN dpkg -i *.deb COPY --from=retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs -ENV PATH=${PATH}:/opt/compile-r7rs/bin:/build/usr/bin +RUN /opt/compile-r7rs/bin/install-docker +WORKDIR / ARG SCHEME=chibi ENV COMPILE_R7RS=${SCHEME} -ENV GUILE_AUTO_COMPILE=0 -RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm diff --git a/Makefile b/Makefile index edabbe0..7ac92e5 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,8 @@ -.PHONY: libtest.o tests/libtest.so libtest.a documentation README.html foreign-c.pdf -PDFENGINE=weasyprint -VERSION=0.10.6 -TEST=primitives +.PHONY: libtest.o tests/libtest.so libtest.a documentation README.html SCHEME=chibi -TMPDIR=tmp/${SCHEME} -SNOW_CHIBI_ARGS="" -DOCKERIMG=${SCHEME}:head +VERSION=0.10.6 CC=gcc - -ifeq "${SCHEME}" "chicken" -DOCKERIMG="chicken:5" -endif +TMPDIR=.tmp/ all: package @@ -23,6 +15,11 @@ package: README.html --description="Portable foreign function interface for R7RS Schemes" \ foreign/c.sld +README.html: README.md + echo "
" > README.html
+	cat README.md >> README.html
+	echo "
" >> README.html + install: package snow-chibi --impls=${SCHEME} ${SNOW_CHIBI_ARGS} install foreign-c-${VERSION}.tgz; \ if [ "${SCHEME}" = "gauche" ]; then \ @@ -35,15 +32,21 @@ install: package uninstall: snow-chibi --impls=${SCHEME} remove "(foreign c)" -test: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a +test-old: ${TMPDIR}/test/libtest.o ${TMPDIR}/test/libtest.so ${TMPDIR}/test/libtest.a cp -r foreign ${TMPDIR}/test/ cp tests/*.scm ${TMPDIR}/test/ cp tests/c-include/libtest.h ${TMPDIR}/test/ cd ${TMPDIR}/test && \ COMPILE_R7RS_CHICKEN="-L -ltest -I. -L." \ - COMPILE_R7RS=${SCHEME} \ - compile-r7rs -o ${TEST} ${TEST}.scm - cd ${TMPDIR}/test \ && printf "\n" | LD_LIBRARY_PATH=. ./${TEST} + COMPILE_R7RS=${SCHEME} timeout 600 compile-r7rs -o ${TEST} ${TEST}.scm + cd ${TMPDIR}/test && printf "\n" | LD_LIBRARY_PATH=. timeout 600 ./${TEST} + +test: + rm -rf ${TMPDIR} + mkdir -p ${TMPDIR} + cp test.scm ${TMPDIR}/ + cp -r foreign ${TMPDIR}/ + cd ${TMPDIR} && COMPILE_R7RS="${SCHEME}" test-r7rs -I . -o test test.scm test-docker: docker build --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=foreign-c-test-${SCHEME} -f Dockerfile.test . @@ -64,9 +67,6 @@ ${TMPDIR}/test/libtest.a: ${TMPDIR}/test/libtest.o tests/c-src/libtest.c ${TMPDIR}: mkdir -p ${TMPDIR} -README.html: README.md - cmark README.md > README.html - chibi: foreign/c/primitives/chibi/foreign-c.stub chibi-ffi foreign/c/primitives/chibi/foreign-c.stub ${CC} \ diff --git a/primitives b/primitives new file mode 100755 index 0000000..9a15c4f --- /dev/null +++ b/primitives @@ -0,0 +1,2 @@ +#!/bin/sh +ypsilon --r7rs --mute --quiet --sitelib=. --top-level-program primitives.scm "$@" diff --git a/test.scm b/test.scm new file mode 100644 index 0000000..dc7d776 --- /dev/null +++ b/test.scm @@ -0,0 +1,11 @@ +(import (scheme base) + (scheme write) + (foreign c) + (srfi 64)) + +(test-begin "Foreign-c") + +(test-assert (number? (c-type-size 'int8))) +(test-assert(= (c-type-size 'int8) 1)) + +(test-end "Foreign-c")