1 # Copyright 1999-2017 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 # @BLURB: common bits to run dev-util/ninja builder
13 # This eclass provides a single function -- eninja -- that can be used
14 # to run the ninja builder alike emake. It does not define any
15 # dependencies, you need to depend on dev-util/ninja yourself. Since
16 # ninja is rarely used stand-alone, most of the time this eclass will
17 # be used indirectly by the eclasses for other build systems (CMake,
20 if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
23 0|1|3) die "EAPI=${EAPI:-0} is not supported (too old)";;
24 # copied from cmake-utils
26 *) die "EAPI=${EAPI} is not yet supported" ;;
29 # @ECLASS-VARIABLE: NINJAOPTS
32 # The default set of options to pass to Ninja. Similar to MAKEOPTS,
33 # supposed to be set in make.conf. If unset, eninja() will convert
36 inherit multiprocessing
41 # Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed
42 # by the supplied arguments. This function dies if ninja fails. Starting
43 # with EAPI 6, it also supports being called via 'nonfatal'.
45 local nonfatal_args=()
46 [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=( -n )
48 if [[ -z ${NINJAOPTS+set} ]]; then
49 NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)"
51 set -- ninja -v ${NINJAOPTS} "$@"
53 "$@" || die "${nonfatal_args[@]}" "${*} failed"