aboutsummaryrefslogtreecommitdiffstats
path: root/community/moonscript/APKBUILD
blob: 8e2a9403d40df319b6d08a97f0f93006543c35a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=moonscript
pkgver=0.5.0
pkgrel=0
pkgdesc="A language that compiles to Lua"
url="http://moonscript.org"
arch="noarch"
license="MIT"
depends="lua-alt-getopt lua-filesystem lua-lpeg"
checkdepends="lua-busted"
makedepends="luarocks"
subpackages=""
source="$pkgname-$pkgver.tar.gz::https://github.com/leafo/$pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

# luajit is not available for s390x
case "$CARCH" in
	s390x|aarch64) _luajit="";;
	*) checkdepends="$checkdepends luajit" _luajit="jit";;
esac

_luaversions="5.1 5.2 5.3"
for _v in $_luaversions; do
	subpackages="$subpackages lua$_v-$pkgname:_subpackage"
	checkdepends="$checkdepends lua$_v lua$_v-busted lua$_v-loadkit"
done

prepare() {
	default_prepare

	cd "$builddir"
	local lver; for lver in $_luaversions; do
		local name; for name in moon moonc; do
			sed "s|^#!/usr/bin/env lua|#!/usr/bin/lua$lver|" \
				bin/$name > bin/$name-$lver
		done
	done
}

check() {
	cd "$builddir"

	local lver; for lver in $_luaversions $_luajit; do
		msg "Testing on lua$lver"
		lua$lver /usr/bin/busted
	done
}

package() {
	cd "$builddir"

	local name; for name in moon moonc; do
		install -D -m 755 bin/$name "$pkgdir"/usr/bin/$name
	done
}

_subpackage() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver ${depends//lua-/lua$lver-}"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local lmod_dir="$subpkgdir/usr/share/lua/$lver"

	cd "$builddir"

	mkdir -p "$lmod_dir"
	cp -r moon moonscript moon.lua moonscript.lua "$lmod_dir"/
	find "$lmod_dir" -name "*.moon" -delete

	local name; for name in moon moonc; do
		install -D -m 755 bin/$name-$lver "$subpkgdir"/usr/bin/$name-$lver
	done
}

sha512sums="f573f9a96502662987de637f7f62b935fab93aa775122c9ae20d98029394e3136e6b519908ce76e1e77c51fbcee162c3ad0aa58eeb1ee56a2b07951437987941  moonscript-0.5.0.tar.gz"