From 1752e4a8fc9d7c61bff08c24be8c0955a2012e0e Mon Sep 17 00:00:00 2001 From: retropikzel Date: Wed, 25 Jun 2025 06:18:28 +0300 Subject: [PATCH] Adding more Jenkins tests --- Jenkinsfile | 8 ++- Makefile | 65 +++++++++++++++++++ .../Dockerfile.jenkins | 0 .../Dockerfile.test | 0 .../Dockerfiles.snow-chibi-install-test | 24 +++++++ foreign/c/libc.scm | 13 ++-- tests/hello.scm | 29 +-------- 7 files changed, 103 insertions(+), 36 deletions(-) rename Dockerfile.jenkins => dockerfiles/Dockerfile.jenkins (100%) rename Dockerfile.test => dockerfiles/Dockerfile.test (100%) create mode 100644 dockerfiles/Dockerfiles.snow-chibi-install-test diff --git a/Jenkinsfile b/Jenkinsfile index 8fd0e8c..6820b90 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,11 +18,17 @@ pipeline { tests.each { test -> stage("${implementation} ${test}") { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - sh "docker build --build-arg COMPILE_R7RS=${implementation} --tag=r7rs-pffi-test-${implementation} -f Dockerfile.test ." + sh "docker build --build-arg COMPILE_R7RS=${implementation} --tag=r7rs-pffi-test-${implementation} -f dockerfiles/Dockerfile.test ." sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t r7rs-pffi-test-${implementation} sh -c \"make COMPILE_R7RS=${implementation} TESTNAME=primitives test-compile-r7rs\"" } } } + stage("${implementation} snow-chibi install test") { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + sh "docker build --build-arg COMPILE_R7RS=${implementation} --tag=r7rs-pffi-test-${implementation} -f dockerfiles/Dockerfile.snow-chibi-install-test ." + sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t r7rs-pffi-test-${implementation} sh -c \"make clean-package package && snow-chibi install --impls=foreign-c-0.10.0.tgz && ${implementation} tests/hello.scm\"" + } + } } } } diff --git a/Makefile b/Makefile index 8b883f4..80e3eb0 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ package: --version=${VERSION} \ --authors="Retropikzel" \ --doc=README.html \ + --foreign-depends=ffi \ --description="Portable foreign function interface for R7RS Schemes" \ foreign/c.sld @@ -89,6 +90,69 @@ docs: -o documentation/foreign-c.pdf \ README.md +chibi: foreign/c/primitives/chibi/foreign-c.stub + chibi-ffi foreign/c/primitives/chibi/foreign-c.stub + ${CC} \ + -g3 \ + -o foreign/c/primitives/chibi/foreign-c.so \ + foreign/c/primitives/chibi/foreign-c.c \ + -fPIC \ + -lffi \ + -shared + +chicken: + @echo "Nothing to build for Chicken" + +cyclone: + @echo "Nothing to build for Cyclone" + +gambit: + @echo "Nothing to build for Gambit" + +gauche: primitives/gauche/foreign-c-primitives-gauche.c primitives/gauche/gauchelib.scm + gauche-package compile \ + --srcdir=primitives/gauche \ + --cc=${CC} \ + --cflags="-I./primitives/include" \ + --libs=-lffi \ + foreign-c-primitives-gauche foreign-c-primitives-gauche.c gauchelib.scm + mkdir -p lib + mv foreign-c-primitives-gauche.so lib/gauche.so + mv foreign-c-primitives-gauche.o lib/gauche.o + +gerbil: + @echo "Nothing to build for Gerbil" + +guile: + @echo "Nothing to build for Guile" + +kawa: + @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: find . -name "*.meta" -delete find . -name "*.link" -delete @@ -100,3 +164,4 @@ clean: find . -name "core.1" -delete find . -name "*@gambit*" -delete rm -rf tmp + rm foreign/c/primitives/chibi/foreign-c.c diff --git a/Dockerfile.jenkins b/dockerfiles/Dockerfile.jenkins similarity index 100% rename from Dockerfile.jenkins rename to dockerfiles/Dockerfile.jenkins diff --git a/Dockerfile.test b/dockerfiles/Dockerfile.test similarity index 100% rename from Dockerfile.test rename to dockerfiles/Dockerfile.test diff --git a/dockerfiles/Dockerfiles.snow-chibi-install-test b/dockerfiles/Dockerfiles.snow-chibi-install-test new file mode 100644 index 0000000..e9b73bc --- /dev/null +++ b/dockerfiles/Dockerfiles.snow-chibi-install-test @@ -0,0 +1,24 @@ +ARG COMPILE_R7RS=chibi +FROM debian:bookworm AS build +RUN apt-get update && apt-get install -y wget build-essential make git +RUN git clone https://github.com/Retropikzel/chibi-scheme.git --branch=snow-chibi-foreign-depends +RUN cd chibi-scheme && make PREFIX=/usr/local-other && make PREFIX=/usr/local-other install + +FROM schemers/${COMPILE_R7RS} +RUN apt-get update && apt-get install -y \ + build-essential \ + git \ + make \ + libffi8 \ + libgc1 \ + libssl3 \ + libuv1 \ + build-essential \ + libffi-dev \ + libmbedtls-dev +COPY --from=build /usr/local-other /usr/local-other +RUN rm -rf /usr/local/bin/snow-chibi +ENV PATH=${PATH}:/usr/local-other/bin +RUN git clone https://gitea.scheme.org/Retropikzel/compile-r7rs.git --depth=1 +RUN cd compile-r7rs && make && make install + diff --git a/foreign/c/libc.scm b/foreign/c/libc.scm index 8c80ac4..0cc1b4f 100644 --- a/foreign/c/libc.scm +++ b/foreign/c/libc.scm @@ -1,13 +1,10 @@ (cond-expand - (windows (define-c-library libc - '("stdio.h" "string.h") - "ucrtbase" - '((additional-versions ("0" "6"))))) + (windows (define-c-library libc '("stdio.h" "string.h") "ucrtbase" '())) (else - (define c-library "c") - (when (get-environment-variable "BE_HOST_CPU") + ;(define c-library "c") + #;(when (get-environment-variable "BE_HOST_CPU") (set! c-library "root")) (define-c-library libc '("stdio.h" "string.h") - c-library - '((additional-versions ("" "0" "6" "7")))))) + "c" + '((additional-versions ("0" "6")))))) diff --git a/tests/hello.scm b/tests/hello.scm index 02d72be..b8a1374 100644 --- a/tests/hello.scm +++ b/tests/hello.scm @@ -2,31 +2,6 @@ (scheme write) (foreign c)) - -(cond-expand - (windows (define-c-library c-stdlib - '("stdlib.h") - "ucrtbase" - '())) - (else (define-c-library c-stdlib - '("stdlib.h") - "c" - '((additional-versions ("6")))))) - -(define-c-procedure c-system c-stdlib 'system 'int '(pointer)) - -(define (anything->string item) - (parameterize - ((current-output-port (open-output-string))) - (display item) - (get-output-string (current-output-port)))) - -(define (system command) - (c-system (string->c-utf8 - (apply string-append - (map (lambda (item) - (string-append (anything->string item) " ")) - command))))) - -(system '(ls)) +(define-c-procedure c-puts libc 'puts 'int '(pointer)) +(c-puts "Hello from C!")