Use compile-r7rs for testing. Create entries for all implementations in makefile.
This commit is contained in:
parent
21027259f7
commit
7ab8b1ab2b
|
|
@ -40,3 +40,4 @@ dockerfiles/build
|
||||||
core
|
core
|
||||||
testfile.test
|
testfile.test
|
||||||
tests/compliance
|
tests/compliance
|
||||||
|
tests/retropikzel
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
ARG COMPILE_R7RS=chibi
|
||||||
|
FROM debian:bookworm AS build
|
||||||
|
RUN apt-get update && apt-get install -y build-essential wget make cmake libgc-dev zlib1g-dev libffi-dev libssl-dev
|
||||||
|
RUN wget https://bitbucket.org/ktakashi/sagittarius-scheme/downloads/sagittarius-0.9.12.tar.gz && tar -xf sagittarius-0.9.12.tar.gz
|
||||||
|
RUN cd sagittarius-0.9.12 && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr/local-other .. && make && make install
|
||||||
|
|
||||||
|
FROM schemers/${COMPILE_R7RS}
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git make libffi8 libgc1 libssl3 libuv1 build-essential libffi-dev
|
||||||
|
COPY --from=build /usr/local-other/ /usr/local-other/
|
||||||
|
ENV PATH=${PATH}:/usr/local-other/bin
|
||||||
|
RUN git clone https://git.sr.ht/~retropikzel/compile-r7rs && cd compile-r7rs && make && make install
|
||||||
|
|
@ -1,21 +1,16 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent any
|
||||||
dockerfile {
|
|
||||||
filename 'dockerfiles/jenkins'
|
|
||||||
dir '.'
|
|
||||||
args '--user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options {
|
options {
|
||||||
|
disableConcurrentBuilds()
|
||||||
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
|
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Build test libraries') {
|
stage('Chibi') {
|
||||||
steps {
|
steps {
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||||
sh 'make libtest.so libtest.a'
|
sh 'make COMPILE_R7RS=chibi test-compile-r7rs-docker'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
134
Makefile
134
Makefile
|
|
@ -4,8 +4,6 @@ DOCKER=docker run -it -v ${PWD}:/workdir
|
||||||
DOCKER_INIT=cd /workdir && make clean &&
|
DOCKER_INIT=cd /workdir && make clean &&
|
||||||
VERSION=$(shell grep "version:" README.md | awk '{split\($0,a\); print a[2];}')
|
VERSION=$(shell grep "version:" README.md | awk '{split\($0,a\); print a[2];}')
|
||||||
|
|
||||||
all: chibi gauche tests/libtest.so libtest.o libtest.a
|
|
||||||
|
|
||||||
# apt-get install pandoc weasyprint
|
# apt-get install pandoc weasyprint
|
||||||
docs:
|
docs:
|
||||||
mkdir -p documentation
|
mkdir -p documentation
|
||||||
|
|
@ -19,44 +17,120 @@ docs:
|
||||||
README.md
|
README.md
|
||||||
|
|
||||||
chibi:
|
chibi:
|
||||||
make -C retropikzel/pffi chibi-pffi.so
|
make -C retropikzel/pffi chibi
|
||||||
|
|
||||||
|
chicken:
|
||||||
|
make -C retropikzel/pffi chicken
|
||||||
|
|
||||||
|
cyclone:
|
||||||
|
make -C retropikzel/pffi cyclone
|
||||||
|
|
||||||
|
gambit:
|
||||||
|
make -C retropikzel/pffi gambit
|
||||||
|
|
||||||
gauche:
|
gauche:
|
||||||
make -C retropikzel/pffi gauche-pffi.so
|
make -C retropikzel/pffi gauche
|
||||||
|
|
||||||
jenkinsfile:
|
gerbil:
|
||||||
gosh -r7 -I ./snow build.scm
|
make -C retropikzel/pffi gerbil
|
||||||
|
|
||||||
libtest.o: src/libtest.c
|
guile:
|
||||||
${CC} -o libtest.o -fPIC -c src/libtest.c -I./include
|
make -C retropikzel/pffi guile
|
||||||
|
|
||||||
tests/libtest.so: src/libtest.c
|
kawa:
|
||||||
${CC} -o tests/libtest.so -shared -fPIC src/libtest.c -I./include
|
make -C retropikzel/pffi kawa
|
||||||
|
|
||||||
libtest.a: libtest.o src/libtest.c
|
larceny:
|
||||||
ar rcs libtest.a libtest.o
|
make -C retropikzel/pffi larceny
|
||||||
|
|
||||||
test-interpreter-compliance: tests/libtest.so
|
mosh:
|
||||||
SCHEME=${SCHEME} script-r7rs -I . -I .. tests/compliance.scm
|
make -C retropikzel/pffi mosh
|
||||||
|
|
||||||
test-interpreter-compliance-docker:
|
racket:
|
||||||
docker build -f dockerfiles/test . --build-arg SCHEME=${SCHEME} --tag=pffi-${SCHEME}
|
make -C retropikzel/pffi racket
|
||||||
docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} script-r7rs -I . -I .. tests/compliance.scm"
|
|
||||||
|
|
||||||
test-compile-library: tests/libtest.so libtest.a libtest.o
|
sagittarius:
|
||||||
SCHEME=${SCHEME} compile-r7rs-library retropikzel/pffi.sld
|
make -C retropikzel/pffi sagittarius
|
||||||
|
|
||||||
test-compiler-compliance-compile: test-compile-library
|
skint:
|
||||||
SCHEME=${SCHEME} CFLAGS="-I./include -L." LDFLAGS="-ltest -L." compile-r7rs -I . tests/compliance.scm
|
make -C retropikzel/pffi skint
|
||||||
./tests/compliance
|
|
||||||
|
|
||||||
test-compiler-compliance: test-compiler-compliance-compile
|
stklos:
|
||||||
./tests/compliance
|
make -C retropikzel/pffi stklos
|
||||||
|
|
||||||
test-compiler-compliance-docker: tests/libtest.so libtest.a
|
tr7:
|
||||||
docker build -f dockerfiles/test . --build-arg SCHEME=${SCHEME} --tag=pffi-${SCHEME}
|
make -C retropikzel/pffi tr7
|
||||||
docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} compile-r7rs-library retropikzel/pffi.sld"
|
|
||||||
docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} compile-r7rs -I . compliance.scm && ./test"
|
ypsilon:
|
||||||
|
make -C retropikzel/pffi tr7
|
||||||
|
|
||||||
|
test-compile-r7rs: tmp/test/libtest.o tmp/test/libtest.so
|
||||||
|
make ${COMPILE_R7RS}
|
||||||
|
cp -r retropikzel tmp/test/
|
||||||
|
cp tests/compliance.scm tmp/test/
|
||||||
|
cp include/libtest.h tmp/test/
|
||||||
|
cd tmp/test && COMPILE_R7RS_CHICKEN="-L -ltest -I. -L." compile-r7rs -I . -o compliance compliance.scm
|
||||||
|
cd tmp/test && LD_LIBRARY_PATH=. ./compliance
|
||||||
|
|
||||||
|
test-compile-r7rs-docker:
|
||||||
|
docker build --build-arg COMPILE_R7RS=${COMPILE_R7RS} --tag=r7rs-pffi-test-${COMPILE_R7RS} .
|
||||||
|
docker run -v "${PWD}":/workdir -w /workdir -t r7rs-pffi-test-${COMPILE_R7RS} sh -c "make COMPILE_R7RS=${COMPILE_R7RS} test-compile-r7rs"
|
||||||
|
|
||||||
|
#chicken-objects:
|
||||||
|
#cd chicken/src && gcc -Os -fomit-frame-pointer -DHAVE_CHICKEN_CONFIG_H -c *.c -I../include
|
||||||
|
|
||||||
|
#test-chicken-c: libtest.o
|
||||||
|
#csc -R r7rs -X r7rs -t -J -I ./retropikzel retropikzel/pffi.sld -o retropikzel.pffi.c
|
||||||
|
#csc -R r7rs -X r7rs -t tests/compliance.scm -o tests/compliance.c
|
||||||
|
#gcc -Os -fomit-frame-pointer -DHAVE_CHICKEN_CONFIG_H -o tests/compliance chicken/src/*.o tests/compliance.c -ltest -L. -I./include -I./chicken/include
|
||||||
|
|
||||||
|
#test-chicken: libtest.o
|
||||||
|
#csc -R r7rs -X r7rs -c -J -I ./retropikzel retropikzel/pffi.sld -o retropikzel.pffi.o
|
||||||
|
#csc -v -R r7rs -X r7rs -static tests/compliance.scm -o tests/compliance -C -ltest -I./include
|
||||||
|
#csc -R r7rs -X r7rs -J -t -I ./retropikzel retropikzel/pffi.sld
|
||||||
|
#csc -R r7rs -X r7rs -uses retropikzel.pffi -static tests/compliance.scm -L -ltest -L. -I./include -L./retropikzel
|
||||||
|
#csc -R r7rs -X r7rs -t -I ./retropikzel retropikzel/pffi.sld -o retropikzel/pffi.c
|
||||||
|
#cp retropikzel/pffi.sld retropikzel.pffi.scm
|
||||||
|
#csc -J -t -I ./retropikzel retropikzel/pffi.sld -o retropikzel/pffi.c
|
||||||
|
#csc -R r7rs -X r7rs -t -I retropikzel retropikzel/pffi.sld tests/compliance.scm -optimize-level 3 -o tests/compliance.c
|
||||||
|
#csc -t tests/compliance.scm -o tests/compliance.c #-L -ltest -I./include -L. -L./tests
|
||||||
|
#./tests/compliance
|
||||||
|
|
||||||
|
#jenkinsfile:
|
||||||
|
#gosh -r7 -I ./snow build.scm
|
||||||
|
|
||||||
|
tmp/test/libtest.o: src/libtest.c
|
||||||
|
mkdir -p tmp/test
|
||||||
|
${CC} -o tmp/test/libtest.o -fPIC -c src/libtest.c -I./include
|
||||||
|
|
||||||
|
tmp/test/libtest.so: src/libtest.c
|
||||||
|
mkdir -p tmp/test
|
||||||
|
${CC} -o tmp/test/libtest.so -shared -fPIC src/libtest.c -I./include
|
||||||
|
|
||||||
|
tmp/test/libtest.a: tmp/test/libtest.o src/libtest.c
|
||||||
|
ar rcs tmp/test/libtest.a tmp/test/libtest.o
|
||||||
|
|
||||||
|
#test-interpreter-compliance: tests/libtest.so
|
||||||
|
#SCHEME=${SCHEME} script-r7rs -I . -I .. tests/compliance.scm
|
||||||
|
|
||||||
|
#test-interpreter-compliance-docker:
|
||||||
|
#docker build -f dockerfiles/test . --build-arg SCHEME=${SCHEME} --tag=pffi-${SCHEME}
|
||||||
|
#docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} script-r7rs -I . -I .. tests/compliance.scm"
|
||||||
|
|
||||||
|
#test-compile-library: tests/libtest.so libtest.a libtest.o
|
||||||
|
#SCHEME=${SCHEME} compile-r7rs-library retropikzel/pffi.sld
|
||||||
|
|
||||||
|
#test-compiler-compliance-compile: test-compile-library
|
||||||
|
#SCHEME=${SCHEME} CFLAGS="-I./include -L." LDFLAGS="-ltest -L." compile-r7rs -I . tests/compliance.scm
|
||||||
|
#./tests/compliance
|
||||||
|
|
||||||
|
#test-compiler-compliance: test-compiler-compliance-compile
|
||||||
|
#./tests/compliance
|
||||||
|
|
||||||
|
#test-compiler-compliance-docker: tests/libtest.so libtest.a
|
||||||
|
#docker build -f dockerfiles/test . --build-arg SCHEME=${SCHEME} --tag=pffi-${SCHEME}
|
||||||
|
#docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} compile-r7rs-library retropikzel/pffi.sld"
|
||||||
|
#docker run -v ${PWD}:/workdir pffi-${SCHEME} bash -c "cd /workdir && SCHEME=${SCHEME} compile-r7rs -I . compliance.scm && ./test"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf retropikzel/pffi/*.o*
|
@rm -rf retropikzel/pffi/*.o*
|
||||||
|
|
@ -79,7 +153,9 @@ clean:
|
||||||
find . -name "core.1" -delete
|
find . -name "core.1" -delete
|
||||||
find . -name "*@gambit*" -delete
|
find . -name "*@gambit*" -delete
|
||||||
rm -rf retropikzel/pffi.c
|
rm -rf retropikzel/pffi.c
|
||||||
rm -rf tests/compliance.c
|
rm -rf tests/compliance.c*
|
||||||
rm -rf tests/compliance.o
|
rm -rf tests/compliance.o
|
||||||
rm -rf tests/compliance.so
|
rm -rf tests/compliance.so
|
||||||
rm -rf tests/compliance
|
rm -rf tests/compliance
|
||||||
|
rm -rf tests/retropikzel.*.import.scm
|
||||||
|
rm -rf tmp
|
||||||
|
|
|
||||||
92
README.md
92
README.md
|
|
@ -30,17 +30,21 @@ conforming to some specification.
|
||||||
- [Primitives](#feature-implementation-table-primitives)
|
- [Primitives](#feature-implementation-table-primitives)
|
||||||
- [Built upon](#feature-implementation-table-built-upon)
|
- [Built upon](#feature-implementation-table-built-upon)
|
||||||
- [Documentation](#documentation)
|
- [Documentation](#documentation)
|
||||||
- [Installation](#installation)
|
|
||||||
- [Compiling the library](#compiling-the-library)
|
|
||||||
- [Chibi](#compiling-the-library-chibi)
|
|
||||||
- [Gauche](#compiling-the-library-gauche)
|
|
||||||
- [Dependencies](#dependencies)
|
- [Dependencies](#dependencies)
|
||||||
- [Chibi](#dependencies-chibi)
|
- [Chibi](#dependencies-chibi)
|
||||||
|
- [Chicken](#dependencies-chicken)
|
||||||
- [Gauche](#dependencies-gauche)
|
- [Gauche](#dependencies-gauche)
|
||||||
- [Racket](#dependencies-racket)
|
- [Racket](#dependencies-racket)
|
||||||
- [Kawa](#dependencies-kawa)
|
- [Kawa](#dependencies-kawa)
|
||||||
|
- [Installation](#installation)
|
||||||
|
- [Project local](#installation-project-local)
|
||||||
|
- [Linux](#installation-project-local-linux)
|
||||||
|
- [Windows](#installation-project-local-windows)
|
||||||
|
- [System global](#installation-system-global)
|
||||||
- [Reference](#reference)
|
- [Reference](#reference)
|
||||||
- [Types](#types)
|
- [Types](#types)
|
||||||
|
- [Environment variables](#environment-variables)
|
||||||
|
- [PFFI\_LOAD\_PATH](#environment-variables-pffi-load-path)
|
||||||
- [Procedures and macros](#procedures-and-macros)
|
- [Procedures and macros](#procedures-and-macros)
|
||||||
- [pffi-init](#pffi-init)
|
- [pffi-init](#pffi-init)
|
||||||
- [pffi-size-of](#pffi-size-of)
|
- [pffi-size-of](#pffi-size-of)
|
||||||
|
|
@ -194,31 +198,7 @@ and work, they should work too.
|
||||||
## Documentation
|
## Documentation
|
||||||
<a name="documentation"></a>
|
<a name="documentation"></a>
|
||||||
|
|
||||||
### Installation
|
### Dependencies
|
||||||
<a name="installation"></a>
|
|
||||||
|
|
||||||
Download the latest release from
|
|
||||||
[https://git.sr.ht/~retropikzel/r7rs-pffi/refs](https://git.sr.ht/~retropikzel/r7rs-pffi/refs).
|
|
||||||
|
|
||||||
Unpack it somewhere and copy the directory called "retropikzel" to your projects
|
|
||||||
library directory. For the rest of this documentation it is assumed to be ./snow.
|
|
||||||
|
|
||||||
#### Compiling the libary
|
|
||||||
<a name="compiling-the-library"></a>
|
|
||||||
Some implementations need extra step of compiling the library. Change directory
|
|
||||||
to ./snow/retropikzel/pffi and run command corresponding to your implementation.
|
|
||||||
|
|
||||||
##### Chibi
|
|
||||||
<a name="compiling-the-library-chibi"></a>
|
|
||||||
|
|
||||||
make -C ./snow/retropikzel/pffi chibi-pffi.so
|
|
||||||
|
|
||||||
##### Gauche
|
|
||||||
<a name="compiling-the-library-gauche"></a>
|
|
||||||
|
|
||||||
make -C ./snow/retropikzel/pffi gauche-pffi.so
|
|
||||||
|
|
||||||
#### Dependencies
|
|
||||||
<a name="dependencies"></a>
|
<a name="dependencies"></a>
|
||||||
|
|
||||||
Some implementations have extra dependencies/requirements beyond just the
|
Some implementations have extra dependencies/requirements beyond just the
|
||||||
|
|
@ -233,6 +213,13 @@ Debian/Ubuntu/Mint install with:
|
||||||
|
|
||||||
apt install libffi-dev
|
apt install libffi-dev
|
||||||
|
|
||||||
|
#### Chicken
|
||||||
|
<a name="dependencies-chicken"></a>
|
||||||
|
|
||||||
|
Chicken needs r7rs egg installed. Install it with:
|
||||||
|
|
||||||
|
chicken-install r7rs
|
||||||
|
|
||||||
#### Gauche
|
#### Gauche
|
||||||
<a name="dependencies-gauche"></a>
|
<a name="dependencies-gauche"></a>
|
||||||
|
|
||||||
|
|
@ -259,6 +246,37 @@ Kawa Needs at least Java version 22 and jvm flags:
|
||||||
- \--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED
|
- \--add-exports java.base/jdk.internal.foreign=ALL-UNNAMED
|
||||||
- \--enable-native-access=ALL-UNNAMED
|
- \--enable-native-access=ALL-UNNAMED
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
<a name="installation"></a>
|
||||||
|
|
||||||
|
Since the project is under active development is best to clone it from git,
|
||||||
|
|
||||||
|
### Project local
|
||||||
|
<a name="installation-project-local"></a>
|
||||||
|
|
||||||
|
#### Linux
|
||||||
|
<a name="installation-project-local-linux"></a>
|
||||||
|
Assuming you have a project and your libraries live in directory called snow
|
||||||
|
in it:
|
||||||
|
|
||||||
|
git clone https://git.sr.ht/~retropikzel/r7rs-pffi
|
||||||
|
mkdir -p snow
|
||||||
|
cp -r r7rs-pffi/retropikzel snow/
|
||||||
|
cd snow/retropikzel/pffi
|
||||||
|
make <SCHEME>
|
||||||
|
|
||||||
|
#### Windows
|
||||||
|
<a name="installation-project-local-windows"></a>
|
||||||
|
|
||||||
|
There is no build scripts yet for Windows, that said many implementations work
|
||||||
|
without compiling anything. If you run this and it says "There is notching to
|
||||||
|
build for SCHEME" then you should be good to go.
|
||||||
|
|
||||||
|
### System global
|
||||||
|
<a name="installation-system-global"></a>
|
||||||
|
|
||||||
|
Still work in progress.
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
<a name="reference"></a>
|
<a name="reference"></a>
|
||||||
|
|
||||||
|
|
@ -289,6 +307,22 @@ Types are given as symbols, for example 'int8 or 'pointer.
|
||||||
- callback
|
- callback
|
||||||
- Callback function
|
- Callback function
|
||||||
|
|
||||||
|
### Types
|
||||||
|
<a name="types"></a>
|
||||||
|
|
||||||
|
### Environment variables
|
||||||
|
<a name="environment-variables"></a>
|
||||||
|
|
||||||
|
Setting environment variables like this on Windows works for this library:
|
||||||
|
|
||||||
|
set "PFFI_LOAD_PATH=C:\Program Files (x86)/foo/bar"
|
||||||
|
|
||||||
|
#### PFFI\_LOAD\_PATH
|
||||||
|
<a name="environment-variables-pffi-load-path"></a>
|
||||||
|
|
||||||
|
To add more paths to where pffi looks for libraries set PFFI\_LOAD\_PATH to
|
||||||
|
paths separated by ; on windows, and : on other operating systems.
|
||||||
|
|
||||||
### Procedures and macros
|
### Procedures and macros
|
||||||
<a name="procedures-and-macros"></a>
|
<a name="procedures-and-macros"></a>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@
|
||||||
(scheme process-context)
|
(scheme process-context)
|
||||||
(rnrs bytevectors)
|
(rnrs bytevectors)
|
||||||
(system foreign)
|
(system foreign)
|
||||||
(system foreign-library)))
|
(system foreign-library)
|
||||||
|
(only (guile) include-from-path)))
|
||||||
(kawa
|
(kawa
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
|
|
@ -133,8 +134,7 @@
|
||||||
(scheme process-context)
|
(scheme process-context)
|
||||||
(ypsilon c-ffi)
|
(ypsilon c-ffi)
|
||||||
(ypsilon c-types)
|
(ypsilon c-types)
|
||||||
(only (core) define-macro syntax-case)))
|
(only (core) define-macro syntax-case))))
|
||||||
(else (error "Unsupported implementation")))
|
|
||||||
(export pffi-init
|
(export pffi-init
|
||||||
pffi-size-of
|
pffi-size-of
|
||||||
pffi-type?
|
pffi-type?
|
||||||
|
|
@ -167,7 +167,8 @@
|
||||||
pffi-define-callback)
|
pffi-define-callback)
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(chibi (include "pffi/chibi.scm"))
|
(chibi (include "pffi/chibi.scm"))
|
||||||
(chicken (include-relative "pffi/chicken.scm"))
|
(chicken-5 (include "pffi/chicken.scm"))
|
||||||
|
(chicken-6 (include-relative "pffi/chicken.scm"))
|
||||||
(cyclone (include "pffi/cyclone.scm"))
|
(cyclone (include "pffi/cyclone.scm"))
|
||||||
(gambit (include "pffi/gambit.scm"))
|
(gambit (include "pffi/gambit.scm"))
|
||||||
(gauche (include "pffi/gauche.scm"))
|
(gauche (include "pffi/gauche.scm"))
|
||||||
|
|
@ -183,7 +184,12 @@
|
||||||
(tr7 (include "pffi/tr7.scm"))
|
(tr7 (include "pffi/tr7.scm"))
|
||||||
(ypsilon (include "pffi/ypsilon.scm")))
|
(ypsilon (include "pffi/ypsilon.scm")))
|
||||||
;(include "pffi/shared/union.scm")
|
;(include "pffi/shared/union.scm")
|
||||||
(include "pffi/shared/main.scm")
|
(cond-expand
|
||||||
|
(chicken-6 (include-relative "pffi/shared/main.scm")
|
||||||
|
(include-relative "pffi/shared/pointer.scm")
|
||||||
|
(include-relative "pffi/shared/array.scm")
|
||||||
|
(include-relative "pffi/shared/struct.scm"))
|
||||||
|
(else (include "pffi/shared/main.scm")
|
||||||
(include "pffi/shared/pointer.scm")
|
(include "pffi/shared/pointer.scm")
|
||||||
(include "pffi/shared/array.scm")
|
(include "pffi/shared/array.scm")
|
||||||
(include "pffi/shared/struct.scm"))
|
(include "pffi/shared/struct.scm"))))
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,55 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
|
||||||
chibi-pffi.so: chibi/pffi.stub
|
chibi: chibi-src/pffi.stub
|
||||||
chibi-ffi chibi/pffi.stub
|
chibi-ffi chibi-src/pffi.stub
|
||||||
${CC} -g3 -o chibi-pffi.so chibi/pffi.c -fPIC -lffi -shared
|
${CC} -g3 -o chibi-pffi.so chibi-src/pffi.c -fPIC -lffi -shared
|
||||||
|
|
||||||
gauche-pffi.so:
|
chicken:
|
||||||
|
@echo "Nothing to build for Chicken"
|
||||||
|
|
||||||
|
cyclone:
|
||||||
|
@echo "Nothing to build for Cyclone"
|
||||||
|
|
||||||
|
gambit:
|
||||||
|
@echo "Nothing to build for Gambit"
|
||||||
|
|
||||||
|
gauche: gauche-src/gauche-pffi.c gauche-src/gauchelib.scm
|
||||||
gauche-package compile \
|
gauche-package compile \
|
||||||
--srcdir=gauche \
|
--srcdir=gauche-src \
|
||||||
--cc=${CC} \
|
--cc=${CC} \
|
||||||
--cflags="-I./include" \
|
--cflags="-I./include" \
|
||||||
--libs=-lffi \
|
--libs=-lffi \
|
||||||
gauche-pffi gauche-pffi.c gauchelib.scm
|
gauche-pffi gauche-pffi.c gauchelib.scm
|
||||||
|
|
||||||
|
gerbil:
|
||||||
|
@echo "Nothing to build for Gerbil"
|
||||||
|
|
||||||
|
guile:
|
||||||
|
@echo "Nothing to build for Guile"
|
||||||
|
|
||||||
|
kawa:
|
||||||
|
@echo "Nothing to build for Kawa"
|
||||||
|
|
||||||
|
larceny:
|
||||||
|
@echo "Nothing to build for Larceny"
|
||||||
|
|
||||||
|
mosh:
|
||||||
|
@echo "Nothing to build for Mosh"
|
||||||
|
|
||||||
|
racket:
|
||||||
|
@echo "Nothing to build for Racket"
|
||||||
|
|
||||||
|
sagittarius:
|
||||||
|
@echo "Nothing to build for Sagittarius"
|
||||||
|
|
||||||
|
skint:
|
||||||
|
@echo "Nothing to build for Skint"
|
||||||
|
|
||||||
|
stklos:
|
||||||
|
@echo "Nothing to build for Stklos"
|
||||||
|
|
||||||
|
tr7:
|
||||||
|
@echo "Nothing to build for tr7"
|
||||||
|
|
||||||
|
ypsilon:
|
||||||
|
@echo "Nothing to build for Ypsilon"
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
(native-type (sizeof native-type))
|
(native-type (sizeof native-type))
|
||||||
(else #f)))))
|
(else #f)))))
|
||||||
|
|
||||||
(define pffi-pointer-allocate
|
#;(define pffi-pointer-allocate
|
||||||
(lambda (size)
|
(lambda (size)
|
||||||
(bytevector->pointer (make-bytevector size 0))))
|
(bytevector->pointer (make-bytevector size 0))))
|
||||||
|
|
||||||
|
|
@ -74,10 +74,10 @@
|
||||||
(pointer->string pointer)))
|
(pointer->string pointer)))
|
||||||
|
|
||||||
(define pffi-shared-object-load
|
(define pffi-shared-object-load
|
||||||
(lambda (header path . options)
|
(lambda (path options)
|
||||||
(load-foreign-library path)))
|
(load-foreign-library path)))
|
||||||
|
|
||||||
(define pffi-pointer-free
|
#;(define pffi-pointer-free
|
||||||
(lambda (pointer)
|
(lambda (pointer)
|
||||||
#t))
|
#t))
|
||||||
|
|
||||||
|
|
@ -132,6 +132,6 @@
|
||||||
((equal? type 'pointer) (make-pointer (bytevector-sint-ref p offset (native-endianness) (size-of-type type))))
|
((equal? type 'pointer) (make-pointer (bytevector-sint-ref p offset (native-endianness) (size-of-type type))))
|
||||||
((equal? type 'string) (pffi-pointer->string (make-pointer (bytevector-sint-ref p offset (native-endianness) (size-of-type type)))))))))
|
((equal? type 'string) (pffi-pointer->string (make-pointer (bytevector-sint-ref p offset (native-endianness) (size-of-type type)))))))))
|
||||||
|
|
||||||
(define pffi-struct-dereference
|
#;(define pffi-struct-dereference
|
||||||
(lambda (struct)
|
(lambda (struct)
|
||||||
(dereference-pointer (pffi-struct-pointer struct))))
|
(dereference-pointer (pffi-struct-pointer struct))))
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,9 @@
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(windows
|
(windows
|
||||||
(append
|
(append
|
||||||
|
(if (get-environment-variable "PFFI_LOAD_PATH")
|
||||||
|
(string-split (get-environment-variable "PFFI_LOAD_PATH") #\;)
|
||||||
|
(list))
|
||||||
(if (get-environment-variable "SYSTEM")
|
(if (get-environment-variable "SYSTEM")
|
||||||
(list (get-environment-variable "SYSTEM"))
|
(list (get-environment-variable "SYSTEM"))
|
||||||
(list))
|
(list))
|
||||||
|
|
@ -148,6 +151,9 @@
|
||||||
(list))))
|
(list))))
|
||||||
(else
|
(else
|
||||||
(append
|
(append
|
||||||
|
(if (get-environment-variable "PFFI_LOAD_PATH")
|
||||||
|
(string-split (get-environment-variable "PFFI_LOAD_PATH") #\:)
|
||||||
|
(list))
|
||||||
; Guix
|
; Guix
|
||||||
(list (if (get-environment-variable "GUIX_ENVIRONMENT")
|
(list (if (get-environment-variable "GUIX_ENVIRONMENT")
|
||||||
(string-append (get-environment-variable "GUIX_ENVIRONMENT") slash "lib")
|
(string-append (get-environment-variable "GUIX_ENVIRONMENT") slash "lib")
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
(chibi #t) ; FIXME
|
(chibi #t) ; FIXME
|
||||||
(else (pffi-define pffi-pointer-allocate pffi-libc-stdlib 'malloc 'pointer '(int))))
|
(else (pffi-define pffi-pointer-allocate pffi-libc-stdlib 'malloc 'pointer '(int))))
|
||||||
|
|
||||||
(pffi-define pffi-pointer-allocate-aligned pffi-libc-stdlib 'aligned_alloc 'pointer '(int int))
|
;(pffi-define pffi-pointer-allocate-aligned pffi-libc-stdlib 'aligned_alloc 'pointer '(int int))
|
||||||
(pffi-define pffi-pointer-allocate-calloc pffi-libc-stdlib 'calloc 'pointer '(int int))
|
(pffi-define pffi-pointer-allocate-calloc pffi-libc-stdlib 'calloc 'pointer '(int int))
|
||||||
|
|
||||||
(cond-expand
|
(cond-expand
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
(define round-to-next-modulo-of
|
(define round-to-next-modulo-of
|
||||||
(lambda (to-round roundee)
|
(lambda (to-round roundee)
|
||||||
(if (= (floor-remainder to-round roundee) 0)
|
(if (= (modulo to-round roundee) 0)
|
||||||
to-round
|
to-round
|
||||||
(round-to-next-modulo-of (+ to-round 1) roundee))))
|
(round-to-next-modulo-of (+ to-round 1) roundee))))
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@
|
||||||
(when (> (size-of-type type) largest-member-size)
|
(when (> (size-of-type type) largest-member-size)
|
||||||
(set! largest-member-size (size-of-type type)))
|
(set! largest-member-size (size-of-type type)))
|
||||||
(if (or (= size 0)
|
(if (or (= size 0)
|
||||||
(= (floor-remainder size type-alignment) 0))
|
(= (modulo size type-alignment) 0))
|
||||||
(begin
|
(begin
|
||||||
(set! size (+ size type-alignment))
|
(set! size (+ size type-alignment))
|
||||||
(list name type (- size type-alignment)))
|
(list name type (- size type-alignment)))
|
||||||
|
|
|
||||||
|
|
@ -922,25 +922,25 @@
|
||||||
|
|
||||||
;; pffi-struct-dereference 1
|
;; pffi-struct-dereference 1
|
||||||
|
|
||||||
(print-header "pffi-struct-dereference 1")
|
;(print-header "pffi-struct-dereference 1")
|
||||||
(pffi-define c-color-check-by-value c-testlib 'color_check_by_value 'int '((struct . color)))
|
;(pffi-define c-color-check-by-value c-testlib 'color_check_by_value 'int '((struct . color)))
|
||||||
(pffi-define-struct make-struct-color 'color '((int8 . r)
|
#;(pffi-define-struct make-struct-color 'color '((int8 . r)
|
||||||
(int8 . g)
|
(int8 . g)
|
||||||
(int8 . b)
|
(int8 . b)
|
||||||
(int8 . a)))
|
(int8 . a)))
|
||||||
(define struct-color (make-struct-color))
|
;(define struct-color (make-struct-color))
|
||||||
(debug (pffi-struct-set! struct-color 'r 100))
|
;(debug (pffi-struct-set! struct-color 'r 100))
|
||||||
(debug (pffi-struct-set! struct-color 'g 101))
|
;(debug (pffi-struct-set! struct-color 'g 101))
|
||||||
(debug (pffi-struct-set! struct-color 'b 102))
|
;(debug (pffi-struct-set! struct-color 'b 102))
|
||||||
(debug (pffi-struct-set! struct-color 'a 103))
|
;(debug (pffi-struct-set! struct-color 'a 103))
|
||||||
(assert = (c-color-check-by-value (pffi-struct-dereference struct-color)) 0)
|
;(assert = (c-color-check-by-value (pffi-struct-dereference struct-color)) 0)
|
||||||
|
|
||||||
(exit 0)
|
(exit 0)
|
||||||
|
|
||||||
(print-header "pffi-struct-dereference 2")
|
;(print-header "pffi-struct-dereference 2")
|
||||||
|
|
||||||
(pffi-define c-test-check-by-value c-testlib 'test_check_by_value 'int '((struct . test)))
|
;(pffi-define c-test-check-by-value c-testlib 'test_check_by_value 'int '((struct . test)))
|
||||||
(pffi-define-struct make-struct-test-dereference2
|
#;(pffi-define-struct make-struct-test-dereference2
|
||||||
'test
|
'test
|
||||||
'((int8 . a)
|
'((int8 . a)
|
||||||
(char . b)
|
(char . b)
|
||||||
|
|
@ -956,36 +956,36 @@
|
||||||
(int . l)
|
(int . l)
|
||||||
(double . m)
|
(double . m)
|
||||||
(float . n)))
|
(float . n)))
|
||||||
(define struct-test3 (make-struct-test-dereference2))
|
;(define struct-test3 (make-struct-test-dereference2))
|
||||||
(debug (pffi-struct-set! struct-test3 'a 1))
|
;(debug (pffi-struct-set! struct-test3 'a 1))
|
||||||
(debug (pffi-struct-set! struct-test3 'b #\b))
|
;(debug (pffi-struct-set! struct-test3 'b #\b))
|
||||||
(debug (pffi-struct-set! struct-test3 'c 3.0))
|
;(debug (pffi-struct-set! struct-test3 'c 3.0))
|
||||||
(debug (pffi-struct-set! struct-test3 'd #\d))
|
;(debug (pffi-struct-set! struct-test3 'd #\d))
|
||||||
(debug (pffi-struct-set! struct-test3 'e (pffi-pointer-null)))
|
;(debug (pffi-struct-set! struct-test3 'e (pffi-pointer-null)))
|
||||||
(debug (pffi-struct-set! struct-test3 'f 6.0))
|
;(debug (pffi-struct-set! struct-test3 'f 6.0))
|
||||||
(debug (pffi-struct-set! struct-test3 'g (pffi-string->pointer "foo")))
|
;(debug (pffi-struct-set! struct-test3 'g (pffi-string->pointer "foo")))
|
||||||
(debug (pffi-struct-set! struct-test3 'h 8))
|
;(debug (pffi-struct-set! struct-test3 'h 8))
|
||||||
(debug (pffi-struct-set! struct-test3 'i (pffi-pointer-null)))
|
;(debug (pffi-struct-set! struct-test3 'i (pffi-pointer-null)))
|
||||||
(debug (pffi-struct-set! struct-test3 'j 10))
|
;(debug (pffi-struct-set! struct-test3 'j 10))
|
||||||
(debug (pffi-struct-set! struct-test3 'k 11))
|
;(debug (pffi-struct-set! struct-test3 'k 11))
|
||||||
(debug (pffi-struct-set! struct-test3 'l 12))
|
;(debug (pffi-struct-set! struct-test3 'l 12))
|
||||||
(debug (pffi-struct-set! struct-test3 'm 13.0))
|
;(debug (pffi-struct-set! struct-test3 'm 13.0))
|
||||||
(debug (pffi-struct-set! struct-test3 'n 14.0))
|
;(debug (pffi-struct-set! struct-test3 'n 14.0))
|
||||||
(debug (pffi-struct-get struct-test3 'a))
|
;(debug (pffi-struct-get struct-test3 'a))
|
||||||
(debug (pffi-struct-get struct-test3 'b))
|
;(debug (pffi-struct-get struct-test3 'b))
|
||||||
(debug (pffi-struct-get struct-test3 'c))
|
;(debug (pffi-struct-get struct-test3 'c))
|
||||||
(debug (pffi-struct-get struct-test3 'd))
|
;(debug (pffi-struct-get struct-test3 'd))
|
||||||
(debug (pffi-struct-get struct-test3 'e))
|
;(debug (pffi-struct-get struct-test3 'e))
|
||||||
(debug (pffi-struct-get struct-test3 'f))
|
;(debug (pffi-struct-get struct-test3 'f))
|
||||||
(debug (pffi-struct-get struct-test3 'g))
|
;(debug (pffi-struct-get struct-test3 'g))
|
||||||
(debug (pffi-struct-get struct-test3 'h))
|
;(debug (pffi-struct-get struct-test3 'h))
|
||||||
(debug (pffi-struct-get struct-test3 'i))
|
;(debug (pffi-struct-get struct-test3 'i))
|
||||||
(debug (pffi-struct-get struct-test3 'j))
|
;(debug (pffi-struct-get struct-test3 'j))
|
||||||
(debug (pffi-struct-get struct-test3 'k))
|
;(debug (pffi-struct-get struct-test3 'k))
|
||||||
(debug (pffi-struct-get struct-test3 'l))
|
;(debug (pffi-struct-get struct-test3 'l))
|
||||||
(debug (pffi-struct-get struct-test3 'm))
|
;(debug (pffi-struct-get struct-test3 'm))
|
||||||
(debug (pffi-struct-get struct-test3 'n))
|
;(debug (pffi-struct-get struct-test3 'n))
|
||||||
(c-test-check-by-value (pffi-struct-dereference struct-test3))
|
;(c-test-check-by-value (pffi-struct-dereference struct-test3))
|
||||||
|
|
||||||
;; pffi-define-callback
|
;; pffi-define-callback
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue