-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup
executable file
·109 lines (92 loc) · 1.98 KB
/
setup
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
#!/bin/bash
# Setup script for webfont-generator. Fetches and builds third-party
# libraries.
BASE_DIR=$(dirname "${BASH_SOURCE-$0}")
VENDOR_DIR="$BASE_DIR"/vendor
SFNTLY_DIR="$VENDOR_DIR"/sfntly
WOFF2_DIR="$VENDOR_DIR"/woff2
JAVA_DIR="$BASE_DIR"/src/java
SFNTLY_COMMIT='0e3a4a3c8e1623749a7d90cbfa5d431ac15c44ef'
WOFF2_COMMIT='5bbcf1f8ad44c07e797a088fec1dd2317611089a'
print_ansi_code() {
printf '\033[%sm' "$1"
}
print_color() {
print_ansi_code "0;$1"
printf '%s' "$2"
print_ansi_code '0'
}
stamp() {
printf '[%s]' "$(date '+%F %r')"
}
log() {
{ print_color '33' "$(stamp)"; echo " $1"; } >&2
}
warn() {
{ print_color '31' "$(stamp) $1"; echo; } >&2
}
command_exists() {
which "$1" 2>&1 > /dev/null
}
require_command() {
local COMMAND=$1
local NAME=${2-$COMMAND}
if command_exists "$COMMAND"; then
log "Found ${COMMAND}."
else
warn "You do not have $NAME installed. Please install $NAME."
false
fi
}
fetch_sfntly() {
if [[ ! -d $SFNTLY_DIR ]]; then
log 'Fetching sfntly...'
git clone https://github.com/rillig/sfntly.git "$SFNTLY_DIR" &&
(
cd "$SFNTLY_DIR" &&
git checkout -q "$SFNTLY_COMMIT"
)
fi
}
build_sfntly() {
log 'Building sfntly...'
(
cd "$SFNTLY_DIR"/java &&
mvn compile
)
}
fetch_woff2() {
if [[ ! -d $WOFF2_DIR ]]; then
log 'Fetching woff2...'
git clone --recursive http://github.com/google/woff2.git "$WOFF2_DIR" &&
(
cd "$WOFF2_DIR" &&
git checkout -q "$WOFF2_COMMIT"
)
fi
}
build_woff2() {
log 'Building woff2...'
make -C "$WOFF2_DIR"
}
build_java() {
log 'Building java classes...'
make -C "$JAVA_DIR"
}
main() {
require_command 'git' &&
require_command 'java' &&
require_command 'javac' &&
require_command 'mvn' &&
require_command 'python3' &&
require_command 'make' &&
require_command 'fontforge' 'FontForge' &&
mkdir -p "$VENDOR_DIR" &&
fetch_sfntly &&
build_sfntly &&
fetch_woff2 &&
build_woff2 &&
build_java &&
log 'Good to go!'
}
main "$@"