diff options
author | Rasmus Andersson <rasmus@notion.se> | 2017-09-04 06:03:17 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2017-09-04 18:12:34 +0300 |
commit | 8234b62ab762637ef24c3398b4204a8ce8db31a7 (patch) | |
tree | 1c8df547021cdb58951630a015e4101ede46dbf1 /init.sh | |
parent | 31ae014e0c827dd76696fdab7e4ca3fed9f6402b (diff) | |
download | inter-8234b62ab762637ef24c3398b4204a8ce8db31a7.tar.xz |
Speeds up font compilation by around 200%
Cython is used to compile some hot paths into native Python extensions.
These hot paths were identified through running ufocompile with the hotshot
profiler and then converting file by file to Cython, starting with the "hottest"
paths and continuing until returns were deminishing. This means that only a few
Python files were converted to Cython.
Closes #23
Closes #20 (really this time)
Diffstat (limited to 'init.sh')
-rwxr-xr-x | init.sh | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -142,6 +142,35 @@ else ln -vfs ../../../misc/ttf2woff/ttf2woff "$VENV_DIR/bin" fi + has_newer() { + DIR=$1 + REF_FILE=$2 + for f in $(find "$DIR" -type f -name '*.pyx' -newer "$REF_FILE" -print -quit); do + return 0 + done + return 1 + } + + check_cython_dep() { + DIR=$1 + REF_FILE=$DIR/$2 + set -e + if [ ! -f "$REF_FILE" ] || has_newer "$DIR" "$REF_FILE"; then + pushd "$DIR" >/dev/null + if [ -f requirements.txt ]; then + pip install -r requirements.txt + fi + python setup.py build_ext --inplace + popd >/dev/null + 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 @@ -179,10 +208,9 @@ else if $NEED_GENERATE; then break fi - for srcfile in $(find src/Interface-${style}.ufo -type f -newer "$GEN_MAKE_FILE"); do + if has_newer "src/Interface-${style}.ufo" "$GEN_MAKE_FILE"; then NEED_GENERATE=true - break - done + fi done fi |