wren-0.4.0.ebuild 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # Copyright 2022-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. DISTUTILS_USE_PEP517=no
  5. PYTHON_COMPAT=(python3_{11..13})
  6. inherit distutils-r1 toolchain-funcs
  7. DESCRIPTION="Wren is a small, fast, class-based concurrent scripting language"
  8. HOMEPAGE="https://wren.io/"
  9. SRC_URI="
  10. https://github.com/wren-lang/${PN}/archive/${PV}.tar.gz
  11. -> ${P}.tar.gz
  12. https://github.com/wren-lang/${PN}-cli/archive/${PV}.tar.gz
  13. -> ${PN}-cli-${PV}.tar.gz
  14. "
  15. LICENSE="MIT"
  16. SLOT="0"
  17. KEYWORDS="amd64 ~arm ~arm64 ~x86"
  18. IUSE="+cli static"
  19. RDEPEND="cli? ( dev-libs/libuv )"
  20. DEPEND="${RDEPEND}"
  21. get_config() {
  22. case "${ARCH}" in
  23. amd64 | arm64) echo 'release_64bit' ;;
  24. arm | x86) echo 'release_32bit' ;;
  25. *) die "unsupported ARCH: ${ARCH}" ;;
  26. esac
  27. }
  28. src_prepare() {
  29. eapply_user
  30. local f=''
  31. local makes=(
  32. projects/make/wren_shared.make
  33. "${WORKDIR}/wren-cli-${PV}/projects/make/wren_cli.make"
  34. )
  35. for f in "${makes[@]}"; do
  36. # Don't pre-strip
  37. sed -e '/^ALL_LDFLAGS/s/-s$//' -i "${f}" || die
  38. done
  39. cat <<-EOF >${PN}.pc
  40. prefix="${EPREFIX}/usr"
  41. libdir="\${prefix}/$(get_libdir)"
  42. includedir="\${prefix}/include"
  43. Name: ${PN}
  44. Description: ${DESCRIPTION}
  45. URL: ${HOMEPAGE}
  46. Version: ${PV}
  47. Libs: "-L\${libdir}" -l${PN}
  48. Cflags: "-I\${includedir}"
  49. EOF
  50. (
  51. cd "${WORKDIR}/wren-cli-${PV}"
  52. eapply "${FILESDIR}/${P}-cli-glibc-build.patch"
  53. )
  54. }
  55. # The test requires `wrem` static library, so build it anyway and then optionally install it or not
  56. # (to disable static build, remove `wren` from `PROJECTS` variable in `projects/make/Makefile`)
  57. src_compile() {
  58. tc-export CC
  59. (
  60. cd projects/make
  61. emake verbose=1 config="$(get_config)"
  62. )
  63. use cli && (
  64. tc-export_build_env
  65. local cli="${WORKDIR}/${PN}-cli-${PV}/src"
  66. local flags=(
  67. ${BUILD_CFLAGS}
  68. ${BUILD_LDFLAGS}
  69. ${BUILD_CPPFLAGS}
  70. )
  71. set -- \
  72. "${CC}" \
  73. "${flags[@]}" \
  74. -luv -L./lib -lwren \
  75. -I"${cli}/cli" -I"${cli}/module" -I./src/include \
  76. "${cli}"/*/*.c -o "${PN}"
  77. einfo "${*}"
  78. ebegin 'building wren cli'
  79. "${@}"
  80. eend "${?}" 'failed to build wren cli'
  81. )
  82. }
  83. python_test() {
  84. "${EPYTHON}" util/test.py || die
  85. }
  86. src_install() {
  87. use cli && dobin "${PN}"
  88. use static && dolib.a lib/libwren.a
  89. dolib.so lib/libwren.so
  90. doheader src/include/wren.h
  91. doheader src/include/wren.hpp
  92. insinto "/usr/$(get_libdir)/pkgconfig"
  93. doins "${PN}.pc"
  94. einstalldocs
  95. }