Made improvements to csc compiling
This commit is contained in:
parent
ea31f48b5e
commit
3f976de9a3
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ install:
|
|||
install compile-r7rs ${PREFIX}/bin/compile-r7rs
|
||||
|
||||
test:
|
||||
@cd test && ../compile-r7rs -D . -D ./libs -D ./libs2 main.scm
|
||||
@cd test && ../compile-r7rs -I . -I ./libs -I ./libs2 main.scm
|
||||
|
||||
clean:
|
||||
find . -name "*.c*" -delete
|
||||
|
|
|
@ -32,12 +32,17 @@ but the ${HOME}/.local/bin needs to be in your path for you to be able to run th
|
|||
|
||||
## Usage
|
||||
|
||||
The environment variable SCC must be set to the same value as the implementations command.
|
||||
The environment variable SCMC must be set to the same value as the implementations command.
|
||||
The command is the first word on the list. So for example guile for Guile, csi for Chicken
|
||||
interpreter, csc for Chicken compiler.
|
||||
|
||||
If the command has .exe at it's end cross compilation from Linux to .exe with Wine is assumed.
|
||||
|
||||
|
||||
Run
|
||||
|
||||
SCMC=<SCHEME> compile-r7rs -I <DIR> <file.scm>
|
||||
|
||||
## Outputs
|
||||
|
||||
### Self contained, self extracting and runnable shell script
|
||||
|
|
32
compile-r7rs
32
compile-r7rs
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ ! "${COMPILE_R7RS_DEBUG}" = "" ]; then set -x; fi
|
||||
|
||||
CC=gcc
|
||||
if [ "" = "${CC}" ]
|
||||
then
|
||||
|
@ -9,11 +11,12 @@ fi
|
|||
output="a.out"
|
||||
libdirs=""
|
||||
|
||||
while getopts "D:o:" flag
|
||||
while getopts "I:A:o:" flag
|
||||
do
|
||||
case $flag in
|
||||
o) output="${OPTARG}";;
|
||||
D) libdirs="$libdirs ${OPTARG}";;
|
||||
A) libdirs="$libdirs ${OPTARG}";;
|
||||
I) libdirs="${OPTARG} $libdirs";;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -23,7 +26,9 @@ if [ ! "" = "${main}" ]; then output="${main%.*}"; fi
|
|||
#tmpdir="${HOME}/.cache/compile-r7rs/$(md5sum $main)/"
|
||||
tmpdir="${HOME}/.cache/compile-r7rs/test"
|
||||
|
||||
case ${SCC} in
|
||||
if [ ! "${COMPILE_R7RS_DEBUG}" = "" ]; then echo "SCMC: ${SCMC}"; fi
|
||||
|
||||
case "${SCMC}" in
|
||||
chibi-scheme)
|
||||
paths="-I $tmpdir"
|
||||
for dir in $libdirs
|
||||
|
@ -43,17 +48,22 @@ case ${SCC} in
|
|||
csc)
|
||||
paths="-I $tmpdir"
|
||||
objects=""
|
||||
units="r7rs,scheme.base,scheme.case-lambda,scheme.char,scheme.complex,scheme.cxr,scheme.eval,scheme.file,scheme.inexact,scheme.lazy,scheme.load,scheme.process-context,scheme.read,scheme.repl,scheme.time,scheme.write,scheme.r5rs"
|
||||
for dir in $libdirs
|
||||
do
|
||||
paths="$paths -I $tmpdir/${dir#./}"
|
||||
for lib in $(find "$dir" -name "*.sld")
|
||||
for lib in $(find "${dir}" -name "*.sld")
|
||||
do
|
||||
echo "Compiling $lib"
|
||||
csc -X r7rs -R r7rs -c -J -unit ${lib%.sld} "$lib"
|
||||
unit0=$(cd "${dir}" && find . -name $(basename "${lib}"))
|
||||
unit1=$(echo "${unit0#\./}" | sed 's/\//\./g')
|
||||
unit=${unit1%.sld}
|
||||
echo "Compiling $lib as unit ${unit}"
|
||||
csc -X r7rs -R r7rs -cc ${CC} ${CSCFLAGS} -c -J -unit ${unit} -uses "${units}" "$lib" -o "${unit}.o"
|
||||
units="${units},${unit}"
|
||||
objects="$objects ${lib%.sld}.o"
|
||||
done
|
||||
done
|
||||
csc -X r7rs -R r7rs -static $objects -o $output $main
|
||||
csc -X r7rs -R r7rs -cc ${CC} ${CSCFLAGS} -o $output -static -uses ${units} $main
|
||||
chmod +x "$output"
|
||||
exit 0
|
||||
;;
|
||||
|
@ -111,7 +121,7 @@ case ${SCC} in
|
|||
do
|
||||
paths="$paths -L $tmpdir/${dir#./}"
|
||||
done
|
||||
scm_cmd="guile --r7rs $paths -s"
|
||||
scm_cmd="guile --r7rs $paths"
|
||||
;;
|
||||
kawa)
|
||||
jar xf kawa.jar
|
||||
|
@ -232,7 +242,7 @@ case ${SCC} in
|
|||
scm_cmd="ypsilon --r7rs $paths --top-level-program"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported SCC (SCheme Compiler) implementation or environment value not set."
|
||||
echo "Unsupported SCMC (SCheMe Compiler) implementation or environment value not set."
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
@ -244,10 +254,10 @@ rm -rf "$output"
|
|||
echo 'CURDIR=${PWD}'
|
||||
echo "cd $tmpdir"
|
||||
echo "{"
|
||||
shar -M --quiet-unshar --no-check-existing --no-timestamp $main $libdirs | grep -v "exit 0"
|
||||
shar -M --quiet-unshar --no-check-existing --no-timestamp $main $(find $libdirs -name "*.scm" -o -name "*.sld" -o -name "*.rkt") | grep -v "exit 0"
|
||||
echo "} > /dev/null"
|
||||
echo 'cd ${CURDIR}'
|
||||
echo "$command"
|
||||
echo "$command \"\$@\""
|
||||
} > "$output"
|
||||
|
||||
chmod +x "$output"
|
||||
|
|
Loading…
Reference in New Issue