blob: a14af06eb81462c7161b13f8d801e9f4254dd50b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# Original Author: Zephyrus (zephyrus@mirach.it)
# Purpose: Implementing useful functions for cmake based ebuilds
#
DEPEND="dev-util/cmake"
IUSE="debug"
inherit toolchain-funcs
EXPORT_FUNCTIONS src_compile src_test src_install
# Based on use_with. See ebuild.sh
# $1 use flag
# $2 extension name
function cmake-utils_use_with() {
debug-print-function $FUNCNAME $*
if [ -z "$1" ]; then
echo "!!! cmake-utils_use_with() called without a parameter." >&2
echo "!!! use_enable <USEFLAG> [<flagname>]" >&2
return 1
fi
local UWORD="$2"
if [ -z "${UWORD}" ]; then
UWORD="$1"
fi
if useq $1; then
echo "-DWITH_${UWORD}=ON"
else
echo "-DWITH_${UWORD}=OFF"
fi
return 0
}
# Based on use_enable. See ebuild.sh
# $1 use flag
# $2 extension name
function cmake-utils_use_enable() {
debug-print-function $FUNCNAME $*
if [ -z "$1" ]; then
echo "!!! cmake-utils_use_enable() called without a parameter." >&2
echo "!!! use_enable <USEFLAG> [<flagname>]" >&2
return 1
fi
local UWORD="$2"
if [ -z "${UWORD}" ]; then
UWORD="$1"
fi
if useq $1; then
echo "-DENABLE_${UWORD}=ON"
else
echo "-DENABLE_${UWORD}=OFF"
fi
return 0
}
# General function for compiling with cmake - Default behaviour is to starts an
# outsource build
function cmake-utils_src_compile() {
debug-print-function $FUNCNAME $*
cmake-utils_src_configureout
cmake-utils_src_make
}
# Functions for software that requires configure and building in the source
# directory
function cmake-utils_src_configurein() {
debug-print-function $FUNCNAME $*
common_configure_code
debug-print "$BASH_SOURCE $LINENO $ECLASS $FUNCNAME: mycmakeargs is $mycmakeargs"
cmake ${mycmakeargs} . || die "Cmake failed"
}
# Functions for software that requires configure and building outside the source
# tree - Default
function cmake-utils_src_configureout() {
debug-print-function $FUNCNAME $*
mkdir ${S}/../${PN}_build
cd ${S}/../${PN}_build
common_configure_code
debug-print "$BASH_SOURCE $LINENO $ECLASS $FUNCNAME: mycmakeargs is $mycmakeargs"
cmake ${mycmakeargs} ${S} || die "Cmake failed"
}
function common_configure_code() {
if use debug; then
mycmakeargs="${mycmakeargs} -DCMAKE_BUILD_TYPE=debug";
fi
# Toolchain arguments
mycmakeargs="${mycmakeargs}
-DCMAKE_C_COMPILER=$(type -P $(tc-getCC))
-DCMAKE_CXX_COMPILER=$(type -P $(tc-getCXX))"
if ! [[ -z ${BINDNOW_FLAGS} ]]; then
# FIXME: is there a better way to handle this?
append-ldflags ${BINDNOW_FLAGS}
fi
}
function cmake-utils_src_make() {
debug-print-function $FUNCNAME $*
# At this point we can automatically check if it's an outsource or an
# insource build
if [[ -d ${S}/../${PN}_build ]]; then
cd ${S}/../${PN}_build;
fi
if ! [[ -z ${CMAKE_COMPILER_VERBOSE} ]]; then
emake VERBOSE=1 || die "Make failed!";
else
emake || die "Make failed!";
fi
}
function cmake-utils_src_install() {
debug-print-function $FUNCNAME $*
# At this point we can automatically check if it's an outsource or an
# insource build
if [[ -d ${S}/../${PN}_build ]]; then
cd ${S}/../${PN}_build;
fi
emake install DESTDIR=${D} || die "Make install failed"
}
function cmake-utils_src_test() {
debug-print-function $FUNCNAME $*
# At this point we can automatically check if it's an outsource or an
# insource build
if [[ -d ${S}/../${PN}_build ]]; then
cd ${S}/../${PN}_build
fi
# Standard implememtation of src_test
addpredict /
if emake -j1 check -n &> /dev/null; then
vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
if ! emake -j1 check; then
die "Make check failed. See above for details."
eerror "Make check failed. See above for details."
fi
elif emake -j1 test -n &> /dev/null; then
vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
if ! emake -j1 test; then
die "Make test failed. See above for details."
eerror "Make test failed. See above for details."
fi
else
vecho ">>> Test phase [none]: ${CATEGORY}/${PF}"
fi
SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
}
|