Compare commits
No commits in common. "main" and "chicken-6" have entirely different histories.
25
Dockerfile
25
Dockerfile
|
@ -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}
|
|
||||||
|
|
|
@ -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 \
|
||||||
|
|
32
Makefile
32
Makefile
|
@ -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:
|
||||||
|
@ -74,10 +50,10 @@ test-r7rs:
|
||||||
mkdir -p ${R7RSTMP}/libs
|
mkdir -p ${R7RSTMP}/libs
|
||||||
mkdir -p ${R7RSTMP}/libs/foo
|
mkdir -p ${R7RSTMP}/libs/foo
|
||||||
mkdir -p ${R7RSTMP}/libs/hello
|
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 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-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
|
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
|
mkdir -p ${R7RSTMP}/libs/srfi
|
||||||
echo "(define over-9000 (lambda () (+ 1 1)))" > ${R7RSTMP}/libs/srfi/9001.scm
|
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)
|
@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:
|
||||||
|
|
26
README.md
26
README.md
|
@ -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>
|
||||||
|
|
|
@ -56,19 +56,16 @@
|
||||||
(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 -static -c -J"
|
||||||
" "
|
" "
|
||||||
,(util-getenv "COMPILE_R7RS_CHICKEN")
|
,(util-getenv "COMPILE_R7RS_CHICKEN")
|
||||||
" -static -c -J -o "
|
" "
|
||||||
|
"-o"
|
||||||
|
" "
|
||||||
,out
|
,out
|
||||||
" "
|
" "
|
||||||
,(search-library-file (append prepend-directories append-directories) library-file)
|
,(search-library-file (append prepend-directories append-directories) library-file)
|
||||||
" "
|
" "
|
||||||
,@(map (lambda (item)
|
|
||||||
(string-append "-I " item " "))
|
|
||||||
(append append-directories
|
|
||||||
prepend-directories))
|
|
||||||
" "
|
|
||||||
"-unit"
|
"-unit"
|
||||||
" "
|
" "
|
||||||
,unit
|
,unit
|
||||||
|
@ -83,7 +80,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")
|
||||||
" "
|
" "
|
||||||
|
|
Loading…
Reference in New Issue