1 |
On nie, 2017-04-30 at 22:28 +0200, Michał Górny wrote: |
2 |
> --- |
3 |
> eclass/ninja-utils.eclass | 57 +++++++++++++++++++++++++++++++++++++++++++++++ |
4 |
> 1 file changed, 57 insertions(+) |
5 |
> create mode 100644 eclass/ninja-utils.eclass |
6 |
> |
7 |
> diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass |
8 |
> new file mode 100644 |
9 |
> index 000000000000..69216176ba61 |
10 |
> --- /dev/null |
11 |
> +++ b/eclass/ninja-utils.eclass |
12 |
> @@ -0,0 +1,57 @@ |
13 |
> +# Copyright 1999-2017 Gentoo Foundation |
14 |
> +# Distributed under the terms of the GNU General Public License v2 |
15 |
> + |
16 |
> +# @ECLASS: ninja-utils.eclass |
17 |
> +# @MAINTAINER: |
18 |
> +# Michał Górny <mgorny@g.o> |
19 |
> +# Mike Gilbert <floppym@g.o> |
20 |
> +# @AUTHOR: |
21 |
> +# Michał Górny <mgorny@g.o> |
22 |
> +# Mike Gilbert <floppym@g.o> |
23 |
> +# @BLURB: common bits to run dev-util/ninja builder |
24 |
> +# @DESCRIPTION: |
25 |
> +# This eclass provides a single function -- eninja -- that can be used |
26 |
> +# to run the ninja builder alike emake. It does not define any |
27 |
> +# dependencies, you need to depend on dev-util/ninja yourself. Since |
28 |
> +# ninja is rarely used stand-alone, most of the time this eclass will |
29 |
> +# be used indirectly by the eclasses for other build systems (CMake, |
30 |
> +# Meson). |
31 |
> + |
32 |
> +if [[ -z ${_NINJA_UTILS_ECLASS} ]]; then |
33 |
> + |
34 |
> +case ${EAPI:-0} in |
35 |
> + 0|1|3) die "EAPI=${EAPI:-0} is not supported (too old)";; |
36 |
> + # copied from cmake-utils |
37 |
> + 2|4|5|6) ;; |
38 |
> + *) die "EAPI=${EAPI} is not yet supported" ;; |
39 |
> +esac |
40 |
> + |
41 |
> +# @ECLASS-VARIABLE: NINJAOPTS |
42 |
> +# @DEFAULT_UNSET |
43 |
> +# @DESCRIPTION: |
44 |
> +# The default set of options to pass to Ninja. Similar to MAKEOPTS, |
45 |
> +# supposed to be set in make.conf. If unset, eninja() will convert |
46 |
> +# MAKEOPTS instead. |
47 |
> + |
48 |
> +inherit multiprocessing |
49 |
> + |
50 |
> +# @FUNCTION: eninja |
51 |
> +# @USAGE: [<args>...] |
52 |
> +# @DESCRIPTION: |
53 |
> +# Call Ninja, passing the NINJAOPTS (or converted MAKEOPTS), followed |
54 |
> +# by the supplied arguments. This function dies if ninja fails. Starting |
55 |
> +# with EAPI 6, it also supports being called via 'nonfatal'. |
56 |
> +eninja() { |
57 |
> + local nonfatal_args=() |
58 |
> + [[ ${EAPI:-0} != [245] ]] && nonfatal_args+=( -n ) |
59 |
> + |
60 |
> + if [[ -z ${NINJAOPTS+set} ]]; then |
61 |
> + NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)" |
62 |
> + fi |
63 |
> + set -- ninja -v ${NINJAOPTS} "$@" |
64 |
> + echo "$@" >&2 |
65 |
> + "$@" || die "${nonfatal_args[@]}" "${*} failed" |
66 |
> +} |
67 |
> + |
68 |
> +_NINJA_UTILS_ECLASS=1 |
69 |
> +fi |
70 |
|
71 |
Committed. |
72 |
|
73 |
-- |
74 |
Best regards, |
75 |
Michał Górny |