public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Justin Lecher (jlec)" <jlec@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog cuda.eclass
Date: Fri, 11 Jan 2013 08:31:49 +0000 (UTC)	[thread overview]
Message-ID: <20130111083150.837322171D@flycatcher.gentoo.org> (raw)

jlec        13/01/11 08:31:49

  Modified:             ChangeLog
  Added:                cuda.eclass
  Log:
  Add new eclass

Revision  Changes    Path
1.608                eclass/ChangeLog

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.608&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.608&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.607&r2=1.608

Index: ChangeLog
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
retrieving revision 1.607
retrieving revision 1.608
diff -u -r1.607 -r1.608
--- ChangeLog	11 Jan 2013 01:06:37 -0000	1.607
+++ ChangeLog	11 Jan 2013 08:31:49 -0000	1.608
@@ -1,6 +1,9 @@
 # ChangeLog for eclass directory
 # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.607 2013/01/11 01:06:37 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.608 2013/01/11 08:31:49 jlec Exp $
+
+  11 Jan 2013; Justin Lecher <jlec@gentoo.org> +cuda.eclass:
+  Add new eclass
 
   11 Jan 2013; Mike Gilbert <floppym@gentoo.org> distutils-r1.eclass:
   Close the lock file explicitly instead of relying on the subshell created by



1.1                  eclass/cuda.eclass

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/cuda.eclass?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/cuda.eclass?rev=1.1&content-type=text/plain

Index: cuda.eclass
===================================================================
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/cuda.eclass,v 1.1 2013/01/11 08:31:49 jlec Exp $

inherit toolchain-funcs versionator

# @ECLASS: cuda.eclass
# @MAINTAINER:
# Justin Lecher <jlec@gentoo.org>
# @BLURB: Common functions for cuda packages
# @DESCRIPTION:
# This eclass contains functions to be used with cuda package. Currently it is
# 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.
# @EXAMPLE:
# inherit cuda

# @ECLASS-VARIABLE: NVCCFLAGS
# @DESCRIPTION:
# nvcc compiler flags (see nvcc --help), which should be used like
# CFLAGS for c compiler
: ${NVCCFLAGS:=-O2}

# @ECLASS-VARIABLE: CUDA_VERBOSE
# @DESCRIPTION:
# Being verbose during compilation to see underlying commands
: ${CUDA_VERBOSE:=true}

# @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.
#
# 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

	# Currently we only support the gnu compiler suite
	if [[ $(tc-getCXX) != *g++* ]]; then
		ewarn "Currently we only support the gnu compiler suite"
		return 2
	fi

	while [ "$1" ]; do
		case $1 in
			-f)
				flag="--compiler-bindir="
				;;
			*)
				;;
		esac
		shift
	done

	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 ${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

	if [[ -n ${gcc_bindir} ]]; then
		if [[ -n ${flag} ]]; then
			ret="${flag}\\\"${gcc_bindir}\\\""
		else
			ret="${gcc_bindir}"
		fi
		echo ${ret}
		return 0
	else
		eerror "Only gcc version(s) ${args} are supported,"
		eerror "of which none is installed"
		die "Only gcc version(s) ${args} are supported"
		return 1
	fi
}

# @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)"

	# Tell nvcc which flags should be used for underlying C compiler
	NVCCFLAGS+=" --compiler-options=\"${CXXFLAGS}\""

	export NVCCFLAGS
}

# @FUNCTION: cuda_pkg_setup
# @DESCRIPTION:
# Call cuda_src_prepare for EAPIs not supporting src_prepare
cuda_pkg_setup() {
	cuda_src_prepare
}

# @FUNCTION: cuda_src_prepare
# @DESCRIPTION:
# Sanitise and export NVCCFLAGS by default
cuda_src_prepare() {
	cuda_sanitize
}


case "${EAPI:-0}" in
	0|1)
		EXPORT_FUNCTIONS pkg_setup ;;
	2|3|4|5)
		EXPORT_FUNCTIONS src_prepare ;;
	*) die "EAPI=${EAPI} is not supported" ;;
esac





             reply	other threads:[~2013-01-11  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11  8:31 Justin Lecher (jlec) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-09-17 10:21 [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog cuda.eclass Justin Lecher (jlec)
2014-11-18 19:44 Justin Lecher (jlec)
2014-11-18 19:54 Justin Lecher (jlec)
2015-05-25 10:07 Justin Lecher (jlec)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130111083150.837322171D@flycatcher.gentoo.org \
    --to=jlec@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox