aboutsummaryrefslogtreecommitdiffstats
path: root/community/lua-rapidjson/APKBUILD
blob: b960bfe90386bc30f410716e091f0448556ccc81 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=lua-rapidjson
_rockname=rapidjson
pkgver=0.5.1
pkgrel=1
pkgdesc="A JSON module for Lua based on the very fast RapidJSON library"
url="https://github.com/xpol/lua-rapidjson"
arch="all"
license="MIT"
makedepends="cmake rapidjson-dev"
subpackages=""
checkdepends="lua-busted"
source="$pkgname-$pkgver.tar.gz::https://github.com/xpol/$pkgname/archive/v$pkgver.tar.gz
	disable-c-cxx-flag-march.patch
	fix-json_encode_spec.patch"
builddir="$srcdir/$pkgname-$pkgver"

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

_luaversions="5.1 5.2 5.3"
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	checkdepends="$checkdepends lua$_v lua$_v-busted lua$_v-dromozoa-utf8"
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done

prepare() {
	default_prepare
	cd "$builddir"

	# Remove bundled rapidjson (use system package),
	# but keep bin directory - it's needed for tests.
	rm -r rapidjson/include
}

build() {
	local lver; for lver in $_luaversions; do
		mkdir -p "$builddir"/build-$lver
		cd "$builddir"/build-$lver

		msg "Building against Lua $lver..."
		cmake .. \
			-DCMAKE_BUILD_TYPE=MinSizeRel \
			-DCMAKE_INSTALL_PREFIX=/usr \
			-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
			-DCMAKE_C_FLAGS="$CFLAGS" \
			-DCMAKE_VERBOSE_MAKEFILE=ON \
			-DBUILD_SHARED_LIBS=ON \
			-DLUA_INCLUDE_DIR="$(pkg-config --variable=includedir lua$lver)" \
			-DLUA_RAPIDJSON_VERSION="$pkgver"
		make
	done
}

check() {
	local lver; for lver in $_luaversions $_luajit; do
		cd "$builddir"/build-${lver/jit/5.1}
		ln -sf ../rapidjson ../spec .

		msg "Testing on lua$lver"
		lua$lver /usr/bin/busted
	done
}

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

_subpackage() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local install_cmod=$(pkg-config --variable=INSTALL_CMOD lua$lver)
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-1"

	install -D -m 755 "$builddir"/build-$lver/rapidjson.so \
		"$subpkgdir"/$install_cmod/rapidjson.so

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="281a7f98212d1648f270180a2f7475884c5cb9c9b1ee901113fc2a96bff86b4897c8d9cc0e40f7cf1b9edd09540119734118f7e06879eaaecf3f3d6f7f5f84e0  lua-rapidjson-0.5.1.tar.gz
9bfe86c75765d0684f33b660129c3ab90629b8518b05d14aa99ea15e6eb39dcb0a56e9a705f2dcae0f463e7ed92c8759628b0fbdaeee43aff34ac7e5b6c6bf10  disable-c-cxx-flag-march.patch
ad66d29f6dd1ed1a3eafff79b77567a28c0b5d746a2564e0ce5fa8a26bf792d788b96ec63bacd907f85c89a561ada690c526e6be36246cd50f8ea45180977cc0  fix-json_encode_spec.patch"