source-foundry / ttfautohint-build

Build ttfautohint from source on Linux and macOS platforms
MIT License
27 stars 12 forks source link

Speed up builds by using multiple cores and parallel building #41

Open CodingMarkus opened 2 years ago

CodingMarkus commented 2 years ago

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.

chrissimpkins commented 2 years ago

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