Please review my inclusion of your suggestions. Additionally I move to src_prepare to be more binpackage compatible as things are only of interest at compile time.
commit 366a690925f5cc5e4bdd2ea984d9ccca65d8f996 Author: Justin Lecher <j...@gentoo.org> Date: Wed Nov 28 11:54:16 2012 +0100 Be bin package friendly Move standard call of cuda_sanitize to src_prepapere as it isn't need for bin packages. Signed-off-by: Justin Lecher <j...@gentoo.org> diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 08cfb72..beac082 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -110,13 +110,23 @@ cuda_sanitize() { # @FUNCTION: cuda_pkg_setup # @DESCRIPTION: -# Sanitise and export NVCCFLAGS by default +# Call cuda_src_prepare for EAPIs not supporting src_prepare cuda_pkg_setup() { + cuda_src_prepare +} + +# @FUNCTION: cuda_src_prepare +# @DESCRIPTION: +# Sanitise and export NVCCFLAGS by default +cuda_src_prepare() { cuda_sanitize } -EXPORT_FUNCTIONS pkg_setup + case "${EAPI:-0}" in - 0|1|2|3|4|5) ;; + 0|1) + EXPORT_FUNCTIONS pkg_setup ;; + 2|3|4|5) + EXPORT_FUNCTIONS src_prepare ;; *) die "EAPI=${EAPI} is not supported" ;; esac commit 07b5a629a7f6e9f163e0dfe9c1927010f527508f Author: Justin Lecher <j...@gentoo.org> Date: Wed Nov 28 11:24:51 2012 +0100 Fix typo in Copyright year Signed-off-by: Justin Lecher <j...@gentoo.org> diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index 0b2e084..08cfb72 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-20012 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ commit 7319422dd7c7427cc741e9bdab2f1211b5af1be4 Author: Justin Lecher <j...@gentoo.org> Date: Wed Nov 28 11:24:16 2012 +0100 Implemented comments from g-dev review * Fix whitespacing * Fix man pages tags * Try to do things in functions instead of global scope * remove _ from local variables * inline check for presents and functionality of cuda-config Signed-off-by: Justin Lecher <j...@gentoo.org> diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass index f8ebd81..0b2e084 100644 --- a/eclass/cuda.eclass +++ b/eclass/cuda.eclass @@ -13,49 +13,45 @@ inherit toolchain-funcs versionator # setting and/or sanitizing NVCCFLAGS, the compiler flags for nvcc. This is # automatically done and exported in src_prepare() or manually by calling # cuda_sanatize. -# -# Common usage: -# +# @EXAMPLE: # inherit cuda # @ECLASS-VARIABLE: NVCCFLAGS -# DESCRIPTION: +# @DESCRIPTION: # nvcc compiler flags (see nvcc --help), which should be used like # CFLAGS for c compiler : ${NVCCFLAGS:=-O2} # @ECLASS-VARIABLE: CUDA_VERBOSE -# DESCRIPTION: +# @DESCRIPTION: # Being verbose during compilation to see underlying commands : ${CUDA_VERBOSE:=true} -[[ "${CUDA_VERBOSE}" == true ]] && NVCCFLAGS+=" -v" - -# @ECLASS-FUNCTION: cuda_gccdir +# @FUNCTION: cuda_gccdir +# @USAGE: [-f] +# @RETURN: gcc bindir compatible with current cuda, optionally (-f) prefixed with "--compiler-bindir=" # @DESCRIPTION: # Helper for determination of the latest gcc bindir supported by # then current nvidia cuda toolkit. # -# Calling plain it returns simply the path, but you probably want to add \"-f\"" -# to get the full flag to add to nvcc call. -# # Example: -# +# @CODE # cuda_gccdir -f # -> --compiler-bindir="/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3" +# @CODE cuda_gccdir() { - local _gcc_bindir _ver _args="" _flag _ret + local gcc_bindir ver args="" flag ret # Currently we only support the gnu compiler suite if [[ $(tc-getCXX) != *g++* ]]; then - ewarn "Currently we only support the gnu compiler suite" + ewarn "Currently we only support the gnu compiler suite" return 2 fi while [ "$1" ]; do case $1 in -f) - _flag="--compiler-bindir=" + flag="--compiler-bindir=" ;; *) ;; @@ -63,43 +59,46 @@ cuda_gccdir() { shift done - if [[ ! $(type -P cuda-config) ]]; then + if ! args=$(cuda-config -s); then eerror "Could not execute cuda-config" eerror "Make sure >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed" die "cuda-config not found" else - _args="$(version_sort $(cuda-config -s))" - if [[ ! -n ${_args} ]]; then + args=$(version_sort ${args}) + if [[ -z ${args} ]]; then die "Could not determine supported gcc versions from cuda-config" fi fi - for _ver in ${_args}; do - has_version sys-devel/gcc:${_ver} && \ - _gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${_ver}* | tail -n 1)" - done + for ver in ${args}; do + has_version sys-devel/gcc:${ver} && \ + gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}* | tail -n 1)" + done - if [[ -n ${_gcc_bindir} ]]; then - if [[ -n ${_flag} ]]; then - _ret="${_flag}\\\"${_gcc_bindir}\\\"" + if [[ -n ${gcc_bindir} ]]; then + if [[ -n ${flag} ]]; then + ret="${flag}\\\"${gcc_bindir}\\\"" else - _ret="${_gcc_bindir}" + ret="${gcc_bindir}" fi - echo ${_ret} + echo ${ret} return 0 else - eerror "Only gcc version(s) ${_args} are supported," + eerror "Only gcc version(s) ${args} are supported," eerror "of which none is installed" - die "Only gcc version(s) ${_args} are supported" + die "Only gcc version(s) ${args} are supported" return 1 - fi + fi } -# @ECLASS-FUNCTION: cuda_sanitize +# @FUNCTION: cuda_sanitize # @DESCRIPTION: # Correct NVCCFLAGS by adding the necessary reference to gcc bindir and # passing CXXFLAGS to underlying compiler without disturbing nvcc. cuda_sanitize() { + # Be verbose if wanted + [[ "${CUDA_VERBOSE}" == true ]] && NVCCFLAGS+=" -v" + # Tell nvcc where to find a compatible compiler NVCCFLAGS+=" $(cuda_gccdir -f)" @@ -109,15 +108,15 @@ cuda_sanitize() { export NVCCFLAGS } -# @ECLASS-FUNCTION: cuda_pkg_setup +# @FUNCTION: cuda_pkg_setup # @DESCRIPTION: -# Sanitise and export NVCCFLAGS by default in pkg_setup +# Sanitise and export NVCCFLAGS by default cuda_pkg_setup() { cuda_sanitize } EXPORT_FUNCTIONS pkg_setup case "${EAPI:-0}" in - 0|1|2|3|4|5) ;; - *) die "EAPI=${EAPI} is not supported" ;; + 0|1|2|3|4|5) ;; + *) die "EAPI=${EAPI} is not supported" ;; esac
# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit toolchain-funcs versionator # @ECLASS: cuda.eclass # @MAINTAINER: # Justin Lecher <j...@gentoo.org> # @BLURB: Common functions for cuda packages # @DESCRIPTION: # This eclass contains functions to be used with cuda package. Currently it is # setting and/or sanitizing NVCCFLAGS, the compiler flags for nvcc. This is # automatically done and exported in src_prepare() or manually by calling # cuda_sanatize. # @EXAMPLE: # inherit cuda # @ECLASS-VARIABLE: NVCCFLAGS # @DESCRIPTION: # nvcc compiler flags (see nvcc --help), which should be used like # CFLAGS for c compiler : ${NVCCFLAGS:=-O2} # @ECLASS-VARIABLE: CUDA_VERBOSE # @DESCRIPTION: # Being verbose during compilation to see underlying commands : ${CUDA_VERBOSE:=true} # @FUNCTION: cuda_gccdir # @USAGE: [-f] # @RETURN: gcc bindir compatible with current cuda, optionally (-f) prefixed with "--compiler-bindir=" # @DESCRIPTION: # Helper for determination of the latest gcc bindir supported by # then current nvidia cuda toolkit. # # Example: # @CODE # cuda_gccdir -f # -> --compiler-bindir="/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3" # @CODE cuda_gccdir() { local gcc_bindir ver args="" flag ret # Currently we only support the gnu compiler suite if [[ $(tc-getCXX) != *g++* ]]; then ewarn "Currently we only support the gnu compiler suite" return 2 fi while [ "$1" ]; do case $1 in -f) flag="--compiler-bindir=" ;; *) ;; esac shift done if ! args=$(cuda-config -s); then eerror "Could not execute cuda-config" eerror "Make sure >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed" die "cuda-config not found" else args=$(version_sort ${args}) if [[ -z ${args} ]]; then die "Could not determine supported gcc versions from cuda-config" fi fi for ver in ${args}; do has_version sys-devel/gcc:${ver} && \ gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}* | tail -n 1)" done if [[ -n ${gcc_bindir} ]]; then if [[ -n ${flag} ]]; then ret="${flag}\\\"${gcc_bindir}\\\"" else ret="${gcc_bindir}" fi echo ${ret} return 0 else eerror "Only gcc version(s) ${args} are supported," eerror "of which none is installed" die "Only gcc version(s) ${args} are supported" return 1 fi } # @FUNCTION: cuda_sanitize # @DESCRIPTION: # Correct NVCCFLAGS by adding the necessary reference to gcc bindir and # passing CXXFLAGS to underlying compiler without disturbing nvcc. cuda_sanitize() { # Be verbose if wanted [[ "${CUDA_VERBOSE}" == true ]] && NVCCFLAGS+=" -v" # Tell nvcc where to find a compatible compiler NVCCFLAGS+=" $(cuda_gccdir -f)" # Tell nvcc which flags should be used for underlying C compiler NVCCFLAGS+=" --compiler-options=\"${CXXFLAGS}\"" export NVCCFLAGS } # @FUNCTION: cuda_pkg_setup # @DESCRIPTION: # Call cuda_src_prepare for EAPIs not supporting src_prepare cuda_pkg_setup() { cuda_src_prepare } # @FUNCTION: cuda_src_prepare # @DESCRIPTION: # Sanitise and export NVCCFLAGS by default cuda_src_prepare() { cuda_sanitize } case "${EAPI:-0}" in 0|1) EXPORT_FUNCTIONS pkg_setup ;; 2|3|4|5) EXPORT_FUNCTIONS src_prepare ;; *) die "EAPI=${EAPI} is not supported" ;; esac
signature.asc
Description: OpenPGP digital signature