Gentoo Archives: gentoo-dev

From: Jason Zaman <perfinion@g.o>
To: gentoo-dev@l.g.o
Cc: Jason Zaman <perfinion@g.o>
Subject: [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4
Date: Tue, 18 Sep 2018 06:39:16
Message-Id: 20180918063817.19338-2-perfinion@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 by Jason Zaman
1 cuda.eclass is only used from EAPI5,6 currently so remove support for
2 older EAPIs.
3
4 Updating to EAPI7 means removing versionator. It was only used to sort
5 the cuda versions. Instead first try the current GCC version, if that
6 fails try best_version, if that still fails just pick the last in
7 the list that works. They are already sorted and hopefully stay that
8 way so version_sort is not required.
9
10 Signed-off-by: Jason Zaman <perfinion@g.o>
11 ---
12 eclass/cuda.eclass | 81 +++++++++++++++++++++++++++++++-----------------------
13 1 file changed, 47 insertions(+), 34 deletions(-)
14
15 diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass
16 index 688251f3a30..3a6fc3a31d1 100644
17 --- a/eclass/cuda.eclass
18 +++ b/eclass/cuda.eclass
19 @@ -1,12 +1,21 @@
20 # Copyright 1999-2016 Gentoo Foundation
21 # Distributed under the terms of the GNU General Public License v2
22
23 -inherit flag-o-matic toolchain-funcs versionator
24 +case "${EAPI:-0}" in
25 + 0|1|2|3|4)
26 + die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
27 + ;;
28 + 5|6|7)
29 + ;;
30 + *)
31 + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
32 + ;;
33 +esac
34
35 # @ECLASS: cuda.eclass
36 # @MAINTAINER:
37 # Justin Lecher <jlec@g.o>
38 -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
39 +# @SUPPORTED_EAPIS: 5 6 7
40 # @BLURB: Common functions for cuda packages
41 # @DESCRIPTION:
42 # This eclass contains functions to be used with cuda package. Currently it is
43 @@ -18,6 +27,9 @@ inherit flag-o-matic toolchain-funcs versionator
44
45 if [[ -z ${_CUDA_ECLASS} ]]; then
46
47 +inherit flag-o-matic toolchain-funcs
48 +[[ ${EAPI} == [56] ]] && inherit eapi7-ver
49 +
50 # @ECLASS-VARIABLE: NVCCFLAGS
51 # @DESCRIPTION:
52 # nvcc compiler flags (see nvcc --help), which should be used like
53 @@ -44,15 +56,15 @@ if [[ -z ${_CUDA_ECLASS} ]]; then
54 cuda_gccdir() {
55 debug-print-function ${FUNCNAME} "$@"
56
57 - local gcc_bindir ver args="" flag ret
58 + local dirs gcc_bindir ver vers="" flag
59
60 # Currently we only support the gnu compiler suite
61 - if ! tc-is-gcc ; then
62 + if ! tc-is-gcc ; then
63 ewarn "Currently we only support the gnu compiler suite"
64 return 2
65 fi
66
67 - while [ "$1" ]; do
68 + while [[ "$1" ]]; do
69 case $1 in
70 -f)
71 flag="--compiler-bindir "
72 @@ -63,34 +75,50 @@ cuda_gccdir() {
73 shift
74 done
75
76 - if ! args=$(cuda-config -s); then
77 + if ! vers="$(cuda-config -s)"; then
78 eerror "Could not execute cuda-config"
79 eerror "Make sure >=dev-util/nvidia-cuda-toolkit-4.2.9-r1 is installed"
80 die "cuda-config not found"
81 - else
82 - args=$(version_sort ${args})
83 - if [[ -z ${args} ]]; then
84 - die "Could not determine supported gcc versions from cuda-config"
85 + fi
86 + if [[ -z ${vers} ]]; then
87 + die "Could not determine supported gcc versions from cuda-config"
88 + fi
89 +
90 + # Try the current gcc version first
91 + ver=$(gcc-version)
92 + if [[ -n "${ver}" ]] && [[ ${vers} =~ ${ver} ]]; then
93 + dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
94 + gcc_bindir="${dirs[${#dirs[@]}-1]}"
95 + fi
96 +
97 + if [[ -z ${gcc_bindir} ]]; then
98 + ver=$(best_version "sys-devel/gcc")
99 + ver=$(ver_cut 1-2 "${ver##*sys-devel/gcc-}")
100 +
101 + if [[ -n "${ver}" ]] && [[ ${vers} =~ ${ver} ]]; then
102 + dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
103 + gcc_bindir="${dirs[${#dirs[@]}-1]}"
104 fi
105 fi
106
107 - for ver in ${args}; do
108 - has_version "=sys-devel/gcc-${ver}*" && \
109 - gcc_bindir="$(ls -d ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}* | tail -n 1)"
110 + for ver in ${vers}; do
111 + if has_version "=sys-devel/gcc-${ver}*"; then
112 + dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
113 + gcc_bindir="${dirs[${#dirs[@]}-1]}"
114 + fi
115 done
116
117 if [[ -n ${gcc_bindir} ]]; then
118 if [[ -n ${flag} ]]; then
119 - ret="${flag}\"${gcc_bindir}\""
120 + echo "${flag}\"${gcc_bindir%/}\""
121 else
122 - ret="${gcc_bindir}"
123 + echo "${gcc_bindir%/}"
124 fi
125 - echo ${ret}
126 return 0
127 else
128 - eerror "Only gcc version(s) ${args} are supported,"
129 + eerror "Only gcc version(s) ${vers} are supported,"
130 eerror "of which none is installed"
131 - die "Only gcc version(s) ${args} are supported"
132 + die "Only gcc version(s) ${vers} are supported"
133 return 1
134 fi
135 }
136 @@ -116,15 +144,6 @@ cuda_sanitize() {
137 export NVCCFLAGS
138 }
139
140 -# @FUNCTION: cuda_pkg_setup
141 -# @DESCRIPTION:
142 -# Call cuda_src_prepare for EAPIs not supporting src_prepare
143 -cuda_pkg_setup() {
144 - debug-print-function ${FUNCNAME} "$@"
145 -
146 - cuda_src_prepare
147 -}
148 -
149 # @FUNCTION: cuda_src_prepare
150 # @DESCRIPTION:
151 # Sanitise and export NVCCFLAGS by default
152 @@ -134,13 +153,7 @@ cuda_src_prepare() {
153 cuda_sanitize
154 }
155
156 -case "${EAPI:-0}" in
157 - 0|1)
158 - EXPORT_FUNCTIONS pkg_setup ;;
159 - 2|3|4|5|6)
160 - EXPORT_FUNCTIONS src_prepare ;;
161 - *) die "EAPI=${EAPI} is not supported" ;;
162 -esac
163 +EXPORT_FUNCTIONS src_prepare
164
165 _CUDA_ECLASS=1
166 fi
167 --
168 2.16.4