Gentoo Archives: gentoo-commits

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