Gentoo Archives: gentoo-commits

From: Justin Lecher <jlec@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sci:master commit in: eclass/
Date: Thu, 29 Nov 2012 07:03:50
Message-Id: 1354098256.7319422dd7c7427cc741e9bdab2f1211b5af1be4.jlec@gentoo
1 commit: 7319422dd7c7427cc741e9bdab2f1211b5af1be4
2 Author: Justin Lecher <jlec <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 28 10:24:16 2012 +0000
4 Commit: Justin Lecher <jlec <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 28 10:24:16 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=7319422d
7
8 Implemented comments from g-dev review
9
10 * Fix whitespacing
11 * Fix man pages tags
12 * Try to do things in functions instead of global scope
13 * remove _ from local variables
14 * inline check for presents and functionality of cuda-config
15
16 Signed-off-by: Justin Lecher <jlec <AT> gentoo.org>
17
18 ---
19 eclass/cuda.eclass | 69 +++++++++++++++++++++++++--------------------------
20 1 files changed, 34 insertions(+), 35 deletions(-)
21
22 diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass
23 index f8ebd81..0b2e084 100644
24 --- a/eclass/cuda.eclass
25 +++ b/eclass/cuda.eclass
26 @@ -13,49 +13,45 @@ inherit toolchain-funcs versionator
27 # setting and/or sanitizing NVCCFLAGS, the compiler flags for nvcc. This is
28 # automatically done and exported in src_prepare() or manually by calling
29 # cuda_sanatize.
30 -#
31 -# Common usage:
32 -#
33 +# @EXAMPLE:
34 # inherit cuda
35
36 # @ECLASS-VARIABLE: NVCCFLAGS
37 -# DESCRIPTION:
38 +# @DESCRIPTION:
39 # nvcc compiler flags (see nvcc --help), which should be used like
40 # CFLAGS for c compiler
41 : ${NVCCFLAGS:=-O2}
42
43 # @ECLASS-VARIABLE: CUDA_VERBOSE
44 -# DESCRIPTION:
45 +# @DESCRIPTION:
46 # Being verbose during compilation to see underlying commands
47 : ${CUDA_VERBOSE:=true}
48
49 -[[ "${CUDA_VERBOSE}" == true ]] && NVCCFLAGS+=" -v"
50 -
51 -# @ECLASS-FUNCTION: cuda_gccdir
52 +# @FUNCTION: cuda_gccdir
53 +# @USAGE: [-f]
54 +# @RETURN: gcc bindir compatible with current cuda, optionally (-f) prefixed with "--compiler-bindir="
55 # @DESCRIPTION:
56 # Helper for determination of the latest gcc bindir supported by
57 # then current nvidia cuda toolkit.
58 #
59 -# Calling plain it returns simply the path, but you probably want to add \"-f\""
60 -# to get the full flag to add to nvcc call.
61 -#
62 # Example:
63 -#
64 +# @CODE
65 # cuda_gccdir -f
66 # -> --compiler-bindir="/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3"
67 +# @CODE
68 cuda_gccdir() {
69 - local _gcc_bindir _ver _args="" _flag _ret
70 + local gcc_bindir ver args="" flag ret
71
72 # Currently we only support the gnu compiler suite
73 if [[ $(tc-getCXX) != *g++* ]]; then
74 - ewarn "Currently we only support the gnu compiler suite"
75 + ewarn "Currently we only support the gnu compiler suite"
76 return 2
77 fi
78
79 while [ "$1" ]; do
80 case $1 in
81 -f)
82 - _flag="--compiler-bindir="
83 + flag="--compiler-bindir="
84 ;;
85 *)
86 ;;
87 @@ -63,43 +59,46 @@ cuda_gccdir() {
88 shift
89 done
90
91 - if [[ ! $(type -P cuda-config) ]]; then
92 + if ! args=$(cuda-config -s); then
93 eerror "Could not execute cuda-config"
94 eerror "Make sure >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed"
95 die "cuda-config not found"
96 else
97 - _args="$(version_sort $(cuda-config -s))"
98 - if [[ ! -n ${_args} ]]; then
99 + args=$(version_sort ${args})
100 + if [[ -z ${args} ]]; then
101 die "Could not determine supported gcc versions from cuda-config"
102 fi
103 fi
104
105 - for _ver in ${_args}; do
106 - has_version sys-devel/gcc:${_ver} && \
107 - _gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${_ver}* | tail -n 1)"
108 - done
109 + for ver in ${args}; do
110 + has_version sys-devel/gcc:${ver} && \
111 + gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}* | tail -n 1)"
112 + done
113
114 - if [[ -n ${_gcc_bindir} ]]; then
115 - if [[ -n ${_flag} ]]; then
116 - _ret="${_flag}\\\"${_gcc_bindir}\\\""
117 + if [[ -n ${gcc_bindir} ]]; then
118 + if [[ -n ${flag} ]]; then
119 + ret="${flag}\\\"${gcc_bindir}\\\""
120 else
121 - _ret="${_gcc_bindir}"
122 + ret="${gcc_bindir}"
123 fi
124 - echo ${_ret}
125 + echo ${ret}
126 return 0
127 else
128 - eerror "Only gcc version(s) ${_args} are supported,"
129 + eerror "Only gcc version(s) ${args} are supported,"
130 eerror "of which none is installed"
131 - die "Only gcc version(s) ${_args} are supported"
132 + die "Only gcc version(s) ${args} are supported"
133 return 1
134 - fi
135 + fi
136 }
137
138 -# @ECLASS-FUNCTION: cuda_sanitize
139 +# @FUNCTION: cuda_sanitize
140 # @DESCRIPTION:
141 # Correct NVCCFLAGS by adding the necessary reference to gcc bindir and
142 # passing CXXFLAGS to underlying compiler without disturbing nvcc.
143 cuda_sanitize() {
144 + # Be verbose if wanted
145 + [[ "${CUDA_VERBOSE}" == true ]] && NVCCFLAGS+=" -v"
146 +
147 # Tell nvcc where to find a compatible compiler
148 NVCCFLAGS+=" $(cuda_gccdir -f)"
149
150 @@ -109,15 +108,15 @@ cuda_sanitize() {
151 export NVCCFLAGS
152 }
153
154 -# @ECLASS-FUNCTION: cuda_pkg_setup
155 +# @FUNCTION: cuda_pkg_setup
156 # @DESCRIPTION:
157 -# Sanitise and export NVCCFLAGS by default in pkg_setup
158 +# Sanitise and export NVCCFLAGS by default
159 cuda_pkg_setup() {
160 cuda_sanitize
161 }
162
163 EXPORT_FUNCTIONS pkg_setup
164 case "${EAPI:-0}" in
165 - 0|1|2|3|4|5) ;;
166 - *) die "EAPI=${EAPI} is not supported" ;;
167 + 0|1|2|3|4|5) ;;
168 + *) die "EAPI=${EAPI} is not supported" ;;
169 esac