[DEPENDS] Use parallel compilation when building packages
Summary:
This diffs try to guess the number of cores availble on the user machine
and forward it (+1) to the -jX option to make when building the
packages.
This JOBS variable can be overriden by the user and fallback to 1 if
it can't guess the number of cores.
For now only ccache makes use of this feature. This is built on all the platforms and is simple enough for demonstrating the feature.
Test Plan:
cd depends
Edit packages/native_ccache.mk, add the line:
echo "BUILDING WITH -j$(JOBS)" && \
before the line:
$(MAKE) -j$(JOBS) make V=1
Check in the output that make is invoked with the appropriated -jX
option(for the ccache package).
make V=1 JOBS=2
Check in the output that make is invoked with the appropriated -j2
option (for the ccache package).
make V=1 build-all
Check in the output that the JOBS is propagated to the ccache package of all the targets.
Run the Gitian builds and check the output is still deterministic (clear
the cached packages before building).
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D4852