From b6bd1451aa060596883c015e7ab646dec2aa0e23 Mon Sep 17 00:00:00 2001 From: retropikzel Date: Fri, 5 Sep 2025 10:01:26 +0300 Subject: [PATCH] Dockerfile fixes. Pass the arguments in linux interpreter scripts. --- Dockerfile | 14 +++++++------- Makefile | 14 +++----------- compile-r7rs.scm | 32 ++++++++++++++++++-------------- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 807934c..c34de87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,16 @@ RUN apt-get update && apt-get install -y \ pandoc \ chicken-bin \ libc-dev -RUN mkdir -p /opt/compile-r7rs -RUN mkdir -p /opt/compile-r7rs/bin -RUN mkdir -p /opt/compile-r7rs/lib RUN chicken-install r7rs -WORKDIR /builddir -COPY Makefile . -COPY compile-r7rs.scm . -COPY libs/ libs/ +WORKDIR /build RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1 RUN cd chibi-scheme && make -j 32 && make -j 32 install +ENV SCHEME=chicken +RUN snow-chibi --impls=${SCHEME} --always-yes install "(foreign c)" +RUN snow-chibi --impls=${SCHEME} --always-yes install "(srfi 170)" +COPY Makefile . +COPY compile-r7rs.scm . +COPY libs libs RUN make PREFIX=/opt/compile-r7rs build-chicken-static && make PREFIX=/opt/compile-r7rs install FROM debian:trixie-slim diff --git a/Makefile b/Makefile index 73fc3dc..0f31baa 100644 --- a/Makefile +++ b/Makefile @@ -9,18 +9,11 @@ endif all: build -container: - docker build -f Dockerfile.test --tag=compile-r7rs - -build: deps +build: echo "#!/bin/sh" > compile-r7rs echo "chibi-scheme -A ${PREFIX}/lib/compile-r7rs ${PREFIX}/lib/compile-r7rs/main.scm \"\$$@\"" >> compile-r7rs -build-chicken-static: deps - csc -R r7rs -X r7rs -I snow/foreign/c -static -c -J -unit foreign.c -o foreign.c.o deps/foreign-c/foreign/c.sld - ar rcs foreign.c.a foreign.c.o - csc -R r7rs -X r7rs -static -c -J -unit srfi-170 -o srfi-170.o deps/foreign-c-srfi-170/srfi/170.sld - ar rcs srfi-170.a srfi-170.o +build-chicken-static: csc -R r7rs -X r7rs -static -c -J -unit libs.util -o libs.util.o libs/util.sld ar rcs libs.util.a libs.util.o csc -R r7rs -X r7rs -static -c -J -unit libs.library-util -o libs.library-util.o libs/library-util.sld @@ -42,8 +35,7 @@ deps: git clone https://git.sr.ht/~retropikzel/foreign-c-srfi-170 deps/foreign-c-srfi-170 --depth=1 install: - cd deps/foreign-c && make all install - cd deps/foreign-c-srfi-170 && make all install + mkdir -p ${PREFIX}/bin mkdir -p ${PREFIX}/lib/compile-r7rs cp -r libs ${PREFIX}/lib/compile-r7rs/ cp compile-r7rs.scm ${PREFIX}/lib/compile-r7rs/main.scm diff --git a/compile-r7rs.scm b/compile-r7rs.scm index 65920e5..7f85a3b 100644 --- a/compile-r7rs.scm +++ b/compile-r7rs.scm @@ -196,8 +196,7 @@ prepend-directories append-directories library-files - r6rs?)) - (string #\newline))) + r6rs?)))) (define scheme-library-command (lambda (library-file) @@ -264,18 +263,23 @@ (display scheme-command) (newline) (with-output-to-file - (if (string=? compilation-target "windows") - (string-append output-file ".bat") - output-file) - (lambda () - (cond ((string=? compilation-target "unix") - (display "#!/bin/sh") - (newline)) - ((string=? compilation-target "windows") - (display "@echo off") - (newline) - (display "start"))) - (display scheme-command))) + (if (string=? compilation-target "windows") + (string-append output-file ".bat") + output-file) + (lambda () + (cond ((string=? compilation-target "unix") + (display "#!/bin/sh") + (newline)) + ((string=? compilation-target "windows") + (display "@echo off") + (newline) + (display "start"))) + (display scheme-command) + (cond ((string=? compilation-target "unix") + (display " \"") + (display "$@") + (display "\""))) + (newline))) (cond ((string=? compilation-target "unix") (c-system (string->c-utf8 (string-append "chmod +x " output-file))))))