-
Notifications
You must be signed in to change notification settings - Fork 3
/
regiment.chez
executable file
·136 lines (113 loc) · 4.37 KB
/
regiment.chez
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /bin/bash
# This version of the script invokes Regiment using full Chez Scheme.
# It will try to load from, heap, boot file, or .so file in that
# order. Failing those it will load from source. If full Chez isn't
# available, it falls back to Petite.
source `dirname $0`/assert_regimentd
function setupchez() {
# Using our own chez wrapper because it obeys "--threaded"
SCHEME="$REGIMENTD/depends/chez"
# [2010.06.26] For now disabling the more "flexible" behaviors
# because it's better to know what's happening:
#
# if [ -e "$CHEZD" ];
# then SCHEME="$REGIMENTD/depends/chez"
# # elif (which chez74 > /dev/null);
# # then SCHEME=chez74;
# elif (which chez > /dev/null);
# then SCHEME=chez;
# elif (which petite > /dev/null);
# then SCHEME=petite
# elif [ -f $REGIMENTD/depends/petite ];
# then SCHEME="$REGIMENTD/depends/petite"
# else echo ERROR: CHEZ SCHEME not found.; exit -1
# fi
}
# [2010.01.19] Why was this not done at the outset before?
setupchez;
if [ -e "$CHEZD" ] && [ "$CHEZTHREADED" != "" ]; then
echo " (Enabling threaded mode.)"
MT=`$REGIMENTD/depends/get_machine_type --threaded`
echo " Note: Executing WS under Chez Scheme with threading support."
CHEZARGS="--threaded"
else
MT=`$REGIMENTD/depends/get_machine_type`
CHEZARGS=
fi
## R6RS VERSION:
############################################################
## FIXME: This branch assumes that the command "chez" is in the path.
## What's a good way to check if we're in R6RS mode?
#CHEZVER=`chez --version &> /dev/stdout`
CHEZVER=$($SCHEME --version &> /dev/stdout)
N=`echo $CHEZVER | sed 's/\\.//g'`
ARGS=$*
function from_source() {
if cd $REGIMENTD/src; then
echo "WARNING: Loading under Chez from (potentally mixed) source/object files."
exec $SCHEME $CHEZARGS --program $REGIMENTD/src/regiment.ss $CURDIR $ARGS
fi # end if cd /src
}
function go() {
FILE=$1
if [ -e $FILE ];
then exec $SCHEME --program $FILE $CURDIR $ARGS
else
# The boot file is not available, but we've compiled a tree of .so's in the build/ dir:
# (This is the method used by "make chezincr2".)
if [ -e "$REGIMENTD/build/$MT/ws" ]; then
CHEZARGS="--libdirs $REGIMENTD/src::$REGIMENTD/build/$MT"
echo " Note: Using object files within $REGIMENTD/build/$MT/"
fi
from_source
fi
}
# Only in newer, R6 supporting versions of Chez:
if (( "$N" > 75 )); then
# echo "Running in R6 mode.."
# RUN New R6RS mode:
CURDIR=`pwd`
if [ "$REGOPTLVL" == "3" ]; then go "$REGIMENTD/build/$MT/regiment.opt.boot"
elif [ "$REGDEBUGMODE" == "" ]; then go "$REGIMENTD/build/$MT/regiment.complete.boot"
else go "$REGIMENTD/build/$MT/regiment.debug.boot"
fi
fi # end if version > 75
## PRE R6RS (HACK):
############################################################
echo "USING OLD METHOD"
ARGS=${1+"$@"}
function script() {
INVOKEDIR=`pwd`
ENTRY="$REGIMENTD/src/regiment_chez.ss"
setupchez;
echo Executing: exec $SCHEME $1 --script "$ENTRY" "$INVOKEDIR" $ARGS
exec $SCHEME $1 --script "$ENTRY" "$INVOKEDIR" $ARGS
}
# First we handle the "ws.opt" cases:
if [ "$REGOPTLVL" == "3" ];
then (if [ -f $REGIMENTD/src/build/$MT/regiment.0.OPT.heap ];
# If we can we use the stored heap,
then exec $REGIMENTD/depends/rawscheme -h $REGIMENTD/src/build/$MT/regiment.0.OPT.heap $*;
# Otherwise check for .boot
elif [ -f "$REGIMENTD/build/$MT/legacy_main_chez_OPT.boot" ]
then setupchez;
script "-b $REGIMENTD/src/build/$MT/legacy_main_chez_OPT.boot ";
# Otherwise fall thruogh to running it as script.
else script;
fi);
# Not currently using heaps for debug mode:
elif [ "$REGDEBUGMODE" == "ON" ];
then script;
# [2007.04.15] In progress: going to move over to using boot files.
# Which means invoking with the boot file explicitly here, rather than
# letting the scheme source pick out the .so file.
elif [ -f "$REGIMENTD/build/$MT/legacy_main_chez.boot" ]
then setupchez;
#exec $SCHEME -b $REGIMENTD/src/build/$MT/main_chez.boot $*;
script "-b $REGIMENTD/src/build/$MT/legacy_main_chez.boot ";
elif [ -f "$REGIMENTD/src/build/$MT/regiment.0.heap" ];
then #echo Running regiment from saved heap...;
exec $REGIMENTD/depends/rawscheme -h $REGIMENTD/src/build/$MT/regiment.0.heap $*;
else
script;
fi