moonscript-0.5.0.ebuild 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. LUA_COMPAT=( lua5-{1..4} luajit )
  5. inherit lua
  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. dev-lua/lpeg[${LUA_USEDEP}]
  17. >=dev-lua/alt-getopt-0.7[${LUA_USEDEP}]
  18. >=dev-lua/luafilesystem-1.5[${LUA_USEDEP}]
  19. "
  20. DEPEND="${RDEPEND}"
  21. DOCS=( docs/. README.md )
  22. src_prepare() {
  23. default
  24. lua_copy_sources
  25. }
  26. moon_tool_compile() {
  27. local in="${1:?}"
  28. local out="${2:?}"
  29. {
  30. printf '%s\n\n' '#!/usr/bin/env lua'
  31. "${LUA}" bin/moonc -p "${in}"
  32. printf '\n%s\n' '-- vim: set filetype=lua:'
  33. printf 'Built %s\n' "${in}" 1>&2
  34. } > "${out}"
  35. }
  36. lua_src_compile() (
  37. set -e
  38. cd "${BUILD_DIR}"
  39. "${LUA}" bin/moonc moon/ moonscript/
  40. moon_tool_compile bin/moon{.moon,}
  41. moon_tool_compile bin/{splat.moon,moon-splat}
  42. find . -type f -name '*.moon' -delete
  43. )
  44. src_compile() {
  45. lua_foreach_impl lua_src_compile
  46. }
  47. lua_src_install() (
  48. cd "${BUILD_DIR}" || die
  49. insinto "$(lua_get_lmod_dir)"
  50. doins -r moon{,script}{,.lua}
  51. )
  52. src_install() {
  53. einstalldocs
  54. lua_foreach_impl lua_src_install
  55. (
  56. set -e
  57. for dir in "${WORKDIR}/${P}"-*; do :; done
  58. cd "${dir}"
  59. dobin bin/moon{,c,-splat}
  60. ) || die
  61. }