3 # A launcher script for Alloy programs, with liberal borrowings from
4 # the Clojure launcher script `clj'.
6 # The following environment variables can be used to configure the
10 # The root directory where Alloy is installed.
12 # The name of the java executable used to run Alloy.
14 # Additional options to be passed to the java executable.
16 # A path to be added to Alloy's classpath.
18 # A path to be searched for native code such as DLL's or JNI
19 # libraries. This gets added to the Java options as
20 # "-Djava.library.path=$ALLOY_LIBRARY_PATH".
22 # This directory, and any jars inside it, will be automatically
23 # added to Alloy's classpath.
26 usage: alloy [options] [file1 [file2] ...]
29 --help, -h show this message
30 --java-cmd, -J the Java executable to use
31 --java-opts, -j options to be passed to the JVM
32 --classpath, -cp add to Alloy's classpath
33 --verbose, -v print initialization information
36 ## read ~/.alloyrc for home configuration
37 [ -e ~
/.alloyrc
] && . ~
/.alloyrc
39 ## read ./.alloyrc for project specific configuration
40 [ -e .
/.alloyrc
] && . .
/.alloyrc
42 if [ ! "$ALLOY_HOME" ]; then
43 # Find the real path to Alloy's home directory if $0 is a symlink
45 while [ -h "$program" ]; do
46 ls=`ls -ld "$program"`
47 link
=`expr "$ls" : '.*-> \(.*\)$'`
48 if expr "$link" : '.*/.*' >/dev
/null
; then
51 program
="`dirname $program`/$link"
54 script_dir
=`dirname "$program"`
55 relative_alloy_home
=`dirname "$script_dir"`
56 ALLOY_HOME
=`cd "$relative_alloy_home" && pwd`
59 if [ ! "$ALLOY_JAVA" ]; then
63 if [ ! "$ALLOY_CLASSPATH" ]; then
67 ## Add Alloy home jars.
68 for jar
in "$ALLOY_HOME"/*.jar
; do
69 ALLOY_CLASSPATH
="$ALLOY_CLASSPATH:$jar"
72 if [ -d "$ALLOY_LIB" ]; then
73 ALLOY_CLASSPATH
="$ALLOY_CLASSPATH:$ALLOY_LIB"
74 for jar
in "$ALLOY_LIB"/*.jar
; do
75 ALLOY_CLASSPATH
="$ALLOY_CLASSPATH:$jar"
80 main
="edu.mit.csail.sdg.alloy4whole.SimpleGUI"
84 echo "$usage"; exit 1;;
86 ALLOY_JAVA
="$2"; shift; shift;;
88 ALLOY_JAVA_OPTS
="$ALLOY_JAVA_OPTS $2"; shift; shift;;
90 ALLOY_CLASSPATH
="$ALLOY_CLASSPATH:$2"; shift; shift;;
92 if [ "$ALLOY_LIBRARY_PATH" ]; then
93 ALLOY_LIBRARY_PATH
="$ALLOY_LIBRARY_PATH:$2";
95 ALLOY_LIBRARY_PATH
="$2";
104 [ $verbose -eq 1 ] && echo "$ALLOY_CLASSPATH"
106 ## Add ALLOY_LIBRARY_PATH to the Java options if necessary
107 if [ -n "$ALLOY_LIBRARY_PATH" ]; then
108 ALLOY_JAVA_OPTS
="$ALLOY_JAVA_OPTS -Djava.library.path=$ALLOY_LIBRARY_PATH"
111 cmd
=`echo "$ALLOY_JAVA" "$ALLOY_JAVA_OPTS" -cp "$ALLOY_CLASSPATH" $main "$@"`
112 [ $verbose -eq 1 ] && echo "$cmd"