aboutsummaryrefslogtreecommitdiffstats
path: root/testing/lua-xml/APKBUILD
blob: 0c623514361c1a06edef481a89caae150dfb6edb (plain)
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
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-xml
_rockname=xml
pkgver=1.1.3
pkgrel=0
pkgdesc="Very fast XML parser for Lua based on RapidXML"
url="https://github.com/lubyk/xml"
arch="all"
license="MIT BSL-1.0"
depends="lua-lub"
checkdepends="lua-lut"
makedepends=""
subpackages=""
source="https://github.com/lubyk/$_rockname/archive/REL-$pkgver/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_rockname-REL-$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
	makedepends="$makedepends lua$_v-dev luarocks$_v"
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done

build() {
	cd "$builddir"

	local lver; for lver in $_luaversions; do
		msg "Building for Lua $lver..."

		luarocks-$lver \
			CC="$CC" \
			CFLAGS="$CFLAGS -fPIC" \
			LUA_INCDIR="$(pkg-config --variable=includedir lua$lver)" \
			LUA_LIBDIR="$(pkg-config --variable=libdir lua$lver)" \
			make --tree=./build-$lver \
			$_rockname-$pkgver-*.rockspec
	done
}

check() {
	cd "$builddir"

	local lver; for lver in $_luaversions $_luajit; do
		msg "Testing on lua$lver"

		ln -sf ../build-${lver/jit/5.1}/lib/lua/${lver/jit/5.1}/xml/core.so xml/
		lua$lver test/all.lua
	done
}

package() {
	mkdir -p "$pkgdir"
}

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

	mkdir -p "$subpkgdir"/usr
	cp -r "$builddir"/build-$lver/* "$subpkgdir"/usr/

	rm -r "$rocksdir"/manifest "$rocksdir"/$_rockname/*/doc
}

sha512sums="fdbfab6aaf46e71a02a2ac6dd0b3f708ee7e712f9704a2b834c2240696519dbcbb28fcee555bd6f12f992ee8713597aaee4b7057efcc1c004303bbe0f2223776  lua-xml-1.1.3.tar.gz"