waf-utils.eclass 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: waf-utils.eclass
  4. # @MAINTAINER:
  5. # maintainer-needed@gentoo.org
  6. # @AUTHOR:
  7. # Original Author: Gilles Dartiguelongue <eva@gentoo.org>
  8. # Various improvements based on cmake-utils.eclass: Tomáš Chvátal <scarabeus@gentoo.org>
  9. # Proper prefix support: Jonathan Callen <jcallen@gentoo.org>
  10. # @BLURB: common ebuild functions for waf-based packages
  11. # @DESCRIPTION:
  12. # The waf-utils eclass contains functions that make creating ebuild for
  13. # waf-based packages much easier.
  14. # Its main features are support of common portage default settings.
  15. [[ ${EAPI} == [45] ]] && inherit eutils
  16. inherit multilib toolchain-funcs multiprocessing
  17. case ${EAPI:-0} in
  18. 4|5|6) EXPORT_FUNCTIONS src_configure src_compile src_install ;;
  19. *) die "EAPI=${EAPI} is not supported" ;;
  20. esac
  21. # @ECLASS-VARIABLE: WAF_VERBOSE
  22. # @DESCRIPTION:
  23. # Set to OFF to disable verbose messages during compilation
  24. # this is _not_ meant to be set in ebuilds
  25. : ${WAF_VERBOSE:=ON}
  26. # @FUNCTION: waf-utils_src_configure
  27. # @DESCRIPTION:
  28. # General function for configuring with waf.
  29. waf-utils_src_configure() {
  30. debug-print-function ${FUNCNAME} "$@"
  31. local fail
  32. if [[ ! ${_PYTHON_ANY_R1} && ! ${_PYTHON_SINGLE_R1} && ! ${_PYTHON_R1} ]]; then
  33. eerror "Using waf-utils.eclass without any python-r1 suite eclass is not supported."
  34. eerror "Please make sure to configure and inherit appropriate -r1 eclass."
  35. eerror "For more information and examples, please see:"
  36. eerror " https://wiki.gentoo.org/wiki/Project:Python/waf-utils_integration"
  37. fail=1
  38. else
  39. if [[ ! ${EPYTHON} ]]; then
  40. eerror "EPYTHON is unset while calling waf-utils. This most likely means that"
  41. eerror "the ebuild did not call the appropriate eclass function before calling waf."
  42. if [[ ${_PYTHON_ANY_R1} ]]; then
  43. eerror "Please ensure that python-any-r1_pkg_setup is called in pkg_setup()."
  44. elif [[ ${_PYTHON_SINGLE_R1} ]]; then
  45. eerror "Please ensure that python-single-r1_pkg_setup is called in pkg_setup()."
  46. else # python-r1
  47. eerror "Please ensure that python_setup is called before waf-utils_src_configure(),"
  48. eerror "or that the latter is used within python_foreach_impl as appropriate."
  49. fi
  50. eerror
  51. fail=1
  52. fi
  53. if [[ ${PYTHON_REQ_USE} != *threads* ]]; then
  54. eerror "Waf requires threading support in Python. To accomodate this requirement,"
  55. eerror "please add 'threads(+)' to PYTHON_REQ_USE variable (above inherit line)."
  56. eerror "For more information and examples, please see:"
  57. eerror " https://wiki.gentoo.org/wiki/Project:Python/waf-utils_integration"
  58. fail=1
  59. fi
  60. fi
  61. [[ ${fail} ]] && die "Invalid use of waf-utils.eclass"
  62. local libdir=()
  63. # @ECLASS-VARIABLE: WAF_BINARY
  64. # @DESCRIPTION:
  65. # Eclass can use different waf executable. Usually it is located in "${S}/waf".
  66. : ${WAF_BINARY:="${S}/waf"}
  67. # @ECLASS-VARIABLE: NO_WAF_LIBDIR
  68. # @DEFAULT_UNSET
  69. # @DESCRIPTION:
  70. # Variable specifying that you don't want to set the libdir for waf script.
  71. # Some scripts does not allow setting it at all and die if they find it.
  72. [[ -z ${NO_WAF_LIBDIR} ]] && libdir=(--libdir="${EPREFIX}/usr/$(get_libdir)")
  73. tc-export AR CC CPP CXX RANLIB
  74. echo "CCFLAGS=\"${CFLAGS}\" LINKFLAGS=\"${CFLAGS} ${LDFLAGS}\" \"${WAF_BINARY}\" --prefix=${EPREFIX}/usr ${libdir[@]} $@ configure"
  75. CCFLAGS="${CFLAGS}" LINKFLAGS="${CFLAGS} ${LDFLAGS}" "${WAF_BINARY}" \
  76. "--prefix=${EPREFIX}/usr" \
  77. "${libdir[@]}" \
  78. "$@" \
  79. configure || die "configure failed"
  80. }
  81. # @FUNCTION: waf-utils_src_compile
  82. # @DESCRIPTION:
  83. # General function for compiling with waf.
  84. waf-utils_src_compile() {
  85. debug-print-function ${FUNCNAME} "$@"
  86. local _mywafconfig
  87. [[ "${WAF_VERBOSE}" ]] && _mywafconfig="--verbose"
  88. local jobs="--jobs=$(makeopts_jobs)"
  89. echo "\"${WAF_BINARY}\" build ${_mywafconfig} ${jobs}"
  90. "${WAF_BINARY}" ${_mywafconfig} ${jobs} || die "build failed"
  91. }
  92. # @FUNCTION: waf-utils_src_install
  93. # @DESCRIPTION:
  94. # Function for installing the package.
  95. waf-utils_src_install() {
  96. debug-print-function ${FUNCNAME} "$@"
  97. echo "\"${WAF_BINARY}\" --destdir=\"${D}\" install"
  98. "${WAF_BINARY}" --destdir="${D}" install || die "Make install failed"
  99. # Manual document installation
  100. einstalldocs
  101. }