app-shells/bash: stable 5.0_p17 for hppa, bug #719942
[gentoo.git] / eclass / ninja-utils.eclass
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: ninja-utils.eclass
5 # @MAINTAINER:
6 # Michał Górny <mgorny@gentoo.org>
7 # Mike Gilbert <floppym@gentoo.org>
8 # @AUTHOR:
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
13 # @DESCRIPTION:
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,
19 # Meson).
20
21 if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then
22
23 case ${EAPI:-0} in
24         0|1|3) die "EAPI=${EAPI:-0} is not supported (too old)";;
25         # copied from cmake-utils
26         2|4|5|6|7) ;;
27         *) die "EAPI=${EAPI} is not yet supported" ;;
28 esac
29
30 # @ECLASS-VARIABLE: NINJAOPTS
31 # @DEFAULT_UNSET
32 # @DESCRIPTION:
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
35 # MAKEOPTS instead.
36
37 inherit multiprocessing
38
39 # @FUNCTION: eninja
40 # @USAGE: [<args>...]
41 # @DESCRIPTION:
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'.
45 eninja() {
46         local nonfatal_args=()
47         [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=( -n )
48
49         if [[ -z ${NINJAOPTS+set} ]]; then
50                 NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)"
51         fi
52         set -- ninja -v ${NINJAOPTS} "$@"
53         echo "$@" >&2
54         "$@" || die "${nonfatal_args[@]}" "${*} failed"
55 }
56
57 _NINJA_UTILS_ECLASS=1
58 fi