Compare commits

..

No commits in common. "main" and "chicken-6" have entirely different histories.

5 changed files with 28 additions and 71 deletions

View File

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

View File

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

View File

@ -2,10 +2,6 @@ PREFIX=/usr/local
SCHEME=chibi
R6RSTMP=tmp/${SCHEME}-r6rs
R7RSTMP=tmp/${SCHEME}-r7rs
DOCKERIMG=${SCHEME}
ifeq "${SCHEME}" "chicken"
DOCKERIMG="chicken:5"
endif
all: build
@ -16,26 +12,6 @@ build: deps
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
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:
mkdir -p deps
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)
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"
test-r7rs:
@ -74,10 +50,10 @@ test-r7rs:
mkdir -p ${R7RSTMP}/libs
mkdir -p ${R7RSTMP}/libs/foo
mkdir -p ${R7RSTMP}/libs/hello
echo "(import (scheme base) (foo bar) (hello world) (srfi 9001)) (baz) (hello-world) (over-9000)" > ${R7RSTMP}/main.scm
echo "(import (scheme base) (foo bar) (hello world) (srfi 9001)) (baz) (hello-word) (over-9000)" > ${R7RSTMP}/main.scm
echo "(define baz (lambda () (display \"Test successfull\") (newline)))" > ${R7RSTMP}/libs/foo/bar.scm
echo "(define-library (foo bar) (import (scheme base) (scheme write) (hello world)) (export baz) (include \"bar.scm\"))" > ${R7RSTMP}/libs/foo/bar.sld
echo "(define hello-world (lambda () (+ 1 1)))" > ${R7RSTMP}/libs/hello/world.scm
echo "(define hello-world (lambda () (+ 1 1)))" > ${R7RSTMP}/libs/hello/world.scm
echo "(define-library (hello world) (import (scheme base) (scheme write)) (export hello-world) (include \"world.scm\"))" > ${R7RSTMP}/libs/hello/world.sld
mkdir -p ${R7RSTMP}/libs/srfi
echo "(define over-9000 (lambda () (+ 1 1)))" > ${R7RSTMP}/libs/srfi/9001.scm
@ -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)
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"
clean:

View File

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

View File

@ -56,19 +56,16 @@
(string-replace (string-cut-from-end library-file 4) #\/ #\-)
(string-replace (string-cut-from-end library-file 4) #\/ #\.))
".a")))
(apply string-append `("csc -R r7rs -X r7rs"
(apply string-append `("csc -static -c -J"
" "
,(util-getenv "COMPILE_R7RS_CHICKEN")
" -static -c -J -o "
" "
"-o"
" "
,out
" "
,(search-library-file (append prepend-directories append-directories) library-file)
" "
,@(map (lambda (item)
(string-append "-I " item " "))
(append append-directories
prepend-directories))
" "
"-unit"
" "
,unit
@ -83,7 +80,7 @@
" "
,out)))))
(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")
" "