wxwidgets.eclass 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Copyright 1999-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: wxwidgets.eclass
  4. # @MAINTAINER:
  5. # wxwidgets@gentoo.org
  6. # @SUPPORTED_EAPIS: 7 8
  7. # @BLURB: Manages build configuration for wxGTK-using packages.
  8. # @DESCRIPTION:
  9. # This eclass sets up the proper environment for ebuilds using the wxGTK
  10. # libraries. Ebuilds using wxPython do not need to inherit this eclass.
  11. #
  12. # More specifically, this eclass controls the configuration chosen by the
  13. # ${ESYSROOT}/usr/bin/wx-config wrapper.
  14. #
  15. # Using the eclass is simple:
  16. #
  17. # - set WX_GTK_VER equal to a SLOT of wxGTK
  18. # - call setup-wxwidgets()
  19. #
  20. # The configuration chosen is based on the version required and the flags
  21. # wxGTK was built with.
  22. case ${EAPI} in
  23. 7|8) ;;
  24. *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
  25. esac
  26. if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
  27. _WXWIDGETS_ECLASS=1
  28. # @ECLASS_VARIABLE: WX_GTK_VER
  29. # @PRE_INHERIT
  30. # @REQUIRED
  31. # @DESCRIPTION:
  32. # The SLOT of the x11-libs/wxGTK you're targeting. Needs to be defined before
  33. # inheriting the eclass. Can be either "3.0" or "3.0-gtk3".
  34. case ${WX_GTK_VER} in
  35. 3.0-gtk3|3.1-gtk3|3.2-gtk3) ;;
  36. 3.0|3.1|3.2)
  37. if [[ ${EAPI} != 7 ]]; then
  38. die "${ECLASS}: GTK 2 no longer supported in EAPI ${EAPI}"
  39. fi
  40. ;;
  41. "") die "WX_GTK_VER not declared" ;;
  42. *) die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT ('3.0', '3.0-gtk3', or '3.2-gtk3')" ;;
  43. esac
  44. readonly WX_GTK_VER
  45. inherit flag-o-matic
  46. # @FUNCTION: setup-wxwidgets
  47. # @DESCRIPTION:
  48. # Call this in your ebuild to set up the environment for wxGTK in src_configure.
  49. # Besides controlling the wx-config wrapper, this exports WX_CONFIG containing
  50. # the path to the config in case it needs to be passed to the build system.
  51. #
  52. # This function also controls the level of debugging output from the libraries.
  53. # Debugging features are enabled by default and need to be disabled at the
  54. # package level. Because this causes many warning dialogs to pop up during
  55. # runtime, we add -DNDEBUG to CPPFLAGS to disable debugging features (unless
  56. # your ebuild has a debug USE flag and it's enabled). If you don't like this
  57. # behavior, you can set WX_DISABLE_NDEBUG to override it.
  58. #
  59. # See: https://docs.wxwidgets.org/trunk/overview_debugging.html
  60. setup-wxwidgets() {
  61. local w wxtoolkit wxconf
  62. case ${WX_GTK_VER} in
  63. 3.0-gtk3|3.1-gtk3|3.2-gtk3) wxtoolkit=gtk3 ;;
  64. 3.0|3.1|3.2) wxtoolkit=gtk2
  65. eqawarn "This package relies on the deprecated GTK 2 slot, which will go away soon (https://bugs.gentoo.org/618642)"
  66. ;;
  67. esac
  68. if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
  69. { in_iuse debug && use debug; } || append-cppflags -DNDEBUG
  70. fi
  71. # toolkit overrides
  72. if has_version -d "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
  73. wxtoolkit="mac"
  74. elif ! has_version -d "x11-libs/wxGTK:${WX_GTK_VER}"[gui]; then
  75. wxtoolkit="base"
  76. fi
  77. wxconf="${wxtoolkit}-unicode-${WX_GTK_VER}"
  78. for w in "${CHOST:-${CBUILD}}-${wxconf}" "${wxconf}"; do
  79. [[ -f ${ESYSROOT}/usr/$(get_libdir)/wx/config/${w} ]] && wxconf=${w} && break
  80. done || die "Failed to find configuration ${wxconf}"
  81. export WX_CONFIG="${ESYSROOT}/usr/$(get_libdir)/wx/config/${wxconf}"
  82. export WX_ECLASS_CONFIG="${WX_CONFIG}"
  83. einfo
  84. einfo "Requested wxWidgets: ${WX_GTK_VER}"
  85. einfo "Using wxWidgets: ${wxconf}"
  86. einfo
  87. }
  88. fi