moonscript-0.5.0.ebuild 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. LUA_COMPAT=( lua5-{1..4} luajit )
  5. inherit lua-single
  6. DESCRIPTION="A programmer friendly language that compiles into Lua"
  7. HOMEPAGE="https://github.com/leafo/moonscript"
  8. SRC_URI="https://github.com/leafo/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  9. LICENSE="MIT"
  10. SLOT="0"
  11. KEYWORDS="amd64 arm ppc x86 ~amd64-linux ~x86-linux"
  12. IUSE="+doc"
  13. REQUIRED_USE="${LUA_REQUIRED_USE}"
  14. RDEPEND="
  15. ${LUA_DEPS}
  16. $(lua_gen_cond_dep '
  17. dev-lua/lpeg[${LUA_USEDEP}]
  18. >=dev-lua/alt-getopt-0.7[${LUA_USEDEP}]
  19. >=dev-lua/luafilesystem-1.5[${LUA_USEDEP}]
  20. ')
  21. "
  22. DEPEND="${RDEPEND}"
  23. src_prepare() {
  24. sed -i "${S}/Makefile" \
  25. -e 's/LUA_C\?PATH=[^ ]\+//g' \
  26. -e 's;"#![^"]\+";"'"${LUA}"'";g' \
  27. || die
  28. sed -i "${S}/bin/moonc" \
  29. -e "1d;2i#!${LUA}"
  30. default
  31. }
  32. rm_moon() {
  33. local f=''
  34. for f in "./${1:?}"/*; do
  35. if [ -d "${f}" ]; then
  36. rm_moon "${f}"
  37. else
  38. case "${f}" in
  39. *.moon) rm -v -- "${f}";;
  40. esac
  41. fi
  42. done
  43. }
  44. src_compile() {
  45. emake LUA_PATH_MAKE='' LUA_CPATH_MAKE='' compile
  46. rm_moon "./${PN}"
  47. }
  48. src_install() {
  49. local DOCS=( docs/. README.md )
  50. einstalldocs
  51. dobin bin/moon{,c}
  52. newbin bin/splat.moon moon-splat
  53. insinto "$(lua_get_lmod_dir)"
  54. doins -r moon{,script}{,.lua}
  55. }