Gentoo Archives: gentoo-commits

From: Tomas Chvatal <scarabeus@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/kde:master commit in: eclass/
Date: Wed, 31 Oct 2012 13:41:11
Message-Id: 1351690843.f472e8d3a2178094c650f673b79441089491d7b6.scarabeus@gentoo
1 commit: f472e8d3a2178094c650f673b79441089491d7b6
2 Author: Tomas Chvatal <tchvatal <AT> suse <DOT> cz>
3 AuthorDate: Wed Oct 31 13:40:43 2012 +0000
4 Commit: Tomas Chvatal <scarabeus <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 31 13:40:43 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=f472e8d3
7
8 [eclass] Try to make cmake-utils work nice with ninja. Wrt bug#439608.
9
10 ---
11 eclass/cmake-utils.eclass | 102 +++++++++++++++++++++++++++++++-------------
12 1 files changed, 72 insertions(+), 30 deletions(-)
13
14 diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
15 index 1adb29d..a624196 100644
16 --- a/eclass/cmake-utils.eclass
17 +++ b/eclass/cmake-utils.eclass
18 @@ -1,6 +1,6 @@
19 # Copyright 1999-2012 Gentoo Foundation
20 # Distributed under the terms of the GNU General Public License v2
21 -# $Header: $
22 +# $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.85 2012/10/25 12:48:58 scarabeus Exp $
23
24 # @ECLASS: cmake-utils.eclass
25 # @MAINTAINER:
26 @@ -44,9 +44,9 @@ CMAKE_REMOVE_MODULES="${CMAKE_REMOVE_MODULES:-yes}"
27
28 # @ECLASS-VARIABLE: CMAKE_MAKEFILE_GENERATOR
29 # @DESCRIPTION:
30 -# Specify a makefile generator to be used by cmake. At this point only "make"
31 -# and "ninja" is supported.
32 -CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-make}"
33 +# Specify a makefile generator to be used by cmake.
34 +# At this point only "emake" and "ninja" is supported.
35 +CMAKE_MAKEFILE_GENERATOR="${CMAKE_MAKEFILE_GENERATOR:-emake}"
36
37 CMAKEDEPEND=""
38 case ${WANT_CMAKE} in
39 @@ -67,6 +67,19 @@ case ${EAPI:-0} in
40 esac
41 EXPORT_FUNCTIONS ${CMAKE_EXPF}
42
43 +case ${CMAKE_MAKEFILE_GENERATOR} in
44 + emake)
45 + CMAKEDEPEND+=" sys-devel/make"
46 + ;;
47 + ninja)
48 + CMAKEDEPEND+=" dev-util/ninja"
49 + ;;
50 + *)
51 + eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
52 + die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
53 + ;;
54 +esac
55 +
56 if [[ ${PN} != cmake ]]; then
57 CMAKEDEPEND+=" >=dev-util/cmake-${CMAKE_MIN_VERSION}"
58 fi
59 @@ -173,10 +186,22 @@ _check_build_dir() {
60
61 # Determine which generator to use
62 _generator_to_use() {
63 - if [[ ${CMAKE_MAKEFILE_GENERATOR} = "ninja" ]]; then
64 - has_version dev-util/ninja && echo "Ninja" && return
65 - fi
66 - echo "Unix Makefiles"
67 + local generator_name
68 +
69 + case ${CMAKE_MAKEFILE_GENERATOR} in
70 + ninja)
71 + generator_name="Ninja"
72 + ;;
73 + emake)
74 + generator_name="Unix Makefiles"
75 + ;;
76 + *)
77 + eerror "Unknown value for \${CMAKE_MAKEFILE_GENERATOR}"
78 + die "Value ${CMAKE_MAKEFILE_GENERATOR} is not supported"
79 + ;;
80 + esac
81 +
82 + echo ${generator_name}
83 }
84
85 # @FUNCTION: cmake-utils_use_with
86 @@ -410,33 +435,52 @@ enable_cmake-utils_src_compile() {
87 cmake-utils_src_make "$@"
88 }
89
90 -# @FUNCTION: cmake-utils_src_make
91 +# @FUNCTION: ninja_src_make
92 +# @INTERNAL
93 # @DESCRIPTION:
94 -# Function for building the package. Automatically detects the build type.
95 -# All arguments are passed to emake.
96 -cmake-utils_src_make() {
97 +# Build the package using ninja generator
98 +ninja_src_make() {
99 debug-print-function ${FUNCNAME} "$@"
100
101 - _check_build_dir
102 - pushd "${CMAKE_BUILD_DIR}" > /dev/null
103 - if [[ $(_generator_to_use) = Ninja ]]; then
104 - # first check if Makefile exist otherwise die
105 [[ -e build.ninja ]] || die "Makefile not found. Error during configure stage."
106 +
107 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
108 - #TODO get load average from portage (-l option)
109 - ninja ${MAKEOPTS} -v "$@"
110 - else
111 - ninja "$@"
112 - fi || die "ninja failed!"
113 + # TODO: get load average from portage (-l option)
114 + ninja ${MAKEOPTS} -v "$@" || die
115 else
116 - # first check if Makefile exist otherwise die
117 + ninja "$@" || die
118 + fi
119 +}
120 +
121 +# @FUNCTION: make_src_make
122 +# @INTERNAL
123 +# @DESCRIPTION:
124 +# Build the package using make generator
125 +emake_src_make() {
126 + debug-print-function ${FUNCNAME} "$@"
127 +
128 [[ -e Makefile ]] || die "Makefile not found. Error during configure stage."
129 +
130 if [[ "${CMAKE_VERBOSE}" != "OFF" ]]; then
131 - emake VERBOSE=1 "$@" || die "Make failed!"
132 + emake VERBOSE=1 "$@" || die
133 else
134 - emake "$@" || die "Make failed!"
135 - fi
136 + emake "$@" || die
137 fi
138 +
139 +}
140 +
141 +# @FUNCTION: cmake-utils_src_make
142 +# @DESCRIPTION:
143 +# Function for building the package. Automatically detects the build type.
144 +# All arguments are passed to emake.
145 +cmake-utils_src_make() {
146 + debug-print-function ${FUNCNAME} "$@"
147 +
148 + _check_build_dir
149 + pushd "${CMAKE_BUILD_DIR}" > /dev/null
150 +
151 + ${CMAKE_MAKEFILE_GENERATOR}_src_make $@
152 +
153 popd > /dev/null
154 }
155
156 @@ -445,12 +489,10 @@ enable_cmake-utils_src_install() {
157
158 _check_build_dir
159 pushd "${CMAKE_BUILD_DIR}" > /dev/null
160 - if [[ $(_generator_to_use) = Ninja ]]; then
161 - DESTDIR=${D} ninja install "$@" || die "died running ninja install"
162 +
163 + DESTDIR=${D} ${CMAKE_MAKEFILE_GENERATOR} install "$@" || die "died running ninja install"
164 base_src_install_docs
165 - else
166 - base_src_install "$@"
167 - fi
168 +
169 popd > /dev/null
170
171 # Backward compatibility, for non-array variables