1 |
From: orbea <orbea@××××××.net> |
2 |
|
3 |
Signed-off-by: Lars Wendler <polynomial-c@g.o> |
4 |
--- |
5 |
eclass/cmake.eclass | 22 ++++++++-------------- |
6 |
eclass/meson.eclass | 4 ++-- |
7 |
eclass/ninja-utils.eclass | 37 +++++++++++++++++++++++++++++++++++-- |
8 |
3 files changed, 45 insertions(+), 18 deletions(-) |
9 |
|
10 |
diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass |
11 |
index 4bd09459ea6..935ee1d8c81 100644 |
12 |
--- a/eclass/cmake.eclass |
13 |
+++ b/eclass/cmake.eclass |
14 |
@@ -52,9 +52,9 @@ _CMAKE_ECLASS=1 |
15 |
# @DEFAULT_UNSET |
16 |
# @DESCRIPTION: |
17 |
# Specify a makefile generator to be used by cmake. |
18 |
-# At this point only "emake" and "ninja" are supported. |
19 |
-# The default is set to "ninja". |
20 |
-: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
21 |
+# At this point only "emake", "eninja" and "ninja" are supported. |
22 |
+# The default is set to "eninja". |
23 |
+: ${CMAKE_MAKEFILE_GENERATOR:=eninja} |
24 |
|
25 |
# @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST |
26 |
# @DESCRIPTION: |
27 |
@@ -117,8 +117,8 @@ case ${CMAKE_MAKEFILE_GENERATOR} in |
28 |
emake) |
29 |
BDEPEND="sys-devel/make" |
30 |
;; |
31 |
- ninja) |
32 |
- BDEPEND="dev-util/ninja" |
33 |
+ eninja|ninja) |
34 |
+ BDEPEND="|| ( dev-util/ninja dev-util/samurai )" |
35 |
;; |
36 |
*) |
37 |
eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}" |
38 |
@@ -335,13 +335,6 @@ cmake_src_prepare() { |
39 |
die "FATAL: Unable to find CMakeLists.txt" |
40 |
fi |
41 |
|
42 |
- # if ninja is enabled but not installed, the build could fail |
43 |
- # this could happen if ninja is manually enabled (eg. make.conf) but not installed |
44 |
- if [[ ${CMAKE_MAKEFILE_GENERATOR} == ninja ]] && ! has_version -b dev-util/ninja; then |
45 |
- eerror "CMAKE_MAKEFILE_GENERATOR is set to ninja, but ninja is not installed." |
46 |
- die "Please install dev-util/ninja or unset CMAKE_MAKEFILE_GENERATOR." |
47 |
- fi |
48 |
- |
49 |
local modules_list |
50 |
if [[ $(declare -p CMAKE_REMOVE_MODULES_LIST) == "declare -a"* ]]; then |
51 |
modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" ) |
52 |
@@ -534,7 +527,7 @@ cmake_src_configure() { |
53 |
|
54 |
local generator_name |
55 |
case ${CMAKE_MAKEFILE_GENERATOR} in |
56 |
- ninja) generator_name="Ninja" ;; |
57 |
+ eninja|ninja) generator_name="Ninja" ;; |
58 |
emake) generator_name="Unix Makefiles" ;; |
59 |
esac |
60 |
|
61 |
@@ -592,8 +585,9 @@ cmake_build() { |
62 |
*) emake VERBOSE=1 "$@" ;; |
63 |
esac |
64 |
;; |
65 |
- ninja) |
66 |
+ eninja|ninja) |
67 |
[[ -e build.ninja ]] || die "build.ninja not found. Error during configure stage." |
68 |
+ CMAKE_MAKEFILE_GENERATOR=eninja |
69 |
eninja "$@" |
70 |
;; |
71 |
esac |
72 |
diff --git a/eclass/meson.eclass b/eclass/meson.eclass |
73 |
index d0ce5adb355..ea02402aa83 100644 |
74 |
--- a/eclass/meson.eclass |
75 |
+++ b/eclass/meson.eclass |
76 |
@@ -1,4 +1,4 @@ |
77 |
-# Copyright 2017-2020 Gentoo Authors |
78 |
+# Copyright 2017-2021 Gentoo Authors |
79 |
# Distributed under the terms of the GNU General Public License v2 |
80 |
|
81 |
# @ECLASS: meson.eclass |
82 |
@@ -55,7 +55,7 @@ if [[ -z ${_MESON_ECLASS} ]]; then |
83 |
_MESON_ECLASS=1 |
84 |
|
85 |
MESON_DEPEND=">=dev-util/meson-0.54.0 |
86 |
- >=dev-util/ninja-1.8.2 |
87 |
+ || ( >=dev-util/ninja-1.8.2 dev-util/samurai ) |
88 |
dev-util/meson-format-array |
89 |
" |
90 |
|
91 |
diff --git a/eclass/ninja-utils.eclass b/eclass/ninja-utils.eclass |
92 |
index ca8d67191dc..5008564dabf 100644 |
93 |
--- a/eclass/ninja-utils.eclass |
94 |
+++ b/eclass/ninja-utils.eclass |
95 |
@@ -1,4 +1,4 @@ |
96 |
-# Copyright 1999-2018 Gentoo Foundation |
97 |
+# Copyright 1999-2021 Gentoo Authors |
98 |
# Distributed under the terms of the GNU General Public License v2 |
99 |
|
100 |
# @ECLASS: ninja-utils.eclass |
101 |
@@ -27,6 +27,15 @@ case ${EAPI:-0} in |
102 |
*) die "EAPI=${EAPI} is not yet supported" ;; |
103 |
esac |
104 |
|
105 |
+# @ECLASS-VARIABLE: NINJA |
106 |
+# @PRE_INHERIT |
107 |
+# @DEFAULT_UNSET |
108 |
+# @DESCRIPTION: |
109 |
+# Specify a compatible ninja implementation to be used by eninja. |
110 |
+# At this point only "ninja" and "samu" are supported. |
111 |
+# The default is set to "ninja". |
112 |
+: ${NINJA:=ninja} |
113 |
+ |
114 |
# @ECLASS-VARIABLE: NINJAOPTS |
115 |
# @DEFAULT_UNSET |
116 |
# @DESCRIPTION: |
117 |
@@ -36,6 +45,30 @@ esac |
118 |
|
119 |
inherit multiprocessing |
120 |
|
121 |
+_ninja_to_use() { |
122 |
+ case "${NINJA}" in |
123 |
+ ninja) |
124 |
+ local ninja=dev-util/${NINJA} |
125 |
+ ;; |
126 |
+ samu) |
127 |
+ local ninja=dev-util/samurai |
128 |
+ ;; |
129 |
+ *) |
130 |
+ eerror "Unknown value for \${NINJA}" |
131 |
+ die "Value ${NINJA} is not supported" |
132 |
+ ;; |
133 |
+ esac |
134 |
+ |
135 |
+ # if ninja or samurai are enabled but not installed, the build could fail |
136 |
+ # this could happen if they are manually enabled (eg. make.conf) but not installed |
137 |
+ if ! has_version -b ${ninja}; then |
138 |
+ eerror "Value ${NINJA} for \${NINJA} is not installed" |
139 |
+ die "Please install ${ninja}" |
140 |
+ fi |
141 |
+ |
142 |
+ echo ${NINJA} |
143 |
+} |
144 |
+ |
145 |
# @FUNCTION: eninja |
146 |
# @USAGE: [<args>...] |
147 |
# @DESCRIPTION: |
148 |
@@ -49,7 +82,7 @@ eninja() { |
149 |
if [[ -z ${NINJAOPTS+set} ]]; then |
150 |
NINJAOPTS="-j$(makeopts_jobs) -l$(makeopts_loadavg "${MAKEOPTS}" 0)" |
151 |
fi |
152 |
- set -- ninja -v ${NINJAOPTS} "$@" |
153 |
+ set -- "$(_ninja_to_use)" -v ${NINJAOPTS} "$@" |
154 |
echo "$@" >&2 |
155 |
"$@" || die "${nonfatal_args[@]}" "${*} failed" |
156 |
} |
157 |
-- |
158 |
2.31.1 |