Commit fa2f626c authored by Natanael Copa's avatar Natanael Copa

main/lua-llthreads: upgrade to 5.1 and build for both 5.1 and 5.2

parent c09a38d1
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_luaversions="5.1 5.2"
pkgname=lua-llthreads
pkgver=1.1
pkgver=1.2
pkgrel=1
pkgdesc="Low-Level native threads module for Lua"
url="https://github.com/Neopallium/lua-llthreads"
arch="all"
license="MIT"
depends=""
makedepends="cmake lua-dev"
depends="lua5.1-llthreads"
makedepends="cmake"
install=""
subpackages=
source="saveas-https://github.com/Neopallium/lua-llthreads/tarball/v1.1/$pkgname-$pkgver.tar.gz"
for _i in $_luaversions; do
makedepends="$makedepends lua$_i-dev"
subpackages="$subpackages lua$_i-llthreads:split_${_i/./_}"
done
source="lua-llthreads-$pkgver.tar.gz::https://github.com/Neopallium/lua-llthreads/archive/v$pkgver.tar.gz
bindings-1.patch
bindings-2.patch
lua-5.2.patch"
_builddir="$srcdir"/Neopallium-lua-llthreads-48c39a5
_sdir="$srcdir"/lua-llthreads-$pkgver
prepare() {
local i
cd "$_builddir"
cd "$_sdir"
for i in $source; do
case $i in
*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
esac
done
cd "$srcdir"
for _i in $_luaversions; do
mkdir -p "$srcdir"/build-$_i
done
}
build() {
cd "$_builddir"
cmake \
-DCMAKE_INSTALL_PREFIX=/usr \
-DINSTALL_CMOD=/usr/lib/lua/5.1 \
. || return 1
make || return 1
for _i in $_luaversions; do
cd "$srcdir"/build-$_i
msg "build for Lua $_i"
CFLAGS="$CFLAGS $(pkg-config --cflags lua$_i)" cmake \
-DCMAKE_INSTALL_PREFIX=/usr \
-DINSTALL_CMOD=/usr/lib/lua/$_i \
"$_sdir" || return 1
make VERBOSE=1 || return 1
done
}
package() {
cd "$_builddir"
make install DESTDIR="$pkgdir" || return 1
for _i in $_luaversions; do
cd "$srcdir"/build-$_i
make install DESTDIR="$pkgdir" || return 1
done
}
md5sums="f5c80984e7d8849ad777b42c4594da8d lua-llthreads-1.1.tar.gz"
_split() {
local d= _ver=$1
pkgdesc="Low-Level native threads module for Lua $_ver"
replaces="$pkgname"
for d in usr/lib/lua usr/share/lua; do
if [ -d "$pkgdir"/$d/$_ver ]; then
mkdir -p "$subpkgdir"/$d
mv "$pkgdir"/$d/$_ver "$subpkgdir"/$d/ || return 1
fi
done
}
for _i in $_luaversions; do
eval "split_${_i/./_}() { _split $_i; }"
done
md5sums="d4adb2e6d4859bf33ebdb3bd6b6c6bb5 lua-llthreads-1.2.tar.gz
399fa42d7dfa7ec2335bd7111b17935e bindings-1.patch
f892e9cb699eef2d5df406063a26d044 bindings-2.patch
5f4a0b8c23968a521072c96c42435475 lua-5.2.patch"
sha256sums="32df7dc903760825536def63fba834466c42e6bd17022d430893c9a6ca3ba8f2 lua-llthreads-1.2.tar.gz
20c2cc64f09dd601fb85d867e7e57b8849a66d9b1992c647282a84af92127902 bindings-1.patch
3bb62563bdd5e4b5261612b5d0498bed4b327f02c7b5ff4a85329b9bc7867b3c bindings-2.patch
5c7f28e7a3ef4e8d1ac6f0ef5cf5680ba58d0aa76e77260d6fe1c4ed74c4b586 lua-5.2.patch"
sha512sums="d8b006e7f135e9c45d88c93d6acf30d41024bee66bd0747ba8112e28c2fe03fbd8f869d6235261108f3df30a08f3a812595a763c82a57674b5ec54a8ca915fa7 lua-llthreads-1.2.tar.gz
eace4eb6226527697aa82b5e455b7ece3d651966f3525471f07476d84714550bb4f75447be34569d57f2ed52bbfd708458305b527621179cfa2f843ae684d931 bindings-1.patch
fd5be1ec7293c0e279877ee139de53c1772c28957c30e276f5fe8e05314c31e81ae6ea18553fe67d912b3f9902b48cd88b962480f5855037783477bbb633e019 bindings-2.patch
234e0afe81bbd2a40689a858febec8778962273553da6d7b876871bd996ed0ad28ca33a15b7e155c313b63f10b0f8bab3ee0a83c0cd14d3378884d0031df720d lua-5.2.patch"
This diff is collapsed.
From 25687f0babcc2b3cdc8b42c7ecf8a34f751062d6 Mon Sep 17 00:00:00 2001
From: "Robert G. Jakabosky" <bobby@sharedrealm.com>
Date: Fri, 2 Mar 2012 17:34:04 -0800
Subject: [PATCH] Re-generate bindings.
---
src/pre_generated-llthreads.nobj.c | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/pre_generated-llthreads.nobj.c b/src/pre_generated-llthreads.nobj.c
index b2d1185..d016651 100644
--- a/src/pre_generated-llthreads.nobj.c
+++ b/src/pre_generated-llthreads.nobj.c
@@ -56,7 +56,7 @@
#define true 1
#endif
#ifndef false
-#define false 1
+#define false 0
#endif
#endif
@@ -250,7 +250,8 @@ static int nobj_check_ffi_support(lua_State *L) {
if(!lua_isnil(L, -1)) {
rc = lua_toboolean(L, -1);
lua_pop(L, 1);
- return rc; /* return results of previous check. */
+ /* use results of previous check. */
+ goto finished;
}
lua_pop(L, 1); /* pop nil. */
@@ -276,6 +277,7 @@ static int nobj_check_ffi_support(lua_State *L) {
lua_pushboolean(L, rc);
lua_rawset(L, LUA_REGISTRYINDEX);
+finished:
/* turn-on hint that there is FFI code enabled. */
if(rc) {
nobj_ffi_support_enabled_hint = 1;
@@ -284,9 +286,29 @@ static int nobj_check_ffi_support(lua_State *L) {
return rc;
}
+typedef struct {
+ const char **ffi_init_code;
+ int offset;
+} nobj_reader_state;
+
+static const char *nobj_lua_Reader(lua_State *L, void *data, size_t *size) {
+ nobj_reader_state *state = (nobj_reader_state *)data;
+ const char *ptr;
+
+ ptr = state->ffi_init_code[state->offset];
+ if(ptr != NULL) {
+ *size = strlen(ptr);
+ state->offset++;
+ } else {
+ *size = 0;
+ }
+ return ptr;
+}
+
static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
- const char *ffi_init_code, const ffi_export_symbol *ffi_exports, int priv_table)
+ const char *ffi_init_code[], const ffi_export_symbol *ffi_exports, int priv_table)
{
+ nobj_reader_state state = { ffi_init_code, 0 };
int err;
/* export symbols to priv_table. */
@@ -296,7 +318,7 @@ static int nobj_try_loading_ffi(lua_State *L, const char *ffi_mod_name,
lua_settable(L, priv_table);
ffi_exports++;
}
- err = luaL_loadbuffer(L, ffi_init_code, strlen(ffi_init_code), ffi_mod_name);
+ err = lua_load(L, nobj_lua_Reader, &state, ffi_mod_name);
if(0 == err) {
lua_pushvalue(L, -2); /* dup C module's table. */
lua_pushvalue(L, priv_table); /* move priv_table to top of stack. */
@@ -670,6 +692,7 @@ static FUNC_UNUSED void * obj_simple_udata_luadelete(lua_State *L, int _index, o
static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int size, obj_type *type)
{
+ void *ud;
#if LUAJIT_FFI
lua_pushlightuserdata(L, type);
lua_rawget(L, LUA_REGISTRYINDEX); /* type's metatable. */
@@ -681,7 +704,7 @@ static FUNC_UNUSED void *obj_simple_udata_luapush(lua_State *L, void *obj, int s
}
#endif
/* create new userdata. */
- void *ud = lua_newuserdata(L, size);
+ ud = lua_newuserdata(L, size);
memcpy(ud, obj, size);
/* get obj_type metatable. */
#if LUAJIT_FFI
@@ -1483,7 +1506,7 @@ static int llthreads__new__func(lua_State *L) {
#if LUAJIT_FFI
static const ffi_export_symbol llthreads_ffi_export[] = {
- {NULL, { .data = NULL } }
+ {NULL, { NULL } }
};
#endif
--
1.8.1.6
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment