This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
build
executable file
·127 lines (119 loc) · 3.45 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source util.sh
function setup() {
# exit early if any sub-commands fails
set -e
if [[ -d env ]]; then
source env/bin/activate
else
if [[ -z ${PYTHON} ]]; then
if [[ -x "$(command -v python3)" ]] \
&& [[ $(python3 -c 'import sys; print(sys.version_info.minor)') -ge 6 ]]; then
PYTHON=python3
elif [[ -x "$(command -v python3.7)" ]]; then
PYTHON=python3.7
elif [[ -x "$(command -v python3.6)" ]]; then
PYTHON=python3.6
else
echo >&2 "Error: python3.6 or greater is required"
exit 1
fi
fi
if [[ ! $(${PYTHON} -m venv --help 2>/dev/null) ]]; then
echo >&2 "error: venv module is not installed."
echo >&2 "This is normally built-in, but some Linux distros maintain a separate package."
echo >&2 "E.g. for Debian, 'sudo apt install python3.7-venv' or similar."
exit 1
fi
${PYTHON} -m venv env
source env/bin/activate
pip install --upgrade pip setuptools wheel
fi
# ensure fontmake submodule is up-to-date
git submodule update --init
pip install -r scripts/fontmake/requirements.txt
pip install -e scripts/fontmake
deactivate
}
function build_all() {
for target in src/*.glyphs src/*/*.plist src/*/*.designspace src/*/*.ufo; do
echo "==== building ${target} ===="
if [[ "$1" == 'variable' ]]; then
build_variable "${target}" "$2"
else
build "${target}" "$1"
fi
echo
done
}
function build() {
source env/bin/activate
case "$1" in
*.plist)
build_plist "$1" 'otf' 'ttf'
;;
*.glyphs)
build_glyphs "$1" 'otf' 'ttf'
;;
*.designspace)
echo "$1"
build_designspace "$1" 'otf' 'ttf'
;;
*.ufo)
build_ufo "$1"
;;
*)
echo "unrecognized source type: \"$1\""
exit 1
;;
esac
if [[ "$?" -ne 0 && "$2" != 'force' ]]; then
exit 1
fi
deactivate
}
function build_variable() {
source env/bin/activate
case "$1" in
*.plist)
build_plist_variable "$1"
;;
*.glyphs)
build_glyphs_variable "$1"
;;
*.designspace)
build_designspace_variable "$1"
;;
*)
echo "unrecognized source type for variable font: \"$1\""
exit 1
;;
esac
if [[ "$?" -ne 0 && "$2" != 'force' ]]; then
exit 1
fi
deactivate
}
function main() {
case "$1" in
setup) setup ;;
all) build_all "$2" "$3" ;;
variable) build_variable "$2" ;;
*) build "$1" ;;
esac
}
main "$@"