1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: ninja-utils.eclass
6 # Michał Górny <mgorny@gentoo.org>
7 # Mike Gilbert <floppym@gentoo.org>
9 # Michał Górny <mgorny@gentoo.org>
10 # Mike Gilbert <floppym@gentoo.org>
11 # @SUPPORTED_EAPIS: 2 4 5 6 7
12 # @BLURB: common bits to run dev-util/ninja builder
14 # This eclass provides a single function -- eninja -- that can be used
15 # to run the ninja builder alike emake. It does not define any
16 # dependencies, you need to depend on dev-util/ninja yourself. Since
17 # ninja is rarely used stand-alone, most of the time this eclass will
18 # be used indirectly by the eclasses for other build systems (CMake,
21 if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
24 0|1|3) die "EAPI=${EAPI:-0} is not supported (too old)";;
25 # copied from cmake-utils
27 *) die "EAPI=${EAPI} is not yet supported" ;;
30 # @ECLASS-VARIABLE: NINJAOPTS
33 # The default set of options to pass to Ninja. Similar to MAKEOPTS,
34 # supposed to be set in make.conf. If unset, eninja() will convert
37 inherit multiprocessing
42 # Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed
43 # by the supplied arguments. This function dies if ninja fails. Starting
44 # with EAPI 6, it also supports being called via 'nonfatal'.
46 local nonfatal_args=()
47 [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=( -n )
49 if [[ -z ${NINJAOPTS+set} ]]; then
50 NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)"
52 set -- ninja -v ${NINJAOPTS} "$@"
54 "$@" || die "${nonfatal_args[@]}" "${*} failed"