source-foundry / ttfautohint-build

Build ttfautohint from source on Linux and macOS platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Speed up builds by using multiple cores and parallel building

CodingMarkus opened this issue · comments

Just add this at the very top of your script:

# Detect how many CPU cores are available
cores=$( (nproc --all || sysctl -n hw.ncpu) 2>/dev/null || echo 1 )

This command will detect the number of CPU cores available on either Linux (nproc) or BSD-like systems (sysctl), including FreeBSD and macOS, and just fall back to 1 on all other systems, which is the same behavior the script currently has, where only one core is used.

And then replace every make with make -j "$cores" and the entire script runs almost 4 times faster on my system.

Thanks! Interested in submitting a pull request to add this?