summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /eclass/scons-utils.eclass
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'eclass/scons-utils.eclass')
-rw-r--r--eclass/scons-utils.eclass235
1 files changed, 235 insertions, 0 deletions
diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
new file mode 100644
index 000000000000..a2a6884e55d3
--- /dev/null
+++ b/eclass/scons-utils.eclass
@@ -0,0 +1,235 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# @ECLASS: scons-utils.eclass
+# @MAINTAINER:
+# mgorny@gentoo.org
+# @BLURB: helper functions to deal with SCons buildsystem
+# @DESCRIPTION:
+# This eclass provides a set of function to help developers sanely call
+# dev-util/scons and pass parameters to it.
+# @EXAMPLE:
+#
+# @CODE
+# inherit scons-utils toolchain-funcs
+#
+# EAPI=4
+#
+# src_configure() {
+# myesconsargs=(
+# CC="$(tc-getCC)"
+# $(use_scons nls ENABLE_NLS)
+# )
+# }
+#
+# src_compile() {
+# escons
+# }
+#
+# src_install() {
+# # note: this can be DESTDIR, INSTALL_ROOT, ... depending on package
+# escons DESTDIR="${D}" install
+# }
+# @CODE
+
+# -- public variables --
+
+# @ECLASS-VARIABLE: SCONS_MIN_VERSION
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The minimal version of SCons required for the build to work.
+
+# @VARIABLE: myesconsargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# List of package-specific options to pass to all SCons calls. Supposed to be
+# set in src_configure().
+
+# @ECLASS-VARIABLE: SCONSOPTS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The default set of options to pass to scons. Similar to MAKEOPTS,
+# supposed to be set in make.conf. If unset, escons() will use cleaned
+# up MAKEOPTS instead.
+
+# @ECLASS-VARIABLE: EXTRA_ESCONS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The additional parameters to pass to SCons whenever escons() is used.
+# Much like EXTRA_EMAKE, this is not supposed to be used in make.conf
+# and not in ebuilds!
+
+# @ECLASS-VARIABLE: USE_SCONS_TRUE
+# @DESCRIPTION:
+# The default value for truth in scons-use() (1 by default).
+: ${USE_SCONS_TRUE:=1}
+
+# @ECLASS-VARIABLE: USE_SCONS_FALSE
+# @DESCRIPTION:
+# The default value for false in scons-use() (0 by default).
+: ${USE_SCONS_FALSE:=0}
+
+# -- EAPI support check --
+
+case ${EAPI:-0} in
+ 0|1|2|3|4|5) ;;
+ *) die "EAPI ${EAPI} unsupported."
+esac
+
+# -- ebuild variables setup --
+
+if [[ -n ${SCONS_MIN_VERSION} ]]; then
+ DEPEND=">=dev-util/scons-${SCONS_MIN_VERSION}"
+else
+ DEPEND="dev-util/scons"
+fi
+
+# -- public functions --
+
+# @FUNCTION: escons
+# @USAGE: [scons-arg] ...
+# @DESCRIPTION:
+# Call scons, passing the supplied arguments, ${myesconsargs[@]},
+# filtered ${MAKEOPTS}, ${EXTRA_ESCONS}. Similar to emake. Like emake,
+# this function does die on failure in EAPI 4 (unless called nonfatal).
+escons() {
+ local ret
+
+ debug-print-function ${FUNCNAME} "${@}"
+
+ # if SCONSOPTS are _unset_, use cleaned MAKEOPTS
+ set -- scons ${SCONSOPTS-$(scons_clean_makeopts)} ${EXTRA_ESCONS} \
+ "${myesconsargs[@]}" "${@}"
+ echo "${@}" >&2
+ "${@}"
+ ret=${?}
+
+ [[ ${ret} -ne 0 ]] && has "${EAPI:-0}" 4 5 && die "escons failed."
+ return ${ret}
+}
+
+# @FUNCTION: scons_clean_makeopts
+# @USAGE: [makeflags] [...]
+# @DESCRIPTION:
+# Strip the supplied makeflags (or ${MAKEOPTS} if called without
+# an argument) of options not supported by SCons and make sure --jobs
+# gets an argument. Output the resulting flag list (suitable
+# for an assignment to SCONSOPTS).
+scons_clean_makeopts() {
+ local new_makeopts
+
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if [[ ${#} -eq 0 ]]; then
+ debug-print "Using MAKEOPTS: [${MAKEOPTS}]"
+ set -- ${MAKEOPTS}
+ else
+ # unquote if necessary
+ set -- ${*}
+ fi
+
+ # empty MAKEOPTS give out empty SCONSOPTS
+ # thus, we do need to worry about the initial setup
+ if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
+ set -- ${_SCONS_CACHE_SCONSOPTS}
+ debug-print "Cache hit: [${*}]"
+ echo ${*}
+ return
+ fi
+ export _SCONS_CACHE_MAKEOPTS=${*}
+
+ while [[ ${#} -gt 0 ]]; do
+ case ${1} in
+ # clean, simple to check -- we like that
+ --jobs=*|--keep-going)
+ new_makeopts=${new_makeopts+${new_makeopts} }${1}
+ ;;
+ # need to take a look at the next arg and guess
+ --jobs)
+ if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
+ new_makeopts="${new_makeopts+${new_makeopts} }${1} ${2}"
+ shift
+ else
+ # no value means no limit, let's pass a random int
+ new_makeopts=${new_makeopts+${new_makeopts} }${1}=5
+ fi
+ ;;
+ # strip other long options
+ --*)
+ ;;
+ # short option hell
+ -*)
+ local str new_optstr
+ new_optstr=
+ str=${1#-}
+
+ while [[ -n ${str} ]]; do
+ case ${str} in
+ k*)
+ new_optstr=${new_optstr}k
+ ;;
+ # -j needs to come last
+ j)
+ if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
+ new_optstr="${new_optstr}j ${2}"
+ shift
+ else
+ new_optstr="${new_optstr}j 5"
+ fi
+ ;;
+ # otherwise, everything after -j is treated as an arg
+ j*)
+ new_optstr=${new_optstr}${str}
+ break
+ ;;
+ esac
+ str=${str#?}
+ done
+
+ if [[ -n ${new_optstr} ]]; then
+ new_makeopts=${new_makeopts+${new_makeopts} }-${new_optstr}
+ fi
+ ;;
+ esac
+ shift
+ done
+
+ set -- ${new_makeopts}
+ export _SCONS_CACHE_SCONSOPTS=${*}
+ debug-print "New SCONSOPTS: [${*}]"
+ echo ${*}
+}
+
+# @FUNCTION: use_scons
+# @USAGE: <use-flag> [var-name] [var-opt-true] [var-opt-false]
+# @DESCRIPTION:
+# Output a SCons parameter with value depending on the USE flag state.
+# If the USE flag is set, output <var-name>=<var-opt-true>; otherwise
+# <var-name>=<var-opt-false>.
+#
+# If <var-name> is omitted, <use-flag> will be used instead. However,
+# if <use-flag> starts with an exclamation mark (!flag), 'no' will be
+# prepended to the name (e.g. noflag).
+#
+# If <var-opt-true> and/or <var-opt-false> are omitted,
+# ${USE_SCONS_TRUE} and/or ${USE_SCONS_FALSE} will be used instead.
+use_scons() {
+ local flag=${1}
+ local varname=${2:-${flag/\!/no}}
+ local vartrue=${3:-${USE_SCONS_TRUE}}
+ local varfalse=${4:-${USE_SCONS_FALSE}}
+
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if [[ ${#} -eq 0 ]]; then
+ eerror "Usage: scons-use <use-flag> [var-name] [var-opt-true] [var-opt-false]"
+ die 'scons-use(): not enough arguments'
+ fi
+
+ if use "${flag}"; then
+ echo "${varname}=${vartrue}"
+ else
+ echo "${varname}=${varfalse}"
+ fi
+}