diff --git a/Jenkinsfile b/Jenkinsfile index d40d546..4a729f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ pipeline { 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=${implementation} foreign-c-0.10.0.tgz && cp tests/hello.scm /tmp/ && cd /tmp && COMPILE_R7RS=${implementation} compile-r7rs -o hello hello.scm && ./hello\"" + sh "docker run -v ${WORKSPACE}:/workdir -w /workdir -t r7rs-pffi-test-${implementation} sh -c \"make snow-chibi-install COMPILE_R7RS=${implementation} && cp tests/hello.scm /tmp/ && cd /tmp && COMPILE_R7RS=${implementation} compile-r7rs -o hello hello.scm && ./hello\"" } } } diff --git a/Makefile b/Makefile index cf3dcaf..45f6799 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ DOCKER_INIT=cd /workdir && make clean && VERSION=$(shell awk '/version:/{ print $$2 }' README.md ) TESTNAME=primitives -package: docs +package: documentation snow-chibi package \ --version=${VERSION} \ --authors="Retropikzel" \ @@ -14,6 +14,9 @@ package: docs --description="Portable foreign function interface for R7RS Schemes" \ foreign/c.sld +snow-chibi-install: clean-package package + snow-chibi --impls=${COMPILE_R7RS} install foreign-c-${VERSION}.tgz + clean-package: rm -rf *.tgz @@ -32,11 +35,17 @@ test-compile-r7rs: tmp/test/libtest.o tmp/test/libtest.so tmp/test/libtest.a cp tests/*.scm tmp/test/ cp tests/c-include/libtest.h tmp/test/ cd tmp/test && \ - COMPILE_R7RS_GAMBIT="-cc-options \"-ltest -I. -L\" -ld-options \"-L.\"" \ COMPILE_R7RS_CHICKEN="-L -static -L -ltest -I. -L." \ compile-r7rs -I . -o ${TESTNAME} ${TESTNAME}.scm cd tmp/test && ./${TESTNAME} +test-compile-r7rs-snow: tmp/test/libtest.o tmp/test/libtest.so tmp/test/libtest.a + cp tests/*.scm tmp/test/ + cp tests/c-include/libtest.h tmp/test/ + cd tmp/test && \ + compile-r7rs -o hello hello.scm + cd tmp/test && ./hello + test-compile-r7rs-wine: cp -r foreign tmp/test/ cp tests/*.scm tmp/test/ @@ -65,7 +74,7 @@ tmp/test/libtest.a: tmp/test/libtest.o tests/c-src/libtest.c documentation/foreign-c.html: # apt-get install pandoc weasyprint -docs: +documentation: README.md mkdir -p documentation pandoc --standalone \ --template templates/documentation.html README.md \ diff --git a/README.md b/README.md index 45d6ced..a1e3001 100644 --- a/README.md +++ b/README.md @@ -144,17 +144,31 @@ Required versions: ## Installation +### Snow-fort + +[https://snow-fort.org/](https://snow-fort.org/) + +Installable with snow-chibi for following implementations. + +- Chibi +- Kawa +- STklos + +### Manul + Either download the latest release from [https://git.sr.ht/~retropikzel/foreign-c/refs](https://git.sr.ht/~retropikzel/foreign-c/refs) -or git clone, preferably with a tag, and copy the _foreign_ directory to your +or git clone, tag, and copy the _foreign_ directory to your library directory. Example assuming libraries in directory _snow_: git clone https://git.sr.ht/~retropikzel/foreign-c --branch LATEST_VERSION + cd foreign-c + make SCHEME_IMPLEMENTATION_NAME + cd .. mkdir -p snow cp -r foreign-c/foreign snow/ - make -C snow/foreign/c SCHEME_IMPLEMENTATION_NAME With most implementations the make command does not compile anything. When that is the case it will say "Nothing to build on SCHEME\_IMPLEMENTATION\_NAME." diff --git a/documentation/foreign-c.html b/documentation/foreign-c.html index 7d21b37..c1c293e 100644 --- a/documentation/foreign-c.html +++ b/documentation/foreign-c.html @@ -366,15 +366,28 @@ Schemes - 0.10.0

Installation

+

Snow-fort

+

https://snow-fort.org/

+

Installable with snow-chibi for following + implementations.

+ +

Manul

Either download the latest release from https://git.sr.ht/~retropikzel/foreign-c/refs - or git clone, preferably with a tag, and copy the - foreign directory to your library directory.

+ or git clone, tag, and copy the foreign directory to + your library directory.

Example assuming libraries in directory snow:

git clone https://git.sr.ht/~retropikzel/foreign-c --branch LATEST_VERSION
+cd foreign-c
+make SCHEME_IMPLEMENTATION_NAME
+cd ..
 mkdir -p snow
-cp -r foreign-c/foreign snow/
-make -C snow/foreign/c SCHEME_IMPLEMENTATION_NAME
+cp -r foreign-c/foreign snow/

With most implementations the make command does not compile anything. When that is the case it will say “Nothing to build on SCHEME_IMPLEMENTATION_NAME.”

diff --git a/documentation/foreign-c.pdf b/documentation/foreign-c.pdf index b99ec83..dada921 100644 Binary files a/documentation/foreign-c.pdf and b/documentation/foreign-c.pdf differ diff --git a/foreign/c.sld b/foreign/c.sld index 444c287..121c725 100644 --- a/foreign/c.sld +++ b/foreign/c.sld @@ -201,7 +201,7 @@ c-bytevector->bytevector ;;;; Utilities - libc + libc-name ;; TODO endianness native-endianness @@ -314,7 +314,7 @@ (gambit (include "c/primitives/gambit.scm")) (gauche (include "c/primitives/gauche/define-c-procedure.scm")) ;(gerbil (include "c/primitives/gerbil.scm")) - (guile (include "c/primitives/guile.scm")) + (guile (include "./c/primitives/guile.scm")) (kawa (include "c/primitives/kawa.scm")) (mit-scheme (include "c/primitives/mit-scheme.scm")) ;(larceny (include "c/primitives/larceny.scm")) diff --git a/foreign/c/libc.scm b/foreign/c/libc.scm index 45cc695..27ec05f 100644 --- a/foreign/c/libc.scm +++ b/foreign/c/libc.scm @@ -1,14 +1,7 @@ (cond-expand (windows - (define-c-library libc - '("stdlib.h" "stdio.h" "string.h") - "ucrtbase" - '())) + (define libc-name "ucrtbase")) (else - (define c-library "c") - (when (get-environment-variable "BE_HOST_CPU") - (set! c-library "root")) - (define-c-library libc - '("stdlib.h" "stdio.h" "string.h") - "c" - '((additional-versions ("0" "6")))))) + (define libc-name + (cond ((get-environment-variable "BE_HOST_CPU") "root") ; Haiku + (else "c"))))) diff --git a/foreign/c/pointer.scm b/foreign/c/pointer.scm index bbb95cc..edbaaaa 100644 --- a/foreign/c/pointer.scm +++ b/foreign/c/pointer.scm @@ -1,3 +1,8 @@ +(define-c-library libc + '("stdlib.h" "stdio.h" "string.h") + libc-name + '((additional-versions ("0" "6")))) + (define-c-procedure c-calloc libc 'calloc 'pointer '(int int)) (cond-expand (gambit diff --git a/tests/hello.scm b/tests/hello.scm index dc3b997..219700c 100644 --- a/tests/hello.scm +++ b/tests/hello.scm @@ -2,6 +2,11 @@ (scheme write) (foreign c)) +(define-c-library libc + '("stdlib.h" "stdio.h" "string.h") + libc-name + '((additional-versions ("0" "6")))) + (define-c-procedure c-puts libc 'puts 'int '(pointer)) (c-puts (string->c-utf8 "Hello from C!")) diff --git a/tests/primitives.scm b/tests/primitives.scm index ea57c5a..dc513bf 100644 --- a/tests/primitives.scm +++ b/tests/primitives.scm @@ -5,6 +5,16 @@ (scheme process-context) (foreign c)) + +(display "libc-name:" ) +(display libc-name) +(newline) + +(define-c-library libc + '("stdlib.h" "stdio.h" "string.h") + libc-name + '((additional-versions ("0" "6")))) + ;; util (define header-count 1)