Compare commits

..

5 Commits

Author SHA1 Message Date
retropikzel 1a66611949 Backup 2025-07-19 18:05:56 +03:00
retropikzel 468b50f90a Fixing dependency reading 2025-07-19 10:35:07 +03:00
retropikzel e946c3408f Fixing dependency reading 2025-07-18 22:52:42 +03:00
retropikzel 958dcdd8a1 Fixing dependency reading 2025-07-18 22:42:21 +03:00
retropikzel d07356cd86 Fixing dependency reading 2025-07-18 22:38:23 +03:00
8 changed files with 35 additions and 71 deletions

View File

@ -1,23 +1,12 @@
FROM schemers/chibi:head AS build FROM schemers/chibi:head
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
build-essential \ build-essential ca-certificates git make libffi-dev
ca-certificates \ RUN git clone https://github.com/ashinn/chibi-scheme.git --depth=1 \
git \ && cd chibi-scheme && make -j 16 && make -j 16 install
make \
libffi-dev \
pandoc \
chicken-bin
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 WORKDIR /builddir
COPY Makefile . COPY Makefile .
COPY compile-r7rs.scm . COPY compile-r7rs.scm .
COPY libs/ libs/ COPY libs/ libs/
RUN make PREFIX=/opt/compile-r7rs build-chicken-static && make PREFIX=/opt/compile-r7rs install RUN make && make install
WORKDIR /workdir
FROM debian:bookworm-slim RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
COPY --from=build /opt/compile-r7rs /opt/compile-r7rs
ENV PATH=/opt/compile-r7rs/bin:${PATH}

View File

@ -1,6 +1,5 @@
ARG SCHEME=chibi ARG SCHEME=chibi
ARG IMAGE=chibi:head FROM schemers/${SCHEME}:head
FROM schemers/${IMAGE}
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
build-essential \ build-essential \
make \ make \

View File

@ -2,10 +2,6 @@ PREFIX=/usr/local
SCHEME=chibi SCHEME=chibi
R6RSTMP=tmp/${SCHEME}-r6rs R6RSTMP=tmp/${SCHEME}-r6rs
R7RSTMP=tmp/${SCHEME}-r7rs R7RSTMP=tmp/${SCHEME}-r7rs
DOCKERIMG=${SCHEME}
ifeq "${SCHEME}" "chicken"
DOCKERIMG="chicken:5"
endif
all: build all: build
@ -16,26 +12,6 @@ build: deps
echo "#!/bin/sh" > compile-r7rs echo "#!/bin/sh" > compile-r7rs
echo "chibi-scheme -A ${PREFIX}/lib/compile-r7rs ${PREFIX}/lib/compile-r7rs/main.scm \"\$$@\"" >> 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
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
ar rcs libs.library-util.a libs.library-util.o
csc -R r7rs -X r7rs -static -c -J -unit libs.data -o libs.data.o libs/data.sld
ar rcs libs.data.a libs.data.o
csc -R r7rs -X r7rs -static \
-o compile-r7rs \
-uses libs.util \
-uses libs.library-util \
-uses libs.data \
-uses foreign.c \
-uses srfi-170 \
compile-r7rs.scm
deps: deps:
mkdir -p deps mkdir -p deps
git clone https://git.sr.ht/~retropikzel/foreign-c deps/foreign-c --depth=1 git clone https://git.sr.ht/~retropikzel/foreign-c deps/foreign-c --depth=1
@ -65,7 +41,7 @@ test-r6rs:
@grep "Test successfull" ${R6RSTMP}/compile-r7rs-test-result.txt || (echo "Test failed, output: " && cat ${R6RSTMP}/compile-r7rs-test-result.txt && exit 1) @grep "Test successfull" ${R6RSTMP}/compile-r7rs-test-result.txt || (echo "Test failed, output: " && cat ${R6RSTMP}/compile-r7rs-test-result.txt && exit 1)
test-r6rs-docker: test-r6rs-docker:
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} . docker build -f Dockerfile.test --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} .
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make && make install && make SCHEME=${SCHEME} test-r6rs" docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make && make install && make SCHEME=${SCHEME} test-r6rs"
test-r7rs: test-r7rs:
@ -87,7 +63,7 @@ test-r7rs:
@grep "Test successfull" ${R7RSTMP}/compile-r7rs-test-result.txt || (echo "Test failed, output: " && cat ${R7RSTMP}/compile-r7rs-test-result.txt && exit 1) @grep "Test successfull" ${R7RSTMP}/compile-r7rs-test-result.txt || (echo "Test failed, output: " && cat ${R7RSTMP}/compile-r7rs-test-result.txt && exit 1)
test-r7rs-docker: test-r7rs-docker:
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} . docker build -f Dockerfile.test --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} .
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make && make install && make SCHEME=${SCHEME} test-r7rs" docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make && make install && make SCHEME=${SCHEME} test-r7rs"
clean: clean:

View File

@ -294,25 +294,21 @@ tried to compile them in wrong order you would run:
## Usage with Docker ## Usage with Docker
<a name="#usage-with-docker"></a> <a name="#usage-with-docker"></a>
The project has Here is a sample Dockerfile to get you started.
[docker image](https://hub.docker.com/repository/docker/retropikzel1/compile-r7rs/general).
It is statically built with Chicken scheme and installed under /opt/compile-r7rs, ARG COMPILE_R7RS=chibi
so it can be copied in your Dockerfile. FROM schemers/${COMPILE_R7RS}
RUN apt-get update && apt-get install -y make git chicken-bin
Here is a sample Dockerfile to get you started: RUN chicken-install r7rs
ARG COMPILE_R7RS=chibi
ARG SCHEME=chibi ENV COMPILE_R7RS=${COMPILE_R7RS}
FROM schemers/${SCHEME} RUN git clone https://git.sr.ht/~retropikzel/compile-r7rs && cd compile-r7rs && make && make install
COPY --from=retropikzel1/compile-r7rs /opt/compile-r7rs /opt/compile-r7rs
ENV PATH=/opt/compile-r7rs/bin:${PATH}
ENV COMPILE_R7RS=${SCHEME}
To use this run: To use this run:
docker build --build-arg SCHEME=${SCHEME} --tag=sometag . export COMPILE_R7RS=<your scheme>
docker run -v "${PWD}":/workdir -w /workdir -t sometag sh -c "compile-r7rs -I . -o main ./snow main.scm" docker build --build-arg COMPILE_R7RS=${COMPILE_R7RS} --tag=compile-r7rs-${COMPILE_R7RS} .
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-${COMPILE_R7RS} sh -c "compile-r7rs -I -o main ./snow main.scm"
## Usual RnRS projects ## Usual RnRS projects
<a name="#usual-rnrs-projects"></a> <a name="#usual-rnrs-projects"></a>

View File

@ -3,6 +3,7 @@
(scheme read) (scheme read)
(scheme write) (scheme write)
(scheme process-context) (scheme process-context)
(scheme cxr)
(foreign c) (foreign c)
(libs util) (libs util)
(libs data) (libs data)

View File

@ -56,7 +56,7 @@
(string-replace (string-cut-from-end library-file 4) #\/ #\-) (string-replace (string-cut-from-end library-file 4) #\/ #\-)
(string-replace (string-cut-from-end library-file 4) #\/ #\.)) (string-replace (string-cut-from-end library-file 4) #\/ #\.))
".a"))) ".a")))
(apply string-append `("csc -R r7rs -X r7rs" (apply string-append `("csc"
" " " "
,(util-getenv "COMPILE_R7RS_CHICKEN") ,(util-getenv "COMPILE_R7RS_CHICKEN")
" -static -c -J -o " " -static -c -J -o "
@ -83,7 +83,7 @@
" " " "
,out))))) ,out)))))
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?) (command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
(apply string-append `("csc -R r7rs -X r7rs" (apply string-append `("csc"
" " " "
,(util-getenv "COMPILE_R7RS_CHICKEN") ,(util-getenv "COMPILE_R7RS_CHICKEN")
" " " "

View File

@ -22,6 +22,7 @@
(car dependencies)))) (car dependencies))))
(cdr dependencies))))) (cdr dependencies)))))
(define library-name->path (define library-name->path
(lambda (name) (lambda (name)
(string-append (string-append

View File

@ -4,6 +4,8 @@
(scheme read) (scheme read)
(scheme write) (scheme write)
(scheme file) (scheme file)
(scheme cxr)
(scheme process-context)
(libs util)) (libs util))
(export library-dependencies) (export library-dependencies)
(include "library-util.scm")) (include "library-util.scm"))