Skip to content

Commit

Permalink
Factor out setting of B2_JOBS
Browse files Browse the repository at this point in the history
Allows reuse in other scripts
  • Loading branch information
Flamefire committed Apr 28, 2022
1 parent 033084a commit 6521312
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 1 addition & 5 deletions ci/enforce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ if [ -z "$B2_CXXSTD" ]; then
export B2_CXXSTD=11
fi

# default parallel build jobs: number of CPUs available + 1
if [ -z "${B2_JOBS}" ]; then
cpus=$(grep -c 'processor' /proc/cpuinfo || python -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
export B2_JOBS=$((cpus + 1))
fi
. "$(dirname "${BASH_SOURCE[0]}")"/set_num_jobs.sh

# Build cmdline arguments for B2 as an array to preserve quotes
if [ -z "$B2_CI_VERSION" ]; then
Expand Down
17 changes: 17 additions & 0 deletions ci/set_num_jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright 2017 - 2019 James E. King III
# Copyright 2022 Alexander Grund
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# Determine a good number of (build) jobs to use and stores it in B2_JOBS
#

if [ -z "${B2_JOBS:-}" ]; then
# default parallel build jobs: number of CPUs available + 1.
# In case of failure 2 CPUs are assumed
cpus=$(grep -c 'processor' /proc/cpuinfo || python -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
export B2_JOBS=$((cpus + 1))
fi

0 comments on commit 6521312

Please sign in to comment.