-
Notifications
You must be signed in to change notification settings - Fork 0
/
runWithInfusion.sh
executable file
·142 lines (114 loc) · 3.96 KB
/
runWithInfusion.sh
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
137
138
139
140
141
142
#!/bin/bash
# the path to where this file is
# replace this with absolute path if needed
ROOT=$(dirname $0)
cd $ROOT
ROOT=$(pwd)
# directory configuration
BUILD_PATH="${WORKSPACE:="$ROOT/builds"}"
# the Pharo virtual machine for running the Moose image
# specify the VM for your platform
PHARO_VM="$ROOT/pharo/Squeak-3.11.3.2135-solaris2.10_i386/bin/squeak"
PHARO_VM="$ROOT/pharo/pharo-vm-0.15.2f-linux/squeak"
PHARO_VM="$ROOT/pharo/Squeak 4.2.2beta1U.app/Contents/MacOS/Squeak VM Opt"
PHARO_VM="$ROOT/pharo/Cog.app/Contents/MacOS/Croquet"
#PHARO_PARAM="-nodisplay -nosound" #for Linux
PHARO_PARAM="-headless" #for Mac
# the location of sources
# copy / link sources in the src folder or change the variable
SRC_PATH="$ROOT/src"
# the desired prefix for the generated files
# this must correspond to the name specified in the importing script
PROJECT_PREFIX="system"
SCRIPTS_PATH="$ROOT/scripts"
# help function
function display_help() {
echo "$(basename $0) [-p target_file_prefix] [-f src_folder] {-s smalltalk_script}"
}
# parse options
while getopts ":p:f:s:?" OPT ; do
case "$OPT" in
p) # prefix
PROJECT_PREFIX=$OPTARG
;;
f) # src
SRC_PATH=$OPTARG
;;
s) # script
if [ -f "$SCRIPTS_PATH/$OPTARG.st" ] ; then
SCRIPTS=("${SCRIPTS[@]}" "$SCRIPTS_PATH/$OPTARG.st")
else
echo "$(basename $0): invalid script ($OPTARG)"
exit 1
fi
;;
\?) # show help
display_help
exit 1
;;
esac
done
if [ -z "$SCRIPTS" ] ; then
# the default scripts
SCRIPTS=("$SCRIPTS_PATH/import-mse.st" "$SCRIPTS_PATH/open-moose-panel.st" "$SCRIPTS_PATH/save-and-quit-image.st")
fi
INFUSION="$ROOT/inFusion"
DATE=`date +%Y-%m-%d--%H-%M-%S`
MSE_FILE="$PROJECT_PREFIX-$DATE.mse"
echo -e "\n"=====STARTING AUTO MOOSE====="\n"
echo -e "\n"Start inFusion"\n"
cd $INFUSION
"./java2mse.sh" $SRC_PATH "famix30" $MSE_FILE
if [ ! -f $MSE_FILE ] ; then
echo -e "\n"=====ERROR PRODUCING MSE FILE====="\n"Make sure the path to the sources is correct
exit 1
fi
echo -e "\n"Load in Moose"\n"
COMPLETE_SCRIPT="$SCRIPTS_PATH/to-run.st"
echo "\"this is the complete script to be run\"" > "$COMPLETE_SCRIPT"
echo "wantedMse := '${MSE_FILE}'." >> $COMPLETE_SCRIPT
for FILE in "${SCRIPTS[@]}" ; do
cat "$FILE" >> "$COMPLETE_SCRIPT"
echo "!" >> "$COMPLETE_SCRIPT"
done
#copy moose images
MOOSE_FILE="moose-$PROJECT_PREFIX-$DATE"
MOOSE_IMAGE_FILE="$MOOSE_FILE.image"
MOOSE_CHANGES_FILE="$MOOSE_FILE.changes"
mkdir "$BUILD_PATH/$MOOSE_FILE"
mv $MSE_FILE "$BUILD_PATH/$MOOSE_FILE"
cd "$BUILD_PATH/$MOOSE_FILE"
cp "$ROOT/res/moose.image" $MOOSE_IMAGE_FILE
cp "$ROOT/res/moose.changes" $MOOSE_CHANGES_FILE
ln -fs "$ROOT/res/PharoV10.sources" "$BUILD_PATH/$MOOSE_FILE"
#copy java sources
mkdir "$BUILD_PATH/$MOOSE_FILE/src"
mkdir "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE"
cd $SRC_PATH
for file in $(find -L . -name '*.java'); do
mkdir -p "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
cp $file "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
done
for file in $(find -L . -name '*.xml'); do
mkdir -p "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
cp $file "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
done
for file in $(find -L . -name '*.MF'); do
mkdir -p "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
cp $file "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
done
for file in $(find -L . -name '*.project'); do
mkdir -p "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
cp $file "$BUILD_PATH/$MOOSE_FILE/src/$PROJECT_PREFIX-$DATE/"$(dirname $file)
done
cd "$BUILD_PATH/$MOOSE_FILE"
"$PHARO_VM" $PHARO_PARAM "$BUILD_PATH/$MOOSE_FILE/$MOOSE_IMAGE_FILE" $COMPLETE_SCRIPT
# cleaning
rm $COMPLETE_SCRIPT
cd $BUILD_PATH
"$ROOT/bin/resize-window.sh" "$BUILD_PATH/$MOOSE_FILE/$MOOSE_IMAGE_FILE"
#tar -czf "$MOOSE_FILE.tgz" "$MOOSE_FILE"
#rm -rf "$BUILD_PATH/$MOOSE_FILE"
rm -rf "$INFUSION/temp"
echo -e "\n"=====DONE=====
exit 0