forked from notofonts/noto-source
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild
executable file
·113 lines (105 loc) · 3 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
#!/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
# exit early if any sub-commands fails
set -e
function setup() {
if [[ ! $(python -m pip --version 2>/dev/null) ]]; then
echo >&2 "error: pip is not installed."
echo >&2 "Try running 'python -m ensurepip' or check installation instructions:"
echo >&2 "https://pip.pypa.io/en/stable/installing/"
exit 1
fi
if [[ ! -d env ]]; then
if [[ ! $(python -m virtualenv --version 2>/dev/null) ]]; then
if [ ! -e scripts/virtualenv/virtualenv.py ]; then
echo "virtualenv is not installed; installing to scripts/virtualenv"
mkdir -p scripts/virtualenv
python -m pip install --target scripts/virtualenv virtualenv
fi
python scripts/virtualenv/virtualenv.py env
else
python -m virtualenv env
fi
fi
source env/bin/activate
# ensure fontmake submodule is up-to-date
git submodule update --init
pip install --upgrade -r scripts/fontmake/requirements.txt
pip install scripts/fontmake
deactivate
}
function build_all() {
for target in src/*.glyphs src/*/*.plist 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'
;;
*.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"
;;
*)
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 "$@"