Gentoo Archives: gentoo-commits

From: "Wulf Krueger (philantrop)" <philantrop@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: cmake-utils.eclass
Date: Sun, 04 Nov 2007 13:17:42
Message-Id: E1IofM8-0000g9-Gk@stork.gentoo.org
1 philantrop 07/11/04 13:17:36
2
3 Added: cmake-utils.eclass
4 Log:
5 New cmake-utils.eclass providing functions for the cmake build system with all requested fixes after the review on gentoo-dev.
6
7 Revision Changes Path
8 1.1 eclass/cmake-utils.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/cmake-utils.eclass?rev=1.1&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/cmake-utils.eclass?rev=1.1&content-type=text/plain
12
13 Index: cmake-utils.eclass
14 ===================================================================
15 # Copyright 1999-2007 Gentoo Foundation
16 # Distributed under the terms of the GNU General Public License v2
17 # $Header: /var/cvsroot/gentoo-x86/eclass/cmake-utils.eclass,v 1.1 2007/11/04 13:17:35 philantrop Exp $
18
19 # @ECLASS: cmake-utils.eclass
20 # @MAINTAINER:
21 # kde@g.o
22 # @BLURB: common ebuild functions for cmake-based packages
23 # @DESCRIPTION:
24 # The cmake-utils eclass contains functions that make creating ebuilds for
25 # cmake-based packages much easier.
26 # Its main features are support of out-of-source builds as well as in-source
27 # builds and an implementation of the well-known use_enable and use_with
28 # functions for CMake.
29
30 # Original author: Zephyrus (zephyrus@××××××.it)
31
32 inherit toolchain-funcs multilib
33
34 DESCRIPTION="Based on the ${ECLASS} eclass"
35
36 DEPEND="dev-util/cmake"
37
38 EXPORT_FUNCTIONS src_compile src_test src_install
39
40 # Internal function use by cmake-utils_use_with and cmake-utils_use_enable
41 _use_me_now() {
42 debug-print-function $FUNCNAME $*
43 [[ -z $2 ]] && die "cmake-utils_use-$1 <USE flag> [<flag name>]"
44 echo "-D$1_${3:-$2}=$(use $2 && echo ON || echo OFF)"
45 }
46
47 # @FUNCTION: cmake-utils_use_with
48 # @USAGE: <USE flag> [flag name]
49 # @DESCRIPTION:
50 # Based on use_with. See ebuild.sh
51 cmake-utils_use_with() { _use_me_now WITH "$@" ; }
52
53 # @FUNCTION: cmake-utils_use_enable
54 # @USAGE: <USE flag> [flag name]
55 # @DESCRIPTION:
56 # Based on use_enable. See ebuild.sh
57 cmake-utils_use_enable() { _use_me_now ENABLE "$@" ; }
58
59 # @FUNCTION: cmake-utils_src_compile
60 # @DESCRIPTION:
61 # General function for compiling with cmake. Default behaviour is to start an
62 # out-of-source build
63 cmake-utils_src_compile() {
64 debug-print-function $FUNCNAME $*
65
66 cmake-utils_src_configureout
67 cmake-utils_src_make
68 }
69
70 # @FUNCTION: cmake-utils_src_configurein
71 # @DESCRIPTION:
72 # Function for software that requires configure and building in the source
73 # directory.
74 cmake-utils_src_configurein() {
75 debug-print-function $FUNCNAME $*
76
77 local cmakeargs="${mycmakeargs} $(_common_configure_code)"
78
79 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
80 cmake ${cmakeargs} . || die "Cmake failed"
81 }
82
83 # @FUNCTION: cmake-utils_src_configureout
84 # @DESCRIPTION:
85 # Function for software that requires configure and building outside the source
86 # tree - default.
87 cmake-utils_src_configureout() {
88 debug-print-function $FUNCNAME $*
89
90 local cmakeargs="${mycmakeargs} $(_common_configure_code)"
91 mkdir "${WORKDIR}"/${PN}_build
92 cd "${WORKDIR}"/${PN}_build
93
94 debug-print "$LINENO $ECLASS $FUNCNAME: mycmakeargs is $cmakeargs"
95 cmake ${cmakeargs} "${S}" || die "Cmake failed"
96 }
97
98 # Internal use only. Common configuration options for all types of builds.
99 _common_configure_code() {
100 local tmp_libdir=$(get_libdir)
101 if has debug ${IUSE} && use debug; then
102 echo -DCMAKE_BUILD_TYPE=debug
103 fi
104 echo -DCMAKE_C_COMPILER=$(type -P $(tc-getCC))
105 echo -DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX))
106 echo -DCMAKE_INSTALL_PREFIX=${PREFIX:-/usr}
107 echo -DLIB_SUFFIX=${tmp_libdir/lib}
108 [[ -n ${CMAKE_NO_COLOR} ]] && echo -DCMAKE_COLOR_MAKEFILE=OFF
109 }
110
111 # @FUNCTION: cmake-utils_src_make
112 # @DESCRIPTION:
113 # Function for building the package. Automatically detects the build type.
114 cmake-utils_src_make() {
115 debug-print-function $FUNCNAME $*
116
117 # At this point we can automatically check if it's an out-of-source or an
118 # in-source build
119 if [[ -d ${WORKDIR}/${PN}_build ]]; then
120 cd "${WORKDIR}"/${PN}_build;
121 fi
122 if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then
123 emake VERBOSE=1 || die "Make failed!";
124 else
125 emake || die "Make failed!";
126 fi
127 }
128
129 # @FUNCTION: cmake-utils_src_install
130 # @DESCRIPTION:
131 # Function for installing the package. Automatically detects the build type.
132 cmake-utils_src_install() {
133 debug-print-function $FUNCNAME $*
134
135 # At this point we can automatically check if it's an out-of-source or an
136 # in-source build
137 if [[ -d ${WORKDIR}/${PN}_build ]]; then
138 cd "${WORKDIR}"/${PN}_build;
139 fi
140 emake install DESTDIR="${D}" || die "Make install failed"
141 }
142
143 # @FUNCTION: cmake-utils_src_test
144 # @DESCRIPTION:
145 # Function for testing the package. Automatically detects the build type.
146 cmake-utils_src_test() {
147 debug-print-function $FUNCNAME $*
148
149 # At this point we can automatically check if it's an out-of-source or an
150 # in-source build
151 if [[ -d ${WORKDIR}/${PN}_build ]]; then
152 cd "${WORKDIR}"/${PN}_build
153 fi
154 # Standard implementation of src_test
155 if emake -j1 check -n &> /dev/null; then
156 einfo ">>> Test phase [check]: ${CATEGORY}/${PF}"
157 if ! emake -j1 check; then
158 die "Make check failed. See above for details."
159 fi
160 elif emake -j1 test -n &> /dev/null; then
161 einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
162 if ! emake -j1 test; then
163 die "Make test failed. See above for details."
164 fi
165 else
166 einfo ">>> Test phase [none]: ${CATEGORY}/${PF}"
167 fi
168 }
169
170
171
172 --
173 gentoo-commits@g.o mailing list