forked from DDMAL/Neon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-verovio
executable file
·104 lines (93 loc) · 2.58 KB
/
update-verovio
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
#!/bin/bash
# A simple script to update the verovio toolkit
# Uses the current develop branch from DDMAL/verovio
# Requires emscripten and git
BUILDDIR="verovio-build"
USAGE="./update-verovio [-b build-directory [-d]] [-l local-verovio] [-h]\n\n-b | --build-dir\t\tSpecify the build directory for verovio.\n-d | --delete\t\tDelete the build directory after building.\n-l | --local\t\tSpecify the path to a preexisting root of verovio source.\n-s | --standalone\t\tBuild a standalone verovio toolkit (not an npm package).\n-h | --help\t\tDisplay this dialogue.\n"
GIT=`which git`
if [[ 0 -ne $? ]]; then
echo >&2 "Git could not be found.";
exit 127;
fi
which emcc > /dev/null 2>&1
if [[ 0 -ne $? ]]; then
echo >&2 "Emscripten (emcc) could not be found.";
exit 127;
fi
which yarn > /dev/null 2>&1
if [[ 0 -ne $? ]]; then
echo >&2 "Yarn could not be found.";
exit 127;
fi
# Parse Arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-l|--local)
LOCALVEROVIO=true
BUILDDIR="$2"
shift
shift
;;
-b|--build-dir)
BUILDDIR="$2"
CUSTOMBUILD=true
shift
shift
;;
-d|--delete)
DELETE=true
shift
;;
-h|--help)
printf "$USAGE"
exit 0
;;
-s|--standalone)
STANDALONE=true
shift
;;
*)
echo >&2 "Unknown option $1"
printf "$USAGE"
# EINVAL Invalid argument
exit 1
;;
esac
done
# Validate Arguments
if [[ $LOCALVEROVIO && $CUSTOMBUILD ]]; then
echo >&2 "Cannot specify local installation and a custom build directory!"
printf "$USAGE"
exit 1
elif [[ $LOCALVEROVIO && $DELETE ]]; then
echo >&2 "This script will not delete a preexisting directory!"
printf "$USAGE"
exit 1
fi
# Get verovio if necessary
if [ ! "$LOCALVEROVIO" ]; then
# Check that $BUILDDIR does not exist
if [ -e $BUILDDIR ]; then
echo >&2 "$BUILDDIR already exists!"
exit 1
fi
$GIT clone --depth 1 https://github.com/DDMAL/verovio.git "$BUILDDIR"
else
if [ ! -d $BUILDDIR ]; then
echo >&2 "$BUILDDIR does not exist!"
exit 1
fi
fi
# Build
(cd "$BUILDDIR/emscripten"; ./buildToolkit -H)
# Copy file
if [ "$STANDALONE" ]; then
cp "$BUILDDIR/emscripten/build/verovio-toolkit.js" src/
else
cp -R "$BUILDDIR/emscripten/npm-dev/" src/verovio-dev
yarn upgrade verovio-dev
fi
if [ "$DELETE" ]; then
rm -rf $BUILDDIR
fi