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