-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild
executable file
·107 lines (96 loc) · 2.85 KB
/
build
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
#!/bin/sh
# This script builds Snap!s assignment submission plugins for Moodle (Snap!, Snap4Arduino, BeetleBlocks and TurtleStitch)
# Plugins will be create in /plugins folder. They must be copied to /your_moodle_site/mod/assign/submission/ folder
# Include print_utils
. ./print_utils
print_help() {
echo
echo "Usage: ./build [OPTION]"
echo
echo "Where [OPTION] can be:"
echo
echo " --snap to build Snap! plugin"
echo
echo " --snap4arduino to build Snap4Arduino plugin"
echo
echo " --beetleblocks to build Beetleblocks plugin"
echo
echo " --turtlestitch to build Turtlestitch plugin"
echo
echo " --all to build all 4 plugins"
echo
echo " --help"
echo " (or no options) to show this info"
echo
}
if test $# -eq 0;
then
print_help
exit 0
fi
# parse parameters
while echo $1 | grep ^- > /dev/null; do eval $( echo $1 | sed 's/-//g' | sed 's/=.*//g' | tr -d '\012')=$( echo $1 | sed 's/.*=//g' | tr -d '\012'); shift; done
if test -n "$help"; then
print_help
exit 0
fi
snapPluginNameString='#snapPluginName#'
snapPluginNames='snap snap4arduino beetleblocks turtlestitch'
snapPluginVersionString='#snapPluginVersion#'
snapPluginAppString='#snapPluginApp#'
snapPluginTableString='#snapPluginTable#'
buildPlugin() {
#Params:
# $1 snapPluginName
# $2 snapPluginVersion
# $3 snapPluginApp
# $4 snapPluginTable
rm -rf plugins/$1
mkdir -p plugins/$1
cp -r ./snapPlugin/* ./plugins/$1/
find ./plugins/$1 -type f | xargs sed -i "s/$snapPluginNameString/$1/g"
for file in $(find ./plugins/$1 -type f -name "*$snapPluginNameString*")
do
new_file=`echo $file | sed "s/$snapPluginNameString/$1/g"`
mv -f $file $new_file
done
find ./plugins/$1 -type f | xargs sed -i "s/$snapPluginVersionString/$2/g"
find ./plugins/$1 -type f | xargs sed -i "s/$snapPluginAppString/$3/g"
find ./plugins/$1 -type f | xargs sed -i "s/$snapPluginTableString/$4/g"
cp ./assets/$1Moodle.png ./plugins/$1/pix/snapMoodle.png
mkdir plugins/$1/run
cp -r ./sources/$1/* ./plugins/$1/run/
echo
print_ok "$3 plugin has been built"
}
buildSnapPlugin() {
buildPlugin snap 6.2.4 Snap! snap
}
buildSnap4arduinoPlugin() {
buildPlugin snap4arduino 6.2 Snap4Arduino snap_s4a
}
buildBeetleblocksPlugin() {
buildPlugin beetleblocks 5.3.2 BeetleBlocks snap_bb
}
buildTurtlestitchPlugin() {
buildPlugin turtlestitch 2.6 TurtleStitch snap_ts
}
if test -n "$all"; then
buildSnapPlugin
buildSnap4arduinoPlugin
buildBeetleblocksPlugin
buildTurtlestitchPlugin
exit 0
fi
if test -n "$snap"; then
buildSnapPlugin
fi
if test -n "$snap4arduino"; then
buildSnap4arduinoPlugin
fi
if test -n "$beetleblocks"; then
buildBeetleblocksPlugin
fi
if test -n "$turtlestitch"; then
buildTurtlestitchPlugin
fi