Index: waf-utils.eclass =================================================================== RCS file: /var/cvsroot/gentoo-x86/eclass/waf-utils.eclass,v retrieving revision 1.5 diff -u -b -B -r1.5 waf-utils.eclass --- waf-utils.eclass 1 Mar 2011 23:02:08 -0000 1.5 +++ waf-utils.eclass 14 May 2011 19:47:46 -0000 @@ -24,6 +24,59 @@ *) die "EAPI=${EAPI} is not supported" ;; esac +# @FUNCTION: waf-utils_waflibdir +# @USAGE: [] +# @DESCRIPTION: +# Echoes the absolute path to the directory containing the waf-based +# project's waflib python module. Ensures that the waflib shipped with a +# project is unpacked if it isn't already. This waflib may be safely +# patched because waf-lite will not touch the waflib directory if it +# already exists. Uses the waf binary specified in WAF_BINARY. +# +# @EXAMPLE +# The simplest case, for a monolithic compilation: +# +# @CODE +# pushd "$(waf-utils_waflibdir)" || die "Unable to patch waflib" +# epatch "${FILESDIR}"/${P}-waf-fix.patch +# popd +# @CODE +# +# Note that if you are using the python eclass and installating python +# modules, you must either call python_set_active_version or call +# waf-utils_waflibdir() from within a function run by +# python_execute(). This is because waf uses a different directory for +# waflib when using python3 than when using python2. +# +# @CODE +# SUPPORT_PYTHON_ABIS=1 +# inherit eutils python waf-utils +# +# # Always use the waf associated with the current python ABI. +# WAF_BINARY=./waf +# +# src_prepare() { +# python_copy_sources +# +# myprepare() { +# epatch "${FILESDIR}"/${P}-sourcecode-fix.patch +# +# pushd "$(waf-utils_waflibdir)" || die "Unable to patch waflib" +# epatch "${FILESDIR}"/${P}-waf-fix.patch +# popd +# } +# python_execute_function -s myprepare +# } +# @CODE +waf-utils_waflibdir() { + debug-print-function ${FUNCNAME} "$@" + + : ${WAF_BINARY:="${S}/waf"} + + python -c "import imp, sys; sys.argv[0] = '${WAF_BINARY}'; waflite = imp.load_source('waflite', '${WAF_BINARY}'); print(waflite.find_lib());" \ + || die "Unable to locate or unpack waflib module from the waf script at ${WAF_BINARY}" +} + # @FUNCTION: waf-utils_src_configure # @DESCRIPTION: # General function for configuring with waf.