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
|
install compile-r7rs ${PREFIX}/bin/compile-r7rs
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@cd test && ../compile-r7rs -D . -D ./libs -D ./libs2 main.scm
|
@cd test && ../compile-r7rs -I . -I ./libs -I ./libs2 main.scm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
find . -name "*.c*" -delete
|
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
|
## 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
|
The command is the first word on the list. So for example guile for Guile, csi for Chicken
|
||||||
interpreter, csc for Chicken compiler.
|
interpreter, csc for Chicken compiler.
|
||||||
|
|
||||||
If the command has .exe at it's end cross compilation from Linux to .exe with Wine is assumed.
|
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
|
## Outputs
|
||||||
|
|
||||||
### Self contained, self extracting and runnable shell script
|
### Self contained, self extracting and runnable shell script
|
||||||
|
|
32
compile-r7rs
32
compile-r7rs
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ ! "${COMPILE_R7RS_DEBUG}" = "" ]; then set -x; fi
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
if [ "" = "${CC}" ]
|
if [ "" = "${CC}" ]
|
||||||
then
|
then
|
||||||
|
@ -9,11 +11,12 @@ fi
|
||||||
output="a.out"
|
output="a.out"
|
||||||
libdirs=""
|
libdirs=""
|
||||||
|
|
||||||
while getopts "D:o:" flag
|
while getopts "I:A:o:" flag
|
||||||
do
|
do
|
||||||
case $flag in
|
case $flag in
|
||||||
o) output="${OPTARG}";;
|
o) output="${OPTARG}";;
|
||||||
D) libdirs="$libdirs ${OPTARG}";;
|
A) libdirs="$libdirs ${OPTARG}";;
|
||||||
|
I) libdirs="${OPTARG} $libdirs";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -23,7 +26,9 @@ if [ ! "" = "${main}" ]; then output="${main%.*}"; fi
|
||||||
#tmpdir="${HOME}/.cache/compile-r7rs/$(md5sum $main)/"
|
#tmpdir="${HOME}/.cache/compile-r7rs/$(md5sum $main)/"
|
||||||
tmpdir="${HOME}/.cache/compile-r7rs/test"
|
tmpdir="${HOME}/.cache/compile-r7rs/test"
|
||||||
|
|
||||||
case ${SCC} in
|
if [ ! "${COMPILE_R7RS_DEBUG}" = "" ]; then echo "SCMC: ${SCMC}"; fi
|
||||||
|
|
||||||
|
case "${SCMC}" in
|
||||||
chibi-scheme)
|
chibi-scheme)
|
||||||
paths="-I $tmpdir"
|
paths="-I $tmpdir"
|
||||||
for dir in $libdirs
|
for dir in $libdirs
|
||||||
|
@ -43,17 +48,22 @@ case ${SCC} in
|
||||||
csc)
|
csc)
|
||||||
paths="-I $tmpdir"
|
paths="-I $tmpdir"
|
||||||
objects=""
|
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
|
for dir in $libdirs
|
||||||
do
|
do
|
||||||
paths="$paths -I $tmpdir/${dir#./}"
|
paths="$paths -I $tmpdir/${dir#./}"
|
||||||
for lib in $(find "$dir" -name "*.sld")
|
for lib in $(find "${dir}" -name "*.sld")
|
||||||
do
|
do
|
||||||
echo "Compiling $lib"
|
unit0=$(cd "${dir}" && find . -name $(basename "${lib}"))
|
||||||
csc -X r7rs -R r7rs -c -J -unit ${lib%.sld} "$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"
|
objects="$objects ${lib%.sld}.o"
|
||||||
done
|
done
|
||||||
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"
|
chmod +x "$output"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
@ -111,7 +121,7 @@ case ${SCC} in
|
||||||
do
|
do
|
||||||
paths="$paths -L $tmpdir/${dir#./}"
|
paths="$paths -L $tmpdir/${dir#./}"
|
||||||
done
|
done
|
||||||
scm_cmd="guile --r7rs $paths -s"
|
scm_cmd="guile --r7rs $paths"
|
||||||
;;
|
;;
|
||||||
kawa)
|
kawa)
|
||||||
jar xf kawa.jar
|
jar xf kawa.jar
|
||||||
|
@ -232,7 +242,7 @@ case ${SCC} in
|
||||||
scm_cmd="ypsilon --r7rs $paths --top-level-program"
|
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
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -244,10 +254,10 @@ rm -rf "$output"
|
||||||
echo 'CURDIR=${PWD}'
|
echo 'CURDIR=${PWD}'
|
||||||
echo "cd $tmpdir"
|
echo "cd $tmpdir"
|
||||||
echo "{"
|
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 "} > /dev/null"
|
||||||
echo 'cd ${CURDIR}'
|
echo 'cd ${CURDIR}'
|
||||||
echo "$command"
|
echo "$command \"\$@\""
|
||||||
} > "$output"
|
} > "$output"
|
||||||
|
|
||||||
chmod +x "$output"
|
chmod +x "$output"
|
||||||
|
|
Loading…
Reference in New Issue