summaryrefslogtreecommitdiff
path: root/init.sh
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2018-09-03 22:55:49 +0300
committerRasmus Andersson <rasmus@notion.se>2018-09-03 22:55:49 +0300
commitc833e252c925e8dd68108660710ca835d95daa6f (patch)
tree6b2e28264ed45efd7f054e453b622098d0d875b8 /init.sh
parent8c1a4c181ef12000179dfec541f1af87e9b03122 (diff)
downloadinter-c833e252c925e8dd68108660710ca835d95daa6f.tar.xz
Major overhaul, moving from UFO2 to Glyphs and UFO3, plus a brand new and much simpler fontbuild
Diffstat (limited to 'init.sh')
-rwxr-xr-xinit.sh267
1 files changed, 173 insertions, 94 deletions
diff --git a/init.sh b/init.sh
index 4dc6238f8..e7bd29ad9 100755
--- a/init.sh
+++ b/init.sh
@@ -7,7 +7,7 @@ if [[ "${BUILD_DIR:0:2}" == "./" ]]; then
BUILD_DIR=${BUILD_DIR:2}
fi
-DIST_DIR=$BUILD_DIR/dist #-hinted|-unhinted
+DIST_DIR=$BUILD_DIR/ # hinted | unhinted
BUILD_TMP_DIR=$BUILD_DIR/tmp
VENV_DIR=$BUILD_DIR/venv
@@ -86,14 +86,26 @@ else
if [[ ! -d "$VENV_DIR/bin" ]]; then
echo "Setting up virtualenv in '$VENV_DIR'"
+ rm -f "$VENV_DIR/lib/python"
require_virtualenv
$virtualenv "$VENV_DIR"
elif [[ ! -z $VIRTUAL_ENV ]] && [[ "$VIRTUAL_ENV" != "$VENV_DIR_ABS" ]]; then
echo "Looks like the repository has moved location -- updating virtualenv"
+ rm -f "$VENV_DIR/lib/python"
require_virtualenv
$virtualenv "$VENV_DIR"
fi
+ # symlink lib/python -> lib/python<version>
+ if [[ ! -d "$VENV_DIR/lib/python" ]]; then
+ for f in "$VENV_DIR/lib/"python*; do
+ if [[ -d "$f" ]]; then
+ ln -svf $(basename "$f") "$VENV_DIR/lib/python"
+ break
+ fi
+ done
+ fi
+
source "$VENV_DIR/bin/activate"
UPDATE_TIMESTAMP_FILE="$VENV_DIR/last-pip-run.mark"
@@ -113,44 +125,65 @@ else
PATCH_DIR=$(pwd)/misc/patches
mkdir -p "$DEPS_DIR"
- check_dep() {
+
+ function fetch() {
+ URL=$1
+ DSTFILE=$2
+ echo "Fetching $URL"
+ curl '-#' -o "$DSTFILE" -L "$URL"
+ }
+
+ function check_dep() {
NAME=$1
REPO_URL=$2
BRANCH=$3
TREE_REF=$4
set -e
REPODIR=$DEPS_DIR/$NAME
+ CHANGED=false
if [[ ! -d "$REPODIR/.git" ]]; then
rm -rf "$REPODIR"
echo "Fetching $NAME from $REPO_URL"
if ! (git clone --recursive --single-branch -b $BRANCH -- "$REPO_URL" "$REPODIR"); then
exit 1
fi
+ CHANGED=true
+ elif [[ "$(git -C "$REPODIR" rev-parse HEAD)" != "$TREE_REF" ]]; then
+ CHANGED=true
+ git -C "$REPODIR" fetch origin
+ fi
+ if $CHANGED; then
if [[ ! -z $TREE_REF ]]; then
git -C "$REPODIR" checkout "$TREE_REF"
git -C "$REPODIR" submodule update
fi
return 1
fi
- # TODO: check that source matches tree ref
return 0
}
- if ! (check_dep \
- woff2 https://github.com/google/woff2.git master 36e6555b92a1519c927ebd43b79621810bf17c1a )
+
+ # woff2
+ LINK=false
+ if ! (check_dep woff2 \
+ https://github.com/google/woff2.git master \
+ a0d0ed7da27b708c0a4e96ad7a998bddc933c06e )
then
echo "Building woff2"
- git -C "$DEPS_DIR/woff2" apply "$PATCH_DIR/woff2.patch"
- if !(make -C "$DEPS_DIR/woff2" -j8 clean all); then
+ make -C "$DEPS_DIR/woff2" -j8 clean
+ if !(make -C "$DEPS_DIR/woff2" -j8 all); then
rm -rf "$DEPS_DIR/woff2"
exit 1
fi
+ elif [[ ! -f "$VENV_DIR/bin/woff2_compress" ]]; then
+ LINK=true
fi
- if [[ ! -f "$VENV_DIR/bin/woff2_compress" ]]; then
- ln -vfs ../../deps/woff2/woff2_compress "$VENV_DIR/bin"
+ if $LINK; then
+ ln -vfs ../../deps/woff2/woff2_compress "$VENV_DIR/bin/woff2_compress"
fi
- # EOT is disabled
+
+ # # EOT (disabled)
# if ! (check_dep \
# ttf2eot https://github.com/rsms/ttf2eot.git master )
# then
@@ -161,15 +194,95 @@ else
# ln -vfs ../../deps/ttf2eot/ttf2eot "$VENV_DIR/bin"
# fi
- if [[ ! -f "$DEPS_DIR/ttfautohint" ]]; then
- URL=https://download.savannah.gnu.org/releases/freetype/ttfautohint-1.6-tty-osx.tar.gz
- echo "Fetching $URL"
- curl '-#' -o "$DEPS_DIR/ttfautohint.tar.gz" -L "$URL"
+
+ # # meson (internal requirement of ots)
+ # MESON_VERSION=0.47.2
+ # pushd "$DEPS_DIR" >/dev/null
+ # MESON_BIN=$PWD/meson-${MESON_VERSION}/meson.py
+ # popd >/dev/null
+ # if [[ ! -f "$MESON_BIN" ]]; then
+ # fetch \
+ # https://github.com/mesonbuild/meson/releases/download/${MESON_VERSION}/meson-${MESON_VERSION}.tar.gz \
+ # "$DEPS_DIR/meson.tar.gz"
+ # tar -C "$DEPS_DIR" -xzf "$DEPS_DIR/meson.tar.gz"
+ # rm "$DEPS_DIR/meson.tar.gz"
+ # fi
+
+
+ # # ninja
+ # NINJA_VERSION=1.8.2
+ # pushd "$DEPS_DIR" >/dev/null
+ # NINJA_BIN=$PWD/ninja-${NINJA_VERSION}
+ # if [[ ! -f "$NINJA_BIN" ]]; then
+ # fetch \
+ # https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-mac.zip \
+ # ninja.zip
+ # rm -f ninja
+ # unzip -q -o ninja.zip
+ # rm ninja.zip
+ # mv ninja "$NINJA_BIN"
+ # fi
+ # popd >/dev/null
+
+
+ # # ots (from source)
+ # LINK=false
+ # if ! (check_dep ots \
+ # https://github.com/khaledhosny/ots.git master \
+ # cad0b4f9405d03ddf801f977f2f65892192ad047 )
+ # then
+ # echo "Building ots"
+ # pushd "$DEPS_DIR/ots" >/dev/null
+ # "$MESON_BIN" build
+ # "$NINJA_BIN" -C build
+ # popd >/dev/null
+ # fi
+
+
+ # ots (from dist)
+ OTS_VERSION=7.1.7
+ OTS_DIR=$DEPS_DIR/ots-${OTS_VERSION}
+ LINK=false
+ if [[ ! -f "$OTS_DIR/ots-sanitize" ]]; then
+ mkdir -p "$OTS_DIR"
+ fetch \
+ https://github.com/khaledhosny/ots/releases/download/v${OTS_VERSION}/ots-${OTS_VERSION}-osx.zip \
+ "$OTS_DIR/ots.zip"
+ pushd "$OTS_DIR" >/dev/null
+ unzip ots.zip
+ rm ots.zip
+ mv ots-* xx-ots
+ mv xx-ots/* .
+ rm -rf xx-ots
+ popd >/dev/null
+ LINK=true
+ fi
+ if $LINK || [[ ! -f "$VENV_DIR/bin/ots-sanitize" ]]; then
+ pushd "$OTS_DIR" >/dev/null
+ for f in ots-*; do
+ popd >/dev/null
+ ln -vfs ../../deps/ots-${OTS_VERSION}/$f "$VENV_DIR/bin/$f"
+ pushd "$OTS_DIR" >/dev/null
+ done
+ popd >/dev/null
+ fi
+
+
+ AUTOHINT_VERSION=1.8.2
+ LINK=false
+ if [[ ! -f "$DEPS_DIR/ttfautohint-${AUTOHINT_VERSION}" ]]; then
+ fetch \
+ https://download.savannah.gnu.org/releases/freetype/ttfautohint-${AUTOHINT_VERSION}-tty-osx.tar.gz
+ "$DEPS_DIR/ttfautohint.tar.gz"
tar -C "$DEPS_DIR" -xzf "$DEPS_DIR/ttfautohint.tar.gz"
rm "$DEPS_DIR/ttfautohint.tar.gz"
+ mv -f "$DEPS_DIR/ttfautohint" "$DEPS_DIR/ttfautohint-${AUTOHINT_VERSION}"
+ LINK=true
+ elif [[ ! -f "$VENV_DIR/bin/ttfautohint" ]]; then
+ LINK=true
fi
- if [[ ! -f "$VENV_DIR/bin/ttfautohint" ]]; then
- ln -vfs ../../deps/ttfautohint "$VENV_DIR/bin"
+ if $LINK; then
+ ln -vfs ../../deps/ttfautohint-1.8.2 "$VENV_DIR/bin/ttfautohint"
fi
if [[ ! -f "$VENV_DIR/bin/ttf2woff" ]] || [[ ! -f "$SRCDIR/misc/ttf2woff/ttf2woff" ]]; then
@@ -189,50 +302,6 @@ else
return 1
}
- check_cython_dep() {
- DIR=$1
- REF_FILE=$DIR/$2
- set -e
- if $clean || $PY_REQUIREMENTS_CHANGED || [ ! -f "$REF_FILE" ] || has_newer "$DIR" "$REF_FILE"; then
- pushd "$DIR" >/dev/null
- if $clean; then
- find . \
- -type f \
- -name '*.c' -or \
- -name '*.o' -or \
- -name '*.pyc' -or \
- -name '*.pyo' \
- | xargs rm
- fi
- if [ -f requirements.txt ]; then
- pip install -r requirements.txt
- fi
- python setup.py build_ext --inplace
- popd >/dev/null
- touch "$REF_FILE"
- PY_REQUIREMENTS_CHANGED=true
- fi
- }
-
- # native booleanOperations module
- check_cython_dep misc/pylib/booleanOperations flatten.so
- check_cython_dep misc/pylib/copy copy.so
- check_cython_dep misc/pylib/fontbuild mix.so
- check_cython_dep misc/pylib/robofab glifLib.so
-
- # ————————————————————————————————————————————————————————————————————————————————————————————————
- # $BUILD_TMP_DIR
- # create and mount spare disk image needed on macOS to support case-sensitive filenames
- if [[ "$(uname)" = *Darwin* ]]; then
- bash misc/mac-tmp-disk-mount.sh
- if $clean; then
- echo "[clean] rm -rf '$BUILD_TMP_DIR'/*"
- rm -rf "$BUILD_TMP_DIR"/*
- fi
- else
- mkdir -p "$BUILD_TMP_DIR"
- fi
-
# ————————————————————————————————————————————————————————————————————————————————————————————————
# $BUILD_DIR/etc/generated.make
master_styles=( \
@@ -273,55 +342,53 @@ else
all_styles=()
+ # add master styles to style array
for style in "${master_styles[@]}"; do
all_styles+=( $style )
echo "${style}_ufo_d := " \
"\$(wildcard src/Inter-UI-${style}.ufo/* src/Inter-UI-${style}.ufo/*/*)" >> "$GEN_MAKE_FILE"
- echo "$BUILD_TMP_DIR/InterUITTF/InterUI-${style}.ttf: \$(${style}_ufo_d)" >> "$GEN_MAKE_FILE"
- echo "$BUILD_TMP_DIR/InterUIOTF/InterUI-${style}.otf: \$(${style}_ufo_d)" >> "$GEN_MAKE_FILE"
done
- echo -n "all_ufo:" >> "$GEN_MAKE_FILE"
- for style in "${master_styles[@]}"; do
- echo -n " \$(${style}_ufo_d)" >> "$GEN_MAKE_FILE"
- done
+ # generate all_ufo: <master_ufos>
+ # echo -n "all_ufo:" >> "$GEN_MAKE_FILE"
+ # for style in "${master_styles[@]}"; do
+ # echo -n " \$(${style}_ufo_d)" >> "$GEN_MAKE_FILE"
+ # done
+ # echo "" >> "$GEN_MAKE_FILE"
+
echo "" >> "$GEN_MAKE_FILE"
+ # add derived styles to style array
for e in "${derived_styles[@]}"; do
style=$(echo "${e%%:*}" | xargs)
dependent_styles=$(echo "${e#*:}" | xargs)
all_styles+=( $style )
-
- echo -n "$BUILD_TMP_DIR/InterUITTF/InterUI-${style}.ttf:" >> "$GEN_MAKE_FILE"
- for depstyle in $dependent_styles; do
- echo -n " \$(${depstyle}_ufo_d)" >> "$GEN_MAKE_FILE"
- done
- echo "" >> "$GEN_MAKE_FILE"
-
- echo -n "$BUILD_TMP_DIR/InterUIOTF/InterUI-${style}.otf:" >> "$GEN_MAKE_FILE"
- for depstyle in $dependent_styles; do
- echo -n " \$(${depstyle}_ufo_d)" >> "$GEN_MAKE_FILE"
- done
- echo "" >> "$GEN_MAKE_FILE"
done
# STYLE and STYLE_ttf targets
for style in "${all_styles[@]}"; do
- echo "${style}_ttf_hinted: $DIST_DIR-hinted/Inter-UI-${style}.ttf" >> "$GEN_MAKE_FILE"
- echo "${style}_ttf: $DIST_DIR-unhinted/Inter-UI-${style}.ttf" >> "$GEN_MAKE_FILE"
- echo "${style}_otf: $DIST_DIR-unhinted/Inter-UI-${style}.otf" >> "$GEN_MAKE_FILE"
+ echo "${style}: ${style}_otf ${style}_ttf ${style}_ttf_hinted ${style}_web ${style}_web_hinted" >> "$GEN_MAKE_FILE"
- echo -n "${style}: ${style}_otf" >> "$GEN_MAKE_FILE"
+ echo "${style}_ttf_hinted: ${DIST_DIR}hinted/Inter-UI-${style}.ttf" >> "$GEN_MAKE_FILE"
+ echo "${style}_ttf: ${DIST_DIR}unhinted/Inter-UI-${style}.ttf" >> "$GEN_MAKE_FILE"
+ echo "${style}_otf: ${DIST_DIR}unhinted/Inter-UI-${style}.otf" >> "$GEN_MAKE_FILE"
+
+ echo -n "${style}_web:" >> "$GEN_MAKE_FILE"
for format in "${web_formats[@]}"; do
- echo -n " $DIST_DIR-unhinted/Inter-UI-${style}.${format}" >> "$GEN_MAKE_FILE"
+ echo -n " ${DIST_DIR}unhinted/Inter-UI-${style}.${format}" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
- echo -n "${style}_hinted: ${style}_ttf_hinted" >> "$GEN_MAKE_FILE"
+ echo -n "${style}_web_hinted:" >> "$GEN_MAKE_FILE"
for format in "${web_formats[@]}"; do
- echo -n " $DIST_DIR-hinted/Inter-UI-${style}.${format}" >> "$GEN_MAKE_FILE"
+ echo -n " ${DIST_DIR}hinted/Inter-UI-${style}.${format}" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
+
+ echo "${style}_check: ${DIST_DIR}unhinted/Inter-UI-${style}.otf ${DIST_DIR}unhinted/Inter-UI-${style}.ttf" >> "$GEN_MAKE_FILE"
+ echo -e "\t misc/fontbuild checkfont $^" >> "$GEN_MAKE_FILE"
+
+ echo "" >> "$GEN_MAKE_FILE"
done
# all_otf target
@@ -348,21 +415,35 @@ else
# all_web target
echo -n "all_web:" >> "$GEN_MAKE_FILE"
for style in "${all_styles[@]}"; do
- echo -n " ${style}" >> "$GEN_MAKE_FILE"
+ echo -n " ${style}_web" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
# all_web_hinted target
echo -n "all_web_hinted:" >> "$GEN_MAKE_FILE"
for style in "${all_styles[@]}"; do
- echo -n " ${style}_hinted" >> "$GEN_MAKE_FILE"
+ echo -n " ${style}_web_hinted" >> "$GEN_MAKE_FILE"
+ done
+ echo "" >> "$GEN_MAKE_FILE"
+
+ # all_check target
+ echo -n "all_check:" >> "$GEN_MAKE_FILE"
+ for style in "${all_styles[@]}"; do
+ echo -n " ${style}_check" >> "$GEN_MAKE_FILE"
+ done
+ echo "" >> "$GEN_MAKE_FILE"
+
+ # all_fonts target
+ echo -n "all_fonts:" >> "$GEN_MAKE_FILE"
+ for style in "${all_styles[@]}"; do
+ echo -n " ${style}" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
- echo -n ".PHONY: all_otf all_ttf_hinted all_ttf all_web all_web_hinted all_ufo" >> "$GEN_MAKE_FILE"
+ echo -n ".PHONY: all_otf all_ttf_hinted all_ttf all_web all_web_hinted all_ufo all_check" >> "$GEN_MAKE_FILE"
for style in "${all_styles[@]}"; do
- echo -n " ${style} ${style}_ttf ${style}_ttf_hinted ${style}_otf" >> "$GEN_MAKE_FILE"
+ echo -n " ${style} ${style}_ttf ${style}_ttf_hinted ${style}_otf ${style}_check" >> "$GEN_MAKE_FILE"
done
echo "" >> "$GEN_MAKE_FILE"
fi
@@ -370,14 +451,12 @@ else
# ————————————————————————————————————————————————————————————————————————————————————————————————
# summary
if ! $VENV_ACTIVE; then
- echo "You now need to activate virtualenv by:"
+ echo -n "You can activate virtualenv by running "
if [ "$0" == "./init.sh" ]; then
# pretty format for common case
- echo " source init.sh"
+ echo '`source init.sh`'
else
- echo " source '$0'"
+ echo "\`source \"$0\"\`"
fi
- echo "Or directly by sourcing the activate script:"
- echo " source '$VENV_DIR/bin/activate'"
fi
fi