summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWulf Krueger <philantrop@gentoo.org>2007-07-22 14:05:37 +0000
committerWulf Krueger <philantrop@gentoo.org>2007-07-22 14:05:37 +0000
commitde0f814434bf5a0494ad9134ebe58d741637b1ed (patch)
tree7c595cc2ea06cda28880e09a37c6bcad46f1c1a7
parentSome user-requested ebuilds that won't make it into the tree for now for diff... (diff)
downloadphilantrop-de0f814434bf5a0494ad9134ebe58d741637b1ed.tar.gz
philantrop-de0f814434bf5a0494ad9134ebe58d741637b1ed.tar.bz2
philantrop-de0f814434bf5a0494ad9134ebe58d741637b1ed.zip
Added Zephyrus' cmake-utils.eclass.
svn path=/trunk/; revision=21
-rw-r--r--eclass/cmake-utils.eclass169
1 files changed, 169 insertions, 0 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
new file mode 100644
index 0000000..a14af06
--- /dev/null
+++ b/eclass/cmake-utils.eclass
@@ -0,0 +1,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%:/}"
+}