public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7
@ 2018-09-18  6:38 Jason Zaman
  2018-09-18  6:38 ` [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4 Jason Zaman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jason Zaman @ 2018-09-18  6:38 UTC (permalink / raw
  To: gentoo-dev; +Cc: Jason Zaman

Signed-off-by: Jason Zaman <perfinion@gentoo.org>
---
 eclass/check-reqs.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
index d1ed395c8b1..689944c8770 100644
--- a/eclass/check-reqs.eclass
+++ b/eclass/check-reqs.eclass
@@ -7,7 +7,7 @@
 # @AUTHOR:
 # Bo Ørsted Andresen <zlin@gentoo.org>
 # Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
 # @BLURB: Provides a uniform way of handling ebuild which have very high build requirements
 # @DESCRIPTION:
 # This eclass provides a uniform way of handling ebuilds which have very high
@@ -63,7 +63,7 @@ if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then
 EXPORT_FUNCTIONS pkg_setup
 case "${EAPI:-0}" in
 	0|1|2|3) ;;
-	4|5|6) EXPORT_FUNCTIONS pkg_pretend ;;
+	4|5|6|7) EXPORT_FUNCTIONS pkg_pretend ;;
 	*) die "EAPI=${EAPI} is not supported" ;;
 esac
 
-- 
2.16.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4
  2018-09-18  6:38 [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
@ 2018-09-18  6:38 ` Jason Zaman
  2018-09-18  6:38 ` [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods Jason Zaman
  2018-09-21 16:07 ` [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Zaman @ 2018-09-18  6:38 UTC (permalink / raw
  To: gentoo-dev; +Cc: Jason Zaman

cuda.eclass is only used from EAPI5,6 currently so remove support for
older EAPIs.

Updating to EAPI7 means removing versionator. It was only used to sort
the cuda versions. Instead first try the current GCC version, if that
fails try best_version, if that still fails just pick the last in
the list that works. They are already sorted and hopefully stay that
way so version_sort is not required.

Signed-off-by: Jason Zaman <perfinion@gentoo.org>
---
 eclass/cuda.eclass | 81 +++++++++++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 34 deletions(-)

diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass
index 688251f3a30..3a6fc3a31d1 100644
--- a/eclass/cuda.eclass
+++ b/eclass/cuda.eclass
@@ -1,12 +1,21 @@
 # Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-inherit flag-o-matic toolchain-funcs versionator
+case "${EAPI:-0}" in
+	0|1|2|3|4)
+		die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
+		;;
+	5|6|7)
+		;;
+	*)
+		die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+		;;
+esac
 
 # @ECLASS: cuda.eclass
 # @MAINTAINER:
 # Justin Lecher <jlec@gentoo.org>
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
+# @SUPPORTED_EAPIS: 5 6 7
 # @BLURB: Common functions for cuda packages
 # @DESCRIPTION:
 # This eclass contains functions to be used with cuda package. Currently it is
@@ -18,6 +27,9 @@ inherit flag-o-matic toolchain-funcs versionator
 
 if [[ -z ${_CUDA_ECLASS} ]]; then
 
+inherit flag-o-matic toolchain-funcs
+[[ ${EAPI} == [56] ]] && inherit eapi7-ver
+
 # @ECLASS-VARIABLE: NVCCFLAGS
 # @DESCRIPTION:
 # nvcc compiler flags (see nvcc --help), which should be used like
@@ -44,15 +56,15 @@ if [[ -z ${_CUDA_ECLASS} ]]; then
 cuda_gccdir() {
 	debug-print-function ${FUNCNAME} "$@"
 
-	local gcc_bindir ver args="" flag ret
+	local dirs gcc_bindir ver vers="" flag
 
 	# Currently we only support the gnu compiler suite
-	if  ! tc-is-gcc ; then
+	if ! tc-is-gcc ; then
 		ewarn "Currently we only support the gnu compiler suite"
 		return 2
 	fi
 
-	while [ "$1" ]; do
+	while [[ "$1" ]]; do
 		case $1 in
 			-f)
 				flag="--compiler-bindir "
@@ -63,34 +75,50 @@ cuda_gccdir() {
 		shift
 	done
 
-	if ! args=$(cuda-config -s); then
+	if ! vers="$(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
+	if [[ -z ${vers} ]]; then
+		die "Could not determine supported gcc versions from cuda-config"
+	fi
+
+	# Try the current gcc version first
+	ver=$(gcc-version)
+	if [[ -n "${ver}" ]] && [[ ${vers} =~ ${ver} ]]; then
+		dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
+		gcc_bindir="${dirs[${#dirs[@]}-1]}"
+	fi
+
+	if [[ -z ${gcc_bindir} ]]; then
+		ver=$(best_version "sys-devel/gcc")
+		ver=$(ver_cut 1-2 "${ver##*sys-devel/gcc-}")
+
+		if [[ -n "${ver}" ]] && [[ ${vers} =~ ${ver} ]]; then
+			dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
+			gcc_bindir="${dirs[${#dirs[@]}-1]}"
 		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)"
+	for ver in ${vers}; do
+		if has_version "=sys-devel/gcc-${ver}*"; then
+			dirs=( ${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/${ver}*/ )
+			gcc_bindir="${dirs[${#dirs[@]}-1]}"
+		fi
 	done
 
 	if [[ -n ${gcc_bindir} ]]; then
 		if [[ -n ${flag} ]]; then
-			ret="${flag}\"${gcc_bindir}\""
+			echo "${flag}\"${gcc_bindir%/}\""
 		else
-			ret="${gcc_bindir}"
+			echo "${gcc_bindir%/}"
 		fi
-		echo ${ret}
 		return 0
 	else
-		eerror "Only gcc version(s) ${args} are supported,"
+		eerror "Only gcc version(s) ${vers} are supported,"
 		eerror "of which none is installed"
-		die "Only gcc version(s) ${args} are supported"
+		die "Only gcc version(s) ${vers} are supported"
 		return 1
 	fi
 }
@@ -116,15 +144,6 @@ cuda_sanitize() {
 	export NVCCFLAGS
 }
 
-# @FUNCTION: cuda_pkg_setup
-# @DESCRIPTION:
-# Call cuda_src_prepare for EAPIs not supporting src_prepare
-cuda_pkg_setup() {
-	debug-print-function ${FUNCNAME} "$@"
-
-	cuda_src_prepare
-}
-
 # @FUNCTION: cuda_src_prepare
 # @DESCRIPTION:
 # Sanitise and export NVCCFLAGS by default
@@ -134,13 +153,7 @@ cuda_src_prepare() {
 	cuda_sanitize
 }
 
-case "${EAPI:-0}" in
-	0|1)
-		EXPORT_FUNCTIONS pkg_setup ;;
-	2|3|4|5|6)
-		EXPORT_FUNCTIONS src_prepare ;;
-	*) die "EAPI=${EAPI} is not supported" ;;
-esac
+EXPORT_FUNCTIONS src_prepare
 
 _CUDA_ECLASS=1
 fi
-- 
2.16.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods
  2018-09-18  6:38 [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
  2018-09-18  6:38 ` [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4 Jason Zaman
@ 2018-09-18  6:38 ` Jason Zaman
  2018-09-21 16:07 ` [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Zaman @ 2018-09-18  6:38 UTC (permalink / raw
  To: gentoo-dev; +Cc: Jason Zaman

cuda_toolkit_version returns the version of dev-util/nvidia-cuda-toolkit
cuda_cudnn_version returns the version of dev-libs/cudnn
cuda_add_sandbox adds the nvidia dev nodes to the sandbox

Signed-off-by: Jason Zaman <perfinion@gentoo.org>
---
 eclass/cuda.eclass | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/eclass/cuda.eclass b/eclass/cuda.eclass
index 3a6fc3a31d1..f1c09ca2e45 100644
--- a/eclass/cuda.eclass
+++ b/eclass/cuda.eclass
@@ -144,6 +144,48 @@ cuda_sanitize() {
 	export NVCCFLAGS
 }
 
+# @FUNCTION: cuda_add_sandbox
+# @USAGE: [-w]
+# @DESCRIPTION:
+# Add nvidia dev nodes to the sandbox predict list.
+# with -w, add to the sandbox write list.
+cuda_add_sandbox() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	local i
+	for i in /dev/nvidia*; do
+		if [[ $1 == '-w' ]]; then
+			addwrite $i
+		else
+			addpredict $i
+		fi
+	done
+}
+
+# @FUNCTION: cuda_toolkit_version
+# @DESCRIPTION:
+# echo the installed version of dev-util/nvidia-cuda-toolkit
+cuda_toolkit_version() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	local v
+	v="$(best_version dev-util/nvidia-cuda-toolkit)"
+	v="${v##*cuda-toolkit-}"
+	ver_cut 1-2 "${v}"
+}
+
+# @FUNCTION: cuda_cudnn_version
+# @DESCRIPTION:
+# echo the installed version of dev-libs/cudnn
+cuda_cudnn_version() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	local v
+	v="$(best_version dev-libs/cudnn)"
+	v="${v##*cudnn-}"
+	ver_cut 1-2 "${v}"
+}
+
 # @FUNCTION: cuda_src_prepare
 # @DESCRIPTION:
 # Sanitise and export NVCCFLAGS by default
-- 
2.16.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7
  2018-09-18  6:38 [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
  2018-09-18  6:38 ` [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4 Jason Zaman
  2018-09-18  6:38 ` [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods Jason Zaman
@ 2018-09-21 16:07 ` Jason Zaman
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Zaman @ 2018-09-21 16:07 UTC (permalink / raw
  To: gentoo-dev

All three of these patches are now in the tree :)
-- Jason
On Tue, Sep 18, 2018 at 02:38:15PM +0800, Jason Zaman wrote:
> Signed-off-by: Jason Zaman <perfinion@gentoo.org>
> ---
>  eclass/check-reqs.eclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/eclass/check-reqs.eclass b/eclass/check-reqs.eclass
> index d1ed395c8b1..689944c8770 100644
> --- a/eclass/check-reqs.eclass
> +++ b/eclass/check-reqs.eclass
> @@ -7,7 +7,7 @@
>  # @AUTHOR:
>  # Bo Ørsted Andresen <zlin@gentoo.org>
>  # Original Author: Ciaran McCreesh <ciaranm@gentoo.org>
> -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6
> +# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
>  # @BLURB: Provides a uniform way of handling ebuild which have very high build requirements
>  # @DESCRIPTION:
>  # This eclass provides a uniform way of handling ebuilds which have very high
> @@ -63,7 +63,7 @@ if [[ ! ${_CHECK_REQS_ECLASS_} ]]; then
>  EXPORT_FUNCTIONS pkg_setup
>  case "${EAPI:-0}" in
>  	0|1|2|3) ;;
> -	4|5|6) EXPORT_FUNCTIONS pkg_pretend ;;
> +	4|5|6|7) EXPORT_FUNCTIONS pkg_pretend ;;
>  	*) die "EAPI=${EAPI} is not supported" ;;
>  esac
>  
> -- 
> 2.16.4
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-21 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-18  6:38 [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman
2018-09-18  6:38 ` [gentoo-dev] [PATCH 2/3] cuda.eclass: update to EAPI7, remove 0-4 Jason Zaman
2018-09-18  6:38 ` [gentoo-dev] [PATCH 3/3] cuda.eclass: Add version and sandbox helper methods Jason Zaman
2018-09-21 16:07 ` [gentoo-dev] [PATCH 1/3] check-reqs.eclass: update to EAPI7 Jason Zaman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox