Compare commits
No commits in common. "a94e179efbb0c1d594c6ecdfcd1ccbb5cb687fb7" and "0e4e8890c4af74db133c1ed381e4be9e6fc86dfb" have entirely different histories.
a94e179efb
...
0e4e8890c4
|
|
@ -17,4 +17,3 @@ deps
|
|||
tmp
|
||||
deb
|
||||
*.deb
|
||||
test-result.txt
|
||||
|
|
|
|||
|
|
@ -10,14 +10,11 @@ RUN make
|
|||
ARG SCHEME=chibi
|
||||
ARG IMAGE=chibi:head
|
||||
FROM schemers/${IMAGE}
|
||||
RUN apt-get update && apt-get install -y \
|
||||
--no-install-recommends \
|
||||
build-essential libffi-dev unzip php libreadline-dev
|
||||
RUN apt-get update && apt-get install -y make gcc libffi-dev unzip
|
||||
COPY --from=cache /cache /cache
|
||||
WORKDIR /cache/chibi-scheme
|
||||
RUN make install
|
||||
WORKDIR /
|
||||
RUN mkdir -p ${HOME}/.snow && echo "()" > ${HOME}/.snow/config.scm
|
||||
RUN snow-chibi install --always-yes "(foreign c)"
|
||||
RUN snow-chibi install --always-yes "(srfi 170)"
|
||||
COPY Makefile .
|
||||
|
|
|
|||
45
Makefile
45
Makefile
|
|
@ -3,7 +3,6 @@ SCHEME=chibi
|
|||
VERSION=1.0.0
|
||||
R6RSTMP=tmp/${SCHEME}-r6rs
|
||||
R7RSTMP=tmp/${SCHEME}-r7rs
|
||||
DOCKERTAG=compile-r7rs-test-${SCHEME}
|
||||
DOCKERIMG=${SCHEME}:head
|
||||
ifeq "${SCHEME}" "chicken"
|
||||
DOCKERIMG="chicken:5"
|
||||
|
|
@ -96,20 +95,8 @@ test-r6rs:
|
|||
@grep "Test successfull (\"1\" \"2\" \"3\")" ${R6RSTMP}/test-result.txt || (echo "Test failed, output: " && cat ${R6RSTMP}/test-result.txt && exit 1)
|
||||
|
||||
test-r6rs-docker:
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=${DOCKERTAG} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} test-r6rs"
|
||||
|
||||
test-r6rs-php:
|
||||
rm -rf ${R6RSTMP}
|
||||
mkdir -p ${R6RSTMP}
|
||||
cp -r r6rs-php-testfiles/* ${R6RSTMP}/
|
||||
cd ${R6RSTMP} && COMPILE_R7RS=${SCHEME} COMPILE_R7RS_TARGET=php compile-r7rs -o main.php main.sps
|
||||
-cd ${R6RSTMP} && php main.php > test-result.txt 2>&1
|
||||
@grep "Test successfull" ${R6RSTMP}/test-result.txt || (echo "Test failed, output: " && cat ${R6RSTMP}/test-result.txt && exit 1)
|
||||
|
||||
test-r6rs-php-docker:
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=${DOCKERTAG} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} test-r6rs-php"
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make SCHEME=${SCHEME} test-r6rs"
|
||||
|
||||
test-r7rs:
|
||||
rm -rf ${R7RSTMP}
|
||||
|
|
@ -120,32 +107,8 @@ test-r7rs:
|
|||
@grep "Test successfull (\"1\" \"2\" \"3\")" ${R7RSTMP}/test-result.txt || (echo "Test failed, output: " && cat ${R7RSTMP}/test-result.txt && exit 1)
|
||||
|
||||
test-r7rs-docker:
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=${DOCKERTAG} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} test-r7rs"
|
||||
|
||||
test-r7rs-wine:
|
||||
rm -rf ${R7RSTMP}
|
||||
mkdir -p ${R7RSTMP}
|
||||
cp -r r7rs-testfiles/* ${R7RSTMP}/
|
||||
cd ${R7RSTMP} && COMPILE_R7RS=${SCHEME} COMPILE_R7RS_TARGET=windows compile-r7rs -I ./libs -o main.bat main.scm
|
||||
-cd ${R7RSTMP} && wine main.bat 1 2 3 > test-result.txt 2>&1
|
||||
@grep "Test successfull (\"1\" \"2\" \"3\")" ${R7RSTMP}/test-result.txt || (echo "Test failed, output: " && cat ${R7RSTMP}/test-result.txt && exit 1)
|
||||
|
||||
test-r7rs-wine-docker:
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=${DOCKERTAG} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} test-r7rs-wine"
|
||||
|
||||
test-r7rs-php:
|
||||
rm -rf ${R7RSTMP}
|
||||
mkdir -p ${R7RSTMP}
|
||||
cp -r r7rs-php-testfiles/* ${R7RSTMP}/
|
||||
cd ${R7RSTMP} && COMPILE_R7RS=${SCHEME} COMPILE_R7RS_TARGET=php compile-r7rs -o main.php main.scm
|
||||
-cd ${R7RSTMP} && php main.php > test-result.txt 2>&1
|
||||
@grep "Test successfull" ${R7RSTMP}/test-result.txt || (echo "Test failed, output: " && cat ${R7RSTMP}/test-result.txt && exit 1)
|
||||
|
||||
test-r7rs-php-docker:
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=${DOCKERTAG} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t ${DOCKERTAG} sh -c "make SCHEME=${SCHEME} test-r7rs-php"
|
||||
docker build -f Dockerfile.test --build-arg IMAGE=${DOCKERIMG} --build-arg SCHEME=${SCHEME} --tag=compile-r7rs-test-${SCHEME} .
|
||||
docker run -v "${PWD}":/workdir -w /workdir -t compile-r7rs-test-${SCHEME} sh -c "make SCHEME=${SCHEME} test-r7rs"
|
||||
|
||||
clean:
|
||||
rm -rf test-r7rs
|
||||
|
|
|
|||
192
compile-r7rs.scm
192
compile-r7rs.scm
|
|
@ -9,20 +9,17 @@
|
|||
(libs library-util)
|
||||
(srfi 170))
|
||||
|
||||
(when (or (member "--list-r6rs" (command-line))
|
||||
(member "--list-r6rs-schemes" (command-line)))
|
||||
(when (member "--list-r6rs-schemes" (command-line))
|
||||
(for-each (lambda (scheme) (display scheme) (display " ")) r6rs-schemes)
|
||||
(newline)
|
||||
(exit 0))
|
||||
|
||||
(when (or (member "--list-r7rs" (command-line))
|
||||
(member "--list-r7rs-schemes" (command-line)))
|
||||
(when (member "--list-r7rs-schemes" (command-line))
|
||||
(for-each (lambda (scheme) (display scheme) (display " ")) r7rs-schemes)
|
||||
(newline)
|
||||
(exit 0))
|
||||
|
||||
(when (or (member "--list" (command-line))
|
||||
(member "--list-schemes" (command-line)))
|
||||
(when (member "--list-schemes" (command-line))
|
||||
(for-each (lambda (scheme) (display scheme) (display " ")) all-schemes)
|
||||
(newline)
|
||||
(exit 0))
|
||||
|
|
@ -35,11 +32,10 @@
|
|||
(newline (current-error-port))
|
||||
(exit 1))
|
||||
(when (not (assoc scheme data)) (error "Unsupported implementation" scheme))
|
||||
(define compilation-target
|
||||
(if (get-environment-variable "COMPILE_R7RS_TARGET")
|
||||
(string->symbol (get-environment-variable "COMPILE_R7RS_TARGET"))
|
||||
(cond-expand (windows 'windows)
|
||||
(else 'unix))))
|
||||
(define compilation-target (if (get-environment-variable "TARGET")
|
||||
(get-environment-variable "TARGET")
|
||||
(cond-expand (windows "windows")
|
||||
(else "unix"))))
|
||||
|
||||
(define input-file
|
||||
(let ((input-file #f))
|
||||
|
|
@ -68,18 +64,12 @@
|
|||
#t
|
||||
#f))
|
||||
|
||||
(define scheme-type (cdr (assoc 'type (cdr (assoc scheme data)))))
|
||||
|
||||
(define output-file
|
||||
(let ((outfile (if (member "-o" (command-line))
|
||||
(if (member "-o" (command-line))
|
||||
(cadr (member "-o" (command-line)))
|
||||
(if input-file
|
||||
"a.out"
|
||||
#f))))
|
||||
(if (and (symbol=? scheme-type 'compiler)
|
||||
(symbol=? compilation-target 'php))
|
||||
(string-append outfile ".bin")
|
||||
outfile)))
|
||||
#f)))
|
||||
|
||||
(define prepend-directories
|
||||
(letrec ((looper (lambda (rest result)
|
||||
|
|
@ -158,29 +148,16 @@
|
|||
(list)
|
||||
(list)))
|
||||
|
||||
(define scheme-type (cdr (assoc 'type (cdr (assoc scheme data)))))
|
||||
|
||||
(define scheme-command
|
||||
(apply (cdr (assoc 'command (cdr (assoc scheme data))))
|
||||
(list
|
||||
(cond
|
||||
((symbol=? compilation-target 'windows) "")
|
||||
((symbol=? compilation-target 'php) "")
|
||||
(else "exec"))
|
||||
;; How to get the script file
|
||||
(cond
|
||||
((symbol=? compilation-target 'windows) "%0%")
|
||||
((symbol=? compilation-target 'php) "$binname")
|
||||
(else "$(cd -- \"$(dirname \"$0\")\" >/dev/null 2>&1 && pwd -P)/\"$0\""))
|
||||
(cond
|
||||
((symbol=? compilation-target 'windows) "")
|
||||
((symbol=? compilation-target 'php) "")
|
||||
(else "\"$@\""))
|
||||
(if input-file input-file "")
|
||||
(list (if input-file input-file "")
|
||||
(if output-file output-file "")
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)))
|
||||
r6rs?)))
|
||||
|
||||
(define scheme-library-command
|
||||
(lambda (library-file)
|
||||
|
|
@ -199,95 +176,112 @@
|
|||
result))))))
|
||||
(looper (command-line) (list))))
|
||||
|
||||
;(display "Scheme ")
|
||||
;(display scheme)
|
||||
;(newline)
|
||||
;(display "Type ")
|
||||
;(display scheme-type)
|
||||
;(newline)
|
||||
;(newline)
|
||||
|
||||
; Compile libraries
|
||||
(when (not (null? library-files))
|
||||
#;(if single-library-input-file
|
||||
(display "Given library file: ")
|
||||
(display "Found library files: "))
|
||||
;(display library-files)
|
||||
;(newline)
|
||||
(when (assoc 'library-command (cdr (assoc scheme data)))
|
||||
(for-each
|
||||
(lambda (file)
|
||||
(let* ((library-command (scheme-library-command file)))
|
||||
;(display "Compiling library ")
|
||||
;(display file)
|
||||
;(newline)
|
||||
(for-each
|
||||
(lambda (command)
|
||||
;(display "Running ")
|
||||
;(write command)
|
||||
;(newline)
|
||||
;(display "Exit code ")
|
||||
(let ((exit-code (c-system (string->c-utf8 command))))
|
||||
;(display exit-code)
|
||||
;(newline)
|
||||
(when (not (= exit-code 0))
|
||||
(exit exit-code))))
|
||||
library-command)))
|
||||
library-files)))
|
||||
|
||||
; Create executable file
|
||||
(when (and (equal? scheme-type 'interpreter) input-file)
|
||||
(when (and output-file (file-exists? output-file))
|
||||
(delete-file output-file))
|
||||
(let ((scheme-program (slurp input-file)))
|
||||
(with-output-to-file
|
||||
output-file
|
||||
(lambda ()
|
||||
(cond
|
||||
((symbol=? compilation-target 'windows)
|
||||
(for-each
|
||||
display
|
||||
`(";dir; start /WAIT " ,scheme-command " && exit"
|
||||
#\newline
|
||||
,scheme-program
|
||||
)))
|
||||
((symbol=? compilation-target 'php)
|
||||
(for-each
|
||||
display
|
||||
`("<?php"
|
||||
" $descriptorspec = array(0 => fopen('php://stdin', 'r'), 1 => array('pipe', 'w'), 2 => fopen('php://stderr', 'w'));"
|
||||
" $cwd = '.';"
|
||||
" $filepath = $_SERVER['SCRIPT_FILENAME'];"
|
||||
" $filename = $_SERVER['SCRIPT_NAME'];"
|
||||
" $binname = '/tmp/test.bin';"
|
||||
" system(\"tail -n+3 $filepath > $binname\");"
|
||||
" $scheme_command = \"" ,scheme-command "\";"
|
||||
" $process = proc_open($scheme_command, $descriptorspec, $pipes, $cwd, $_ENV);"
|
||||
" echo stream_get_contents($pipes[1]);"
|
||||
" die();"
|
||||
" ?>"
|
||||
#\newline
|
||||
#\newline
|
||||
,scheme-program)))
|
||||
(else
|
||||
(for-each
|
||||
display
|
||||
`(#\newline
|
||||
(let ((shebang-line (string-append
|
||||
(cond ((string=? compilation-target "unix")
|
||||
(string-append
|
||||
"#!/bin/sh"
|
||||
(string #\newline)
|
||||
"#|"
|
||||
#\newline
|
||||
,scheme-command
|
||||
#\newline
|
||||
(string #\newline)
|
||||
"tmpfile=$(mktemp)"
|
||||
(string #\newline)
|
||||
"tail -n+9 \"$0\" > ${tmpfile}"
|
||||
(string #\newline)))
|
||||
((string=? compilation-target "windows")
|
||||
(string-append
|
||||
"@echo off"
|
||||
(string #\newline)
|
||||
"start")))
|
||||
scheme-command
|
||||
(cond ((string=? compilation-target "unix")
|
||||
(string-append
|
||||
" \"$@\""
|
||||
(string #\newline)
|
||||
"rm -rf ${tmpfile}"
|
||||
(string #\newline)
|
||||
"exit"
|
||||
(string #\newline)
|
||||
"|#"
|
||||
#\newline
|
||||
,scheme-program))))))
|
||||
(cond ((symbol=? compilation-target 'unix)
|
||||
(string #\newline)))
|
||||
((string=? compilation-target "windows")
|
||||
""))))
|
||||
(scheme-program (slurp input-file)))
|
||||
;(display "Creating startup script ")
|
||||
;(display output-file)
|
||||
;(newline)
|
||||
;(display "Starting with ")
|
||||
;(display shebang-line)
|
||||
;(newline)
|
||||
(with-output-to-file
|
||||
(if (string=? compilation-target "windows")
|
||||
(string-append output-file ".bat")
|
||||
output-file)
|
||||
(lambda ()
|
||||
(display shebang-line)
|
||||
(newline)
|
||||
(display scheme-program)
|
||||
(newline)))
|
||||
(cond ((string=? compilation-target "unix")
|
||||
(c-system (string->c-utf8 (string-append "chmod +x " output-file)))))))
|
||||
|
||||
(when (and (symbol=? scheme-type 'compiler) input-file)
|
||||
(when (and (equal? scheme-type 'compiler) input-file)
|
||||
(when (and output-file (file-exists? output-file))
|
||||
(delete-file output-file))
|
||||
;(display "Compiling file ")
|
||||
;(display input-file)
|
||||
;(newline)
|
||||
(for-each
|
||||
(lambda (command)
|
||||
;(display "Running ")
|
||||
;(write command)
|
||||
;(newline)
|
||||
;(display "Exit code ")
|
||||
(let ((exit-code (c-system (string->c-utf8 command))))
|
||||
;(display exit-code)
|
||||
;(newline)
|
||||
(when (not (= exit-code 0))
|
||||
(exit exit-code))))
|
||||
scheme-command)
|
||||
(cond
|
||||
((symbol=? compilation-target 'php)
|
||||
(let* ((php-file (string-cut-from-end output-file 4))
|
||||
(port (open-binary-output-file php-file))
|
||||
(bin (slurp-bytes output-file)))
|
||||
(for-each
|
||||
(lambda (item) (write-bytevector (string->utf8 item) port))
|
||||
`("<?php"
|
||||
" $descriptorspec = array(0 => fopen('php://stdin', 'r'), 1 => array('pipe', 'w'), 2 => fopen('php://stderr', 'w'));"
|
||||
" $cwd = '.';"
|
||||
" $filepath = $_SERVER['SCRIPT_FILENAME'];"
|
||||
" $binname = '/tmp/test.bin';"
|
||||
" system(\"tail -n+3 $filepath > $binname\");"
|
||||
" $process = proc_open($binname, $descriptorspec, $pipes, $cwd, $_ENV);"
|
||||
" echo stream_get_contents($pipes[1]);"
|
||||
" die();"
|
||||
" ?>"
|
||||
,(string #\newline)
|
||||
,(string #\newline)))
|
||||
(write-bytevector bin port)
|
||||
(close-output-port port)))
|
||||
(else #t)))
|
||||
;(newline)
|
||||
)
|
||||
|
||||
|
|
|
|||
475
libs/data.sld
475
libs/data.sld
|
|
@ -8,24 +8,13 @@
|
|||
(libs util))
|
||||
(export data)
|
||||
(begin
|
||||
(define pwd (cond-expand (windows "%CD%") (else "${PWD}")))
|
||||
(define data
|
||||
`((chezscheme
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(let ((separator (cond-expand (windows ";") (else ":"))))
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" chezscheme "
|
||||
`("chezscheme "
|
||||
,(util-getenv "COMPILE_R7RS_CHEZSCHEME")
|
||||
" "
|
||||
,(if (and (null? prepend-directories)
|
||||
|
|
@ -33,41 +22,29 @@
|
|||
""
|
||||
(apply string-append
|
||||
(list "--libdirs "
|
||||
"'"
|
||||
"\""
|
||||
(apply string-append
|
||||
(map (lambda (item)
|
||||
(string-append item separator))
|
||||
(append prepend-directories append-directories)))
|
||||
"'")))
|
||||
" --program "
|
||||
,script-file
|
||||
" "
|
||||
,args))))))
|
||||
"\"")))
|
||||
" --program ${tmpfile}"))))))
|
||||
(chibi
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" chibi-scheme "
|
||||
`("chibi-scheme"
|
||||
" "
|
||||
,(util-getenv "COMPILE_R7RS_CHIBI")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
(string-append "-I" " " item " "))
|
||||
prepend-directories)
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
(string-append "-A" " " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(chicken
|
||||
(type . compiler)
|
||||
(library-command . ,(lambda (library-file prepend-directories append-directories r6rs?)
|
||||
|
|
@ -97,19 +74,11 @@
|
|||
"-unit "
|
||||
unit)
|
||||
,(string-append "ar rcs " static-out " " out)))))
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
`(,(string-append "csc -R r7rs -X r7rs "
|
||||
(util-getenv "COMPILE_R7RS_CHICKEN")
|
||||
" -static "
|
||||
" "
|
||||
(apply string-append
|
||||
(map (lambda (item)
|
||||
(string-append "-I " item " "))
|
||||
|
|
@ -139,16 +108,7 @@
|
|||
(search-library-file (append prepend-directories
|
||||
append-directories)
|
||||
library-file)))))
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
`(,(string-append "cyclone "
|
||||
(util-getenv "COMPILE_R7RS_CYCLONE")
|
||||
" "
|
||||
|
|
@ -166,29 +126,18 @@
|
|||
"sleep 0"))))))
|
||||
(foment
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" foment "
|
||||
`("foment "
|
||||
,(util-getenv "COMPILE_R7RS_FOMENT")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
(string-append "-I" " " item " "))
|
||||
prepend-directories)
|
||||
,@(map (lambda (item)
|
||||
(string-append "-A" " " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
#;(gambit
|
||||
(type . compiler)
|
||||
(library-command . ,(lambda (library-file prepend-directories append-directories r6rs?)
|
||||
|
|
@ -222,21 +171,9 @@
|
|||
output-tmp-file))))))
|
||||
(gauche
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
,(if (symbol=? compilation-target 'windows)
|
||||
" gosh.exe "
|
||||
" gosh ")
|
||||
`("gosh "
|
||||
,(util-getenv "COMPILE_R7RS_GAUCHE")
|
||||
" -r7 "
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -245,9 +182,7 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append "-A" " " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(guile
|
||||
(type . interpreter)
|
||||
(library-command . ,(lambda (library-file prepend-directories append-directories r6rs?)
|
||||
|
|
@ -267,19 +202,9 @@
|
|||
(string-cut-from-end library-path 4)
|
||||
".go")
|
||||
library-path)))))
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" guile "
|
||||
`("guile "
|
||||
,(util-getenv "COMPILE_R7RS_GUILE")
|
||||
,(if r6rs? " --r6rs -x .sls " " --r7rs -x .sld ")
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -287,49 +212,22 @@
|
|||
"-L " (dirname item) " "))
|
||||
(append prepend-directories
|
||||
append-directories))
|
||||
" -s "
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" -s ${tmpfile}")))))
|
||||
(ikarus
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`( "IKARUS_LIBRARY_PATH="
|
||||
,@(map (lambda (item) (string-append item ":")) prepend-directories)
|
||||
,@(map (lambda (item) (string-append item ":")) append-directories)
|
||||
" "
|
||||
,exec-cmd
|
||||
" ikarus "
|
||||
,(util-getenv "COMPILE_R7RS_IKARUS")
|
||||
" --r6rs-script "
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" --r6rs-script ${tmpfile}")))))
|
||||
(ironscheme
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" ironscheme "
|
||||
`("ironscheme "
|
||||
,(util-getenv "COMPILE_R7RS_IRONSCHEME")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -338,83 +236,90 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append "-I \"" item "\" "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(kawa
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`("CLASSPATH="
|
||||
,@(map (lambda (item)
|
||||
(if (char=? (string-ref item 0) #\/)
|
||||
(string-append item ":")
|
||||
(string-append pwd "/" item ":")))
|
||||
(append prepend-directories
|
||||
append-directories))
|
||||
" "
|
||||
,exec-cmd
|
||||
" kawa -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED -J--enable-native-access=ALL-UNNAMED -J--enable-preview "
|
||||
`("kawa -J--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED -J--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED -J--enable-native-access=ALL-UNNAMED -J--enable-preview "
|
||||
,(util-getenv "COMPILE_R7RS_KAWA")
|
||||
" -Dkawa.import.path="
|
||||
,@(map (lambda (item)
|
||||
(if (char=? (string-ref item 0) #\/)
|
||||
(string-append item "/*.sld")
|
||||
(string-append pwd "/" item "/*.sld")))
|
||||
(string-append item "/*.sld:"))
|
||||
(append prepend-directories
|
||||
append-directories))
|
||||
" -f "
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" --script1 ${0}"))))
|
||||
(command-old . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(set! append-directories
|
||||
(append append-directories
|
||||
(list "/usr/local/share/kawa/lib")))
|
||||
(let* ((output-jar (string-append output-file ".jar"))
|
||||
(main-class
|
||||
(string-append (string-cut-from-end (path->filename input-file)
|
||||
4)))
|
||||
(kawa-jar-path "/usr/local/share/kawa/lib/kawa.jar")
|
||||
(classpath
|
||||
(string-append
|
||||
kawa-jar-path " "
|
||||
(apply
|
||||
string-append
|
||||
(map (lambda (dir)
|
||||
(string-append dir " "))
|
||||
(append prepend-directories append-directories)))))
|
||||
(import-paths
|
||||
(apply
|
||||
string-append
|
||||
`("-Dkawa.import.path="
|
||||
,@(map (lambda (dir)
|
||||
(string-append dir "/*.sld:"))
|
||||
(append prepend-directories append-directories))
|
||||
"*.sld")))
|
||||
(library-dirs (apply string-append
|
||||
(append (map (lambda (item)
|
||||
(string-append item " "))
|
||||
(append prepend-directories
|
||||
append-directories)))))
|
||||
(class-files
|
||||
(apply
|
||||
string-append
|
||||
(map
|
||||
(lambda (lib)
|
||||
(string-append
|
||||
(string-cut-from-end
|
||||
(search-library-file (append prepend-directories
|
||||
append-directories)
|
||||
lib)
|
||||
4)
|
||||
".class "))
|
||||
library-files))))
|
||||
`(,(string-append "rm -rf " output-jar)
|
||||
,(string-append
|
||||
"echo 'Main-Class: " main-class "\nClass-Path: . " classpath "' > MANIFEST.mf")
|
||||
,(string-append "kawa " import-paths " --main -C " input-file)
|
||||
,(string-append "jar cfm " output-jar " MANIFEST.mf " main-class ".class ")
|
||||
,(string-append "jar uf " output-jar " " library-dirs)
|
||||
,(string-append "printf '#!/bin/sh\nMYSELF=$(which \"$0\" 2>/dev/null)\n[ $? -gt 0 -a -f \"$0\" ] && MYSELF=\"./$0\"\njava=java\nif test -n \"$JAVA_HOME\"; then\n java=\"$JAVA_HOME/bin/java\"\nfi\nexec \"$java\" --add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED --add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED --add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED --enable-native-access=ALL-UNNAMED --enable-preview -jar $MYSELF \"$@\"\nexit 1\n' > " output-file)
|
||||
,(string-append "cat " output-jar " >> " output-file)
|
||||
,(string-append "rm -rf " output-jar)
|
||||
,(string-append "chmod +x " output-file))))))
|
||||
(larceny
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" larceny -nobanner -quiet -utf8 "
|
||||
`("larceny -nobanner -quiet -utf8 "
|
||||
,(if r6rs? " -r6 " " -r7 ")
|
||||
,(util-getenv "COMPILE_R7RS_LARCENY")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
(string-append "-I " item " "))
|
||||
prepend-directories)
|
||||
,@(map (lambda (item)
|
||||
(string-append "-A " item " "))
|
||||
append-directories)
|
||||
" -program "
|
||||
,script-file
|
||||
" -- "
|
||||
,args)))))
|
||||
" -program ${tmpfile} --")))))
|
||||
(loko
|
||||
(type . compiler)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(let ((out (string-cut-from-end input-file 4)))
|
||||
`(,(string-append "LOKO_LIBRARY_PATH="
|
||||
(apply string-append
|
||||
|
|
@ -436,48 +341,22 @@
|
|||
,(string-append "mv " out " " output-file))))))
|
||||
(meevax
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" meevax "
|
||||
`("meevax "
|
||||
,(util-getenv "COMPILE_R7RS_MEEVAX")
|
||||
,@(map (lambda (item)
|
||||
(if (char=? (string-ref item 0) #\/)
|
||||
(string-append " -I " pwd "/" item " ")
|
||||
(string-append " -I " item " ")))
|
||||
(string-append " -I" " " item " "))
|
||||
prepend-directories)
|
||||
,@(map (lambda (item)
|
||||
(if (char=? (string-ref item 0) #\/)
|
||||
(string-append " -A " pwd "/" item " ")
|
||||
(string-append " -A " item " ")))
|
||||
(string-append " -A" " " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(mit-scheme
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" mit-scheme --batch-mode --no-init-file "
|
||||
`("mit-scheme --batch-mode --no-init-file "
|
||||
,@(map
|
||||
(lambda (item)
|
||||
(string-append "--load "
|
||||
|
|
@ -486,24 +365,10 @@
|
|||
item)
|
||||
" "))
|
||||
library-files)
|
||||
" --load "
|
||||
,script-file
|
||||
" --eval '(exit 0)' "
|
||||
,(if (string=? args "")
|
||||
""
|
||||
(string-append " --args " args)))))))
|
||||
" --load \"${tmpfile}\" --eval \"(exit 0)\" --args")))))
|
||||
(mosh
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(let ((dirs (append append-directories prepend-directories)))
|
||||
(apply string-append
|
||||
`(,(if (> (length dirs) 0)
|
||||
|
|
@ -512,13 +377,9 @@
|
|||
(apply string-append
|
||||
(map (lambda (item) (string-append item ":")) dirs)))
|
||||
"")
|
||||
" "
|
||||
,exec-cmd
|
||||
" mosh "
|
||||
,(util-getenv "COMPILE_R7RS_MOSH")
|
||||
,script-file
|
||||
" "
|
||||
,args))))))
|
||||
" ${tmpfile}"))))))
|
||||
(racket
|
||||
(type . interpreter)
|
||||
(library-command . ,(lambda (library-file prepend-directories append-directories r6rs?)
|
||||
|
|
@ -527,59 +388,31 @@
|
|||
library-file))
|
||||
(library-rkt-file (change-file-suffix full-path ".rkt")))
|
||||
(if r6rs?
|
||||
`("sleep 0") ;`(,(string-append "plt-r6rs --compile " library-file))
|
||||
`(,(string-append "plt-r6rs --compile " library-file))
|
||||
`(,(string-append "printf "
|
||||
"'#lang r7rs\\n"
|
||||
"(import (except (scheme base) let let-values let*-values string-copy string-copy! string-for-each string-map string-fill! string->list))\\n"
|
||||
"(include \"" (path->filename library-file) "\")\\n' > "
|
||||
library-rkt-file))))))
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(let ((rkt-input-file (if (string=? input-file "")
|
||||
""
|
||||
(change-file-suffix input-file ".rkt"))))
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
,(if r6rs?
|
||||
" plt-r6rs "
|
||||
" racket ")
|
||||
`("racket "
|
||||
,(util-getenv "COMPILE_R7RS_RACKET")
|
||||
,(if r6rs? "" " -I r7rs ")
|
||||
,(if r6rs? " -I r6rs " " -I r7rs ")
|
||||
,@(map (lambda (item)
|
||||
(string-append
|
||||
(if r6rs? " ++path " " -S ")
|
||||
item " "))
|
||||
(string-append " -S " item " "))
|
||||
(append prepend-directories
|
||||
append-directories))
|
||||
,(if r6rs? "" " --script ")
|
||||
,script-file
|
||||
" "
|
||||
,args))))))
|
||||
" ${tmpfile}"))))))
|
||||
(sagittarius
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
,(if (symbol=? compilation-target 'windows)
|
||||
" sash.exe -d "
|
||||
" sash -d ")
|
||||
`("sash -d "
|
||||
,(util-getenv "COMPILE_R7RS_SAGITTARIUS")
|
||||
,(if r6rs? " -r6 " " -r7 ")
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -588,24 +421,12 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append " -A " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(skint
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" skint "
|
||||
`("skint "
|
||||
,(util-getenv "COMPILE_R7RS_SKINT")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -614,25 +435,12 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append "-A " item "/ "))
|
||||
append-directories)
|
||||
" --program="
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" --program=${tmpfile}")))))
|
||||
(stklos
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" stklos "
|
||||
`("stklos "
|
||||
,(util-getenv "COMPILE_R7RS_STKLOS")
|
||||
" "
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -641,21 +449,10 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append "-A " item " "))
|
||||
append-directories)
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(tr7
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`("TR7_LIB_PATH="
|
||||
,@(map (lambda (item)
|
||||
|
|
@ -664,25 +461,12 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append item ":"))
|
||||
append-directories)
|
||||
" "
|
||||
,exec-cmd
|
||||
" tr7i -1 "
|
||||
" tr7i "
|
||||
,(util-getenv "COMPILE_R7RS_TR7")
|
||||
,script-file
|
||||
" "
|
||||
,args)))))
|
||||
" ${tmpfile}")))))
|
||||
(vicare
|
||||
(type . compiler)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`("vicare "
|
||||
,(util-getenv "COMPILE_R7RS_VICARE")
|
||||
|
|
@ -695,19 +479,9 @@
|
|||
" --compile-program")))))
|
||||
(ypsilon
|
||||
(type . interpreter)
|
||||
(command . ,(lambda (exec-cmd
|
||||
script-file
|
||||
args
|
||||
input-file
|
||||
output-file
|
||||
prepend-directories
|
||||
append-directories
|
||||
library-files
|
||||
r6rs?
|
||||
compilation-target)
|
||||
(command . ,(lambda (input-file output-file prepend-directories append-directories library-files r6rs?)
|
||||
(apply string-append
|
||||
`(,exec-cmd
|
||||
" ypsilon "
|
||||
`("ypsilon "
|
||||
,(util-getenv "COMPILE_R7RS_YPSILON")
|
||||
,(if r6rs? " --r6rs " " --r7rs ")
|
||||
" --mute"
|
||||
|
|
@ -718,7 +492,4 @@
|
|||
,@(map (lambda (item)
|
||||
(string-append "--sitelib=" item " "))
|
||||
append-directories)
|
||||
" --top-level-program "
|
||||
,script-file
|
||||
" "
|
||||
,args)))))))))
|
||||
" --top-level-program ${tmpfile}")))))))))
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
dirname
|
||||
search-library-file
|
||||
slurp
|
||||
slurp-bytes
|
||||
file->list
|
||||
trim
|
||||
trim-end
|
||||
|
|
@ -217,17 +216,6 @@
|
|||
(string-append line (string #\newline)))
|
||||
(looper (list) (read-line))))))))
|
||||
|
||||
(define (slurp-bytes path)
|
||||
(letrec* ((looper (lambda (result bytes)
|
||||
(if (eof-object? bytes)
|
||||
result
|
||||
(looper (bytevector-append result bytes)
|
||||
(read-bytevector 4000))))))
|
||||
(with-input-from-file
|
||||
path
|
||||
(lambda ()
|
||||
(looper (bytevector) (read-bytevector 4000))))))
|
||||
|
||||
(define (file->list path)
|
||||
(letrec* ((looper (lambda (result line)
|
||||
(if (eof-object? line)
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
#!r6rs
|
||||
(import (rnrs)
|
||||
(rnrs programs))
|
||||
|
||||
(display "Test successfull")
|
||||
(newline)
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
(import (scheme base)
|
||||
(scheme read)
|
||||
(scheme write))
|
||||
|
||||
(display "Test successfull")
|
||||
(newline)
|
||||
|
|
@ -8,11 +8,16 @@
|
|||
(hello-world)
|
||||
|
||||
(define l (list "1" "2" "3"))
|
||||
|
||||
;; Implementations are allowed to give different amout of args
|
||||
(cond-expand
|
||||
;; Meevax gives too much args
|
||||
;; For this test for now this is okay
|
||||
(meevax (when (> (length (command-line)) 3) (write l)))
|
||||
;; mit-scheme gives too much args
|
||||
;; For this test for now this is okay
|
||||
(mit (when (> (length (command-line)) 3) (write l)))
|
||||
;; tr7 gives too much args
|
||||
;; For this test for now this is okay
|
||||
(tr7 (when (> (length (command-line)) 3) (write l)))
|
||||
(else (write (list-tail (command-line) 1))))
|
||||
|
||||
(over-9000)
|
||||
|
|
|
|||
Loading…
Reference in New Issue