Skip to content

Commit 953c35b

Browse files
committed
[build-ttf.sh] updated script to support pinned and system installed build dep versions
1 parent 4d8a9a1 commit 953c35b

File tree

1 file changed

+58
-38
lines changed

1 file changed

+58
-38
lines changed

build-ttf.sh

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,52 +7,72 @@
77
# Copyright 2018 Christopher Simpkins
88
# MIT License
99
#
10-
# Usage: ./build-ttf.sh (--install-dependencies)
10+
# Usage: ./build-ttf.sh (--system)
1111
# Arguments:
12-
# --install-dependencies (optional) - installs all
13-
# build dependencies prior to the build script execution
12+
# --system (optional) - use system installed build dependencies
1413
#
1514
# /////////////////////////////////////////////////////////////////
1615

17-
# ttfautohint local install path from Werner Lemberg's ttfautohint-build.sh install script
16+
# default build tooling definitions
1817
TTFAH="$HOME/ttfautohint-build/local/bin/ttfautohint"
18+
FONTMAKE="pipenv run fontmake"
19+
PYTHON="pipenv run python"
20+
INSTALLFLAG=0
1921

2022
# test for number of arguments
2123
if [ $# -gt 1 ]
2224
then
2325
echo "Inappropriate arguments included in your command." 1>&2
24-
echo "Usage: ./build-ttf.sh (--install-dependencies)" 1>&2
26+
echo "Usage: ./build-ttf.sh (--system)" 1>&2
2527
exit 1
2628
fi
2729

28-
# Optional build dependency install request with syntax `./build.sh --install-dependencies`
29-
if [ "$1" = "--install-dependencies" ]
30-
then
31-
# ttfautohint v1.6 (must be pinned to v1.6 and above for Hack instruction sets)
32-
tools/scripts/install/ttfautohint-build.sh
33-
34-
fi
35-
36-
# confirm executable installs and library imports for build dependencies
37-
INSTALLFLAG=0
38-
39-
40-
# ttfautohint installed
41-
# - tests for install to local path from ttfautohint-build.sh script
42-
# - if not found on this path, tests for install on system PATH - if found, revises TTFAH to the string "ttfautohint" for execution of instruction sets
43-
if ! [ -f "$TTFAH" ]
44-
then
45-
if ! which ttfautohint
46-
then
47-
echo "Unable to install ttfautohint from source. Please attempt a manual install of this build dependency and then repeat your build attempt." 1>&2
48-
INSTALLFLAG=1
49-
else
50-
TTFAH="ttfautohint" # revise TTFAH variable to ttfautohint installed on the user's PATH for excecution of hints below
51-
fi
52-
fi
53-
# if any of the dependency installs failed, exit and do not attempt build, notify user
54-
if [ $INSTALLFLAG -eq 1 ]
30+
# Optional build with system-installed build dependencies instead of pinned build process defined versions
31+
if [ "$1" = "--system" ]
5532
then
33+
# re-define the default executables to executables that exist on PATH
34+
TTFAH="ttfautohint"
35+
FONTMAKE="fontmake"
36+
PYTHON="python3"
37+
38+
echo "================================="
39+
echo " BUILD ENVIRONMENT"
40+
echo "================================="
41+
# test re-defined system-installed build dependency paths
42+
if ! which "$TTFAH"; then
43+
echo "Unable to identify a system installed version of ttfautohint. Please install and try again." 1>&2
44+
INSTALLFLAG=1
45+
else
46+
ttfautohint --version
47+
fi
48+
if ! which "$FONTMAKE"; then
49+
echo "Unable to identify a system installed version of fontmake. Please install and try again." 1>&2
50+
INSTALLFLAG=1
51+
else
52+
"$FONTMAKE" --version
53+
fi
54+
if ! which "$PYTHON"; then
55+
echo "Unable to identify a Python 3 installation. Please install and try again." 1>&2
56+
INSTALLFLAG=1
57+
else
58+
"$PYTHON" --version
59+
fi
60+
echo "================================="
61+
echo " "
62+
echo "================================="
63+
echo " "
64+
fi
65+
66+
# test for local ttfautohint install using repository provided install script and defined ttfautohint version (and its dependencies)
67+
# no tests for Python build dependencies here because they are always installed by default & tested in the pipenv virtualenv before these steps
68+
if ! [ -f "$TTFAH" ]; then
69+
echo "Unable to identify the expected local install path for ttfautohint. Please install and try again." 1>&2
70+
INSTALLFLAG=1
71+
fi
72+
73+
74+
# If any of the dependency checks failed, exit the build and notify user
75+
if [ $INSTALLFLAG -eq 1 ]; then
5676
echo "Build canceled." 1>&2
5777
exit 1
5878
fi
@@ -87,29 +107,29 @@ fi
87107

88108
# build regular set
89109

90-
if ! pipenv run fontmake -u "source/Hack-Regular.ufo" -o ttf
110+
if ! $FONTMAKE -u "source/Hack-Regular.ufo" -o ttf
91111
then
92112
echo "Unable to build the Hack-Regular variant set. Build canceled." 1>&2
93113
exit 1
94114
fi
95115

96116
# build bold set
97-
if ! pipenv run fontmake -u "source/Hack-Bold.ufo" -o ttf
117+
if ! $FONTMAKE -u "source/Hack-Bold.ufo" -o ttf
98118
then
99119
echo "Unable to build the Hack-Bold variant set. Build canceled." 1>&2
100120
exit 1
101121
fi
102122

103123
# build italic set
104-
if ! pipenv run fontmake -u "source/Hack-Italic.ufo" -o ttf
124+
if ! $FONTMAKE -u "source/Hack-Italic.ufo" -o ttf
105125
then
106126
echo "Unable to build the Hack-Italic variant set. Build canceled." 1>&2
107127
exit 1
108128
fi
109129

110130
# build bold italic set
111131

112-
if ! pipenv run fontmake -u "source/Hack-BoldItalic.ufo" -o ttf
132+
if ! $FONTMAKE -u "source/Hack-BoldItalic.ufo" -o ttf
113133
then
114134
echo "Unable to build the Hack-BoldItalic variant set. Build canceled." 1>&2
115135
exit 1
@@ -121,7 +141,7 @@ fi
121141
echo " "
122142
echo "Attempting DSIG table fixes with fontbakery..."
123143
echo " "
124-
if ! pipenv run python postbuild_processing/fixes/fix-dsig.py master_ttf/*.ttf
144+
if ! $PYTHON postbuild_processing/fixes/fix-dsig.py master_ttf/*.ttf
125145
then
126146
echo "Unable to complete DSIG table fixes on the release files"
127147
exit 1
@@ -131,7 +151,7 @@ fi
131151
echo " "
132152
echo "Attempting fstype fixes with fontbakery..."
133153
echo " "
134-
if ! pipenv run python postbuild_processing/fixes/fix-fstype.py master_ttf/*.ttf
154+
if ! $PYTHON postbuild_processing/fixes/fix-fstype.py master_ttf/*.ttf
135155
then
136156
echo "Unable to complete fstype fixes on the release files"
137157
exit 1

0 commit comments

Comments
 (0)