From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-528818-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 06B301381F3
	for <garchives@archives.gentoo.org>; Thu, 29 Nov 2012 07:03:50 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B96B621C02E;
	Thu, 29 Nov 2012 07:03:22 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id F037621C004
	for <gentoo-commits@lists.gentoo.org>; Thu, 29 Nov 2012 07:03:21 +0000 (UTC)
Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id C93BA33DA94
	for <gentoo-commits@lists.gentoo.org>; Thu, 29 Nov 2012 07:03:20 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id 2BFE1E5436
	for <gentoo-commits@lists.gentoo.org>; Thu, 29 Nov 2012 07:03:19 +0000 (UTC)
From: "Justin Lecher" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" <jlec@gentoo.org>
Message-ID: <1354098256.7319422dd7c7427cc741e9bdab2f1211b5af1be4.jlec@gentoo>
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
X-VCS-Repository: proj/sci
X-VCS-Files: eclass/cuda.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: jlec
X-VCS-Committer-Name: Justin Lecher
X-VCS-Revision: 7319422dd7c7427cc741e9bdab2f1211b5af1be4
X-VCS-Branch: master
Date: Thu, 29 Nov 2012 07:03:19 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 6687dce5-7f6e-4c8c-bb93-b5b9c94ee473
X-Archives-Hash: b4f3c118b79cea3375f7519bbbe12d51

commit:     7319422dd7c7427cc741e9bdab2f1211b5af1be4
Author:     Justin Lecher <jlec <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 28 10:24:16 2012 +0000
Commit:     Justin Lecher <jlec <AT> gentoo <DOT> org>
CommitDate: Wed Nov 28 10:24:16 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=7319422d

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 <jlec <AT> gentoo.org>

---
 eclass/cuda.eclass |   69 +++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 35 deletions(-)

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